[ Index ]

PHP Cross Reference of Mambo 4.6.5

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

title

Body

[close]

/administrator/components/com_menus/content_blog_section/ -> content_blog_section.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 content_blog_section {
  21  
  22      /**
  23      * @param database A database connector object
  24      * @param integer The unique id of the section to edit (0 if new)
  25      */
  26  	function edit( $uid, $menutype, $option ) {
  27          global $database, $my, $mainframe;
  28          global $mosConfig_absolute_path;
  29  
  30          $menu = new mosMenu( $database );
  31          $menu->load( $uid );
  32  
  33          // fail if checked out not by 'me'
  34          if ($menu->checked_out && $menu->checked_out <> $my->id) {
  35              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";
  36              exit(0);
  37          }
  38  
  39          if ($uid) {
  40              $menu->checkout( $my->id );
  41              // get previously selected Categories
  42              $params =& new mosParameters( $menu->params );
  43              $secids = $params->def( 'sectionid', '' );
  44              if ( $secids ) {
  45                  // @RawSQLUse, trivial_implementation, SELECT, CONCEPT
  46                  $query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`"
  47                  . "\n FROM #__sections AS s"
  48                  . "\n WHERE s.scope = 'content'"
  49                  . "\n AND s.id IN ( ". $secids . ")"
  50                  . "\n ORDER BY s.name"
  51                  ;
  52                  $database->setQuery( $query );
  53                  $lookup = $database->loadObjectList();
  54              } else {
  55                  $lookup             = '';
  56              }
  57          } else {
  58              $menu->type             = 'content_blog_section';
  59              $menu->menutype         = $menutype;
  60              $menu->ordering         = 9999;
  61              $menu->parent             = intval( mosGetParam( $_POST, 'parent', 0 ) );
  62              $menu->published         = 1;
  63              $lookup                 = '';
  64          }
  65  
  66          // build the html select list for section
  67          $rows[] = mosHTML::makeOption( '', T_('All Sections') );
  68          // @RawSQLUse, trivial_implementation, SELECT, CONCEPT
  69          $query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`"
  70          . "\n FROM #__sections AS s"
  71          . "\n WHERE s.scope = 'content'"
  72          . "\n ORDER BY s.name"
  73          ;
  74          $database->setQuery( $query );
  75          $rows = array_merge( $rows, $database->loadObjectList() );
  76          $section = mosHTML::selectList( $rows, 'secid[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $lookup );
  77          $lists['sectionid']        = $section;
  78  
  79          // build the html select list for ordering
  80          $lists['ordering']         = mosAdminMenus::Ordering( $menu, $uid );
  81          // build the html select list for the group access
  82          $lists['access']         = mosAdminMenus::Access( $menu );
  83          // build the html select list for paraent item
  84          $lists['parent']         = mosAdminMenus::Parent( $menu );
  85          // build published button option
  86          $lists['published']     = mosAdminMenus::Published( $menu );
  87          // build the url link output
  88          $lists['link']         = mosAdminMenus::Link( $menu, $uid );
  89  
  90          // get params definitions
  91          $params =& new mosAdminParameters( $menu->params, $mainframe->getPath( 'menu_xml', $menu->type ), 'menu' );
  92  
  93          content_blog_section_html::edit( $menu, $lists, $params, $option );
  94      }
  95  
  96  	function saveMenu( $option, $task ) {
  97          global $database;
  98  
  99          $params = mosGetParam( $_POST, 'params', '' );
 100          $secids    = mosGetParam( $_POST, 'secid', array() );
 101          $secid    = implode( ',', $secids );
 102          
 103          $params[sectionid]    = $secid;
 104          if (is_array( $params )) {
 105              $txt = array();
 106              foreach ($params as $k=>$v) {
 107                 $txt[] = "$k=$v";
 108              }
 109              $_POST['params'] = mosParameters::textareaHandling( $txt );
 110          }
 111  
 112          $row = new mosMenu( $database );
 113  
 114          if (!$row->bind( $_POST )) {
 115              echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
 116              exit();
 117          }
 118          
 119          if ( count( $secids )== 1 && $secids[0] != '' ) {
 120              $row->link = str_replace( 'id=0','id='. $secids[0], $row->link );
 121              $row->componentid = $secids[0];
 122          }
 123          
 124          if (!$row->check()) {
 125              echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
 126              exit();
 127          }
 128          if (!$row->store()) {
 129              echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
 130              exit();
 131          }
 132          $row->checkin();
 133          $row->updateOrder( "menutype='$row->menutype' AND parent='$row->parent'" );
 134          
 135          $msg = 'Menu item Saved';
 136          switch ( $task ) {
 137              case 'apply':
 138                  mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype .'&task=edit&id='. $row->id, $msg );
 139                  break;
 140          
 141              case 'save':
 142              default:
 143                  mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype, $msg );
 144              break;
 145          }
 146      }
 147  
 148  }
 149  ?>