📄 admin.content.php
字号:
/*** 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, $adminLanguage; if (!is_array( $cid ) || count( $cid ) < 1) { echo "<script> alert(\"". $adminLanguage->A_COMP_CONTENT_SEL_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, $adminLanguage; $sectcat = mosGetParam( $_POST, 'sectcat', '' ); list( $newsect, $newcat ) = explode( ',', $sectcat ); if (!$newsect && !$newcat ) { mosRedirect( "index.php?option=com_content§ionid=$sectionid&mosmsg=". $adminLanguage->A_COMP_CONTENT_ERR_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." ". $adminLanguage->A_COMP_CONTENT_MOVED .": ". $section .", ". $adminLanguage->A_COMP_CATEG .": ". $category; mosRedirect( 'index2.php?option='. $option .'§ionid='. $sectionid .'&mosmsg='. $msg );}/*** Form for copying item(s)**/function copyItem( $cid, $sectionid, $option ) { global $database, $adminLanguage; if (!is_array( $cid ) || count( $cid ) < 1) { echo "<script> alert(\"". $adminLanguage->A_COMP_CONTENT_SEL_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, $my, $adminLanguage; $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=". $adminLanguage->A_COMP_CONTENT_ERR_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.* 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 ." ". $adminLanguage->A_COMP_CONTENT_COPIED .": ". $section .", ". $adminLanguage->A_COMP_CATEG .": ". $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, $adminLanguage; $row = new mosContent($database); $row->Load($id); $row->hits = "0"; $row->store(); $row->checkin(); $msg = $adminLanguage->A_COMP_CONTENT_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, $adminLanguage; $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 ." ". $adminLanguage->A_COMP_CONTENT_IN_MENU .": ". $menu ." ". $adminLanguage->A_COMP_CONTENT_SUCCESS; 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, $adminLanguage; $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 = $adminLanguage->A_COMP_ORDER_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?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -