[ Index ]

PHP Cross Reference of Mambo 4.6.5

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

title

Body

[close]

/administrator/components/com_menus/wrapper/ -> wrapper.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  /**
  21  * Wrapper class
  22  */
  23  class wrapper_menu {
  24  
  25  	function edit( &$uid, $menutype, $option ) {
  26          global $database, $my, $mainframe;
  27          global $mosConfig_absolute_path;
  28  
  29          $menu = new mosMenu( $database );
  30          $menu->load( $uid );
  31  
  32          // fail if checked out not by 'me'
  33          if ($menu->checked_out && $menu->checked_out <> $my->id) {
  34              echo "<script>alert('".sprintf(T_('The module % is currently being edited by another administrator'), $menu->title)."'); document.location.href='index2.php?option=$option'</script>\n";
  35              exit(0);
  36          }
  37  
  38          if ( $uid ) {
  39              $menu->checkout( $my->id );
  40          } else {
  41              $menu->type = 'wrapper';
  42              $menu->menutype = $menutype;
  43              $menu->ordering = 9999;
  44              $menu->parent = intval( mosGetParam( $_POST, 'parent', 0 ) );
  45              $menu->published = 1;
  46              $menu->link = 'index.php?option=com_wrapper';
  47          }
  48  
  49          // build the html select list for ordering
  50          $lists['ordering']         = mosAdminMenus::Ordering( $menu, $uid );
  51          // build the html select list for the group access
  52          $lists['access']         = mosAdminMenus::Access( $menu );
  53          // build the html select list for paraent item
  54          $lists['parent']         = mosAdminMenus::Parent( $menu );
  55          // build published button option
  56          $lists['published']     = mosAdminMenus::Published( $menu );
  57          // build the url link output
  58          $lists['link']         = mosAdminMenus::Link( $menu, $uid );
  59          
  60          // get params definitions
  61          $params =& new mosAdminParameters( $menu->params, $mainframe->getPath( 'menu_xml', $menu->type ), 'menu' );
  62          if ( $uid ) {
  63              $menu->url = $params->def( 'url', '' );
  64          }
  65  
  66          wrapper_menu_html::edit( $menu, $lists, $params, $option );
  67      }
  68  
  69  
  70  	function saveMenu( $option, $task ) {
  71          global $database;
  72      
  73          $params = mosGetParam( $_POST, 'params', '' );
  74          $params[url] = mosGetParam( $_POST, 'url', '' );
  75          
  76          if (is_array( $params )) {
  77              $txt = array();
  78              foreach ($params as $k=>$v) {
  79                 $txt[] = "$k=$v";
  80              }
  81               $_POST['params'] = mosParameters::textareaHandling( $txt );
  82          }            
  83  
  84          $row = new mosMenu( $database );
  85      
  86          if (!$row->bind( $_POST )) {
  87              echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
  88              exit();
  89          }
  90      
  91          if (!$row->check()) {
  92              echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
  93              exit();
  94          }
  95          if (!$row->store()) {
  96              echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
  97              exit();
  98          }
  99          $row->checkin();
 100          $row->updateOrder( "menutype='$row->menutype' AND parent='$row->parent'" );
 101          
 102          
 103          $msg = 'Menu item Saved';
 104          switch ( $task ) {
 105              case 'apply':
 106                  mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype .'&task=edit&id='. $row->id, $msg );
 107                  break;
 108          
 109              case 'save':
 110              default:
 111                  mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype, $msg );
 112              break;
 113          }
 114      }
 115  }
 116  
 117  
 118  ?>