[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/administrator/components/com_typedcontent/ -> admin.typedcontent.php (source)

   1  <?php
   2  /**
   3  * @version $Id: admin.typedcontent.php 5099 2006-09-19 22:31:33Z Saka $
   4  * @package Joomla
   5  * @subpackage Content
   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  require_once( $mainframe->getPath( 'admin_html' ) );
  19  
  20  $cid = josGetArrayInts( 'cid' );
  21  
  22  switch ( $task ) {
  23      case 'cancel':
  24          cancel( $option );
  25          break;
  26  
  27      case 'new':
  28          edit( 0, $option );
  29          break;
  30  
  31      case 'edit':
  32          edit( $id, $option );
  33          break;
  34  
  35      case 'editA':
  36          edit( intval( $cid[0] ), $option );
  37          break;
  38  
  39      case 'go2menu':
  40      case 'go2menuitem':
  41      case 'resethits':
  42      case 'menulink':
  43      case 'save':
  44      case 'apply':
  45          save( $option, $task );
  46          break;
  47  
  48      case 'remove':
  49          trash( $cid, $option );
  50          break;
  51  
  52      case 'publish':
  53          changeState( $cid, 1, $option );
  54          break;
  55  
  56      case 'unpublish':
  57          changeState( $cid, 0, $option );
  58          break;
  59  
  60      case 'accesspublic':
  61          changeAccess( intval( $cid[0] ), 0, $option );
  62          break;
  63  
  64      case 'accessregistered':
  65          changeAccess( intval( $cid[0] ), 1, $option );
  66          break;
  67  
  68      case 'accessspecial':
  69          changeAccess( intval( $cid[0] ), 2, $option );
  70          break;
  71  
  72      case 'saveorder':
  73          saveOrder( $cid );
  74          break;
  75  
  76      default:
  77          view( $option );
  78          break;
  79  }
  80  
  81  /**
  82  * Compiles a list of installed or defined modules
  83  * @param database A database connector object
  84  */
  85  function view( $option ) {
  86      global $database, $mainframe, $mosConfig_list_limit;
  87  
  88      $filter_authorid     = intval( $mainframe->getUserStateFromRequest( "filter_authorid{$option}", 'filter_authorid', 0 ) );
  89      $order                 = $mainframe->getUserStateFromRequest( "zorder", 'zorder', 'c.ordering DESC' );
  90      $limit                 = intval( $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ) );
  91      $limitstart         = intval( $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ) );
  92      $search             = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' );
  93      if (get_magic_quotes_gpc()) {
  94          $search            = stripslashes( $search );
  95      }
  96  
  97      // used by filter
  98      if ( $search ) {
  99          $searchEscaped = $database->getEscaped( trim( strtolower( $search ) ) );
 100          $search_query = "\n AND ( LOWER( c.title ) LIKE '%$searchEscaped%' OR LOWER( c.title_alias ) LIKE '%$searchEscaped%' )";
 101      } else {
 102          $search_query = '';
 103      }
 104  
 105      $filter = '';
 106      if ( $filter_authorid > 0 ) {
 107          $filter = "\n AND c.created_by = " . (int) $filter_authorid;
 108      }
 109  
 110      $orderAllowed = array( 'c.ordering ASC', 'c.ordering DESC', 'c.id ASC', 'c.id DESC', 'c.title ASC', 'c.title DESC', 'c.created ASC', 'c.created DESC', 'z.name ASC', 'z.name DESC', 'c.state ASC', 'c.state DESC', 'c.access ASC', 'c.access DESC' );
 111      if (!in_array( $order, $orderAllowed )) {
 112          $order = 'c.ordering DESC';
 113      }
 114  
 115      // get the total number of records
 116      $query = "SELECT count(*)"
 117      . "\n FROM #__content AS c"
 118      . "\n WHERE c.sectionid = 0"
 119      . "\n AND c.catid = 0"
 120      . "\n AND c.state != -2"
 121      . $search_query
 122      . $filter
 123      ;
 124      $database->setQuery( $query );
 125      $total = $database->loadResult();
 126      require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' );
 127      $pageNav = new mosPageNav( $total, $limitstart, $limit );
 128  
 129      $query = "SELECT c.*, g.name AS groupname, u.name AS editor, z.name AS creator"
 130      . "\n FROM #__content AS c"
 131      . "\n LEFT JOIN #__groups AS g ON g.id = c.access"
 132      . "\n LEFT JOIN #__users AS u ON u.id = c.checked_out"
 133      . "\n LEFT JOIN #__users AS z ON z.id = c.created_by"
 134      . "\n WHERE c.sectionid = 0"
 135      . "\n AND c.catid = 0"
 136      . "\n AND c.state != -2"
 137      . $search_query
 138      . $filter
 139      . "\n ORDER BY ". $order
 140      ;
 141      $database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
 142      $rows = $database->loadObjectList();
 143  
 144      if ($database->getErrorNum()) {
 145          echo $database->stderr();
 146          return false;
 147      }
 148  
 149      $count = count( $rows );
 150      for( $i = 0; $i < $count; $i++ ) {
 151          $query = "SELECT COUNT( id )"
 152          . "\n FROM #__menu"
 153          . "\n WHERE componentid = " . (int) $rows[$i]->id
 154          . "\n AND type = 'content_typed'"
 155          . "\n AND published != -2"
 156          ;
 157          $database->setQuery( $query );
 158          $rows[$i]->links = $database->loadResult();
 159      }
 160  
 161      $ordering[] = mosHTML::makeOption( 'c.ordering ASC', 'Ordering asc' );
 162      $ordering[] = mosHTML::makeOption( 'c.ordering DESC', 'Ordering desc' );
 163      $ordering[] = mosHTML::makeOption( 'c.id ASC', 'ID asc' );
 164      $ordering[] = mosHTML::makeOption( 'c.id DESC', 'ID desc' );
 165      $ordering[] = mosHTML::makeOption( 'c.title ASC', 'Title asc' );
 166      $ordering[] = mosHTML::makeOption( 'c.title DESC', 'Title desc' );
 167      $ordering[] = mosHTML::makeOption( 'c.created ASC', 'Date asc' );
 168      $ordering[] = mosHTML::makeOption( 'c.created DESC', 'Date desc' );
 169      $ordering[] = mosHTML::makeOption( 'z.name ASC', 'Author asc' );
 170      $ordering[] = mosHTML::makeOption( 'z.name DESC', 'Author desc' );
 171      $ordering[] = mosHTML::makeOption( 'c.state ASC', 'Published asc' );
 172      $ordering[] = mosHTML::makeOption( 'c.state DESC', 'Published desc' );
 173      $ordering[] = mosHTML::makeOption( 'c.access ASC', 'Access asc' );
 174      $ordering[] = mosHTML::makeOption( 'c.access DESC', 'Access desc' );
 175      $javascript = 'onchange="document.adminForm.submit();"';
 176      $lists['order'] = mosHTML::selectList( $ordering, 'zorder', 'class="inputbox" size="1"'. $javascript, 'value', 'text', $order );
 177  
 178      // get list of Authors for dropdown filter
 179      $query = "SELECT c.created_by AS value, u.name AS text"
 180      . "\n FROM #__content AS c"
 181      . "\n LEFT JOIN #__users AS u ON u.id = c.created_by"
 182      . "\n WHERE c.sectionid = 0"
 183      . "\n GROUP BY u.name"
 184      . "\n ORDER BY u.name"
 185      ;
 186      $authors[] = mosHTML::makeOption( '0', _SEL_AUTHOR );
 187      $database->setQuery( $query );
 188      $authors = array_merge( $authors, $database->loadObjectList() );
 189      $lists['authorid']    = mosHTML::selectList( $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_authorid );
 190  
 191      HTML_typedcontent::showContent( $rows, $pageNav, $option, $search, $lists );
 192  }
 193  
 194  /**
 195  * Compiles information to add or edit content
 196  * @param database A database connector object
 197  * @param string The name of the category section
 198  * @param integer The unique id of the category to edit (0 if new)
 199  */
 200  function edit( $uid, $option ) {
 201      global $database, $my, $mainframe;
 202      global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_offset;
 203  
 204      $row = new mosContent( $database );
 205      $row->load( (int)$uid );
 206  
 207      $lists         = array();
 208      $nullDate     = $database->getNullDate();
 209  
 210      if ($uid) {
 211          // fail if checked out not by 'me'
 212          if ($row->isCheckedOut( $my->id )) {
 213              mosErrorAlert( "The module ".$row->title." is currently being edited by another administrator" );
 214          }
 215  
 216          $row->checkout( $my->id );
 217  
 218          if (trim( $row->images )) {
 219              $row->images = explode( "\n", $row->images );
 220          } else {
 221              $row->images = array();
 222          }
 223  
 224          $row->created         = mosFormatDate( $row->created, _CURRENT_SERVER_TIME_FORMAT );
 225          $row->modified         = $row->modified == $nullDate ? '' : mosFormatDate( $row->modified, _CURRENT_SERVER_TIME_FORMAT );
 226          $row->publish_up     = mosFormatDate( $row->publish_up, _CURRENT_SERVER_TIME_FORMAT );
 227  
 228          if (trim( $row->publish_down ) == $nullDate || trim( $row->publish_down ) == '' || trim( $row->publish_down ) == '-' ) {
 229              $row->publish_down = 'Never';
 230          }
 231          $row->publish_down     = mosFormatDate( $row->publish_down, _CURRENT_SERVER_TIME_FORMAT );
 232  
 233          $query = "SELECT name"
 234          . "\n FROM #__users"
 235          . "\n WHERE id = " . (int) $row->created_by
 236          ;
 237          $database->setQuery( $query );
 238          $row->creator = $database->loadResult();
 239  
 240          // test to reduce unneeded query
 241          if ( $row->created_by == $row->modified_by ) {
 242              $row->modifier = $row->creator;
 243          } else {
 244              $query = "SELECT name"
 245              . "\n FROM #__users"
 246              . "\n WHERE id = " . (int) $row->modified_by
 247              ;
 248              $database->setQuery( $query );
 249              $row->modifier = $database->loadResult();
 250          }
 251  
 252          // get list of links to this item
 253          $and     = "\n AND componentid = " . (int) $row->id;
 254          $menus     = mosAdminMenus::Links2Menu( 'content_typed', $and );
 255      } else {
 256          // initialise values for a new item
 257          $row->version         = 0;
 258          $row->state         = 1;
 259          $row->images         = array();
 260          $row->publish_up     = date( 'Y-m-d H:i:s', time() + ( $mosConfig_offset * 60 * 60 ) );
 261          $row->publish_down     = 'Never';
 262          $row->sectionid     = 0;
 263          $row->catid         = 0;
 264          $row->creator         = '';
 265          $row->modified         = $nullDate;
 266          $row->modifier         = '';
 267          $row->ordering         = 0;
 268          $menus = array();
 269      }
 270  
 271      // calls function to read image from directory
 272      $pathA         = $mosConfig_absolute_path .'/images/stories';
 273      $pathL         = $mosConfig_live_site .'/images/stories';
 274      $images     = array();
 275      $folders     = array();
 276      $folders[]     = mosHTML::makeOption( '/' );
 277      mosAdminMenus::ReadImages( $pathA, '/', $folders, $images );
 278      // list of folders in images/stories/
 279      $lists['folders']         = mosAdminMenus::GetImageFolders( $folders, $pathL );
 280      // list of images in specfic folder in images/stories/
 281      $lists['imagefiles']    = mosAdminMenus::GetImages( $images, $pathL );
 282      // list of saved images
 283      $lists['imagelist']     = mosAdminMenus::GetSavedImages( $row, $pathL );
 284  
 285      // build list of users
 286      $active = ( intval( $row->created_by ) ? intval( $row->created_by ) : $my->id );
 287      $lists['created_by']     = mosAdminMenus::UserSelect( 'created_by', $active );
 288      // build the html select list for the group access
 289      $lists['access']         = mosAdminMenus::Access( $row );
 290      // build the html select list for menu selection
 291      $lists['menuselect']    = mosAdminMenus::MenuSelect( );
 292      // build the select list for the image positions
 293      $lists['_align']         = mosAdminMenus::Positions( '_align' );
 294      // build the select list for the image caption alignment
 295      $lists['_caption_align']     = mosAdminMenus::Positions( '_caption_align' );
 296      // build the select list for the image caption position
 297      $pos[] = mosHTML::makeOption( 'bottom', _CMN_BOTTOM );
 298      $pos[] = mosHTML::makeOption( 'top', _CMN_TOP );
 299      $lists['_caption_position'] = mosHTML::selectList( $pos, '_caption_position', 'class="inputbox" size="1"', 'value', 'text' );
 300  
 301      // get params definitions
 302      $params = new mosParameters( $row->attribs, $mainframe->getPath( 'com_xml', 'com_typedcontent' ), 'component' );
 303  
 304      HTML_typedcontent::edit( $row, $images, $lists, $params, $option, $menus );
 305  }
 306  
 307  /**
 308  * Saves the typed content item
 309  */
 310  function save( $option, $task ) {
 311      global $database, $my, $mosConfig_offset;
 312  
 313      $nullDate     = $database->getNullDate();
 314      $menu         = strval( mosGetParam( $_POST, 'menu', 'mainmenu' ) );
 315      $menuid        = intval( mosGetParam( $_POST, 'menuid', 0 ) );
 316  
 317      $row = new mosContent( $database );
 318      if (!$row->bind( $_POST )) {
 319          echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
 320          exit();
 321      }
 322  
 323      if ($row->id) {
 324          $row->modified         = date( 'Y-m-d H:i:s' );
 325          $row->modified_by     = $my->id;
 326      }
 327  
 328      $row->created_by     = $row->created_by ? $row->created_by : $my->id;
 329  
 330      if ($row->created && strlen(trim( $row->created )) <= 10) {
 331          $row->created     .= ' 00:00:00';
 332      }
 333      $row->created         = $row->created ? mosFormatDate( $row->created, _CURRENT_SERVER_TIME_FORMAT, -$mosConfig_offset ) : date( 'Y-m-d H:i:s' );
 334  
 335      if (strlen(trim( $row->publish_up )) <= 10) {
 336          $row->publish_up .= ' 00:00:00';
 337      }
 338      $row->publish_up = mosFormatDate($row->publish_up, _CURRENT_SERVER_TIME_FORMAT, -$mosConfig_offset );
 339  
 340      if (trim( $row->publish_down ) == 'Never' || trim( $row->publish_down ) == '') {
 341          $row->publish_down = $nullDate;
 342      } else {
 343          if (strlen(trim( $row->publish_down )) <= 10) {
 344              $row->publish_down .= ' 00:00:00';
 345          }
 346          $row->publish_down = mosFormatDate( $row->publish_down, _CURRENT_SERVER_TIME_FORMAT, -$mosConfig_offset );
 347      }
 348  
 349      $row->state = intval( mosGetParam( $_REQUEST, 'published', 0 ) );
 350  
 351      // Save Parameters
 352      $params = mosGetParam( $_POST, 'params', '' );
 353      if (is_array( $params )) {
 354          $txt = array();
 355          foreach ( $params as $k=>$v) {
 356              $txt[] = "$k=$v";
 357          }
 358          $row->attribs = implode( "\n", $txt );
 359      }
 360  
 361      // code cleaner for xhtml transitional compliance
 362      $row->introtext = str_replace( '<br>', '<br />', $row->introtext );
 363  
 364      $row->title = ampReplace( $row->title );
 365  
 366      if (!$row->check()) {
 367          echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
 368          exit();
 369      }
 370      if (!$row->store()) {
 371          echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
 372          exit();
 373      }
 374      $row->checkin();
 375  
 376      // clean any existing cache files
 377      mosCache::cleanCache( 'com_content' );
 378  
 379      switch ( $task ) {
 380          case 'go2menu':
 381              mosRedirect( 'index2.php?option=com_menus&menutype='. $menu );
 382              break;
 383  
 384          case 'go2menuitem':
 385              mosRedirect( 'index2.php?option=com_menus&menutype='. $menu .'&task=edit&hidemainmenu=1&id='. $menuid );
 386              break;
 387  
 388          case 'menulink':
 389              menuLink( $option, $row->id );
 390              break;
 391  
 392          case 'resethits':
 393              resethits( $option, $row->id );
 394              break;
 395  
 396          case 'save':
 397              $msg = 'Typed Content Item saved';
 398              mosRedirect( 'index2.php?option='. $option, $msg );
 399              break;
 400  
 401          case 'apply':
 402          default:
 403              $msg = 'Changes to Typed Content Item saved';
 404              mosRedirect( 'index2.php?option='. $option .'&task=edit&hidemainmenu=1&id='. $row->id, $msg );
 405              break;
 406      }
 407  }
 408  
 409  /**
 410  * Trashes the typed content item
 411  */
 412  function trash( &$cid, $option ) {
 413      global $database;
 414  
 415      $total = count( $cid );
 416      if ( $total < 1) {
 417          echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n";
 418          exit;
 419      }
 420  
 421      $state = '-2';
 422      $ordering = '0';
 423      //seperate contentids
 424      mosArrayToInts( $cid );
 425      $cids = 'id=' . implode( ' OR id=', $cid );
 426      $query = "UPDATE #__content"
 427      . "\n SET state = " . (int) $state . ", ordering = " . (int) $ordering
 428      . "\n WHERE ( $cids )"
 429      ;
 430      $database->setQuery( $query );
 431      if ( !$database->query() ) {
 432          echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
 433          exit();
 434      }
 435  
 436      // clean any existing cache files
 437      mosCache::cleanCache( 'com_content' );
 438  
 439      $msg = $total ." Item(s) sent to the Trash";
 440      mosRedirect( 'index2.php?option='. $option, $msg );
 441  }
 442  
 443  /**
 444  * Changes the state of one or more content pages
 445  * @param string The name of the category section
 446  * @param integer A unique category id (passed from an edit form)
 447  * @param array An array of unique category id numbers
 448  * @param integer 0 if unpublishing, 1 if publishing
 449  * @param string The name of the current user
 450  */
 451  function changeState( $cid=null, $state=0, $option ) {
 452      global $database, $my;
 453  
 454      if (count( $cid ) < 1) {
 455          $action = $state == 1 ? 'publish' : ($state == -1 ? 'archive' : 'unpublish');
 456          echo "<script> alert('Select an item to $action'); window.history.go(-1);</script>\n";
 457          exit;
 458      }
 459  
 460      mosArrayToInts( $cid );
 461      $total    = count ( $cid );
 462      $cids    = 'id=' . implode( ' OR id=', $cid );
 463  
 464      $query = "UPDATE #__content"
 465      . "\n SET state = " . (int) $state
 466      . "\n WHERE ( $cids )"
 467      . "\n AND ( checked_out = 0 OR ( checked_out = " . (int) $my->id . " ) )"
 468      ;
 469      $database->setQuery( $query );
 470      if (!$database->query()) {
 471          echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
 472          exit();
 473      }
 474  
 475      if (count( $cid ) == 1) {
 476          $row = new mosContent( $database );
 477          $row->checkin( $cid[0] );
 478      }
 479  
 480      // clean any existing cache files
 481      mosCache::cleanCache( 'com_content' );
 482  
 483      if ( $state == "1" ) {
 484          $msg = $total ." Item(s) successfully Published";
 485      } else if ( $state == "0" ) {
 486          $msg = $total ." Item(s) successfully Unpublished";
 487      }
 488      mosRedirect( 'index2.php?option='. $option .'&msg='. $msg );
 489  }
 490  
 491  /**
 492  * changes the access level of a record
 493  * @param integer The increment to reorder by
 494  */
 495  function changeAccess( $id, $access, $option  ) {
 496      global $database;
 497  
 498      $row = new mosContent( $database );
 499      $row->load( (int)$id );
 500      $row->access = $access;
 501  
 502      if ( !$row->check() ) {
 503          return $row->getError();
 504      }
 505      if ( !$row->store() ) {
 506          return $row->getError();
 507      }
 508  
 509      // clean any existing cache files
 510      mosCache::cleanCache( 'com_content' );
 511  
 512      mosRedirect( 'index2.php?option='. $option );
 513  }
 514  
 515  
 516  /**
 517  * Function to reset Hit count of a content item
 518  */
 519  function resethits( $option, $id ) {
 520      global $database;
 521  
 522      $row = new mosContent($database);
 523      $row->Load( (int)$id );
 524      $row->hits = "0";
 525      $row->store();
 526      $row->checkin();
 527  
 528      $msg = 'Successfully Reset Hit';
 529      mosRedirect( 'index2.php?option='. $option .'&task=edit&hidemainmenu=1&id='. $row->id, $msg );
 530  }
 531  
 532  /**
 533  * Cancels an edit operation
 534  * @param database A database connector object
 535  */
 536  function cancel( $option ) {
 537      global $database;
 538  
 539      $row = new mosContent( $database );
 540      $row->bind( $_POST );
 541      $row->checkin();
 542      mosRedirect( 'index2.php?option='. $option );
 543  }
 544  
 545  function menuLink( $option, $id ) {
 546      global $database;
 547  
 548      $menu     = strval( mosGetParam( $_POST, 'menuselect', '' ) );
 549      $link     = strval( mosGetParam( $_POST, 'link_name', '' ) );
 550  
 551      $link    = stripslashes( ampReplace($link) );
 552  
 553      $row                 = new mosMenu( $database );
 554      $row->menutype         = $menu;
 555      $row->name             = $link;
 556      $row->type             = 'content_typed';
 557      $row->published        = 1;
 558      $row->componentid    = $id;
 559      $row->link            = 'index.php?option=com_content&task=view&id='. $id;
 560      $row->ordering        = 9999;
 561  
 562      if (!$row->check()) {
 563          echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
 564          exit();
 565      }
 566      if (!$row->store()) {
 567          echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
 568          exit();
 569      }
 570      $row->checkin();
 571      $row->updateOrder( "menutype=" . $database->Quote( $row->menutype ) . " AND parent=" . (int) $row->parent );
 572  
 573      // clean any existing cache files
 574      mosCache::cleanCache( 'com_content' );
 575  
 576      $msg = $link .' (Link - Static Content) in menu: '. $menu .' successfully created';
 577      mosRedirect( 'index2.php?option='. $option .'&task=edit&hidemainmenu=1&id='. $id, $msg );
 578  }
 579  
 580  function go2menu() {
 581      global $database;
 582  
 583      // checkin content
 584      $row = new mosContent( $database );
 585      $row->bind( $_POST );
 586      $row->checkin();
 587  
 588      $menu = strval( mosGetParam( $_POST, 'menu', 'mainmenu' ) );
 589  
 590      mosRedirect( 'index2.php?option=com_menus&menutype='. $menu );
 591  }
 592  
 593  function go2menuitem() {
 594      global $database;
 595  
 596      // checkin content
 597      $row = new mosContent( $database );
 598      $row->bind( $_POST );
 599      $row->checkin();
 600  
 601      $menu     = strval( mosGetParam( $_POST, 'menu', 'mainmenu' ) );
 602      $id        = intval( mosGetParam( $_POST, 'menuid', 0 ) );
 603  
 604      mosRedirect( 'index2.php?option=com_menus&menutype='. $menu .'&task=edit&hidemainmenu=1&id='. $id );
 605  }
 606  
 607  function saveOrder( &$cid ) {
 608      global $database;
 609  
 610      $total        = count( $cid );
 611      $order         = josGetArrayInts( 'order' );
 612  
 613      $row         = new mosContent( $database );
 614      $conditions = array();
 615  
 616      // update ordering values
 617      for ( $i=0; $i < $total; $i++ ) {
 618          $row->load( (int) $cid[$i] );
 619          if ($row->ordering != $order[$i]) {
 620              $row->ordering = $order[$i];
 621              if (!$row->store()) {
 622                  echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
 623                  exit();
 624              } // if
 625              // remember to updateOrder this group
 626              $condition = "catid=" . (int) $row->catid . " AND state >= 0";
 627              $found = false;
 628              foreach ( $conditions as $cond )
 629                  if ($cond[1]==$condition) {
 630                      $found = true;
 631                      break;
 632                  } // if
 633              if (!$found) $conditions[] = array($row->id, $condition);
 634          } // if
 635      } // for
 636  
 637      // execute updateOrder for each group
 638      foreach ( $conditions as $cond ) {
 639          $row->load( $cond[0] );
 640          $row->updateOrder( $cond[1] );
 641      } // foreach
 642  
 643      // clean any existing cache files
 644      mosCache::cleanCache( 'com_content' );
 645  
 646      $msg     = 'New ordering saved';
 647      mosRedirect( 'index2.php?option=com_typedcontent', $msg );
 648  } // saveOrder
 649  ?>


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