XH 1.6: removal of special handling for Menumanager

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

XH 1.6: removal of special handling for Menumanager

Post by cmb » Tue Nov 06, 2012 9:58 am

Hello Community,

in CMSimple_XH there's code to handle the missing changes to the pagedata when saving changes from the Menumanager. IMO the core of CMSimple_XH shouldn't have any special handling of a single plugin. So I suggest to remove this special treatment in CMSimple_XH 1.6.

But this would make the Menumager incompatible to CMSimple_XH, and unfortunately it seems, that further development of the Menumanager was ceased. Perhaps another developer is interested in further maintaining the plugin, and making available a version that would work with CMSimple_XH (1.6). If so, one should contact its author for permission to do so.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH 1.7: Removal of special handling for Menumanager

Post by cmb » Thu Feb 26, 2015 1:13 am

Well, as far as I know there is no CMSimple_XH 1.6 compatible Menumanager version anymore. Even if there was, the special handling of Menumanager in the core is likely unnecessary or even unwanted. Therefore I propose to remove this special handling, and suggest the following patch:

Code: Select all

Index: cmsimple/classes/Controller.php
===================================================================
--- cmsimple/classes/Controller.php	(revision 1490)
+++ cmsimple/classes/Controller.php	(working copy)
@@ -431,40 +431,6 @@
     }
 
     /**
-     * Returns whether saving from menumanager is requested.
-     *
-     * @return bool
-     *
-     * @global string Whether the menumanager is requested.
-     * @global string The requested action.
-     */
-    public function isSavingMenumanager()
-    {
-        global $menumanager, $action, $text;
-
-        return isset($menumanager) && $menumanager == 'true'
-            && $action == 'saverearranged' && !empty($text);
-    }
-
-    /**
-     * Handles menumanager requests.
-     *
-     * @return void
-     *
-     * @global array             The paths of system files and folders.
-     * @global string            The menumanager page information.
-     * @global XH_PageDataRouter The page data router.
-     */
-    public function handleMenumanager()
-    {
-        global $pth, $text, $pd_router;
-
-        if (!$pd_router->refresh_from_menu_manager($text)) {
-            e('notwritable', 'content', $pth['file']['content']);
-        }
-    }
-
-    /**
      * Returns whether page data have to be saved.
      *
      * @return bool
Index: cmsimple/classes/PageDataRouter.php
===================================================================
--- cmsimple/classes/PageDataRouter.php	(revision 1490)
+++ cmsimple/classes/PageDataRouter.php	(working copy)
@@ -352,64 +352,6 @@
     }
 
     /**
-     * Updates the page data according to changes from the menumanager plugin.
-     * Returns whether that succeeded.
-     *
-     * @param string $changes The changed page structure.
-     *
-     * @return bool
-     *
-     * @todo Remove sometimes in the future.
-     */
-// @codingStandardsIgnoreStart
-    public function refresh_from_menu_manager($changes)
-    {
-// @codingStandardsIgnoreEnd
-        $changes = explode(',', $changes);
-        /*
-         * Create an up-to-date page data array ...
-         */
-        $new_data = array();
-        /*
-         * index counter is needed for changed headings
-         */
-        $i = 0;
-        foreach ($changes as $temp) {
-            $infos = explode('^', $temp);
-            $old_position = $infos[0];
-            if ($old_position == 'New') {
-                /*
-                 * Page was added: create a new record
-                 * These informations are created by default
-                 */
-                $params = array();
-                $title = trim(strip_tags($infos[2]));
-                $url = uenc($title);
-                $params['url'] = $url;
-                $new_data[] = $this->new_page($params);
-            } else {
-                /*
-                 * Get the old record
-                 */
-                $new_data[] = $this->find_page($old_position);
-            }
-            if (isset($infos[3])) {
-                /*
-                 * if the heading has changed:
-                 * update 'url'
-                 */
-                $url = uenc(trim(strip_tags($infos[3])));
-                $new_data[$i]['url'] = $url;
-            }
-            $i++;
-        }
-        /*
-         * Replace the old data with the new array
-         */
-        return $this->model->refresh($new_data);
-    }
-
-    /**
      * Updates the page data of a single page and returns whether that succeeded.
      *
      * @param int   $s      The index of the page.
Index: cmsimple/cms.php
===================================================================
--- cmsimple/cms.php	(revision 1490)
+++ cmsimple/cms.php	(working copy)
@@ -1059,9 +1059,6 @@
 
 if (XH_ADM) {
     $o .= ' '; // generate fake output to suppress later adjustment of $s
-    if ($_XH_controller->isSavingMenumanager()) {
-        $_XH_controller->handleMenumanager();
-    }
     if ($_XH_controller->wantsSavePageData()) {
         $_XH_controller->handleSavePageData();
     }
Index: tests/unit/ControllerTest.php
===================================================================
--- tests/unit/ControllerTest.php	(revision 1490)
+++ tests/unit/ControllerTest.php	(working copy)
@@ -1322,73 +1322,6 @@
 }
 
 /**
- * Testing the handling of menumanager requests.
- *
- * @category Testing
- * @package  XH
- * @author   The CMSimple_XH developers <devs@cmsimple-xh.org>
- * @license  http://www.gnu.org/licenses/gpl-3.0.en.html GNU GPLv3
- * @link     http://cmsimple-xh.org/
- * @since    1.6.3
- */
-class ControllerMenumanagerTest extends PHPUnit_Framework_TestCase
-{
-    /**
-     * The test subject.
-     *
-     * @var XH_Controller
-     */
-    protected $subject;
-
-    /**
-     * The e() mock.
-     *
-     * @var object
-     */
-    protected $eMock;
-
-    /**
-     * Sets up the test fixture.
-     *
-     * @return void
-     *
-     * @global XH_PageDataRouter The page data router.
-     */
-    public function setUp()
-    {
-        global $pd_router;
-
-        $pd_router = $this->getMockBuilder('XH_PageDataRouter')
-            ->disableOriginalConstructor()->getMock();
-        $this->subject = new XH_Controller();
-        $this->eMock = new PHPUnit_Extensions_MockFunction('e', $this->subject);
-    }
-
-    /**
-     * Tests it.
-     *
-     * @return void
-     *
-     * @global string Whether the menumanager is requested.
-     * @global string The requested action.
-     * @global string The menumanager page information.
-     * @global XH_PageDataRouter The page data router.
-     */
-    public function testIt()
-    {
-        global $menumanager, $action, $text, $pd_router;
-
-        $menumanager = 'true';
-        $action = 'saverearranged';
-        $text = 'foo';
-        $pd_router->expects($this->once())->method('refresh_from_menu_manager')
-            ->will($this->returnValue(false));
-        $this->eMock->expects($this->once());
-        $this->subject->handleMenumanager();
-    }
-}
-
-/**
  * Testing the handling of save page data requests.
  *
  * @category Testing
Note that I do not want to wipe Menumanager out of CMSimple_XH. On the contrary I would be happy if there was an alternative to Pagemanager -- what else would $cf['pagemanager']['external'] be good for? However, I do not have the time to update Menumanager and at the same time improve/update Pagemanager (that would simply be a clash of interests, and I'm already behind with regard to jsTree 3). I hope someone else will make an alternative to Pagemanager available soon.
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH 1.6: removal of special handling for Menumanager

Post by cmb » Mon Mar 23, 2015 12:52 am

Done (r1519).
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply