📄 admin.menus.php
字号:
switch ( $task ) { case 'apply': mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype .'&task=edit&id='. $row->id . '&hidemainmenu=1' , $msg ); break; case 'save': default: mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype, $msg ); break; }}/*** Publishes or Unpublishes one or more menu sections* @param database A database connector object* @param string The name of the category section* @param array An array of id numbers* @param integer 0 if unpublishing, 1 if publishing*/function publishMenuSection( $cid=null, $publish=1 ) { global $database, $mosConfig_absolute_path, $adminLanguage; if (!is_array( $cid ) || count( $cid ) < 1) { return $adminLanguage->A_COMP_MENUS_SELECT_TO . ($publish ? $adminLanguage->A_COMP_PUBLISH : $adminLanguage->A_COMP_UNPUBLISH); } $menu = new mosMenu( $database ); foreach ($cid as $id) { $menu->load( $id ); $menu->published = $publish; if (!$menu->check()) { return $menu->getError(); } if (!$menu->store()) { return $menu->getError(); } if ($menu->type) { $database = &$database; $task = $publish ? 'publish' : 'unpublish'; require( $mosConfig_absolute_path . '/administrator/components/com_menus/' . $menu->type . '/' . $menu->type . '.menu.php' ); } } return null;}/*** Trashes a menu record*/function TrashMenuSection( $cid=NULL ) { global $database, $adminLanguage; $state = "-2"; //seperate contentids $cids = implode( ',', $cid ); $query = "UPDATE #__menu SET published = '". $state ."', ordering = '0'" . "\n WHERE id IN ( ". $cids ." )" ; $database->setQuery( $query ); if ( !$database->query() ) { echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; exit(); } $total = count( $cid ); $msg = $total ." ". $adminLanguage->A_COMP_TYPED_TRASHED; return $msg;}/*** Cancels an edit operation*/function cancelMenu( $option ) { global $database; $menu = new mosMenu( $database ); $menu->bind( $_POST ); $menuid = mosGetParam( $_POST, 'menuid', 0 ); if ( $menuid ) { $menu->id = $menuid; } $menu->checkin();/* if ( $menu->type == 'content_typed' ) { $contentid = mosGetParam( $_POST, 'id', 0 ); $content = new mosContent( $database ); $content->load( $contentid ); $content->checkin(); }*/ mosRedirect( 'index2.php?option='. $option .'&menutype='. $menu->menutype );}/*** Moves the order of a record* @param integer The increment to reorder by*/function orderMenu( $uid, $inc, $option ) { global $database; $row = new mosMenu( $database ); $row->load( $uid ); $row->move( $inc, 'menutype="'. $row->menutype .'" AND parent="'. $row->parent .'"' ); mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype );}/*** changes the access level of a record* @param integer The increment to reorder by*/function accessMenu( $uid, $access, $option, $menutype ) { global $database; $menu = new mosMenu( $database ); $menu->load( $uid ); $menu->access = $access; if (!$menu->check()) { return $menu->getError(); } if (!$menu->store()) { return $menu->getError(); } mosRedirect( 'index2.php?option='. $option .'&menutype='. $menutype );}/*** Form for moving item(s) to a specific menu*/function moveMenu( $option, $cid, $menutype ) { global $database, $adminLanguage; if (!is_array( $cid ) || count( $cid ) < 1) { echo "<script> alert('$adminLanguage->A_COMP_CATEG_ITEM_MOVE'); window.history.go(-1);</script>\n"; exit; } ## query to list selected menu items $cids = implode( ',', $cid ); $query = "SELECT a.name FROM #__menu AS a WHERE a.id IN ( ". $cids ." )"; $database->setQuery( $query ); $items = $database->loadObjectList(); ## query to choose menu $query = "SELECT a.params FROM #__modules AS a WHERE a.module = 'mod_mainmenu' ORDER BY a.title"; $database->setQuery( $query ); $modules = $database->loadObjectList(); foreach ( $modules as $module) { $params = mosParseParams( $module->params ); // adds menutype to array $type = trim( @$params->menutype ); $menu[] = mosHTML::makeOption( $type, $type ); } // build the html select list $MenuList = mosHTML::selectList( $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null ); HTML_menusections::moveMenu( $option, $cid, $MenuList, $items, $menutype );}/*** Add all descendants to list of meni id's*/function addDescendants($id, &$cid){ global $database; $database->setQuery("SELECT id FROM #__menu WHERE parent=$id"); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo "<script> alert('". $database->getErrorMsg() ."'); window.history.go(-1); </script>\n"; exit(); } // if foreach ($rows as $row) { $found = false; foreach ($cid as $idx) if ($idx == $row->id) { $found = true; break; } // if if (!$found) $cid[] = $row->id; addDescendants($row->id, $cid); } // foreach} // addDescendants/*** Save the item(s) to the menu selected*/function moveMenuSave( $option, $cid, $menu, $menutype ) { global $database, $my; // add all decendants to the list foreach ($cid as $id) addDescendants($id, $cid); $row = new mosMenu( $database ); $ordering = 1000000; $firstroot = 0; foreach ($cid as $id) { $row->load( $id ); // is it moved together with his parent? $found = false; if ($row->parent != 0) foreach ($cid as $idx) if ($idx == $row->parent) { $found = true; break; } // if if (!$found) { $row->parent = 0; $row->ordering = $ordering++; if (!$firstroot) $firstroot = $row->id; } // if $row->menutype = $menu; if ( !$row->store() ) { echo "<script> alert('". $database->getErrorMsg() ."'); window.history.go(-1); </script>\n"; exit(); } // if } // foreach if ($firstroot) { $row->load( $firstroot ); $row->updateOrder( "menutype='". $row->menutype ."' AND parent='". $row->parent ."'" ); } // if $msg = count($cid) . $adminLanguage->A_COMP_MENUS_MOVED_TO . $menu; mosRedirect( 'index2.php?option='. $option .'&menutype='. $menutype .'&mosmsg='. $msg );} // moveMenuSave/*** Form for copying item(s) to a specific menu*/function copyMenu( $option, $cid, $menutype ) { global $database, $adminLanguage; if (!is_array( $cid ) || count( $cid ) < 1) { echo "<script> alert('$adminLanguage->A_COMP_CATEG_ITEM_MOVE'); window.history.go(-1);</script>\n"; exit; } ## query to list selected menu items $cids = implode( ',', $cid ); $query = "SELECT a.name FROM #__menu AS a WHERE a.id IN ( ". $cids ." )"; $database->setQuery( $query ); $items = $database->loadObjectList(); $menuTypes = mosAdminMenus::menutypes(); foreach ( $menuTypes as $menuType ) { $menu[] = mosHTML::makeOption( $menuType, $menuType ); } // build the html select list $MenuList = mosHTML::selectList( $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null ); HTML_menusections::copyMenu( $option, $cid, $MenuList, $items, $menutype );}/*** Save the item(s) to the menu selected*/function copyMenuSave( $option, $cid, $menu, $menutype ) { global $database, $adminLanguage; $curr = new mosMenu( $database ); $cidref = array(); foreach( $cid as $id ) { $curr->load( $id ); $curr->id = NULL; if ( !$curr->store() ) { echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; exit(); } $cidref[] = array($id, $curr->id); } foreach ( $cidref as $ref ) { $curr->load( $ref[1] ); if ($curr->parent!=0) { $found = false; foreach ( $cidref as $ref2 ) if ($curr->parent == $ref2[0]) { $curr->parent = $ref2[1]; $found = true; break; } // if if (!$found && $curr->menutype!=$menu) $curr->parent = 0; } // if $curr->menutype = $menu; $curr->ordering = '9999'; if ( !$curr->store() ) { echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; exit(); } $curr->updateOrder( "menutype='". $curr->menutype ."' AND parent='". $curr->parent ."'" ); } // foreach $msg = count( $cid ) . $adminLanguage->A_COMP_MENUS_COPIED_TO . $menu; mosRedirect( 'index2.php?option='. $option .'&menutype='. $menutype .'&mosmsg='. $msg );}function ReadMenuXML( $type, $component=-1 ) { global $mosConfig_absolute_path; // XML library require_once( $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php' ); // xml file for module $xmlfile = $mosConfig_absolute_path .'/administrator/components/com_menus/'. $type .'/'. $type .'.xml'; $xmlDoc =& new DOMIT_Lite_Document(); $xmlDoc->resolveErrors( true ); if ($xmlDoc->loadXML( $xmlfile, false, true )) { $element = &$xmlDoc->documentElement; if ( $element->getTagName() == 'mosinstall' && ( $element->getAttribute( 'type' ) == 'component' || $element->getAttribute( 'type' ) == 'menu' ) ) { // Menu Type Name $element = &$xmlDoc->getElementsByPath( 'name', 1 ); $name = $element ? trim( $element->getText() ) : ''; // Menu Type Description $element = &$xmlDoc->getElementsByPath( 'description', 1 ); $descrip = $element ? trim( $element->getText() ) : ''; // Menu Type Group $element = &$xmlDoc->getElementsByPath( 'group', 1 ); $group = $element ? trim( $element->getText() ) : ''; } } if ( ( $component <> -1 ) && ( $name == 'Component') ) { $name .= ' - '. $component; } $row[0] = $name; $row[1] = $descrip; $row[2] = $group; return $row;}function saveOrder( &$cid, $menutype ) { global $database; $total = count( $cid ); $order = mosGetParam( $_POST, 'order', array(0) ); $row = new mosMenu( $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(); } // remember to updateOrder this group $condition = "menutype = '$menutype' AND parent = '$row->parent' AND published >= 0"; $found = false; foreach ( $conditions as $cond ) if ($cond[1]==$condition) { $found = true; break; } // if if (!$found) $conditions[] = array($row->id, $condition); } // for } // for // execute updateOrder for each group foreach ( $conditions as $cond ) { $row->load( $cond[0] ); $row->updateOrder( $cond[1] ); } // foreach $msg = $adminLanguage->A_COMP_MENUS_NEW_ORDER_SAVED; mosRedirect( 'index2.php?option=com_menus&menutype='. $menutype, $msg );} // saveOrder?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -