[ Indice ]

Riferimento incrociato di Joomla! 1.5.14 - VM 1.1.4

Servizio fornito da VMItalia
Classe:   Funzione:   Variabile:   Costante:  
Storico Ricerche +

titolo

Corpo

[chiudi]

/administrator/components/com_trash/ -> admin.trash.php (sorgente)

   1  <?php
   2  /**
   3  * @version        $Id: admin.trash.php 10381 2008-06-01 03:35:53Z pasamio $
   4  * @package        Joomla
   5  * @subpackage    Trash
   6  * @copyright    Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
   7  * @license        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( '_JEXEC' ) or die( 'Restricted access' );
  17  
  18  /*
  19   * Make sure the user is authorized to view this page
  20   */
  21  $user = & JFactory::getUser();
  22  if (!$user->authorize( 'com_trash', 'manage' )) {
  23      $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
  24  }
  25  
  26  require_once( JApplicationHelper::getPath( 'admin_html' ) );
  27  
  28  $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
  29  $mid = JRequest::getVar( 'mid', array(0), 'post', 'array' );
  30  
  31  JArrayHelper::toInteger($cid, array(0));
  32  JArrayHelper::toInteger($mid, array(0));
  33  
  34  switch ($task)
  35  {
  36      case 'deleteconfirm':
  37          viewdeleteTrash( $cid, $mid, $option );
  38          break;
  39  
  40      case 'delete':
  41          deleteTrash( $cid, $option );
  42          break;
  43  
  44      case 'restoreconfirm':
  45          viewrestoreTrash( $cid, $mid, $option );
  46          break;
  47  
  48      case 'restore':
  49          restoreTrash( $cid, $option );
  50          break;
  51  
  52      case 'viewMenu':
  53          viewTrashMenu( $option );
  54          break;
  55  
  56      case 'viewContent':
  57          viewTrashContent( $option );
  58          break;
  59  
  60      default:
  61          $return = JRequest::getCmd( 'return', 'viewContent', 'post' );
  62          if ( $return == 'viewMenu' ) {
  63              viewTrashMenu( $option );
  64          } else {
  65              viewTrashContent( $option );
  66          }
  67          break;
  68  }
  69  
  70  
  71  /**
  72  * Compiles a list of trash items
  73  */
  74  function viewTrashContent( $option )
  75  {
  76      global $mainframe;
  77  
  78      $db                    =& JFactory::getDBO();
  79      $filter_order        = $mainframe->getUserStateFromRequest( "$option.viewContent.filter_order",        'filter_order',        'sectname', 'cmd' );
  80      $filter_order_Dir    = $mainframe->getUserStateFromRequest( "$option.viewContent.filter_order_Dir",    'filter_order_Dir',    '',            'word' );
  81      $search                = $mainframe->getUserStateFromRequest( "$option.search",                        'search',             '',            'string' );
  82      $search                = JString::strtolower( $search );
  83  
  84      $limit        = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
  85      $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
  86  
  87      $where[] = 'c.state = -2';
  88  
  89      if ($search) {
  90          $where[] = 'LOWER(c.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
  91      }
  92  
  93      $where         = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
  94      $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', s.name, cc.name, c.title';
  95  
  96      // get the total number of content
  97      $query = 'SELECT count(c.id)'
  98      . ' FROM #__content AS c'
  99      . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid'
 100      . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = "content"'
 101      . ' LEFT JOIN #__groups AS g ON g.id = c.access'
 102      . ' LEFT JOIN #__users AS u ON u.id = c.checked_out'
 103      . $where
 104      ;
 105      $db->setQuery( $query );
 106      $total = $db->loadResult();
 107  
 108      jimport('joomla.html.pagination');
 109      $pageNav = new JPagination( $total, $limitstart, $limit );
 110  
 111      // Query articles
 112      $query = 'SELECT c.title, c.id, c.sectionid, c.catid, g.name AS groupname, cc.title AS catname, s.title AS sectname'
 113      . ' FROM #__content AS c'
 114      . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid'
 115      . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope="content"'
 116      . ' LEFT JOIN #__groups AS g ON g.id = c.access'
 117      . ' LEFT JOIN #__users AS u ON u.id = c.checked_out'
 118      . $where
 119      . $orderby
 120      ;
 121      $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
 122      $contents = $db->loadObjectList();
 123  
 124      for ( $i = 0; $i < count($contents); $i++ ) {
 125          if ( ( $contents[$i]->sectionid == 0 ) && ( $contents[$i]->catid == 0 ) ) {
 126              $contents[$i]->sectname = JText::_('UNCATEGORIZED');
 127          }
 128      }
 129  
 130      // table ordering
 131      $lists['order_Dir']    = $filter_order_Dir;
 132      $lists['order']        = $filter_order;
 133  
 134      // search filter
 135      $lists['search']= $search;
 136  
 137      HTML_trash::showListContent( $option, $contents, $pageNav, $lists );
 138  }
 139  
 140  /**
 141  * Compiles a list of trash items
 142  */
 143  function viewTrashMenu( $option )
 144  {
 145      global $mainframe;
 146  
 147      $db                    =& JFactory::getDBO();
 148      $filter_order        = $mainframe->getUserStateFromRequest( "$option.viewMenu.filter_order",        'filter_order',        'm.menutype',    'cmd' );
 149      $filter_order_Dir    = $mainframe->getUserStateFromRequest( "$option.viewMenu.filter_order_Dir",    'filter_order_Dir',    '',                'word' );
 150      $limit                = $mainframe->getUserStateFromRequest( "limit",                                'limit',            $mainframe->getCfg('list_limit'), 'int' );
 151      $limitstart         = $mainframe->getUserStateFromRequest( "$option.viewMenu.limitstart",        'limitstart',         0,                'int' );
 152      $search                = $mainframe->getUserStateFromRequest( "$option.search",                    'search',            '',                'string' );
 153      $search                = JString::strtolower( $search );
 154  
 155      $where[] = 'm.published = -2';
 156  
 157      if ($search) {
 158          $where[] = 'LOWER(m.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
 159      }
 160  
 161      $where         = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
 162      $orderby     = ' ORDER BY '. $filter_order . ' ' . $filter_order_Dir .', m.menutype, m.ordering, m.ordering,  m.name';
 163  
 164      $query = 'SELECT count(*)'
 165      . ' FROM #__menu AS m'
 166      . ' LEFT JOIN #__users AS u ON u.id = m.checked_out'
 167      . $where
 168      ;
 169      $db->setQuery( $query );
 170      $total = $db->loadResult();
 171  
 172      jimport('joomla.html.pagination');
 173      $pageNav = new JPagination( $total, $limitstart, $limit );
 174  
 175      // Query menu items
 176      $query = 'SELECT m.name, m.id, m.menutype, m.type, com.name AS com_name'
 177      . ' FROM #__menu AS m'
 178      . ' LEFT JOIN #__users AS u ON u.id = m.checked_out'
 179      . ' LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type = "components"'
 180      . $where
 181      . $orderby
 182      ;
 183      $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
 184      $menus = $db->loadObjectList();
 185  
 186      // table ordering
 187      $lists['order_Dir']    = $filter_order_Dir;
 188      $lists['order']        = $filter_order;
 189  
 190      // search filter
 191      $lists['search']= $search;
 192  
 193      HTML_trash::showListMenu( $option, $menus, $pageNav, $lists );
 194  }
 195  
 196  
 197  /**
 198  * Compiles a list of the items you have selected to permanently delte
 199  */
 200  function viewdeleteTrash( $cid, $mid, $option )
 201  {
 202      global $mainframe;
 203  
 204      $db =& JFactory::getDBO();
 205      $return = JRequest::getCmd( 'return', 'viewContent', 'post' );
 206  
 207      JArrayHelper::toInteger($cid, array(0));
 208      JArrayHelper::toInteger($mid, array(0));
 209  
 210      // seperate contentids
 211      $cids = implode( ',', $cid );
 212      $mids = implode( ',', $mid );
 213  
 214      if ( $cids ) {
 215          // Articles query
 216          $query =     'SELECT a.title AS name'
 217          . ' FROM #__content AS a'
 218          . ' WHERE ( a.id IN ( '.$cids.' ) )'
 219          . ' ORDER BY a.title'
 220          ;
 221          $db->setQuery( $query );
 222          $items = $db->loadObjectList();
 223          $id = $cid;
 224          $type = "content";
 225      } else if ( $mids ) {
 226          // Articles query
 227          $query =     'SELECT a.name'
 228          . ' FROM #__menu AS a'
 229          . ' WHERE ( a.id IN ( '.$mids.' ) )'
 230          . ' ORDER BY a.name'
 231          ;
 232          $db->setQuery( $query );
 233          $items = $db->loadObjectList();
 234          $id = $mid;
 235          $type = "menu";
 236      }
 237  
 238      HTML_trash::showDelete( $option, $id, $items, $type, $return );
 239  }
 240  
 241  
 242  /**
 243  * Permanently deletes the selected list of trash items
 244  */
 245  function deleteTrash( $cid, $option )
 246  {
 247      global $mainframe;
 248  
 249      // Check for request forgeries
 250      JRequest::checkToken() or jexit( 'Invalid Token' );
 251  
 252      $db        =& JFactory::getDBO();
 253      $return    = JRequest::getCmd( 'return', 'viewContent', 'post' );
 254      $type    = JRequest::getCmd( 'type', '', 'post' );
 255  
 256      $total = count( $cid );
 257  
 258      if ( $type == 'content' )
 259      {
 260          $obj =& JTable::getInstance('content');
 261  
 262          require_once  (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_frontpage'.DS.'tables'.DS.'frontpage.php');
 263          $fp = new TableFrontPage( $db );
 264          foreach ( $cid as $id ) {
 265              $id = intval( $id );
 266              $obj->delete( $id );
 267              $fp->delete( $id );
 268          }
 269      } else if ( $type == "menu" ) {
 270          $obj =& JTable::getInstance('menu');
 271          foreach ( $cid as $id ) {
 272              $id = intval( $id );
 273              $obj->delete( $id );
 274          }
 275      }
 276  
 277      $msg = JText::sprintf( 'Item(s) successfully Deleted', $total );
 278      $mainframe->redirect( 'index.php?option='.$option.'&task='.$return, $msg );
 279  }
 280  
 281  
 282  /**
 283  * Compiles a list of the items you have selected to permanently delte
 284  */
 285  function viewrestoreTrash( $cid, $mid, $option ) {
 286      global $mainframe;
 287  
 288      $db        =& JFactory::getDBO();
 289      $return = JRequest::getCmd( 'return', 'viewContent', 'post' );
 290  
 291      JArrayHelper::toInteger($cid, array(0));
 292      JArrayHelper::toInteger($mid, array(0));
 293  
 294      // seperate contentids
 295      $cids = implode( ',', $cid );
 296      $mids = implode( ',', $mid );
 297  
 298      if ( $cids ) {
 299          // Articles query
 300          $query = 'SELECT a.title AS name'
 301          . ' FROM #__content AS a'
 302          . ' WHERE ( a.id IN ( '.$cids.' ) )'
 303          . ' ORDER BY a.title'
 304          ;
 305          $db->setQuery( $query );
 306          $items = $db->loadObjectList();
 307          $id = $cid;
 308          $type = "content";
 309      } else if ( $mids ) {
 310          // Articles query
 311          $query = 'SELECT a.name'
 312          . ' FROM #__menu AS a'
 313          . ' WHERE ( a.id IN ( '.$mids.' ) )'
 314          . ' ORDER BY a.name'
 315          ;
 316          $db->setQuery( $query );
 317          $items = $db->loadObjectList();
 318          $id = $mid;
 319          $type = "menu";
 320      }
 321  
 322      HTML_trash::showRestore( $option, $id, $items, $type, $return );
 323  }
 324  
 325  
 326  /**
 327  * Restores items selected to normal - restores to an unpublished state
 328  */
 329  function restoreTrash( $cid, $option )
 330  {
 331      global $mainframe;
 332  
 333      // Check for request forgeries
 334      JRequest::checkToken() or jexit( 'Invalid Token' );
 335  
 336      $db        = & JFactory::getDBO();
 337      $type    = JRequest::getCmd( 'type', '', 'post' );
 338  
 339      $total = count( $cid );
 340  
 341      // restores to an unpublished state
 342      $state         = 0;
 343      $ordering     = 9999;
 344  
 345      if ( $type == 'content' ) {
 346          $return = 'viewContent';
 347  
 348          //seperate contentids
 349          JArrayHelper::toInteger($cid, array(0));
 350          $cids = implode( ',', $cid );
 351  
 352          // query to restore article
 353          $query = 'UPDATE #__content'
 354          . ' SET state = '.(int) $state.', ordering = '.(int) $ordering
 355          . ' WHERE id IN ( '.$cids.' )'
 356          ;
 357          $db->setQuery( $query );
 358          if ( !$db->query() ) {
 359              JError::raiseError(500, $db->getErrorMsg() );
 360          }
 361      } else if ( $type == 'menu' ) {
 362          $return = 'viewMenu';
 363  
 364          jimport('joomla.application.component.model');
 365          JModel::addIncludePath(JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models');
 366          $model =& JModel::getInstance('List', 'MenusModel');
 367          $total = $model->fromTrash($cid);
 368  
 369          if (!$total) {
 370              JError::raiseError(500, $db->getErrorMsg() );
 371          }
 372      }
 373  
 374      $msg = JText::sprintf( 'Item(s) successfully Restored', $total );
 375      $mainframe->redirect( 'index.php?option='.$option.'&task='.$return, $msg );
 376  }
 377  
 378  function ReadMenuXML( $type, $component=-1 )
 379  {
 380      // xml file for module
 381      $xmlfile = JPATH_ADMINISTRATOR .'/components/com_menus/'. $type .'/'. $type .'.xml';
 382  
 383      $data = JApplicationHelper::parseXMLInstallFile($xmlfile);
 384  
 385      if ( $data['type'] == 'component' || $data['type'] == 'menu' )
 386      {
 387          if ( ( $component <> -1 ) && ( $data['name'] == 'Component') ) {
 388              $data['name'] .= ' - '. $component;
 389          }
 390  
 391          $row[0]    = $data['name'];
 392      }
 393  
 394      return $row;
 395  }


Generato il: Mon Oct 19 20:29:27 2009 Generato con PHPXref 0.7