Source for file admin.containers.php

Documentation is available at admin.containers.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @author Mambo Foundation Inc see README.php
  5. @copyright Mambo Foundation Inc.
  6. *  See COPYRIGHT.php for copyright notices and details.
  7. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
  8. *  LICENSE.php
  9. *  Mambo is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU General Public License
  11. *  as published by the Free Software Foundation; version 2 of the
  12. *  License.
  13. *  Date: 10 March 2006
  14. *  Original Script: psx-dude - psx-dude@psx-dude.net
  15. ***/
  16.  
  17. // Don't allow direct linking
  18. if (!defined'_VALID_MOS' )) die'Direct Access to this location is not allowed.' );
  19.  
  20. require_once($mosConfig_absolute_path.'/components/com_containers/containers.class.php');
  21. require_once$mainframe->getPath'admin_html' ) );
  22.  
  23.     var $parentid = 0;
  24.     
  25.     function getRequestData ({
  26.         $this->parentid = mosGetParam($_REQUEST'parentid'0);
  27.     }
  28.     
  29.     function listTask ({
  30.         // Get the search string that will constrain the list of containers displayed
  31.         $search trimstrtolowermosGetParam$_POST'search''' ) ) );
  32.         // Get the flag that tells us whether to continue to nested containers right down to the bottom
  33.         $descendants intval(mosGetParam($_POST'descendants'0));
  34.         // Create the container above our present position - might be degenerate
  35.         $handler mosContainerHandler::getInstance();
  36.         $container =$handler->getBasicContainer($this->parentid);
  37.         // Get all the containers that are to be displayed
  38.         if ($descendants$folders $container->getDescendants($search);
  39.         else $folders $container->getChildren(false,$search);
  40.         // Generate a container list for user to select where to be
  41.         $clist $container->getSelectList('parentid''class="inputbox" size="1" onchange="document.adminForm.submit();"'false);
  42.         // Create and activate a View object
  43.         $view $this->admin->newHTMLClassCheck ('listContainersHTML'$thiscount($folders)$clist);
  44.         $view->view(array_slice($folders,$this->admin->limitstart,$this->admin->limit)$descendants$search);
  45.     }
  46.     
  47.     function addTask ({
  48.         // This is our new container - nothing much in it to start with
  49.         $container =new mosContainer();
  50.         // Its parent is by default the situation we are in at present
  51.         $container->parentid $this->parentid;
  52.         // Generate a container list so the user can change the parent
  53.         $clist $container->getSelectList('parentid''class="inputbox"'false);
  54.         // Create and activate a View object
  55.         $view $this->admin->newHTMLClassCheck ('editContainersHTML'$this0$clist);
  56.         $view->view($container);
  57.     }
  58.     
  59.     function editTask ({
  60.         // Create a container object that will be filled with data from the DB using currid as key
  61.         $handler mosContainerHandler::getInstance();
  62.         $container =$handler->getContainer($this->admin->currid);
  63.         $parent =$container->getParent();
  64.         // Generate a container list so the user can change the parent
  65.         $clist $parent->getSelectList('parentid''class="inputbox"'false$container->id);
  66.         // Create and activate a View object
  67.         $view $this->admin->newHTMLClassCheck ('editContainersHTML'$this0$clist);
  68.         $view->view($container);
  69.     }
  70.     
  71.     function saveTask ({
  72.         // Create a container object that will be filled with data from the DB using currid as key
  73.         $handler mosContainerHandler::getInstance();
  74.         $container =$handler->getContainer($this->admin->currid);
  75.         // Clear tick box fields as nothing will be received if they are unticked
  76.         $container->published 0;
  77.         // Add the new information from the form just submitted
  78.         $container->addPostData();
  79.         // By default, a new container is automatically published
  80.         if ($this->admin->currid == 0$container->published 1;
  81.         // Save the new information about the container to the database
  82.         $container->saveValues ();
  83.         // Next we locate ourselves where this container has finished up and list containers
  84.         $this->parentid = $container->parentid;
  85.         $this->listTask();
  86.     }
  87.     
  88.     function saveorderTask ({
  89.         // Create a container object that will be filled with data from the DB using currid as key
  90.         $handler mosContainerHandler::getInstance();
  91.         $container =$handler->getContainer($this->admin->currid);
  92.         // Reorder based on the first container in the list
  93.         $where "parentid = ".$container->parentid;
  94.         $container->updateOrder($where$this->admin->cfid$this->admin->order);
  95.         $handler->resetData();
  96.         $this->parentid = $container->parentid;
  97.         $this->listTask();
  98.     }
  99.     
  100.     function orderupTask ({
  101.         // Create a container object that will be filled with data from the DB using currid as key
  102.         $handler mosContainerHandler::getInstance();
  103.         $container =$handler->getContainer($this->admin->currid);
  104.         // Reorder based on the first container in the list
  105.         $where "parentid = ".$container->parentid;
  106.         $container->move(-1$where);
  107.         $handler->resetData();
  108.         $this->parentid = $container->parentid;
  109.         $this->listTask();
  110.     }
  111.  
  112.     function orderdownTask ({
  113.         // Create a container object that will be filled with data from the DB using currid as key
  114.         $handler mosContainerHandler::getInstance();
  115.         $container =$handler->getContainer($this->admin->currid);
  116.         // Reorder based on the first container in the list
  117.         $where "parentid = ".$container->parentid;
  118.         $container->move(+1$where);
  119.         $handler->resetData();
  120.         $this->parentid = $container->parentid;
  121.         $this->listTask();
  122.     }
  123.     
  124.     function deleteTask ({
  125.         // In case the Javascript cannot do the check, ensure at least one item selected
  126.         $this->admin->check_selection(_DOWN_SEL_FILE_DEL);
  127.         // For each selected container, create an object then delete (will delete from DB)
  128.         $dlist array();
  129.         $handler mosContainerHandler::getInstance();
  130.         foreach ($this->admin->cfid as $id$dlist[$handler->getDescendantIDList($id);
  131.         $deletelist implode (','$dlist);
  132.         $mambothandler mosMambotHandler::getInstance();
  133.         $mambothandler->loadBotGroup('container');
  134.         $messages $mambothandler->trigger('preDelete'$deletelist);
  135.         foreach ($messages as $messageif ($message{
  136.             // Create and activate a View object
  137.             $view $this->admin->newHTMLClassCheck ('messageContainersHTML'$this0'');
  138.             $view->view($container);
  139.         }
  140.         else {
  141.             $mambothandler->trigger('doDelete'$deletelist);
  142.             // Now show the list of containers again
  143.             $this->listTask();
  144.         }
  145.     }
  146.     
  147.     function publishTask ({
  148.         $this->publishToggle(1);
  149.     }
  150.  
  151.     function unpublishTask ({
  152.         $this->publishToggle(0);
  153.     }
  154.     
  155.     function publishToggle ($publish{
  156.         // Check that one or more items have been selected (Javascript may not have run)
  157.         $this->admin->check_selection(_DOWN_PUB_PROMPT.($publish 'publish' 'unpublish'));
  158.         mosContainer::togglePublished($this->admin->cfid,$publish);
  159.         // The file/folder counts only include published items, so recalculate
  160.         $this->repository->resetCounts(array());
  161.         // List out the containers again
  162.         $this->listTask();
  163.     }
  164.  
  165.  
  166. }
  167.     
  168. new mosComponentAdminManager('Containers');
  169.  
  170. ?>

Documentation generated on Mon, 05 May 2008 16:13:58 +0400 by phpDocumentor 1.4.0