- md5
- 855e92b9ff99a6b5827ac268338c97a8
- sha1
- 2d9a4466ddbc4ae03d1dd99c8d9fe2fc834517f4
- sha256
- 60c37d16b4de063e3892cb72025234b4056c5e76393a4326fb168757e28b3a88
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243
<?php
/**
* @version $Id: admin.content.php 393 2005-10-08 13:37:52Z akede $
* @package Joomla
* @subpackage Content
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
require_once( $mainframe->getPath( 'admin_html' ) );
$sectionid = mosGetParam( $_REQUEST, 'sectionid', 0 );
$id = mosGetParam( $_REQUEST, 'id', '' );
$cid = mosGetParam( $_POST, 'cid', array(0) );
if (!is_array( $cid )) {
$cid = array(0);
}
switch ($task) {
case 'new':
editContent( 0, $sectionid, $option );
break;
case 'edit':
editContent( $id, $sectionid, $option );
break;
case 'editA':
editContent( $cid[0], '', $option );
break;
case 'go2menu':
case 'go2menuitem':
case 'resethits':
case 'menulink':
case 'apply':
case 'save':
mosCache::cleanCache( 'com_content' );
saveContent( $sectionid, $task );
break;
case 'remove':
removeContent( $cid, $sectionid, $option );
break;
case 'publish':
changeContent( $cid, 1, $option );
break;
case 'unpublish':
changeContent( $cid, 0, $option );
break;
case 'toggle_frontpage':
toggleFrontPage( $cid, $sectionid, $option );
break;
case 'archive':
changeContent( $cid, -1, $option );
break;
case 'unarchive':
changeContent( $cid, 0, $option );
break;
case 'cancel':
cancelContent();
break;
case 'orderup':
orderContent( $cid[0], -1, $option );
break;
case 'orderdown':
orderContent( $cid[0], 1, $option );
break;
case 'showarchive':
viewArchive( $sectionid, $option );
break;
case 'movesect':
moveSection( $cid, $sectionid, $option );
break;
case 'movesectsave':
moveSectionSave( $cid, $sectionid, $option );
break;
case 'copy':
copyItem( $cid, $sectionid, $option );
break;
case 'copysave':
copyItemSave( $cid, $sectionid, $option );
break;
case 'accesspublic':
accessMenu( $cid[0], 0, $option );
break;
case 'accessregistered':
accessMenu( $cid[0], 1, $option );
break;
case 'accessspecial':
accessMenu( $cid[0], 2, $option );
break;
case 'saveorder':
saveOrder( $cid );
break;
default:
viewContent( $sectionid, $option );
break;
}
/**
* Compiles a list of installed or defined modules
* @param database A database connector object
*/
function viewContent( $sectionid, $option ) {
global $database, $mainframe, $mosConfig_list_limit;
$catid = $mainframe->getUserStateFromRequest( "catid{$option}{$sectionid}", 'catid', 0 );
$filter_authorid = $mainframe->getUserStateFromRequest( "filter_authorid{$option}{$sectionid}", 'filter_authorid', 0 );
$filter_sectionid = $mainframe->getUserStateFromRequest( "filter_sectionid{$option}{$sectionid}", 'filter_sectionid', 0 );
$limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit );
$limitstart = $mainframe->getUserStateFromRequest( "view{$option}{$sectionid}limitstart", 'limitstart', 0 );
$search = $mainframe->getUserStateFromRequest( "search{$option}{$sectionid}", 'search', '' );
$search = $database->getEscaped( trim( strtolower( $search ) ) );
$redirect = $sectionid;
$filter = ''; //getting a undefined variable error
if ( $sectionid == 0 ) {
// used to show All content items
$where = array(
"c.state >= 0",
"c.catid = cc.id",
"cc.section = s.id",
"s.scope = 'content'",
);
$order = "\n ORDER BY s.title, c.catid, cc.ordering, cc.title, c.ordering";
$all = 1;
//$filter = "\n , #__sections AS s WHERE s.id = c.section";
if ($filter_sectionid > 0) {
$filter = "\n WHERE cc.section = $filter_sectionid";
}
$section->title = 'All Content Items';
$section->id = 0;
} else {
$where = array(
"c.state >= 0",
"c.catid = cc.id",
"cc.section = s.id",
"s.scope = 'content'",
"c.sectionid = '$sectionid'"
);
$order = "\n ORDER BY cc.ordering, cc.title, c.ordering";
$all = NULL;
$filter = "\n WHERE cc.section = '$sectionid'";
$section = new mosSection( $database );
$section->load( $sectionid );
}
// used by filter
if ( $filter_sectionid > 0 ) {
$where[] = "c.sectionid = $filter_sectionid";
}
if ( $catid > 0 ) {
$where[] = "c.catid = $catid";
}
if ( $filter_authorid > 0 ) {
$where[] = "c.created_by = $filter_authorid";
}
if ( $search ) {
$where[] = "LOWER( c.title ) LIKE '%$search%'";
}
// get the total number of records
$query = "SELECT COUNT(*)"
. "\n FROM ( #__content AS c, #__categories AS cc, #__sections AS s )"
. ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "" )
;
$database->setQuery( $query );
$total = $database->loadResult();
require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' );
$pageNav = new mosPageNav( $total, $limitstart, $limit );
$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"
. "\n FROM ( #__content AS c, #__categories AS cc, #__sections AS s )"
. "\n LEFT JOIN #__groups AS g ON g.id = c.access"
. "\n LEFT JOIN #__users AS u ON u.id = c.checked_out"
. "\n LEFT JOIN #__users AS v ON v.id = c.created_by"
. "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id"
. ( count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : '' )
. $order
. "\n LIMIT $pageNav->limitstart, $pageNav->limit"
;
$database->setQuery( $query );
$rows = $database->loadObjectList();
if ($database->getErrorNum()) {
echo $database->stderr();
return false;
}
// get list of categories for dropdown filter
$query = "SELECT cc.id AS value, cc.title AS text, section"
. "\n FROM #__categories AS cc"
. "\n INNER JOIN #__sections AS s ON s.id = cc.section "
. $filter
. "\n ORDER BY s.ordering, cc.ordering"
;
$lists['catid'] = filterCategory( $query, $catid );
// get list of sections for dropdown filter
$javascript = 'onchange="document.adminForm.submit();"';
$lists['sectionid'] = mosAdminMenus::SelectSection( 'filter_sectionid', $filter_sectionid, $javascript );
// get list of Authors for dropdown filter
$query = "SELECT c.created_by, u.name"
. "\n FROM #__content AS c"
. "\n INNER JOIN #__sections AS s ON s.id = c.sectionid"
. "\n LEFT JOIN #__users AS u ON u.id = c.created_by"
. "\n WHERE c.state != -1"
. "\n AND c.state != -2"
. "\n GROUP BY u.name"
. "\n ORDER BY u.name"
;
$authors[] = mosHTML::makeOption( '0', _SEL_AUTHOR, 'created_by', 'name' );
$database->setQuery( $query );
$authors = array_merge( $authors, $database->loadObjectList() );
$lists['authorid'] = mosHTML::selectList( $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid );
HTML_content::showContent( $rows, $section, $lists, $search, $pageNav, $all, $redirect );
}
/**
* Shows a list of archived content items
* @param int The section id
*/
function viewArchive( $sectionid, $option ) {
global $database, $mainframe, $mosConfig_list_limit;
$catid = $mainframe->getUserStateFromRequest( "catidarc{$option}{$sectionid}", 'catid', 0 );
$limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit );
$limitstart = $mainframe->getUserStateFromRequest( "viewarc{$option}{$sectionid}limitstart", 'limitstart', 0 );
$search = $mainframe->getUserStateFromRequest( "searcharc{$option}{$sectionid}", 'search', '' );
$filter_authorid = $mainframe->getUserStateFromRequest( "filter_authorid{$option}{$sectionid}", 'filter_authorid', 0 );
$filter_sectionid = $mainframe->getUserStateFromRequest( "filter_sectionid{$option}{$sectionid}", 'filter_sectionid', 0 );
$search = $database->getEscaped( trim( strtolower( $search ) ) );
$redirect = $sectionid;
if ( $sectionid == 0 ) {
$where = array(
"c.state = -1",
"c.catid = cc.id",
"cc.section = s.id",
"s.scope = 'content'"
);
$filter = "\n , #__sections AS s WHERE s.id = c.section";
$all = 1;
} else {
$where = array(
"c.state = -1",
"c.catid = cc.id",
"cc.section = s.id",
"s.scope = 'content'",
"c.sectionid= $sectionid"
);
$filter = "\n WHERE section = '$sectionid'";
$all = NULL;
}
// used by filter
if ( $filter_sectionid > 0 ) {
$where[] = "c.sectionid = $filter_sectionid";
}
if ( $filter_authorid > 0 ) {
$where[] = "c.created_by = $filter_authorid";
}
if ($catid > 0) {
$where[] = "c.catid = $catid";
}
if ($search) {
$where[] = "LOWER( c.title ) LIKE '%$search%'";
}
// get the total number of records
$query = "SELECT COUNT(*)"
. "FROM ( #__content AS c, #__categories AS cc, #__sections AS s )"
. ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : '' )
;
$database->setQuery( $query );
$total = $database->loadResult();
require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' );
$pageNav = new mosPageNav( $total, $limitstart, $limit );
$query = "SELECT c.*, g.name AS groupname, cc.name, v.name AS author"
. "\n FROM ( #__content AS c, #__categories AS cc, #__sections AS s )"
. "\n LEFT JOIN #__groups AS g ON g.id = c.access"
. "\n LEFT JOIN #__users AS v ON v.id = c.created_by"
. ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : '' )
. "\n ORDER BY c.catid, c.ordering"
. "\n LIMIT $pageNav->limitstart, $pageNav->limit"
;
$database->setQuery( $query );
$rows = $database->loadObjectList();
if ($database->getErrorNum()) {
echo $database->stderr();
return;
}
// get list of categories for dropdown filter
$query = "SELECT c.id AS value, c.title AS text"
. "\n FROM #__categories AS c"
. $filter
. "\n ORDER BY c.ordering"
;
$lists['catid'] = filterCategory( $query, $catid );
// get list of sections for dropdown filter
$javascript = 'onchange="document.adminForm.submit();"';
$lists['sectionid'] = mosAdminMenus::SelectSection( 'filter_sectionid', $filter_sectionid, $javascript );
$section = new mosSection( $database );
$section->load( $sectionid );
// get list of Authors for dropdown filter
$query = "SELECT c.created_by, u.name"
. "\n FROM #__content AS c"
. "\n INNER JOIN #__sections AS s ON s.id = c.sectionid"
. "\n LEFT JOIN #__users AS u ON u.id = c.created_by"
. "\n WHERE c.state = -1"
. "\n GROUP BY u.name"
. "\n ORDER BY u.name"
;
$authors[] = mosHTML::makeOption( '0', _SEL_AUTHOR, 'created_by', 'name' );
$database->setQuery( $query );
$authors = array_merge( $authors, $database->loadObjectList() );
$lists['authorid'] = mosHTML::selectList( $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid );
HTML_content::showArchive( $rows, $section, $lists, $search, $pageNav, $option, $all, $redirect );
}
/**
* Compiles information to add or edit the record
* @param database A database connector object
* @param integer The unique id of the record to edit (0 if new)
* @param integer The id of the content section
*/
function editContent( $uid=0, $sectionid=0, $option ) {
global $database, $my, $mainframe;
global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_offset;
$redirect = mosGetParam( $_POST, 'redirect', '' );
if ( !$redirect ) {
$redirect = $sectionid;
}
// load the row from the db table
$row = new mosContent( $database );
$row->load( $uid );
if ($uid) {
$sectionid = $row->sectionid;
if ($row->state < 0) {
mosRedirect( 'index2.php?option=com_content§ionid='. $row->sectionid, 'You cannot edit an archived item' );
}
}
if ( $sectionid == 0 ) {
$where = "\n WHERE section NOT LIKE '%com_%'";
} else {
$where = "\n WHERE section = '$sectionid'";
}
// get the type name - which is a special category
if ($row->sectionid){
$query = "SELECT name"
. "\n FROM #__sections"
. "\n WHERE id = $row->sectionid"
;
$database->setQuery( $query );
$section = $database->loadResult();
$contentSection = $section;
} else {
$query = "SELECT name"
. "\n FROM #__sections"
. "\n WHERE id = $sectionid"
;
$database->setQuery( $query );
$section = $database->loadResult();
$contentSection = $section;
}
// fail if checked out not by 'me'
if ($row->checked_out && $row->checked_out != $my->id) {
mosRedirect( 'index2.php?option=com_content', 'The module '. $row->title .' is currently being edited by another administrator' );
}
if ($uid) {
$row->checkout( $my->id );
if (trim( $row->images )) {
$row->images = explode( "\n", $row->images );
} else {
$row->images = array();
}
$row->created = mosFormatDate( $row->created, '%Y-%m-%d %H:%M:%S' );
$row->modified = mosFormatDate( $row->modified, '%Y-%m-%d %H:%M:%S' );
$row->publish_up = mosFormatDate( $row->publish_up, '%Y-%m-%d %H:%M:%S' );
$nullDate = $database->getNullDate();
if (trim( $row->publish_down ) == $nullDate) {
$row->publish_down = 'Never';
}
$query = "SELECT name"
. "\n FROM #__users"
. "\n WHERE id = $row->created_by"
;
$database->setQuery( $query );
$row->creator = $database->loadResult();
$query = "SELECT name"
. "\n FROM #__users"
. "\n WHERE id = $row->modified_by"
;
$database->setQuery( $query );
$row->modifier = $database->loadResult();
$query = "SELECT content_id"
. "\n FROM #__content_frontpage"
. "\n WHERE content_id = $row->id"
;
$database->setQuery( $query );
$row->frontpage = $database->loadResult();
// get list of links to this item
$and = "\n AND componentid = $row->id";
$menus = mosAdminMenus::Links2Menu( 'content_item_link', $and );
} else {
if ( !$sectionid && $_POST['filter_sectionid'] ) {
$sectionid = $_POST['filter_sectionid'];
}
if ( $_POST['catid'] ) {
$row->catid = $_POST['catid'];
$category = new mosCategory( $database );
$category->load( $_POST['catid'] );
$sectionid = $category->section;
} else {
$row->catid = NULL;
}
$row->sectionid = $sectionid;
$row->version = 0;
$row->state = 1;
$row->ordering = 0;
$row->images = array();
$row->publish_up = date( 'Y-m-d', time() + $mosConfig_offset * 60 * 60 );
$row->publish_down = 'Never';
$row->creator = '';
$row->modifier = '';
$row->frontpage = 0;
$menus = array();
}
$javascript = "onchange=\"changeDynaList( 'catid', sectioncategories, document.adminForm.sectionid.options[document.adminForm.sectionid.selectedIndex].value, 0, 0);\"";
$query = "SELECT s.id, s.title"
. "\n FROM #__sections AS s"
. "\n ORDER BY s.ordering";
$database->setQuery( $query );
if ( $sectionid == 0 ) {
$sections[] = mosHTML::makeOption( '-1', 'Select Section', 'id', 'title' );
$sections = array_merge( $sections, $database->loadObjectList() );
$lists['sectionid'] = mosHTML::selectList( $sections, 'sectionid', 'class="inputbox" size="1" '. $javascript, 'id', 'title' );
} else {
$sections = $database->loadObjectList();
$lists['sectionid'] = mosHTML::selectList( $sections, 'sectionid', 'class="inputbox" size="1" '. $javascript, 'id', 'title', intval( $row->sectionid ) );
}
$sections = $database->loadObjectList();
$sectioncategories = array();
$sectioncategories[-1] = array();
$sectioncategories[-1][] = mosHTML::makeOption( '-1', 'Select Category', 'id', 'name' );
foreach($sections as $section) {
$sectioncategories[$section->id] = array();
$query = "SELECT id, name"
. "\n FROM #__categories"
. "\n WHERE section = '$section->id'"
. "\n ORDER BY ordering"
;
$database->setQuery( $query );
$rows2 = $database->loadObjectList();
foreach($rows2 as $row2) {
$sectioncategories[$section->id][] = mosHTML::makeOption( $row2->id, $row2->name, 'id', 'name' );
}
}
// get list of categories
if ( !$row->catid && !$row->sectionid ) {
$categories[] = mosHTML::makeOption( '-1', 'Select Category', 'id', 'name' );
$lists['catid'] = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1"', 'id', 'name' );
} else {
$query = "SELECT id, name"
. "\n FROM #__categories"
. $where
. "\n ORDER BY ordering"
;
$database->setQuery( $query );
$categories[] = mosHTML::makeOption( '-1', 'Select Category', 'id', 'name' );
$categories = array_merge( $categories, $database->loadObjectList() );
$lists['catid'] = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1"', 'id', 'name', intval( $row->catid ) );
}
// build the html select list for ordering
$query = "SELECT ordering AS value, title AS text"
. "\n FROM #__content"
. "\n WHERE catid = $row->catid"
. "\n AND state >= 0"
. "\n ORDER BY ordering"
;
$lists['ordering'] = mosAdminMenus::SpecificOrdering( $row, $uid, $query, 1 );
// calls function to read image from directory
$pathA = $mosConfig_absolute_path .'/images/stories';
$pathL = $mosConfig_live_site .'/images/stories';
$images = array();
$folders = array();
$folders[] = mosHTML::makeOption( '/' );
mosAdminMenus::ReadImages( $pathA, '/', $folders, $images );
// list of folders in images/stories/
$lists['folders'] = mosAdminMenus::GetImageFolders( $folders, $pathL );
// list of images in specfic folder in images/stories/
$lists['imagefiles'] = mosAdminMenus::GetImages( $images, $pathL );
// list of saved images
$lists['imagelist'] = mosAdminMenus::GetSavedImages( $row, $pathL );
// build list of users
$active = ( intval( $row->created_by ) ? intval( $row->created_by ) : $my->id );
$lists['created_by'] = mosAdminMenus::UserSelect( 'created_by', $active );
// build the select list for the image position alignment
$lists['_align'] = mosAdminMenus::Positions( '_align' );
// build the select list for the image caption alignment
$lists['_caption_align'] = mosAdminMenus::Positions( '_caption_align' );
// build the html select list for the group access
$lists['access'] = mosAdminMenus::Access( $row );
// build the html select list for menu selection
$lists['menuselect'] = mosAdminMenus::MenuSelect( );
// build the select list for the image caption position
$pos[] = mosHTML::makeOption( 'bottom', _CMN_BOTTOM );
$pos[] = mosHTML::makeOption( 'top', _CMN_TOP );
$lists['_caption_position'] = mosHTML::selectList( $pos, '_caption_position', 'class="inputbox" size="1"', 'value', 'text' );
// get params definitions
$params = new mosParameters( $row->attribs, $mainframe->getPath( 'com_xml', 'com_content' ), 'component' );
HTML_content::editContent( $row, $contentSection, $lists, $sectioncategories, $images, $params, $option, $redirect, $menus );
}
/**
* Saves the content item an edit form submit
* @param database A database connector object
*/
function saveContent( $sectionid, $task ) {
global $database, $my, $mainframe, $mosConfig_offset;
$menu = mosGetParam( $_POST, 'menu', 'mainmenu' );
$menuid = mosGetParam( $_POST, 'menuid', 0 );
$row = new mosContent( $database );
if (!$row->bind( $_POST )) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
$isNew = ( $row->id < 1 );
if ($isNew) {
//$row->created = $row->created ? $row->created : date( 'Y-m-d H:i:s' );
$row->created = $row->created ? mosFormatDate( $row->created, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset * 60 * 60 ) : date( 'Y-m-d H:i:s' );
$row->created_by = $row->created_by ? $row->created_by : $my->id;
} else {
$row->modified = date( 'Y-m-d H:i:s' );
$row->modified_by = $my->id;
//$row->created = $row->created ? $row->created : date( 'Y-m-d H:i:s' );
$row->created = $row->created ? mosFormatDate( $row->created, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset ) : date( 'Y-m-d H:i:s' );
$row->created_by = $row->created_by ? $row->created_by : $my->id;
}
if (strlen(trim( $row->publish_up )) <= 10) {
$row->publish_up .= " 00:00:00";
}
$row->publish_up = mosFormatDate($row->publish_up, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset );
$nullDate = $database->getNullDate();
if (trim( $row->publish_down ) == "Never") {
$row->publish_down = $nullDate;
}
$row->state = mosGetParam( $_REQUEST, 'published', 0 );
$params = mosGetParam( $_POST, 'params', '' );
if (is_array( $params )) {
$txt = array();
foreach ( $params as $k=>$v) {
$txt[] = "$k=$v";
}
$row->attribs = implode( "\n", $txt );
}
// code cleaner for xhtml transitional compliance
$row->introtext = str_replace( '<br>', '<br />', $row->introtext );
$row->fulltext = str_replace( '<br>', '<br />', $row->fulltext );
// remove <br /> take being automatically added to empty fulltext
$length = strlen( $row->fulltext ) < 9;
$search = strstr( $row->fulltext, '<br />');
if ( $length && $search ) {
$row->fulltext = NULL;
}
$row->title = ampReplace( $row->title );
if (!$row->check()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
$row->version++;
if (!$row->store()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
// manage frontpage items
require_once( $mainframe->getPath( 'class', 'com_frontpage' ) );
$fp = new mosFrontPage( $database );
if (mosGetParam( $_REQUEST, 'frontpage', 0 )) {
// toggles go to first place
if (!$fp->load( $row->id )) {
// new entry
$query = "INSERT INTO #__content_frontpage"
. "\n VALUES ( $row->id, 1 )"
;
$database->setQuery( $query );
if (!$database->query()) {
echo "<script> alert('".$database->stderr()."');</script>\n";
exit();
}
$fp->ordering = 1;
}
} else {
// no frontpage mask
if (!$fp->delete( $row->id )) {
$msg .= $fp->stderr();
}
$fp->ordering = 0;
}
$fp->updateOrder();
$row->checkin();
$row->updateOrder( "catid = $row->catid AND state >= 0" );
$redirect = mosGetParam( $_POST, 'redirect', $sectionid );
switch ( $task ) {
case 'go2menu':
mosRedirect( 'index2.php?option=com_menus&menutype='. $menu );
break;
case 'go2menuitem':
mosRedirect( 'index2.php?option=com_menus&menutype='. $menu .'&task=edit&hidemainmenu=1&id='. $menuid );
break;
case 'menulink':
menuLink( $redirect, $row->id );
break;
case 'resethits':
resethits( $redirect, $row->id );
break;
case 'apply':
$msg = 'Successfully Saved changes to Item: '. $row->title;
mosRedirect( 'index2.php?option=com_content§ionid='. $redirect .'&task=edit&hidemainmenu=1&id='. $row->id, $msg );
break;
case 'save':
default:
$msg = 'Successfully Saved Item: '. $row->title;
mosRedirect( 'index2.php?option=com_content§ionid='. $redirect, $msg );
break;
}
}
/**
* Changes the state of one or more content pages
* @param string The name of the category section
* @param integer A unique category id (passed from an edit form)
* @param array An array of unique category id numbers
* @param integer 0 if unpublishing, 1 if publishing
* @param string The name of the current user
*/
function changeContent( $cid=null, $state=0, $option ) {
global $database, $my;
if (count( $cid ) < 1) {
$action = $state == 1 ? 'publish' : ($state == -1 ? 'archive' : 'unpublish');
echo "<script> alert('Select an item to $action'); window.history.go(-1);</script>\n";
exit;
}
$total = count ( $cid );
$cids = implode( ',', $cid );
$query = "UPDATE #__content"
. "\n SET state = $state"
. "\n WHERE id IN ( $cids ) AND ( checked_out = 0 OR (checked_out = $my->id ) )"
;
$database->setQuery( $query );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
exit();
}
if (count( $cid ) == 1) {
$row = new mosContent( $database );
$row->checkin( $cid[0] );
}
if ( $state == "-1" ) {
$msg = $total ." Item(s) successfully Archived";
} else if ( $state == "1" ) {
$msg = $total ." Item(s) successfully Published";
} else if ( $state == "0" ) {
$msg = $total ." Item(s) successfully Unpublished";
}
$redirect = mosGetParam( $_POST, 'redirect', $row->sectionid );
$task = mosGetParam( $_POST, 'returntask', '' );
if ( $task ) {
$task = '&task='. $task;
} else {
$task = '';
}
mosRedirect( 'index2.php?option='. $option . $task .'§ionid='. $redirect .'&mosmsg='. $msg );
}
/**
* Changes the state of one or more content pages
* @param string The name of the category section
* @param integer A unique category id (passed from an edit form)
* @param array An array of unique category id numbers
* @param integer 0 if unpublishing, 1 if publishing
* @param string The name of the current user
*/
function toggleFrontPage( $cid, $section, $option ) {
global $database, $mainframe;
if (count( $cid ) < 1) {
echo "<script> alert('Select an item to toggle'); window.history.go(-1);</script>\n";
exit;
}
$msg = '';
require_once( $mainframe->getPath( 'class', 'com_frontpage' ) );
$fp = new mosFrontPage( $database );
foreach ($cid as $id) {
// toggles go to first place
if ($fp->load( $id )) {
if (!$fp->delete( $id )) {
$msg .= $fp->stderr();
}
$fp->ordering = 0;
} else {
// new entry
$query = "INSERT INTO #__content_frontpage"
. "\n VALUES ( $id, 0 )"
;
$database->setQuery( $query );
if (!$database->query()) {
echo "<script> alert('".$database->stderr()."');</script>\n";
exit();
}
$fp->ordering = 0;
}
$fp->updateOrder();
}
mosRedirect( 'index2.php?option='. $option .'§ionid='. $section, $msg );
}
function removeContent( &$cid, $sectionid, $option ) {
global $database;
$total = count( $cid );
if ( $total < 1) {
echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n";
exit;
}
$state = '-2';
$ordering = '0';
//seperate contentids
$cids = implode( ',', $cid );
$query = "UPDATE #__content"
. "\n SET state = $state, ordering = $ordering"
. "\n WHERE id IN ( $cids )"
;
$database->setQuery( $query );
if ( !$database->query() ) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
exit();
}
$msg = $total ." Item(s) sent to the Trash";
$return = mosGetParam( $_POST, 'returntask', '' );
mosRedirect( 'index2.php?option='. $option .'&task='. $return .'§ionid='. $sectionid, $msg );
}
/**
* Cancels an edit operation
*/
function cancelContent( ) {
global $database;
$row = new mosContent( $database );
$row->bind( $_POST );
$row->checkin();
$redirect = mosGetParam( $_POST, 'redirect', 0 );
mosRedirect( 'index2.php?option=com_content§ionid='. $redirect );
}
/**
* Moves the order of a record
* @param integer The increment to reorder by
*/
function orderContent( $uid, $inc, $option ) {
global $database;
$row = new mosContent( $database );
$row->load( $uid );
$row->move( $inc, "catid = $row->catid AND state >= 0" );
$redirect = mosGetParam( $_POST, 'redirect', $row->sectionid );
mosRedirect( 'index2.php?option='. $option .'§ionid='. $redirect );
}
/**
* Form for moving item(s) to a different section and category
*/
function moveSection( $cid, $sectionid, $option ) {
global $database;
if (!is_array( $cid ) || count( $cid ) < 1) {
echo "<script> alert('Select an item to move'); window.history.go(-1);</script>\n";
exit;
}
//seperate contentids
$cids = implode( ',', $cid );
// Content Items query
$query = "SELECT a.title"
. "\n FROM #__content AS a"
. "\n WHERE ( a.id IN ( $cids ) )"
. "\n ORDER BY a.title"
;
$database->setQuery( $query );
$items = $database->loadObjectList();
$database->setQuery(
$query = "SELECT CONCAT_WS( ', ', s.id, c.id ) AS `value`, CONCAT_WS( '/', s.name, c.name ) AS `text`"
. "\n FROM #__sections AS s"
. "\n INNER JOIN #__categories AS c ON c.section = s.id"
. "\n WHERE s.scope = 'content'"
. "\n ORDER BY s.name, c.name"
);
$rows = $database->loadObjectList();
// build the html select list
$sectCatList = mosHTML::selectList( $rows, 'sectcat', 'class="inputbox" size="8"', 'value', 'text', null );
HTML_content::moveSection( $cid, $sectCatList, $option, $sectionid, $items );
}
/**
* Save the changes to move item(s) to a different section and category
*/
function moveSectionSave( &$cid, $sectionid, $option ) {
global $database, $my;
$sectcat = mosGetParam( $_POST, 'sectcat', '' );
list( $newsect, $newcat ) = explode( ',', $sectcat );
if (!$newsect && !$newcat ) {
mosRedirect( "index.php?option=com_content§ionid=$sectionid&mosmsg=An error has occurred" );
}
// find section name
$query = "SELECT a.name"
. "\n FROM #__sections AS a"
. "\n WHERE a.id = $newsect"
;
$database->setQuery( $query );
$section = $database->loadResult();
// find category name
$query = "SELECT a.name"
. "\n FROM #__categories AS a"
. "\n WHERE a.id = $newcat"
;
$database->setQuery( $query );
$category = $database->loadResult();
$total = count( $cid );
$cids = implode( ',', $cid );
$row = new mosContent( $database );
// update old orders - put existing items in last place
foreach ($cid as $id) {
$row->load( intval( $id ) );
$row->ordering = 0;
$row->store();
$row->updateOrder( "catid = $row->catid AND state >= 0" );
}
$query = "UPDATE #__content SET sectionid = $newsect, catid = $newcat"
. "\n WHERE id IN ( $cids )"
. "\n AND ( checked_out = 0 OR ( checked_out = $my->id ) )"
;
$database->setQuery( $query );
if ( !$database->query() ) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
exit();
}
// update new orders - put items in last place
foreach ($cid as $id) {
$row->load( intval( $id ) );
$row->ordering = 0;
$row->store();
$row->updateOrder( "catid = $row->catid AND state >= 0" );
}
$msg = $total. ' Item(s) successfully moved to Section: '. $section .', Category: '. $category;
mosRedirect( 'index2.php?option='. $option .'§ionid='. $sectionid .'&mosmsg='. $msg );
}
/**
* Form for copying item(s)
**/
function copyItem( $cid, $sectionid, $option ) {
global $database;
if (!is_array( $cid ) || count( $cid ) < 1) {
echo "<script> alert('Select an item to move'); window.history.go(-1);</script>\n";
exit;
}
//seperate contentids
$cids = implode( ',', $cid );
## Content Items query
$query = "SELECT a.title"
. "\n FROM #__content AS a"
. "\n WHERE ( a.id IN ( $cids ) )"
. "\n ORDER BY a.title"
;
$database->setQuery( $query );
$items = $database->loadObjectList();
## Section & Category query
$query = "SELECT CONCAT_WS(',',s.id,c.id) AS `value`, CONCAT_WS(' // ', s.name, c.name) AS `text`"
. "\n FROM #__sections AS s"
. "\n INNER JOIN #__categories AS c ON c.section = s.id"
. "\n WHERE s.scope = 'content'"
. "\n ORDER BY s.name, c.name"
;
$database->setQuery( $query );
$rows = $database->loadObjectList();
// build the html select list
$sectCatList = mosHTML::selectList( $rows, 'sectcat', 'class="inputbox" size="10"', 'value', 'text', NULL );
HTML_content::copySection( $option, $cid, $sectCatList, $sectionid, $items );
}
/**
* saves Copies of items
**/
function copyItemSave( $cid, $sectionid, $option ) {
global $database;
$sectcat = mosGetParam( $_POST, 'sectcat', '' );
//seperate sections and categories from selection
$sectcat = explode( ',', $sectcat );
list( $newsect, $newcat ) = $sectcat;
if ( !$newsect && !$newcat ) {
mosRedirect( 'index.php?option=com_content§ionid='. $sectionid .'&mosmsg=An error has occurred' );
}
// find section name
$query = "SELECT a.name"
. "\n FROM #__sections AS a"
. "\n WHERE a.id = $newsect"
;
$database->setQuery( $query );
$section = $database->loadResult();
// find category name
$query = "SELECT a.name"
. "\n FROM #__categories AS a"
. "\n WHERE a.id = $newcat"
;
$database->setQuery( $query );
$category = $database->loadResult();
$total = count( $cid );
for ( $i = 0; $i < $total; $i++ ) {
$row = new mosContent( $database );
// main query
$query = "SELECT a.*"
. "\n FROM #__content AS a"
. "\n WHERE a.id = ". $cid[$i] .""
;
$database->setQuery( $query );
$item = $database->loadObjectList();
// values loaded into array set for store
$row->id = NULL;
$row->sectionid = $newsect;
$row->catid = $newcat;
$row->hits = '0';
$row->ordering = '0';
$row->title = $item[0]->title;
$row->title_alias = $item[0]->title_alias;
$row->introtext = $item[0]->introtext;
$row->fulltext = $item[0]->fulltext;
$row->state = $item[0]->state;
$row->mask = $item[0]->mask;
$row->created = $item[0]->created;
$row->created_by = $item[0]->created_by;
$row->created_by_alias = $item[0]->created_by_alias;
$row->modified = $item[0]->modified;
$row->modified_by = $item[0]->modified_by;
$row->checked_out = $item[0]->checked_out;
$row->checked_out_time = $item[0]->checked_out_time;
$row->frontpage_up = $item[0]->frontpage_up;
$row->frontpage_down = $item[0]->frontpage_down;
$row->publish_up = $item[0]->publish_up;
$row->publish_down = $item[0]->publish_down;
$row->images = $item[0]->images;
$row->attribs = $item[0]->attribs;
$row->version = $item[0]->parentid;
$row->parentid = $item[0]->parentid;
$row->metakey = $item[0]->metakey;
$row->metadesc = $item[0]->metadesc;
$row->access = $item[0]->access;
if (!$row->check()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
if (!$row->store()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
$row->updateOrder( "catid='". $row->catid ."' AND state >= 0" );
}
$msg = $total. ' Item(s) successfully copied to Section: '. $section .', Category: '. $category;
mosRedirect( 'index2.php?option='. $option .'§ionid='. $sectionid .'&mosmsg='. $msg );
}
/**
* Function to reset Hit count of a content item
* PT
*/
function resethits( $redirect, $id ) {
global $database;
$row = new mosContent($database);
$row->Load($id);
$row->hits = 0;
$row->store();
$row->checkin();
$msg = 'Successfully Reset Hit count';
mosRedirect( 'index2.php?option=com_content§ionid='. $redirect .'&task=edit&hidemainmenu=1&id='. $id, $msg );
}
/**
* @param integer The id of the content item
* @param integer The new access level
* @param string The URL option
*/
function accessMenu( $uid, $access, $option ) {
global $database;
$row = new mosContent( $database );
$row->load( $uid );
$row->access = $access;
if ( !$row->check() ) {
return $row->getError();
}
if ( !$row->store() ) {
return $row->getError();
}
$redirect = mosGetParam( $_POST, 'redirect', $row->sectionid );
mosRedirect( 'index2.php?option='. $option .'§ionid='. $redirect );
}
function filterCategory( $query, $active=NULL ) {
global $database;
$categories[] = mosHTML::makeOption( '0', _SEL_CATEGORY );
$database->setQuery( $query );
$categories = array_merge( $categories, $database->loadObjectList() );
$category = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $active );
return $category;
}
function menuLink( $redirect, $id ) {
global $database;
$menu = mosGetParam( $_POST, 'menuselect', '' );
$link = mosGetParam( $_POST, 'link_name', '' );
$row = new mosMenu( $database );
$row->menutype = $menu;
$row->name = $link;
$row->type = 'content_item_link';
$row->published = 1;
$row->componentid = $id;
$row->link = 'index.php?option=com_content&task=view&id='. $id;
$row->ordering = 9999;
if (!$row->check()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
if (!$row->store()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
$row->checkin();
$row->updateOrder( "menutype = '$row->menutype' AND parent = $row->parent" );
$msg = $link .' (Link - Content Item) in menu: '. $menu .' successfully created';
mosRedirect( 'index2.php?option=com_content§ionid='. $redirect .'&task=edit&hidemainmenu=1&id='. $id, $msg );
}
function go2menu() {
$menu = mosGetParam( $_POST, 'menu', 'mainmenu' );
mosRedirect( 'index2.php?option=com_menus&menutype='. $menu );
}
function go2menuitem() {
$menu = mosGetParam( $_POST, 'menu', 'mainmenu' );
$id = mosGetParam( $_POST, 'menuid', 0 );
mosRedirect( 'index2.php?option=com_menus&menutype='. $menu .'&task=edit&hidemainmenu=1&id='. $id );
}
function saveOrder( &$cid ) {
global $database;
$total = count( $cid );
$order = mosGetParam( $_POST, 'order', array(0) );
$redirect = mosGetParam( $_POST, 'redirect', 0 );
$rettask = mosGetParam( $_POST, 'returntask', '' );
$row = new mosContent( $database );
$conditions = array();
// update ordering values
for( $i=0; $i < $total; $i++ ) {
$row->load( $cid[$i] );
if ($row->ordering != $order[$i]) {
$row->ordering = $order[$i];
if (!$row->store()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
exit();
} // if
// remember to updateOrder this group
$condition = "catid = $row->catid AND state >= 0";
$found = false;
foreach ( $conditions as $cond )
if ($cond[1]==$condition) {
$found = true;
break;
} // if
if (!$found) $conditions[] = array($row->id, $condition);
} // if
} // for
// execute updateOrder for each group
foreach ( $conditions as $cond ) {
$row->load( $cond[0] );
$row->updateOrder( $cond[1] );
} // foreach
$msg = 'New ordering saved';
switch ( $rettask ) {
case 'showarchive':
mosRedirect( 'index2.php?option=com_content&task=showarchive§ionid='. $redirect, $msg );
break;
default:
mosRedirect( 'index2.php?option=com_content§ionid='. $redirect, $msg );
break;
} // switch
} // saveOrder
?>
No other release has this exact content. See every version of this file.