[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

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

   1  <?php
   2  /**
   3  * @version $Id: content_blog_section.class.php 5047 2006-09-14 13:49:01Z friesengeist $
   4  * @package Joomla
   5  * @subpackage Menus
   6  * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
   7  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
   8  * Joomla! is free software. This version may have been modified pursuant
   9  * to the GNU General Public License, and as distributed it includes or
  10  * is derivative of works licensed under the GNU General Public License or
  11  * other free or open source software licenses.
  12  * See COPYRIGHT.php for copyright notices and details.
  13  */
  14  
  15  // no direct access
  16  defined( '_VALID_MOS' ) or die( 'Restricted access' );
  17  
  18  /**
  19  * @package Joomla
  20  * @subpackage Menus
  21  */
  22  class content_blog_section {
  23  
  24      /**
  25      * @param database A database connector object
  26      * @param integer The unique id of the section to edit (0 if new)
  27      */
  28  	function edit( $uid, $menutype, $option ) {
  29          global $database, $my, $mainframe;
  30  
  31          $menu = new mosMenu( $database );
  32          $menu->load( (int)$uid );
  33  
  34          // fail if checked out not by 'me'
  35          if ($menu->checked_out && $menu->checked_out != $my->id) {
  36              mosErrorAlert( "The module ".$menu->title." is currently being edited by another administrator" );
  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                  $secidsArray = explode( ',', $secids );
  46                  mosArrayToInts( $secidsArray );
  47                  $secids = 's.id=' . implode( ' OR s.id=', $secidsArray );
  48                  $query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`"
  49                  . "\n FROM #__sections AS s"
  50                  . "\n WHERE s.scope = 'content'"
  51                  . "\n AND ( $secids )"
  52                  . "\n ORDER BY s.name"
  53                  ;
  54                  $database->setQuery( $query );
  55                  $lookup = $database->loadObjectList();
  56              } else {
  57                  $lookup             = '';
  58              }
  59          } else {
  60              $menu->type             = 'content_blog_section';
  61              $menu->menutype         = $menutype;
  62              $menu->ordering         = 9999;
  63              $menu->parent             = intval( mosGetParam( $_POST, 'parent', 0 ) );
  64              $menu->published         = 1;
  65              $lookup                 = '';
  66          }
  67  
  68          // build the html select list for section
  69          $rows[] = mosHTML::makeOption( '', 'All Sections' );
  70          $query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`"
  71          . "\n FROM #__sections AS s"
  72          . "\n WHERE s.scope = 'content'"
  73          . "\n ORDER BY s.name"
  74          ;
  75          $database->setQuery( $query );
  76          $rows = array_merge( $rows, $database->loadObjectList() );
  77          $section = mosHTML::selectList( $rows, 'secid[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $lookup );
  78          $lists['sectionid']        = $section;
  79  
  80          // build the html select list for ordering
  81          $lists['ordering']         = mosAdminMenus::Ordering( $menu, $uid );
  82          // build the html select list for the group access
  83          $lists['access']         = mosAdminMenus::Access( $menu );
  84          // build the html select list for paraent item
  85          $lists['parent']         = mosAdminMenus::Parent( $menu );
  86          // build published button option
  87          $lists['published']     = mosAdminMenus::Published( $menu );
  88          // build the url link output
  89          $lists['link']         = mosAdminMenus::Link( $menu, $uid );
  90  
  91          // get params definitions
  92          $params = new mosParameters( $menu->params, $mainframe->getPath( 'menu_xml', $menu->type ), 'menu' );
  93  
  94          content_blog_section_html::edit( $menu, $lists, $params, $option );
  95      }
  96  
  97  	function saveMenu( $option, $task ) {
  98          global $database;
  99  
 100          $params = mosGetParam( $_POST, 'params', '' );
 101          
 102          $secids    = josGetArrayInts( 'secid' );
 103          $secid    = implode( ',', $secids );
 104  
 105          $params['sectionid']    = $secid;
 106          if (is_array( $params )) {
 107              $txt = array();
 108              foreach ($params as $k=>$v) {
 109                  $txt[] = "$k=$v";
 110              }
 111              $_POST['params'] = mosParameters::textareaHandling( $txt );
 112          }
 113  
 114          $row = new mosMenu( $database );
 115  
 116          if (!$row->bind( $_POST )) {
 117              echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
 118              exit();
 119          }
 120  
 121          if ( count( $secids )== 1 && $secids[0] != '' ) {
 122              $row->link = str_replace( 'id=0','id='. $secids[0], $row->link );
 123              $row->componentid = $secids[0];
 124          }
 125  
 126          if (!$row->check()) {
 127              echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
 128              exit();
 129          }
 130          if (!$row->store()) {
 131              echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
 132              exit();
 133          }
 134          $row->checkin();
 135          $row->updateOrder( "menutype = " . $database->Quote( $row->menutype ) . " AND parent = " . (int) $row->parent );
 136  
 137          $msg = 'Menu item Saved';
 138          switch ( $task ) {
 139              case 'apply':
 140                  mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype .'&task=edit&id='. $row->id, $msg );
 141                  break;
 142  
 143              case 'save':
 144              default:
 145                  mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype, $msg );
 146              break;
 147          }
 148      }
 149  
 150  }
 151  ?>


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics