[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: admin.frontpage.php 4996 2006-09-10 16:33:55Z friesengeist $ 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 // ensure user has access to this function 19 if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' ) | $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'com_frontpage' ))) { 20 mosRedirect( 'index2.php', _NOT_AUTH ); 21 } 22 23 // call 24 require_once( $mainframe->getPath( 'admin_html' ) ); 25 require_once( $mainframe->getPath( 'class' ) ); 26 27 $cid = josGetArrayInts( 'cid' ); 28 29 switch ($task) { 30 case 'publish': 31 changeFrontPage( $cid, 1, $option ); 32 break; 33 34 case 'unpublish': 35 changeFrontPage( $cid, 0, $option ); 36 break; 37 38 case 'archive': 39 changeFrontPage( $cid, -1, $option ); 40 break; 41 42 case 'remove': 43 removeFrontPage( $cid, $option ); 44 break; 45 46 case 'orderup': 47 orderFrontPage( intval( $cid[0] ), -1, $option ); 48 break; 49 50 case 'orderdown': 51 orderFrontPage( intval( $cid[0] ), 1, $option ); 52 break; 53 54 case 'saveorder': 55 saveOrder( $cid ); 56 break; 57 58 case 'accesspublic': 59 accessMenu( intval( $cid[0] ), 0 ); 60 break; 61 62 case 'accessregistered': 63 accessMenu( intval( $cid[0] ), 1 ); 64 break; 65 66 case 'accessspecial': 67 accessMenu( intval( $cid[0] ), 2 ); 68 break; 69 70 default: 71 viewFrontPage( $option ); 72 break; 73 } 74 75 76 /** 77 * Compiles a list of frontpage items 78 */ 79 function viewFrontPage( $option ) { 80 global $database, $mainframe, $mosConfig_list_limit; 81 82 $catid = intval( $mainframe->getUserStateFromRequest( "catid{$option}", 'catid', 0 ) ); 83 $filter_authorid = intval( $mainframe->getUserStateFromRequest( "filter_authorid{$option}", 'filter_authorid', 0 ) ); 84 $filter_sectionid = intval( $mainframe->getUserStateFromRequest( "filter_sectionid{$option}", 'filter_sectionid', 0 ) ); 85 86 $limit = intval( $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ) ); 87 $limitstart = intval( $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ) ); 88 $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); 89 if (get_magic_quotes_gpc()) { 90 $search = stripslashes( $search ); 91 } 92 93 $where = array( 94 "c.state >= 0" 95 ); 96 97 // used by filter 98 if ( $filter_sectionid > 0 ) { 99 $where[] = "c.sectionid = " . (int) $filter_sectionid; 100 } 101 if ( $catid > 0 ) { 102 $where[] = "c.catid = " . (int) $catid; 103 } 104 if ( $filter_authorid > 0 ) { 105 $where[] = "c.created_by = " . (int) $filter_authorid; 106 } 107 108 if ($search) { 109 $where[] = "LOWER( c.title ) LIKE '%" . $database->getEscaped( trim( strtolower( $search ) ) ) . "%'"; 110 } 111 112 // get the total number of records 113 $query = "SELECT count(*)" 114 . "\n FROM #__content AS c" 115 . "\n INNER JOIN #__categories AS cc ON cc.id = c.catid" 116 . "\n INNER JOIN #__sections AS s ON s.id = cc.section AND s.scope='content'" 117 . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = c.id" 118 . (count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : '' ) 119 ; 120 $database->setQuery( $query ); 121 $total = $database->loadResult(); 122 123 require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' ); 124 $pageNav = new mosPageNav( $total, $limitstart, $limit ); 125 126 $query = "SELECT c.*, g.name AS groupname, cc.name, s.name AS sect_name, u.name AS editor, f.ordering AS fpordering, v.name AS author" 127 . "\n FROM #__content AS c" 128 . "\n INNER JOIN #__categories AS cc ON cc.id = c.catid" 129 . "\n INNER JOIN #__sections AS s ON s.id = cc.section AND s.scope='content'" 130 . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = c.id" 131 . "\n INNER 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 v ON v.id = c.created_by" 134 . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") 135 . "\n ORDER BY f.ordering" 136 ; 137 $database->setQuery( $query, $pageNav->limitstart,$pageNav->limit ); 138 139 $rows = $database->loadObjectList(); 140 if ($database->getErrorNum()) { 141 echo $database->stderr(); 142 return false; 143 } 144 145 // get list of categories for dropdown filter 146 $query = "SELECT cc.id AS value, cc.title AS text, section" 147 . "\n FROM #__categories AS cc" 148 . "\n INNER JOIN #__sections AS s ON s.id = cc.section " 149 . "\n ORDER BY s.ordering, cc.ordering" 150 ; 151 $categories[] = mosHTML::makeOption( '0', _SEL_CATEGORY ); 152 $database->setQuery( $query ); 153 $categories = array_merge( $categories, $database->loadObjectList() ); 154 $lists['catid'] = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $catid ); 155 156 // get list of sections for dropdown filter 157 $javascript = 'onchange="document.adminForm.submit();"'; 158 $lists['sectionid'] = mosAdminMenus::SelectSection( 'filter_sectionid', $filter_sectionid, $javascript ); 159 160 // get list of Authors for dropdown filter 161 $query = "SELECT c.created_by, u.name" 162 . "\n FROM #__content AS c" 163 . "\n INNER JOIN #__sections AS s ON s.id = c.sectionid" 164 . "\n LEFT JOIN #__users AS u ON u.id = c.created_by" 165 . "\n WHERE c.state != -1" 166 . "\n AND c.state != -2" 167 . "\n GROUP BY u.name" 168 . "\n ORDER BY u.name" 169 ; 170 $authors[] = mosHTML::makeOption( '0', _SEL_AUTHOR, 'created_by', 'name' ); 171 $database->setQuery( $query ); 172 $authors = array_merge( $authors, $database->loadObjectList() ); 173 $lists['authorid'] = mosHTML::selectList( $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid ); 174 175 HTML_content::showList( $rows, $search, $pageNav, $option, $lists ); 176 } 177 178 /** 179 * Changes the state of one or more content pages 180 * @param array An array of unique category id numbers 181 * @param integer 0 if unpublishing, 1 if publishing 182 */ 183 function changeFrontPage( $cid=null, $state=0, $option ) { 184 global $database, $my; 185 186 if (count( $cid ) < 1) { 187 $action = $state == 1 ? 'publish' : ($state == -1 ? 'archive' : 'unpublish'); 188 echo "<script> alert('Select an item to $action'); window.history.go(-1);</script>\n"; 189 exit; 190 } 191 192 mosArrayToInts( $cid ); 193 $cids = 'id=' . implode( ' OR id=', $cid ); 194 195 $query = "UPDATE #__content" 196 . "\n SET state = " . (int) $state 197 . "\n WHERE ( $cids )" 198 . "\n AND ( checked_out = 0 OR ( checked_out = " . (int) $my->id . " ) )" 199 ; 200 $database->setQuery( $query ); 201 if (!$database->query()) { 202 echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; 203 exit(); 204 } 205 206 if (count( $cid ) == 1) { 207 $row = new mosContent( $database ); 208 $row->checkin( $cid[0] ); 209 } 210 211 // clean any existing cache files 212 mosCache::cleanCache( 'com_content' ); 213 214 mosRedirect( "index2.php?option=$option" ); 215 } 216 217 function removeFrontPage( &$cid, $option ) { 218 global $database; 219 220 if (!is_array( $cid ) || count( $cid ) < 1) { 221 echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n"; 222 exit; 223 } 224 $fp = new mosFrontPage( $database ); 225 foreach ($cid as $id) { 226 if (!$fp->delete( (int)$id )) { 227 echo "<script> alert('".$fp->getError()."'); </script>\n"; 228 exit(); 229 } 230 $obj = new mosContent( $database ); 231 $obj->load( (int)$id ); 232 $obj->mask = 0; 233 if (!$obj->store()) { 234 echo "<script> alert('".$fp->getError()."'); </script>\n"; 235 exit(); 236 } 237 } 238 $fp->updateOrder(); 239 240 // clean any existing cache files 241 mosCache::cleanCache( 'com_content' ); 242 243 mosRedirect( "index2.php?option=$option" ); 244 } 245 246 /** 247 * Moves the order of a record 248 * @param integer The increment to reorder by 249 */ 250 function orderFrontPage( $uid, $inc, $option ) { 251 global $database; 252 253 $fp = new mosFrontPage( $database ); 254 $fp->load( (int)$uid ); 255 $fp->move( $inc ); 256 257 // clean any existing cache files 258 mosCache::cleanCache( 'com_content' ); 259 260 mosRedirect( "index2.php?option=$option" ); 261 } 262 263 /** 264 * @param integer The id of the content item 265 * @param integer The new access level 266 * @param string The URL option 267 */ 268 function accessMenu( $uid, $access ) { 269 global $database; 270 271 $row = new mosContent( $database ); 272 $row->load( (int)$uid ); 273 $row->access = $access; 274 275 if ( !$row->check() ) { 276 return $row->getError(); 277 } 278 if ( !$row->store() ) { 279 return $row->getError(); 280 } 281 282 // clean any existing cache files 283 mosCache::cleanCache( 'com_content' ); 284 285 mosRedirect( 'index2.php?option=com_frontpage' ); 286 } 287 288 function saveOrder( &$cid ) { 289 global $database; 290 291 $total = count( $cid ); 292 $order = josGetArrayInts( 'order' ); 293 294 for( $i=0; $i < $total; $i++ ) { 295 $query = "UPDATE #__content_frontpage" 296 . "\n SET ordering = " . (int) $order[$i] 297 . "\n WHERE content_id = " . (int) $cid[$i]; 298 $database->setQuery( $query ); 299 if (!$database->query()) { 300 echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; 301 exit(); 302 } 303 304 // update ordering 305 $row = new mosFrontPage( $database ); 306 $row->load( (int)$cid[$i] ); 307 $row->updateOrder(); 308 } 309 310 // clean any existing cache files 311 mosCache::cleanCache( 'com_content' ); 312 313 $msg = 'New ordering saved'; 314 mosRedirect( 'index2.php?option=com_frontpage', $msg ); 315 } 316 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |