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

