Annotation of /mambo/branches/4.6/administrator/components/com_content/admin.content.php
Parent Directory
|
Revision Log
Revision 905 - (view) (download)
| 1 : | neilt | 492 | <?php |
| 2 : | /** | ||
| 3 : | * @package Mambo Open Source | ||
| 4 : | * @subpackage Content | ||
| 5 : | * @copyright (C) 2005 - 2006 Mambo Foundation Inc. | ||
| 6 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL | ||
| 7 : | * | ||
| 8 : | neilt | 516 | * |
| 9 : | neilt | 492 | * Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure |
| 10 : | * that Mambo remained free Open Source software owned and managed by the community. | ||
| 11 : | * Mambo is Free Software | ||
| 12 : | */ | ||
| 13 : | |||
| 14 : | /** ensure this file is being included by a parent file */ | ||
| 15 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 16 : | |||
| 17 : | require_once( $mainframe->getPath( 'admin_html' ) ); | ||
| 18 : | require_once($mosConfig_absolute_path.'/components/com_content/content.class.php'); | ||
| 19 : | |||
| 20 : | $sectionid = mosGetParam( $_REQUEST, 'sectionid', 0 ); | ||
| 21 : | $id = mosGetParam( $_REQUEST, 'id', '' ); | ||
| 22 : | $cid = mosGetParam( $_POST, 'cid', array(0) ); | ||
| 23 : | if (!is_array( $cid )) { | ||
| 24 : | $cid = array(0); | ||
| 25 : | } | ||
| 26 : | |||
| 27 : | switch ($task) { | ||
| 28 : | case 'clean_cache': | ||
| 29 : | mosCache::cleanCache( 'com_content' ); | ||
| 30 : | mosRedirect( 'index2.php', 'Cache cleaned' ); | ||
| 31 : | break; | ||
| 32 : | |||
| 33 : | case 'new': | ||
| 34 : | editContent( 0, $sectionid, $option ); | ||
| 35 : | break; | ||
| 36 : | |||
| 37 : | case 'edit': | ||
| 38 : | editContent( $id, $sectionid, $option ); | ||
| 39 : | break; | ||
| 40 : | |||
| 41 : | case 'editA': | ||
| 42 : | editContent( $cid[0], '', $option ); | ||
| 43 : | break; | ||
| 44 : | |||
| 45 : | case 'go2menu': | ||
| 46 : | case 'go2menuitem': | ||
| 47 : | case 'resethits': | ||
| 48 : | case 'menulink': | ||
| 49 : | case 'apply': | ||
| 50 : | case 'save': | ||
| 51 : | mosCache::cleanCache( 'com_content' ); | ||
| 52 : | saveContent( $sectionid, $task ); | ||
| 53 : | break; | ||
| 54 : | |||
| 55 : | case 'remove': | ||
| 56 : | removeContent( $cid, $sectionid, $option ); | ||
| 57 : | break; | ||
| 58 : | |||
| 59 : | case 'publish': | ||
| 60 : | changeContent( $cid, 1, $option ); | ||
| 61 : | break; | ||
| 62 : | |||
| 63 : | case 'unpublish': | ||
| 64 : | changeContent( $cid, 0, $option ); | ||
| 65 : | break; | ||
| 66 : | |||
| 67 : | case 'toggle_frontpage': | ||
| 68 : | toggleFrontPage( $cid, $sectionid, $option ); | ||
| 69 : | break; | ||
| 70 : | |||
| 71 : | case 'archive': | ||
| 72 : | changeContent( $cid, -1, $option ); | ||
| 73 : | break; | ||
| 74 : | |||
| 75 : | case 'unarchive': | ||
| 76 : | changeContent( $cid, 0, $option ); | ||
| 77 : | break; | ||
| 78 : | |||
| 79 : | case 'cancel': | ||
| 80 : | cancelContent(); | ||
| 81 : | break; | ||
| 82 : | |||
| 83 : | case 'orderup': | ||
| 84 : | orderContent( $cid[0], -1, $option ); | ||
| 85 : | break; | ||
| 86 : | |||
| 87 : | case 'orderdown': | ||
| 88 : | orderContent( $cid[0], 1, $option ); | ||
| 89 : | break; | ||
| 90 : | |||
| 91 : | case 'showarchive': | ||
| 92 : | viewArchive( $sectionid, $option ); | ||
| 93 : | break; | ||
| 94 : | |||
| 95 : | case 'movesect': | ||
| 96 : | moveSection( $cid, $sectionid, $option ); | ||
| 97 : | break; | ||
| 98 : | |||
| 99 : | case 'movesectsave': | ||
| 100 : | moveSectionSave( $cid, $sectionid, $option ); | ||
| 101 : | break; | ||
| 102 : | |||
| 103 : | case 'copy': | ||
| 104 : | copyItem( $cid, $sectionid, $option ); | ||
| 105 : | break; | ||
| 106 : | |||
| 107 : | case 'copysave': | ||
| 108 : | copyItemSave( $cid, $sectionid, $option ); | ||
| 109 : | break; | ||
| 110 : | |||
| 111 : | case 'accesspublic': | ||
| 112 : | accessMenu( $cid[0], 0, $option ); | ||
| 113 : | break; | ||
| 114 : | |||
| 115 : | case 'accessregistered': | ||
| 116 : | accessMenu( $cid[0], 1, $option ); | ||
| 117 : | break; | ||
| 118 : | |||
| 119 : | case 'accessspecial': | ||
| 120 : | accessMenu( $cid[0], 2, $option ); | ||
| 121 : | break; | ||
| 122 : | |||
| 123 : | case 'saveorder': | ||
| 124 : | saveOrder( $cid ); | ||
| 125 : | break; | ||
| 126 : | |||
| 127 : | default: | ||
| 128 : | viewContent( $sectionid, $option ); | ||
| 129 : | break; | ||
| 130 : | } | ||
| 131 : | |||
| 132 : | /** | ||
| 133 : | * Compiles a list of installed or defined modules | ||
| 134 : | * @param database A database connector object | ||
| 135 : | */ | ||
| 136 : | function viewContent( $sectionid, $option ) { | ||
| 137 : | global $database, $mainframe, $mosConfig_list_limit; | ||
| 138 : | |||
| 139 : | $catid = $mainframe->getUserStateFromRequest( "catid{$option}{$sectionid}", 'catid', 0 ); | ||
| 140 : | $filter_authorid = $mainframe->getUserStateFromRequest( "filter_authorid{$option}{$sectionid}", 'filter_authorid', 0 ); | ||
| 141 : | $filter_sectionid = $mainframe->getUserStateFromRequest( "filter_sectionid{$option}{$sectionid}", 'filter_sectionid', 0 ); | ||
| 142 : | $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ); | ||
| 143 : | $limitstart = $mainframe->getUserStateFromRequest( "view{$option}{$sectionid}limitstart", 'limitstart', 0 ); | ||
| 144 : | $search = $mainframe->getUserStateFromRequest( "search{$option}{$sectionid}", 'search', '' ); | ||
| 145 : | $search = $database->getEscaped( trim( strtolower( $search ) ) ); | ||
| 146 : | $redirect = $sectionid; | ||
| 147 : | $filter = ''; //getting a undefined variable error | ||
| 148 : | |||
| 149 : | if ( $sectionid == 0 ) { | ||
| 150 : | // used to show All content items | ||
| 151 : | $where = array( | ||
| 152 : | "c.state >= 0", | ||
| 153 : | "c.catid=cc.id", | ||
| 154 : | "cc.section=s.id", | ||
| 155 : | "s.scope='content'", | ||
| 156 : | ); | ||
| 157 : | $order = "\n ORDER BY s.title, c.catid, cc.ordering, cc.title, c.ordering"; | ||
| 158 : | $all = 1; | ||
| 159 : | //$filter = "\n , #__sections AS s WHERE s.id = c.section"; | ||
| 160 : | |||
| 161 : | if ($filter_sectionid > 0) { | ||
| 162 : | $filter = "\nWHERE cc.section=$filter_sectionid"; | ||
| 163 : | } | ||
| 164 : | $section->title = T_('All Content Items'); | ||
| 165 : | $section->id = 0; | ||
| 166 : | } else { | ||
| 167 : | $where = array( | ||
| 168 : | "c.state >= 0", | ||
| 169 : | "c.catid=cc.id", | ||
| 170 : | "cc.section=s.id", | ||
| 171 : | "s.scope='content'", | ||
| 172 : | "c.sectionid='$sectionid'" | ||
| 173 : | ); | ||
| 174 : | $order = "\n ORDER BY cc.ordering, cc.title, c.ordering"; | ||
| 175 : | $all = NULL; | ||
| 176 : | $filter = "\n WHERE cc.section = '$sectionid'"; | ||
| 177 : | $section = new mosSection( $database ); | ||
| 178 : | $section->load( $sectionid ); | ||
| 179 : | } | ||
| 180 : | |||
| 181 : | // used by filter | ||
| 182 : | if ( $filter_sectionid > 0 ) { | ||
| 183 : | $where[] = "c.sectionid = '$filter_sectionid'"; | ||
| 184 : | } | ||
| 185 : | if ( $catid > 0 ) { | ||
| 186 : | $where[] = "c.catid = '$catid'"; | ||
| 187 : | } | ||
| 188 : | if ( $filter_authorid > 0 ) { | ||
| 189 : | $where[] = "c.created_by = '$filter_authorid'"; | ||
| 190 : | } | ||
| 191 : | |||
| 192 : | if ( $search ) { | ||
| 193 : | $where[] = "LOWER( c.title ) LIKE '%$search%'"; | ||
| 194 : | } | ||
| 195 : | |||
| 196 : | // get the total number of records | ||
| 197 : | $database->setQuery( "SELECT count(*) FROM #__content AS c, #__categories AS cc, #__sections AS s" | ||
| 198 : | . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") | ||
| 199 : | ); | ||
| 200 : | $total = $database->loadResult(); | ||
| 201 : | require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' ); | ||
| 202 : | $pageNav = new mosPageNav( $total, $limitstart, $limit ); | ||
| 203 : | |||
| 204 : | $query = "SELECT c.*, g.name AS groupname, cc.name, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author" | ||
| 205 : | . "\n FROM #__categories AS cc, #__sections AS s, #__content AS c" | ||
| 206 : | . "\n LEFT JOIN #__groups AS g ON g.id = c.access" | ||
| 207 : | . "\n LEFT JOIN #__users AS u ON u.id = c.checked_out" | ||
| 208 : | . "\n LEFT JOIN #__users AS v ON v.id = c.created_by" | ||
| 209 : | . "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id" | ||
| 210 : | . ( count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : '' ) | ||
| 211 : | . $order | ||
| 212 : | . "\n LIMIT $pageNav->limitstart,$pageNav->limit" | ||
| 213 : | ; | ||
| 214 : | $database->setQuery( $query ); | ||
| 215 : | $rows = $database->loadObjectList(); | ||
| 216 : | |||
| 217 : | if ($database->getErrorNum()) { | ||
| 218 : | echo $database->stderr(); | ||
| 219 : | return false; | ||
| 220 : | } | ||
| 221 : | |||
| 222 : | // get list of categories for dropdown filter | ||
| 223 : | $query = "SELECT cc.id AS value, cc.title AS text, section" | ||
| 224 : | . "\n FROM #__categories AS cc" | ||
| 225 : | . "\n INNER JOIN #__sections AS s ON s.id=cc.section " | ||
| 226 : | . $filter | ||
| 227 : | . "\n ORDER BY s.ordering, cc.ordering" | ||
| 228 : | ; | ||
| 229 : | $lists['catid'] = filterCategory( $query, $catid ); | ||
| 230 : | |||
| 231 : | // get list of sections for dropdown filter | ||
| 232 : | $javascript = 'onchange="document.adminForm.submit();"'; | ||
| 233 : | $lists['sectionid'] = mosAdminMenus::SelectSection( 'filter_sectionid', $filter_sectionid, $javascript ); | ||
| 234 : | |||
| 235 : | // get list of Authors for dropdown filter | ||
| 236 : | $query = "SELECT c.created_by AS value, u.name AS text" | ||
| 237 : | . "\n FROM #__content AS c" | ||
| 238 : | . "\n INNER JOIN #__sections AS s ON s.id = c.sectionid" | ||
| 239 : | . "\n LEFT JOIN #__users AS u ON u.id = c.created_by" | ||
| 240 : | . "\n WHERE c.state <> '-1'" | ||
| 241 : | . "\n AND c.state <> '-2'" | ||
| 242 : | . "\n GROUP BY u.name" | ||
| 243 : | . "\n ORDER BY u.name" | ||
| 244 : | ; | ||
| 245 : | $authors[] = mosHTML::makeOption( '0', T_('- All Authors -') ); | ||
| 246 : | $database->setQuery( $query ); | ||
| 247 : | cauld | 741 | if (is_array($database->loadObjectList())) { |
| 248 : | $authors = array_merge( $authors, $database->loadObjectList() ); | ||
| 249 : | } | ||
| 250 : | neilt | 492 | $lists['authorid'] = mosHTML::selectList( $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_authorid ); |
| 251 : | |||
| 252 : | HTML_content::showContent( $rows, $section, $lists, $search, $pageNav, $all, $redirect ); | ||
| 253 : | } | ||
| 254 : | |||
| 255 : | /** | ||
| 256 : | * Shows a list of archived content items | ||
| 257 : | * @param int The section id | ||
| 258 : | */ | ||
| 259 : | function viewArchive( $sectionid, $option ) { | ||
| 260 : | global $database, $mainframe, $mosConfig_list_limit; | ||
| 261 : | |||
| 262 : | $catid = $mainframe->getUserStateFromRequest( "catidarc{$option}{$sectionid}", 'catid', 0 ); | ||
| 263 : | $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ); | ||
| 264 : | $limitstart = $mainframe->getUserStateFromRequest( "viewarc{$option}{$sectionid}limitstart", 'limitstart', 0 ); | ||
| 265 : | $search = $mainframe->getUserStateFromRequest( "searcharc{$option}{$sectionid}", 'search', '' ); | ||
| 266 : | $filter_authorid = $mainframe->getUserStateFromRequest( "filter_authorid{$option}{$sectionid}", 'filter_authorid', 0 ); | ||
| 267 : | $filter_sectionid = $mainframe->getUserStateFromRequest( "filter_sectionid{$option}{$sectionid}", 'filter_sectionid', 0 ); | ||
| 268 : | $search = $database->getEscaped( trim( strtolower( $search ) ) ); | ||
| 269 : | $redirect = $sectionid; | ||
| 270 : | |||
| 271 : | if ( $sectionid == 0 ) { | ||
| 272 : | $where = array( | ||
| 273 : | "c.state = -1", | ||
| 274 : | "c.catid=cc.id", | ||
| 275 : | "cc.section=s.id", | ||
| 276 : | "s.scope='content'" | ||
| 277 : | ); | ||
| 278 : | $filter = "\n , #__sections AS s WHERE s.id = c.section"; | ||
| 279 : | $all = 1; | ||
| 280 : | } else { | ||
| 281 : | $where = array( | ||
| 282 : | "c.state = -1", | ||
| 283 : | "c.catid=cc.id", | ||
| 284 : | "cc.section=s.id", | ||
| 285 : | "s.scope='content'", | ||
| 286 : | "c.sectionid='$sectionid'" | ||
| 287 : | ); | ||
| 288 : | $filter = "\n WHERE section = '$sectionid'"; | ||
| 289 : | $all = NULL; | ||
| 290 : | } | ||
| 291 : | |||
| 292 : | // used by filter | ||
| 293 : | if ( $filter_sectionid > 0 ) { | ||
| 294 : | $where[] = "c.sectionid = '$filter_sectionid'"; | ||
| 295 : | } | ||
| 296 : | if ( $filter_authorid > 0 ) { | ||
| 297 : | $where[] = "c.created_by = '$filter_authorid'"; | ||
| 298 : | } | ||
| 299 : | if ($catid > 0) { | ||
| 300 : | $where[] = "c.catid='$catid'"; | ||
| 301 : | } | ||
| 302 : | if ($search) { | ||
| 303 : | $where[] = "LOWER(c.title) LIKE '%$search%'"; | ||
| 304 : | } | ||
| 305 : | |||
| 306 : | // get the total number of records | ||
| 307 : | $query = "SELECT count(*)" | ||
| 308 : | . "FROM #__content AS c, #__categories AS cc, #__sections AS s" | ||
| 309 : | . ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : '' ) | ||
| 310 : | ; | ||
| 311 : | $database->setQuery( $query ); | ||
| 312 : | $total = $database->loadResult(); | ||
| 313 : | |||
| 314 : | require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' ); | ||
| 315 : | $pageNav = new mosPageNav( $total, $limitstart, $limit ); | ||
| 316 : | |||
| 317 : | $query = "SELECT c.*, g.name AS groupname, cc.name, v.name AS author" | ||
| 318 : | . "\n FROM #__categories AS cc, #__sections AS s, #__content AS c" | ||
| 319 : | . "\n LEFT JOIN #__groups AS g ON g.id = c.access" | ||
| 320 : | . "\n LEFT JOIN #__users AS v ON v.id = c.created_by" | ||
| 321 : | . ( count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : '' ) | ||
| 322 : | . "\n ORDER BY c.catid, c.ordering" | ||
| 323 : | . "\n LIMIT $pageNav->limitstart,$pageNav->limit" | ||
| 324 : | ; | ||
| 325 : | $database->setQuery( $query ); | ||
| 326 : | $rows = $database->loadObjectList(); | ||
| 327 : | if ($database->getErrorNum()) { | ||
| 328 : | echo $database->stderr(); | ||
| 329 : | return; | ||
| 330 : | } | ||
| 331 : | |||
| 332 : | // get list of categories for dropdown filter | ||
| 333 : | $query = "SELECT c.id AS value, c.title AS text" | ||
| 334 : | . "\n FROM #__categories AS c" | ||
| 335 : | . $filter | ||
| 336 : | . "\n ORDER BY c.ordering" | ||
| 337 : | ; | ||
| 338 : | $lists['catid'] = filterCategory( $query, $catid ); | ||
| 339 : | |||
| 340 : | // get list of sections for dropdown filter | ||
| 341 : | $javascript = 'onchange="document.adminForm.submit();"'; | ||
| 342 : | $lists['sectionid'] = mosAdminMenus::SelectSection( 'filter_sectionid', $filter_sectionid, $javascript ); | ||
| 343 : | |||
| 344 : | $section = new mosSection( $database ); | ||
| 345 : | $section->load( $sectionid ); | ||
| 346 : | |||
| 347 : | // get list of Authors for dropdown filter | ||
| 348 : | $query = "SELECT c.created_by AS value, u.name AS text" | ||
| 349 : | . "\n FROM #__content AS c" | ||
| 350 : | . "\n INNER JOIN #__sections AS s ON s.id = c.sectionid" | ||
| 351 : | . "\n LEFT JOIN #__users AS u ON u.id = c.created_by" | ||
| 352 : | . "\n WHERE c.state = '-1'" | ||
| 353 : | . "\n GROUP BY u.name" | ||
| 354 : | . "\n ORDER BY u.name" | ||
| 355 : | ; | ||
| 356 : | $authors[] = mosHTML::makeOption( '0', T_('- All Authors -') ); | ||
| 357 : | $database->setQuery( $query ); | ||
| 358 : | $moreauthors = $database->loadObjectList(); | ||
| 359 : | if ($moreauthors) $authors = array_merge( $authors, $moreauthors ); | ||
| 360 : | $lists['authorid'] = mosHTML::selectList( $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_authorid ); | ||
| 361 : | |||
| 362 : | HTML_content::showArchive( $rows, $section, $lists, $search, $pageNav, $option, $all, $redirect ); | ||
| 363 : | } | ||
| 364 : | |||
| 365 : | /** | ||
| 366 : | * Compiles information to add or edit the record | ||
| 367 : | * @param database A database connector object | ||
| 368 : | * @param integer The unique id of the record to edit (0 if new) | ||
| 369 : | * @param integer The id of the content section | ||
| 370 : | */ | ||
| 371 : | function editContent( $uid=0, $sectionid=0, $option ) { | ||
| 372 : | global $database, $my, $mainframe; | ||
| 373 : | global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_offset; | ||
| 374 : | |||
| 375 : | $redirect = mosGetParam( $_POST, 'redirect', '' ); | ||
| 376 : | if ( !$redirect ) { | ||
| 377 : | $redirect = $sectionid; | ||
| 378 : | } | ||
| 379 : | |||
| 380 : | // load the row from the db table | ||
| 381 : | $row = new mosContent( $database ); | ||
| 382 : | $row->load( $uid ); | ||
| 383 : | |||
| 384 : | if ($uid) { | ||
| 385 : | $sectionid = $row->sectionid; | ||
| 386 : | if ($row->state < 0) { | ||
| 387 : | mosRedirect( 'index2.php?option=com_content§ionid='. $row->sectionid, T_('You cannot edit an archived item') ); | ||
| 388 : | } | ||
| 389 : | } | ||
| 390 : | |||
| 391 : | if ( $sectionid == 0 ) { | ||
| 392 : | $where = "\n WHERE section NOT LIKE '%com_%'"; | ||
| 393 : | } else { | ||
| 394 : | $where = "\n WHERE section='$sectionid'"; | ||
| 395 : | } | ||
| 396 : | |||
| 397 : | // get the type name - which is a special category | ||
| 398 : | if ($row->sectionid){ | ||
| 399 : | $query = "SELECT name FROM #__sections WHERE id=$row->sectionid"; | ||
| 400 : | $database->setQuery( $query ); | ||
| 401 : | $section = $database->loadResult(); | ||
| 402 : | $contentSection = $section; | ||
| 403 : | } else { | ||
| 404 : | $query = "SELECT name FROM #__sections WHERE id=$sectionid"; | ||
| 405 : | $database->setQuery( $query ); | ||
| 406 : | $section = $database->loadResult(); | ||
| 407 : | $contentSection = $section; | ||
| 408 : | } | ||
| 409 : | |||
| 410 : | // fail if checked out not by 'me' | ||
| 411 : | if ($row->checked_out && $row->checked_out <> $my->id) { | ||
| 412 : | mosRedirect( 'index2.php?option=com_content', sprintf(T_('The module %s is currently being edited by another administrator'), $row->title) ); | ||
| 413 : | } | ||
| 414 : | |||
| 415 : | if ($uid) { | ||
| 416 : | $row->checkout( $my->id ); | ||
| 417 : | if (trim( $row->images )) { | ||
| 418 : | $row->images = explode( "\n", $row->images ); | ||
| 419 : | } else { | ||
| 420 : | $row->images = array(); | ||
| 421 : | } | ||
| 422 : | |||
| 423 : | $row->created = mosFormatDate( $row->created, '%Y-%m-%d %H:%M:%S' ); | ||
| 424 : | $row->modified = mosFormatDate( $row->modified, '%Y-%m-%d %H:%M:%S' ); | ||
| 425 : | $row->publish_up = mosFormatDate( $row->publish_up, '%Y-%m-%d %H:%M:%S' ); | ||
| 426 : | |||
| 427 : | if (trim( $row->publish_down ) == '0000-00-00 00:00:00') { | ||
| 428 : | $row->publish_down = T_('Never'); | ||
| 429 : | } | ||
| 430 : | |||
| 431 : | $query = "SELECT name from #__users" | ||
| 432 : | . "\n WHERE id=$row->created_by" | ||
| 433 : | ; | ||
| 434 : | $database->setQuery( $query ); | ||
| 435 : | $row->creator = $database->loadResult(); | ||
| 436 : | |||
| 437 : | $query = "SELECT name from #__users" | ||
| 438 : | . "\n WHERE id=$row->modified_by" | ||
| 439 : | ; | ||
| 440 : | $database->setQuery( $query ); | ||
| 441 : | $row->modifier = $database->loadResult(); | ||
| 442 : | |||
| 443 : | $query = "SELECT content_id from #__content_frontpage" | ||
| 444 : | . "\n WHERE content_id=$row->id" | ||
| 445 : | ; | ||
| 446 : | $database->setQuery( $query ); | ||
| 447 : | $row->frontpage = $database->loadResult(); | ||
| 448 : | |||
| 449 : | // get list of links to this item | ||
| 450 : | $_and = "\n AND componentid = ". $row->id; | ||
| 451 : | $menus = mosAdminMenus::Links2Menu( 'content_item_link', $_and ); | ||
| 452 : | } else { | ||
| 453 : | $row->sectionid = $sectionid; | ||
| 454 : | $row->version = 0; | ||
| 455 : | $row->state = 1; | ||
| 456 : | $row->ordering = 0; | ||
| 457 : | $row->images = array(); | ||
| 458 : | //$row->publish_up = date( 'Y-m-d', time() ); | ||
| 459 : | $row->publish_up = date( 'Y-m-d', time() + $mosConfig_offset * 60 * 60 ); | ||
| 460 : | $row->publish_down = T_('Never'); | ||
| 461 : | $row->catid = NULL; | ||
| 462 : | $row->creator = ''; | ||
| 463 : | $row->modifier = ''; | ||
| 464 : | $row->frontpage = 0; | ||
| 465 : | $menus = array(); | ||
| 466 : | } | ||
| 467 : | |||
| 468 : | $javascript = "onchange=\"changeDynaList( 'catid', sectioncategories, document.adminForm.sectionid.options[document.adminForm.sectionid.selectedIndex].value, 0, 0);\""; | ||
| 469 : | |||
| 470 : | $query = "SELECT s.id AS value, s.title AS text" | ||
| 471 : | . "\n FROM #__sections AS s" | ||
| 472 : | . "\n ORDER BY s.ordering"; | ||
| 473 : | $database->setQuery( $query ); | ||
| 474 : | neilt | 516 | |
| 475 : | $sections = $database->loadObjectList(); | ||
| 476 : | |||
| 477 : | neilt | 492 | if ( $sectionid == 0 ) { |
| 478 : | neilt | 516 | if ($sections) { |
| 479 : | array_unshift ($sections, mosHTML::makeOption( '-1', T_('Select Section'))); | ||
| 480 : | neilt | 492 | } else { |
| 481 : | $sections[] = mosHTML::makeOption( '-1', T_('Add Section(s) First') ); | ||
| 482 : | } | ||
| 483 : | $lists['sectionid'] = mosHTML::selectList( $sections, 'sectionid', 'class="inputbox" size="1" '. $javascript, 'value', 'text' ); | ||
| 484 : | } else { | ||
| 485 : | neilt | 517 | $lists['sectionid'] = mosHTML::selectList( $sections, 'sectionid', 'class="inputbox" size="1" '. $javascript, 'value', 'text', intval( $row->sectionid)); |
| 486 : | neilt | 492 | } |
| 487 : | neilt | 516 | |
| 488 : | neilt | 492 | $sectioncategories = array(); |
| 489 : | $sectioncategories[-1] = array(); | ||
| 490 : | $sectioncategories[-1][] = mosHTML::makeOption( '-1', T_('Select Category') ); | ||
| 491 : | neilt | 516 | if ($sections) foreach($sections as $section) { |
| 492 : | $sectioncategories[$section->value] = array(); | ||
| 493 : | $query = "SELECT id AS value, name AS text" | ||
| 494 : | . "\n FROM #__categories" | ||
| 495 : | . "\n WHERE section='$section->value'" | ||
| 496 : | . "\n ORDER BY ordering"; | ||
| 497 : | $database->setQuery( $query ); | ||
| 498 : | $rows2 = $database->loadObjectList(); | ||
| 499 : | if ($rows2) foreach($rows2 as $row2) $sectioncategories[$section->value][] = mosHTML::makeOption( $row2->value, $row2->text ); | ||
| 500 : | else $sectioncategories[$section->value][] = mosHTML::makeOption( "-1", T_('Add Categories First') ); | ||
| 501 : | neilt | 492 | } |
| 502 : | |||
| 503 : | // get list of categories | ||
| 504 : | if ( !$row->catid && !$row->sectionid ) { | ||
| 505 : | $categories[] = mosHTML::makeOption( '-1', T_('Select Category') ); | ||
| 506 : | $lists['catid'] = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1"', 'value', 'text' ); | ||
| 507 : | } else { | ||
| 508 : | $query = "SELECT id AS value, name AS text" | ||
| 509 : | . "\n FROM #__categories" | ||
| 510 : | . $where | ||
| 511 : | . "\n ORDER BY ordering"; | ||
| 512 : | $database->setQuery( $query ); | ||
| 513 : | $categories[] = mosHTML::makeOption( '-1', T_('Select Category') ); | ||
| 514 : | $categories = array_merge( $categories, $database->loadObjectList() ); | ||
| 515 : | $lists['catid'] = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1"', 'value', 'text', intval( $row->catid ) ); | ||
| 516 : | } | ||
| 517 : | |||
| 518 : | // build the html select list for ordering | ||
| 519 : | $query = "SELECT ordering AS value, title AS text" | ||
| 520 : | . "\n FROM #__content" | ||
| 521 : | . "\n WHERE catid='$row->catid'" | ||
| 522 : | . "\n AND state >= 0" | ||
| 523 : | . "\n ORDER BY ordering" | ||
| 524 : | ; | ||
| 525 : | $lists['ordering'] = mosAdminMenus::SpecificOrdering( $row, $uid, $query, 1 ); | ||
| 526 : | |||
| 527 : | // calls function to read image from directory | ||
| 528 : | $pathA = $mosConfig_absolute_path .'/images/stories'; | ||
| 529 : | $pathL = $mosConfig_live_site .'/images/stories'; | ||
| 530 : | $images = array(); | ||
| 531 : | $folders = array(); | ||
| 532 : | $folders[] = mosHTML::makeOption( '/' ); | ||
| 533 : | mosAdminMenus::ReadImages( $pathA, '/', $folders, $images ); | ||
| 534 : | |||
| 535 : | // list of folders in images/stories/ | ||
| 536 : | $lists['folders'] = mosAdminMenus::GetImageFolders( $folders, $pathL ); | ||
| 537 : | // list of images in specfic folder in images/stories/ | ||
| 538 : | $lists['imagefiles'] = mosAdminMenus::GetImages( $images, $pathL ); | ||
| 539 : | // list of saved images | ||
| 540 : | $lists['imagelist'] = mosAdminMenus::GetSavedImages( $row, $pathL ); | ||
| 541 : | |||
| 542 : | // build list of users | ||
| 543 : | $active = ( intval( $row->created_by ) ? intval( $row->created_by ) : $my->id ); | ||
| 544 : | $lists['created_by'] = mosAdminMenus::UserSelect( 'created_by', $active ); | ||
| 545 : | // build the select list for the image position alignment | ||
| 546 : | $lists['_align'] = mosAdminMenus::Positions( '_align' ); | ||
| 547 : | // build the select list for the image caption alignment | ||
| 548 : | $lists['_caption_align'] = mosAdminMenus::Positions( '_caption_align' ); | ||
| 549 : | // build the html select list for the group access | ||
| 550 : | $lists['access'] = mosAdminMenus::Access( $row ); | ||
| 551 : | // build the html select list for menu selection | ||
| 552 : | $lists['menuselect'] = mosAdminMenus::MenuSelect( ); | ||
| 553 : | |||
| 554 : | // build the select list for the image caption position | ||
| 555 : | $pos[] = mosHTML::makeOption( 'bottom', T_('Bottom') ); | ||
| 556 : | $pos[] = mosHTML::makeOption( 'top', T_('Top') ); | ||
| 557 : | $lists['_caption_position'] = mosHTML::selectList( $pos, '_caption_position', 'class="inputbox" size="1"', 'value', 'text' ); | ||
| 558 : | |||
| 559 : | |||
| 560 : | // get params definitions | ||
| 561 : | $params =& new mosAdminParameters( $row->attribs, $mainframe->getPath( 'com_xml', 'com_content' ), 'component' ); | ||
| 562 : | |||
| 563 : | HTML_content::editContent( $row, $contentSection, $lists, $sectioncategories, $images, $params, $option, $redirect, $menus ); | ||
| 564 : | } | ||
| 565 : | |||
| 566 : | /** | ||
| 567 : | * Saves the content item an edit form submit | ||
| 568 : | * @param database A database connector object | ||
| 569 : | */ | ||
| 570 : | function saveContent( $sectionid, $task ) { | ||
| 571 : | global $database, $my, $mainframe, $mosConfig_offset; | ||
| 572 : | |||
| 573 : | $menu = mosGetParam( $_POST, 'menu', 'mainmenu' ); | ||
| 574 : | $menuid = mosGetParam( $_POST, 'menuid', 0 ); | ||
| 575 : | |||
| 576 : | $row = new mosContent( $database ); | ||
| 577 : | if (!$row->bind( $_POST )) { | ||
| 578 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 579 : | exit(); | ||
| 580 : | } | ||
| 581 : | |||
| 582 : | $isNew = ( $row->id < 1 ); | ||
| 583 : | if ($isNew) { | ||
| 584 : | //$row->created = $row->created ? $row->created : date( "Y-m-d H:i:s" ); | ||
| 585 : | $row->created = $row->created ? mosFormatDate( $row->created, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset * 60 * 60 ) : date( "Y-m-d H:i:s" ); | ||
| 586 : | $row->created_by = $row->created_by ? $row->created_by : $my->id; | ||
| 587 : | } else { | ||
| 588 : | $row->modified = date( "Y-m-d H:i:s" ); | ||
| 589 : | $row->modified_by = $my->id; | ||
| 590 : | //$row->created = $row->created ? $row->created : date( "Y-m-d H:i:s" ); | ||
| 591 : | $row->created = $row->created ? mosFormatDate( $row->created, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset ) : date( "Y-m-d H:i:s" ); | ||
| 592 : | $row->created_by = $row->created_by ? $row->created_by : $my->id; | ||
| 593 : | } | ||
| 594 : | |||
| 595 : | if (strlen(trim( $row->publish_up )) <= 10) { | ||
| 596 : | $row->publish_up .= " 00:00:00"; | ||
| 597 : | } | ||
| 598 : | $row->publish_up = mosFormatDate($row->publish_up, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset ); | ||
| 599 : | |||
| 600 : | if (trim( $row->publish_down ) == T_("Never")) { | ||
| 601 : | $row->publish_down = "0000-00-00 00:00:00"; | ||
| 602 : | } | ||
| 603 : | |||
| 604 : | $row->state = mosGetParam( $_REQUEST, 'published', 0 ); | ||
| 605 : | |||
| 606 : | $params = mosGetParam( $_POST, 'params', '' ); | ||
| 607 : | if (is_array( $params )) { | ||
| 608 : | $txt = array(); | ||
| 609 : | foreach ( $params as $k=>$v) { | ||
| 610 : | $txt[] = "$k=$v"; | ||
| 611 : | } | ||
| 612 : | $row->attribs = implode( "\n", $txt ); | ||
| 613 : | } | ||
| 614 : | |||
| 615 : | // code cleaner for xhtml transitional compliance | ||
| 616 : | $row->introtext = str_replace( '<br>', '<br />', $row->introtext ); | ||
| 617 : | $row->fulltext = str_replace( '<br>', '<br />', $row->fulltext ); | ||
| 618 : | |||
| 619 : | // remove <br /> take being automatically added to empty fulltext | ||
| 620 : | $length = strlen( $row->fulltext ) < 9; | ||
| 621 : | $search = strstr( $row->fulltext, '<br />'); | ||
| 622 : | if ( $length && $search ) { | ||
| 623 : | $row->fulltext = NULL; | ||
| 624 : | } | ||
| 625 : | |||
| 626 : | if (!$row->check()) { | ||
| 627 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 628 : | exit(); | ||
| 629 : | } | ||
| 630 : | $row->version++; | ||
| 631 : | if (!$row->store()) { | ||
| 632 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 633 : | exit(); | ||
| 634 : | } | ||
| 635 : | |||
| 636 : | // manage frontpage items | ||
| 637 : | require_once( $mainframe->getPath( 'class', 'com_frontpage' ) ); | ||
| 638 : | $fp = new mosFrontPage( $database ); | ||
| 639 : | |||
| 640 : | if (mosGetParam( $_REQUEST, 'frontpage', 0 )) { | ||
| 641 : | |||
| 642 : | // toggles go to first place | ||
| 643 : | if (!$fp->load( $row->id )) { | ||
| 644 : | // new entry | ||
| 645 : | $database->setQuery( "INSERT INTO #__content_frontpage VALUES ('$row->id','1')" ); | ||
| 646 : | if (!$database->query()) { | ||
| 647 : | echo "<script> alert('".$database->stderr()."');</script>\n"; | ||
| 648 : | exit(); | ||
| 649 : | } | ||
| 650 : | $fp->ordering = 1; | ||
| 651 : | } | ||
| 652 : | } else { | ||
| 653 : | // no frontpage mask | ||
| 654 : | if (!$fp->delete( $row->id )) { | ||
| 655 : | $msg .= $fp->stderr(); | ||
| 656 : | } | ||
| 657 : | $fp->ordering = 0; | ||
| 658 : | } | ||
| 659 : | $fp->updateOrder(); | ||
| 660 : | |||
| 661 : | $row->checkin(); | ||
| 662 : | $row->updateOrder( "catid='$row->catid' AND state >= 0" ); | ||
| 663 : | |||
| 664 : | $redirect = mosGetParam( $_POST, 'redirect', $sectionid ); | ||
| 665 : | switch ( $task ) { | ||
| 666 : | case 'go2menu': | ||
| 667 : | mosRedirect( 'index2.php?option=com_menus&menutype='. $menu ); | ||
| 668 : | break; | ||
| 669 : | |||
| 670 : | case 'go2menuitem': | ||
| 671 : | mosRedirect( 'index2.php?option=com_menus&menutype='. $menu .'&task=edit&hidemainmenu=1&id='. $menuid ); | ||
| 672 : | break; | ||
| 673 : | |||
| 674 : | case 'menulink': | ||
| 675 : | menuLink( $redirect, $row->id ); | ||
| 676 : | break; | ||
| 677 : | |||
| 678 : | case 'resethits': | ||
| 679 : | resethits( $redirect, $row->id ); | ||
| 680 : | break; | ||
| 681 : | |||
| 682 : | case 'apply': | ||
| 683 : | $msg = T_('Successfully Saved changes to Item: '). $row->title; | ||
| 684 : | mosRedirect( 'index2.php?option=com_content§ionid='. $redirect .'&task=edit&hidemainmenu=1&id='. $row->id, $msg ); | ||
| 685 : | |||
| 686 : | case 'save': | ||
| 687 : | default: | ||
| 688 : | $msg = T_('Successfully Saved Item: '). $row->title; | ||
| 689 : | mosRedirect( 'index2.php?option=com_content§ionid='. $redirect, $msg ); | ||
| 690 : | |||
| 691 : | break; | ||
| 692 : | } | ||
| 693 : | } | ||
| 694 : | |||
| 695 : | /** | ||
| 696 : | * Changes the state of one or more content pages | ||
| 697 : | * @param string The name of the category section | ||
| 698 : | * @param integer A unique category id (passed from an edit form) | ||
| 699 : | * @param array An array of unique category id numbers | ||
| 700 : | * @param integer 0 if unpublishing, 1 if publishing | ||
| 701 : | * @param string The name of the current user | ||
| 702 : | */ | ||
| 703 : | function changeContent( $cid=null, $state=0, $option ) { | ||
| 704 : | global $database, $my; | ||
| 705 : | |||
| 706 : | if (count( $cid ) < 1) { | ||
| 707 : | $action = $state == 1 ? T_('publish') : ($state == -1 ? T_('archive') : T_('unpublish')); | ||
| 708 : | echo "<script> alert('".sprintf(T_('Select an item to %s'),$action)."'); window.history.go(-1);</script>\n"; | ||
| 709 : | exit; | ||
| 710 : | } | ||
| 711 : | |||
| 712 : | $total = count ( $cid ); | ||
| 713 : | $cids = implode( ',', $cid ); | ||
| 714 : | |||
| 715 : | $database->setQuery( "UPDATE #__content SET state='$state'" | ||
| 716 : | . "\nWHERE id IN ($cids) AND (checked_out=0 OR (checked_out='".$my->id."'))" | ||
| 717 : | ); | ||
| 718 : | if (!$database->query()) { | ||
| 719 : | echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; | ||
| 720 : | exit(); | ||
| 721 : | } | ||
| 722 : | |||
| 723 : | if (count( $cid ) == 1) { | ||
| 724 : | $row = new mosContent( $database ); | ||
| 725 : | $row->checkin( $cid[0] ); | ||
| 726 : | } | ||
| 727 : | |||
| 728 : | if ( $state == "-1" ) { | ||
| 729 : | $msg = sprintf(Tn_('%d Item successfully Archived', '%d Items successfully Archived',$total),$total); | ||
| 730 : | } else if ( $state == "1" ) { | ||
| 731 : | $msg = sprintf(Tn_('%d Item successfully Published', '%d Items successfully Published',$total),$total); | ||
| 732 : | } else if ( $state == "0" ) { | ||
| 733 : | $msg = sprintf(Tn_('%d Item successfully Unpublished', '%d Items successfully Unpublished',$total),$total); | ||
| 734 : | } | ||
| 735 : | |||
| 736 : | $redirect = mosGetParam( $_POST, 'redirect', $row->sectionid ); | ||
| 737 : | $task = mosGetParam( $_POST, 'returntask', '' ); | ||
| 738 : | if ( $task ) { | ||
| 739 : | $task = '&task='. $task; | ||
| 740 : | } else { | ||
| 741 : | $task = ''; | ||
| 742 : | } | ||
| 743 : | |||
| 744 : | mosRedirect( 'index2.php?option='. $option . $task .'§ionid='. $redirect .'&mosmsg='. $msg ); | ||
| 745 : | } | ||
| 746 : | |||
| 747 : | /** | ||
| 748 : | * Changes the state of one or more content pages | ||
| 749 : | * @param string The name of the category section | ||
| 750 : | * @param integer A unique category id (passed from an edit form) | ||
| 751 : | * @param array An array of unique category id numbers | ||
| 752 : | * @param integer 0 if unpublishing, 1 if publishing | ||
| 753 : | * @param string The name of the current user | ||
| 754 : | */ | ||
| 755 : | function toggleFrontPage( $cid, $section, $option ) { | ||
| 756 : | global $database, $my, $mainframe; | ||
| 757 : | |||
| 758 : | if (count( $cid ) < 1) { | ||
| 759 : | echo "<script> alert('".T_('Select an item to toggle')."'); window.history.go(-1);</script>\n"; | ||
| 760 : | exit; | ||
| 761 : | } | ||
| 762 : | |||
| 763 : | $msg = ''; | ||
| 764 : | require_once( $mainframe->getPath( 'class', 'com_frontpage' ) ); | ||
| 765 : | |||
| 766 : | $fp = new mosFrontPage( $database ); | ||
| 767 : | foreach ($cid as $id) { | ||
| 768 : | // toggles go to first place | ||
| 769 : | if ($fp->load( $id )) { | ||
| 770 : | if (!$fp->delete( $id )) { | ||
| 771 : | $msg .= $fp->stderr(); | ||
| 772 : | } | ||
| 773 : | $fp->ordering = 0; | ||
| 774 : | } else { | ||
| 775 : | // new entry | ||
| 776 : | $database->setQuery( "INSERT INTO #__content_frontpage VALUES ('$id','0')" ); | ||
| 777 : | if (!$database->query()) { | ||
| 778 : | echo "<script> alert('".$database->stderr()."');</script>\n"; | ||
| 779 : | exit(); | ||
| 780 : | } | ||
| 781 : | $fp->ordering = 0; | ||
| 782 : | } | ||
| 783 : | $fp->updateOrder(); | ||
| 784 : | } | ||
| 785 : | |||
| 786 : | mosRedirect( 'index2.php?option='. $option .'§ionid='. $section, $msg ); | ||
| 787 : | } | ||
| 788 : | |||
| 789 : | function removeContent( &$cid, $sectionid, $option ) { | ||
| 790 : | global $database, $mainframe; | ||
| 791 : | |||
| 792 : | $total = count( $cid ); | ||
| 793 : | if ( $total < 1) { | ||
| 794 : | echo "<script> alert('".T_('Select an item to delete')."'); window.history.go(-1);</script>\n"; | ||
| 795 : | exit; | ||
| 796 : | } | ||
| 797 : | |||
| 798 : | $state = '-2'; | ||
| 799 : | $ordering = '0'; | ||
| 800 : | //seperate contentids | ||
| 801 : | $cids = implode( ',', $cid ); | ||
| 802 : | $query = "UPDATE #__content SET state = '". $state ."', ordering = '". $ordering ."'" | ||
| 803 : | . "\n WHERE id IN ( ". $cids ." )" | ||
| 804 : | ; | ||
| 805 : | $database->setQuery( $query ); | ||
| 806 : | if ( !$database->query() ) { | ||
| 807 : | echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; | ||
| 808 : | exit(); | ||
| 809 : | } | ||
| 810 : | |||
| 811 : | $msg = sprintf(Tn_('%d Item sent to the Trash', '%d Items sent to the Trash',$total),$total); | ||
| 812 : | $return = mosGetParam( $_POST, 'returntask', '' ); | ||
| 813 : | mosRedirect( 'index2.php?option='. $option .'&task='. $return .'§ionid='. $sectionid, $msg ); | ||
| 814 : | } | ||
| 815 : | |||
| 816 : | /** | ||
| 817 : | * Cancels an edit operation | ||
| 818 : | */ | ||
| 819 : | function cancelContent( ) { | ||
| 820 : | global $database; | ||
| 821 : | |||
| 822 : | $row = new mosContent( $database ); | ||
| 823 : | $row->bind( $_POST ); | ||
| 824 : | alwarren | 905 | // sanitize |
| 825 : | $row->id = intval($row->id); | ||
| 826 : | neilt | 492 | $row->checkin(); |
| 827 : | |||
| 828 : | $redirect = mosGetParam( $_POST, 'redirect', 0 ); | ||
| 829 : | mosRedirect( 'index2.php?option=com_content§ionid='. $redirect ); | ||
| 830 : | } | ||
| 831 : | |||
| 832 : | /** | ||
| 833 : | * Moves the order of a record | ||
| 834 : | * @param integer The increment to reorder by | ||
| 835 : | */ | ||
| 836 : | function orderContent( $uid, $inc, $option ) { | ||
| 837 : | global $database; | ||
| 838 : | |||
| 839 : | $row = new mosContent( $database ); | ||
| 840 : | $row->load( $uid ); | ||
| 841 : | $row->move( $inc, "catid='$row->catid' AND state >= 0" ); | ||
| 842 : | |||
| 843 : | $redirect = mosGetParam( $_POST, 'redirect', $row->sectionid ); | ||
| 844 : | |||
| 845 : | mosRedirect( 'index2.php?option='. $option .'§ionid='. $redirect ); | ||
| 846 : | } | ||
| 847 : | |||
| 848 : | /** | ||
| 849 : | * Form for moving item(s) to a different section and category | ||
| 850 : | */ | ||
| 851 : | function moveSection( $cid, $sectionid, $option ) { | ||
| 852 : | global $database; | ||
| 853 : | |||
| 854 : | if (!is_array( $cid ) || count( $cid ) < 1) { | ||
| 855 : | echo "<script> alert('".T_('Select an item to move')."'); window.history.go(-1);</script>\n"; | ||
| 856 : | exit; | ||
| 857 : | } | ||
| 858 : | |||
| 859 : | //seperate contentids | ||
| 860 : | $cids = implode( ',', $cid ); | ||
| 861 : | // Content Items query | ||
| 862 : | $query = "SELECT a.title" | ||
| 863 : | . "\n FROM #__content AS a" | ||
| 864 : | . "\n WHERE ( a.id IN (". $cids .") )" | ||
| 865 : | . "\n ORDER BY a.title" | ||
| 866 : | ; | ||
| 867 : | $database->setQuery( $query ); | ||
| 868 : | $items = $database->loadObjectList(); | ||
| 869 : | |||
| 870 : | $database->setQuery( | ||
| 871 : | $query = "SELECT CONCAT_WS( ', ', s.id, c.id ) AS `value`, CONCAT_WS( '/', s.name, c.name ) AS `text`" | ||
| 872 : | . "\n FROM #__sections AS s" | ||
| 873 : | . "\n INNER JOIN #__categories AS c ON c.section = s.id" | ||
| 874 : | . "\n WHERE s.scope = 'content'" | ||
| 875 : | . "\n ORDER BY s.name, c.name" | ||
| 876 : | ); | ||
| 877 : | $rows = $database->loadObjectList(); | ||
| 878 : | // build the html select list | ||
| 879 : | $sectCatList = mosHTML::selectList( $rows, 'sectcat', 'class="inputbox" size="8"', 'value', 'text', null ); | ||
| 880 : | |||
| 881 : | HTML_content::moveSection( $cid, $sectCatList, $option, $sectionid, $items ); | ||
| 882 : | } | ||
| 883 : | |||
| 884 : | /** | ||
| 885 : | * Save the changes to move item(s) to a different section and category | ||
| 886 : | */ | ||
| 887 : | function moveSectionSave( &$cid, $sectionid, $option ) { | ||
| 888 : | global $database, $my; | ||
| 889 : | |||
| 890 : | $sectcat = mosGetParam( $_POST, 'sectcat', '' ); | ||
| 891 : | list( $newsect, $newcat ) = explode( ',', $sectcat ); | ||
| 892 : | |||
| 893 : | if (!$newsect && !$newcat ) { | ||
| 894 : | mosRedirect( "index.php?option=com_content§ionid=$sectionid&mosmsg=".T_('An error has occurred')."" ); | ||
| 895 : | } | ||
| 896 : | |||
| 897 : | // find section name | ||
| 898 : | $query = "SELECT a.name" | ||
| 899 : | . "\n FROM #__sections AS a" | ||
| 900 : | . "\n WHERE a.id = ". $newsect ."" | ||
| 901 : | ; | ||
| 902 : | $database->setQuery( $query ); | ||
| 903 : | $section = $database->loadResult(); | ||
| 904 : | |||
| 905 : | // find category name | ||
| 906 : | $query = "SELECT a.name" | ||
| 907 : | . "\n FROM #__categories AS a" | ||
| 908 : | . "\n WHERE a.id = ". $newcat ."" | ||
| 909 : | ; | ||
| 910 : | $database->setQuery( $query ); | ||
| 911 : | $category = $database->loadResult(); | ||
| 912 : | |||
| 913 : | $total = count( $cid ); | ||
| 914 : | $cids = implode( ',', $cid ); | ||
| 915 : | |||
| 916 : | $row = new mosContent( $database ); | ||
| 917 : | // update old orders - put existing items in last place | ||
| 918 : | foreach ($cid as $id) { | ||
| 919 : | $row->load( intval( $id ) ); | ||
| 920 : | $row->ordering = 0; | ||
| 921 : | $row->store(); | ||
| 922 : | $row->updateOrder( "catid='$row->catid' AND state >= 0" ); | ||
| 923 : | } | ||
| 924 : | |||
| 925 : | $query = "UPDATE #__content SET sectionid = '". $newsect ."', catid='". $newcat ."'" | ||
| 926 : | . "\n WHERE id IN ($cids)" | ||
| 927 : | . "\n AND ( checked_out='0' OR ( checked_out='". $my->id ."') )" | ||
| 928 : | ; | ||
| 929 : | $database->setQuery( $query ); | ||
| 930 : | if ( !$database->query() ) { | ||
| 931 : | echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; | ||
| 932 : | exit(); | ||
| 933 : | } | ||
| 934 : | |||
| 935 : | // update new orders - put items in last place | ||
| 936 : | foreach ($cid as $id) { | ||
| 937 : | $row->load( intval( $id ) ); | ||
| 938 : | $row->ordering = 0; | ||
| 939 : | $row->store(); | ||
| 940 : | $row->updateOrder( "catid='". $row->catid ."' AND state >= 0" ); | ||
| 941 : | } | ||
| 942 : | |||
| 943 : | $msg = sprintf(Tn_('%d Item successfully moved to Section: %s, Category: %s', '%d Items successfully moved to Section: %s, Category: %s',$total),$total, $section, $category); | ||
| 944 : | mosRedirect( 'index2.php?option='. $option .'§ionid='. $sectionid .'&mosmsg='. $msg ); | ||
| 945 : | } | ||
| 946 : | |||
| 947 : | |||
| 948 : | /** | ||
| 949 : | * Form for copying item(s) | ||
| 950 : | **/ | ||
| 951 : | function copyItem( $cid, $sectionid, $option ) { | ||
| 952 : | global $database; | ||
| 953 : | |||
| 954 : | if (!is_array( $cid ) || count( $cid ) < 1) { | ||
| 955 : | echo "<script> alert('".T_('Select an item to move')."'); window.history.go(-1);</script>\n"; | ||
| 956 : | exit; | ||
| 957 : | } | ||
| 958 : | |||
| 959 : | //seperate contentids | ||
| 960 : | $cids = implode( ',', $cid ); | ||
| 961 : | ## Content Items query | ||
| 962 : | $query = "SELECT a.title" | ||
| 963 : | . "\n FROM #__content AS a" | ||
| 964 : | . "\n WHERE ( a.id IN (". $cids .") )" | ||
| 965 : | . "\n ORDER BY a.title" | ||
| 966 : | ; | ||
| 967 : | $database->setQuery( $query ); | ||
| 968 : | $items = $database->loadObjectList(); | ||
| 969 : | |||
| 970 : | ## Section & Category query | ||
| 971 : | $query = "SELECT CONCAT_WS(',',s.id,c.id) AS `value`, CONCAT_WS(' // ', s.name, c.name) AS `text`" | ||
| 972 : | . "\n FROM #__sections AS s" | ||
| 973 : | . "\n INNER JOIN #__categories AS c ON c.section = s.id" | ||
| 974 : | . "\n WHERE s.scope='content'" | ||
| 975 : | . "\n ORDER BY s.name, c.name" | ||
| 976 : | ; | ||
| 977 : | $database->setQuery( $query ); | ||
| 978 : | $rows = $database->loadObjectList(); | ||
| 979 : | // build the html select list | ||
| 980 : | $sectCatList = mosHTML::selectList( $rows, 'sectcat', 'class="inputbox" size="10"', 'value', 'text', NULL ); | ||
| 981 : | |||
| 982 : | HTML_content::copySection( $option, $cid, $sectCatList, $sectionid, $items ); | ||
| 983 : | } | ||
| 984 : | |||
| 985 : | |||
| 986 : | /** | ||
| 987 : | * saves Copies of items | ||
| 988 : | **/ | ||
| 989 : | function copyItemSave( $cid, $sectionid, $option ) { | ||
| 990 : | global $database, $my; | ||
| 991 : | |||
| 992 : | $sectcat = mosGetParam( $_POST, 'sectcat', '' ); | ||
| 993 : | //seperate sections and categories from selection | ||
| 994 : | $sectcat = explode( ',', $sectcat ); | ||
| 995 : | list( $newsect, $newcat ) = $sectcat; | ||
| 996 : | |||
| 997 : | if ( !$newsect && !$newcat ) { | ||
| 998 : | mosRedirect( 'index.php?option=com_content§ionid='. $sectionid .'&mosmsg='.urlencode(T_('An error has occurred'))); | ||
| 999 : | } | ||
| 1000 : | |||
| 1001 : | // find section name | ||
| 1002 : | $query = "SELECT a.name" | ||
| 1003 : | . "\n FROM #__sections AS a" | ||
| 1004 : | . "\n WHERE a.id = ". $newsect ."" | ||
| 1005 : | ; | ||
| 1006 : | $database->setQuery( $query ); | ||
| 1007 : | $section = $database->loadResult(); | ||
| 1008 : | |||
| 1009 : | // find category name | ||
| 1010 : | $query = "SELECT a.name" | ||
| 1011 : | . "\n FROM #__categories AS a" | ||
| 1012 : | . "\n WHERE a.id = ". $newcat ."" | ||
| 1013 : | ; | ||
| 1014 : | $database->setQuery( $query ); | ||
| 1015 : | $category = $database->loadResult(); | ||
| 1016 : | |||
| 1017 : | $total = count( $cid ); | ||
| 1018 : | for ( $i = 0; $i < $total; $i++ ) { | ||
| 1019 : | $row = new mosContent( $database ); | ||
| 1020 : | |||
| 1021 : | // main query | ||
| 1022 : | $query = "SELECT a.* FROM #__content AS a" | ||
| 1023 : | . "\n WHERE a.id = ". $cid[$i] .""; | ||
| 1024 : | ; | ||
| 1025 : | $database->setQuery( $query ); | ||
| 1026 : | $item = $database->loadObjectList(); | ||
| 1027 : | |||
| 1028 : | // values loaded into array set for store | ||
| 1029 : | $row->id = NULL; | ||
| 1030 : | $row->sectionid = $newsect; | ||
| 1031 : | $row->catid = $newcat; | ||
| 1032 : | $row->hits = '0'; | ||
| 1033 : | $row->ordering = '0'; | ||
| 1034 : | $row->title = $item[0]->title; | ||
| 1035 : | $row->title_alias = $item[0]->title_alias; | ||
| 1036 : | $row->introtext = $item[0]->introtext; | ||
| 1037 : | $row->fulltext = $item[0]->fulltext; | ||
| 1038 : | $row->state = $item[0]->state; | ||
| 1039 : | $row->mask = $item[0]->mask; | ||
| 1040 : | $row->created = $item[0]->created; | ||
| 1041 : | $row->created_by = $item[0]->created_by; | ||
| 1042 : | $row->created_by_alias = $item[0]->created_by_alias; | ||
| 1043 : | $row->modified = $item[0]->modified; | ||
| 1044 : | $row->modified_by = $item[0]->modified_by; | ||
| 1045 : | $row->checked_out = $item[0]->checked_out; | ||
| 1046 : | $row->checked_out_time = $item[0]->checked_out_time; | ||
| 1047 : | $row->frontpage_up = $item[0]->frontpage_up; | ||
| 1048 : | $row->frontpage_down = $item[0]->frontpage_down; | ||
| 1049 : | $row->publish_up = $item[0]->publish_up; | ||
| 1050 : | $row->publish_down = $item[0]->publish_down; | ||
| 1051 : | $row->images = $item[0]->images; | ||
| 1052 : | $row->attribs = $item[0]->attribs; | ||
| 1053 : | $row->version = $item[0]->parentid; | ||
| 1054 : | $row->parentid = $item[0]->parentid; | ||
| 1055 : | $row->metakey = $item[0]->metakey; | ||
| 1056 : | $row->metadesc = $item[0]->metadesc; | ||
| 1057 : | $row->access = $item[0]->access; | ||
| 1058 : | |||
| 1059 : | if (!$row->check()) { | ||
| 1060 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 1061 : | exit(); | ||
| 1062 : | } | ||
| 1063 : | if (!$row->store()) { | ||
| 1064 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 1065 : | exit(); | ||
| 1066 : | } | ||
| 1067 : | $row->updateOrder( "catid='". $row->catid ."' AND state >= 0" ); | ||
| 1068 : | } | ||
| 1069 : | |||
| 1070 : | $msg = sprintf(Tn_('%d Item successfully copied to Section: %s, Category: %s', '%d Items successfully copied to Section: %s, Category: %s',$total),$total, $section, $category); | ||
| 1071 : | mosRedirect( 'index2.php?option='. $option .'§ionid='. $sectionid .'&mosmsg='. $msg ); | ||
| 1072 : | } | ||
| 1073 : | |||
| 1074 : | /** | ||
| 1075 : | * Function to reset Hit count of a content item | ||
| 1076 : | * PT | ||
| 1077 : | */ | ||
| 1078 : | function resethits( $redirect, $id ) { | ||
| 1079 : | global $database; | ||
| 1080 : | |||
| 1081 : | $row = new mosContent($database); | ||
| 1082 : | $row->Load($id); | ||
| 1083 : | $row->hits = "0"; | ||
| 1084 : | $row->store(); | ||
| 1085 : | $row->checkin(); | ||
| 1086 : | |||
| 1087 : | $msg = T_('Successfully Reset Hit count'); | ||
| 1088 : | mosRedirect( 'index2.php?option=com_content§ionid='. $redirect .'&task=edit&hidemainmenu=1&id='. $id, $msg ); | ||
| 1089 : | } | ||
| 1090 : | |||
| 1091 : | /** | ||
| 1092 : | * @param integer The id of the content item | ||
| 1093 : | * @param integer The new access level | ||
| 1094 : | * @param string The URL option | ||
| 1095 : | */ | ||
| 1096 : | function accessMenu( $uid, $access, $option ) { | ||
| 1097 : | global $database; | ||
| 1098 : | |||
| 1099 : | $row = new mosContent( $database ); | ||
| 1100 : | $row->load( $uid ); | ||
| 1101 : | $row->access = $access; | ||
| 1102 : | |||
| 1103 : | if ( !$row->check() ) { | ||
| 1104 : | return $row->getError(); | ||
| 1105 : | } | ||
| 1106 : | if ( !$row->store() ) { | ||
| 1107 : | return $row->getError(); | ||
| 1108 : | } | ||
| 1109 : | |||
| 1110 : | $redirect = mosGetParam( $_POST, 'redirect', $row->sectionid ); | ||
| 1111 : | |||
| 1112 : | mosRedirect( 'index2.php?option='. $option .'§ionid='. $redirect ); | ||
| 1113 : | } | ||
| 1114 : | |||
| 1115 : | function filterCategory( $query, $active=NULL ) { | ||
| 1116 : | global $database; | ||
| 1117 : | |||
| 1118 : | $categories[] = mosHTML::makeOption( '0', T_('- All Categories -') ); | ||
| 1119 : | $database->setQuery( $query ); | ||
| 1120 : | cauld | 741 | if (is_array($database->loadObjectList())) { |
| 1121 : | $categories = array_merge( $categories, $database->loadObjectList() ); | ||
| 1122 : | } | ||
| 1123 : | neilt | 492 | $category = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $active ); |
| 1124 : | |||
| 1125 : | return $category; | ||
| 1126 : | } | ||
| 1127 : | |||
| 1128 : | function menuLink( $redirect, $id ) { | ||
| 1129 : | global $database; | ||
| 1130 : | |||
| 1131 : | $menu = mosGetParam( $_POST, 'menuselect', '' ); | ||
| 1132 : | $link = mosGetParam( $_POST, 'link_name', '' ); | ||
| 1133 : | |||
| 1134 : | $row = new mosMenu( $database ); | ||
| 1135 : | $row->menutype = $menu; | ||
| 1136 : | $row->name = $link; | ||
| 1137 : | $row->type = 'content_item_link'; | ||
| 1138 : | $row->published = 1; | ||
| 1139 : | $row->componentid = $id; | ||
| 1140 : | $row->link = 'index.php?option=com_content&task=view&id='. $id; | ||
| 1141 : | $row->ordering = 9999; | ||
| 1142 : | |||
| 1143 : | if (!$row->check()) { | ||
| 1144 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 1145 : | exit(); | ||
| 1146 : | } | ||
| 1147 : | if (!$row->store()) { | ||
| 1148 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 1149 : | exit(); | ||
| 1150 : | } | ||
| 1151 : | $row->checkin(); | ||
| 1152 : | $row->updateOrder( "menutype='$row->menutype' AND parent='$row->parent'" ); | ||
| 1153 : | |||
| 1154 : | $msg = sprintf(T_('%s (Link - Static Content) in menu: %s successfully created'),$link, $menu); | ||
| 1155 : | mosRedirect( 'index2.php?option=com_content§ionid='. $redirect .'&task=edit&hidemainmenu=1&id='. $id, $msg ); | ||
| 1156 : | } | ||
| 1157 : | |||
| 1158 : | function go2menu() { | ||
| 1159 : | $menu = mosGetParam( $_POST, 'menu', 'mainmenu' ); | ||
| 1160 : | |||
| 1161 : | mosRedirect( 'index2.php?option=com_menus&menutype='. $menu ); | ||
| 1162 : | } | ||
| 1163 : | |||
| 1164 : | function go2menuitem() { | ||
| 1165 : | $menu = mosGetParam( $_POST, 'menu', 'mainmenu' ); | ||
| 1166 : | $id = mosGetParam( $_POST, 'menuid', 0 ); | ||
| 1167 : | |||
| 1168 : | mosRedirect( 'index2.php?option=com_menus&menutype='. $menu .'&task=edit&hidemainmenu=1&id='. $id ); | ||
| 1169 : | } | ||
| 1170 : | |||
| 1171 : | function saveOrder( &$cid ) { | ||
| 1172 : | global $database; | ||
| 1173 : | $order = mosGetParam( $_POST, 'order', array(0) ); | ||
| 1174 : | $redirect = mosGetParam( $_POST, 'redirect', 0 ); | ||
| 1175 : | $rettask = mosGetParam( $_POST, 'returntask', '' ); | ||
| 1176 : | $row = new mosContent( $database ); | ||
| 1177 : | $categories = array(); | ||
| 1178 : | // update ordering values | ||
| 1179 : | foreach ($cid as $i=>$ciditem) { | ||
| 1180 : | $row->load( $ciditem ); | ||
| 1181 : | if ($row->ordering != $order[$i]) { | ||
| 1182 : | $row->ordering = $order[$i]; | ||
| 1183 : | if (!$row->store()) { | ||
| 1184 : | echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; | ||
| 1185 : | exit(); | ||
| 1186 : | } | ||
| 1187 : | // remember to updateOrder this group | ||
| 1188 : | $categories[$row->catid] = $row->id; | ||
| 1189 : | } | ||
| 1190 : | } | ||
| 1191 : | // execute updateOrder for each group | ||
| 1192 : | foreach ($categories as $catid=>$rowid) { | ||
| 1193 : | $row->updateOrder("catid = $catid AND state >= 0"); | ||
| 1194 : | } // foreach | ||
| 1195 : | |||
| 1196 : | $msg = T_('New ordering saved'); | ||
| 1197 : | switch ( $rettask ) { | ||
| 1198 : | case 'showarchive': | ||
| 1199 : | mosRedirect( 'index2.php?option=com_content&task=showarchive§ionid='. $redirect, $msg ); | ||
| 1200 : | break; | ||
| 1201 : | |||
| 1202 : | default: | ||
| 1203 : | mosRedirect( 'index2.php?option=com_content§ionid='. $redirect, $msg ); | ||
| 1204 : | break; | ||
| 1205 : | } // switch | ||
| 1206 : | } // saveOrder | ||
| 1207 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

