[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/administrator/components/com_menus/components/ -> components.class.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @subpackage Menus
   5  * @author Mambo Foundation Inc see README.php
   6  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   7  * See COPYRIGHT.php for copyright notices and details.
   8  * @license GNU/GPL Version 2, see LICENSE.php
   9  *
  10  * Redistributions of files must retain the above copyright notice.
  11  *
  12  * Mambo is free software; you can redistribute it and/or
  13  * modify it under the terms of the GNU General Public License
  14  * as published by the Free Software Foundation; version 2 of the License.
  15  */
  16  
  17  /** ensure this file is being included by a parent file */
  18  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  19  
  20  class components_menu {
  21      /**
  22      * @param database A database connector object
  23      * @param integer The unique id of the category to edit (0 if new)
  24      */
  25  	function edit( $uid, $menutype, $option ) {
  26          global $database, $my, $mainframe;
  27  
  28          $menu = new mosMenu( $database );
  29          $menu->load( $uid );
  30  
  31          $row = new mosComponent( $database );
  32          // load the row from the db table
  33          $row->load( $menu->componentid );
  34  
  35          // fail if checked out not by 'me'
  36          if ( $menu->checked_out && $menu->checked_out <> $my->id ) {
  37              echo "<script>alert('".sprintf(T_('"The module %s is currently being edited by another administrator'), $menu->title)."'); document.location.href='index2.php?option=$option'</script>\n";
  38              exit(0);
  39          }
  40  
  41          if ( $uid ) {
  42              // do stuff for existing item
  43              $menu->checkout( $my->id );
  44          } else {
  45              // do stuff for new item
  46              $menu->type = 'components';
  47              $menu->menutype = $menutype;
  48              $menu->browserNav = 0;
  49              $menu->ordering = 9999;
  50              $menu->parent = intval( mosGetParam( $_POST, 'parent', 0 ) );
  51              $menu->published = 1;
  52          }
  53  
  54          $query = "SELECT c.id AS value, c.name AS text, c.link" 
  55          . "\n FROM #__components AS c"
  56          . "\n WHERE c.link <> ''" 
  57          . "\n ORDER BY c.name"
  58          ;
  59          $database->setQuery( $query );
  60          $components = $database->loadObjectList( );
  61  
  62          // build the html select list for section
  63          $lists['componentid']     = mosAdminMenus::Component( $menu, $uid );
  64  
  65          // componentname
  66          $lists['componentname'] = mosAdminMenus::ComponentName( $menu, $uid );
  67          // build the html select list for ordering
  68          $lists['ordering']         = mosAdminMenus::Ordering( $menu, $uid );
  69          // build the html select list for the group access
  70          $lists['access']         = mosAdminMenus::Access( $menu );
  71          // build the html select list for paraent item
  72          $lists['parent']         = mosAdminMenus::Parent( $menu );
  73          // build published button option
  74          $lists['published']     = mosAdminMenus::Published( $menu );
  75          // build the url link output
  76          $lists['link']         = mosAdminMenus::Link( $menu, $uid );
  77          
  78          // get params definitions
  79          $params =& new mosAdminParameters( $menu->params, $mainframe->getPath( 'com_xml', $row->option ), 'component' );
  80  
  81          components_menu_html::edit( $menu, $components, $lists, $params, $option );
  82      }
  83  }
  84  ?>