| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 * @subpackage Menus 5 * @author Mambo Foundation Inc see README.php 6 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 7 * See COPYRIGHT.php for copyright notices and details. 8 * @license GNU/GPL Version 2, see LICENSE.php 9 * 10 * Redistributions of files must retain the above copyright notice. 11 * 12 * Mambo is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; version 2 of the License. 15 */ 16 17 /** ensure this file is being included by a parent file */ 18 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 19 20 require_once( $mainframe->getPath( 'admin_html' ) ); 21 22 $id = intval( mosGetParam( $_GET, 'id', 0 ) ); 23 $type = mosGetParam( $_REQUEST, 'type', false ); 24 $menutype = mosGetParam( $_REQUEST, 'menutype', 'mainmenu' ); 25 $task = mosGetParam( $_REQUEST, 'task', '' ); 26 $access = mosGetParam( $_POST, 'access', '' ); 27 $utaccess = mosGetParam( $_POST, 'utaccess', '' ); 28 $ItemName = mosGetParam( $_POST, 'ItemName', '' ); 29 $menu = mosGetParam( $_POST, 'menu', '' ); 30 $cid = mosGetParam( $_POST, 'cid', array(0) ); 31 32 $path = $mosConfig_absolute_path .'/administrator/components/com_menus/'; 33 34 if (!is_array( $cid )) { 35 $cid = array(0); 36 } 37 38 39 switch ($task) { 40 case 'new': 41 addMenuItem( $cid, $menutype, $option, $task ); 42 break; 43 44 case 'edit': 45 $cid[0] = ( $id ? $id : $cid[0] ); 46 $menu = new mosMenu( $database ); 47 if ( $cid[0] ) { 48 $menu->load( $cid[0] ); 49 } else { 50 $menu->type = $type; 51 } 52 53 if ( $menu->type ) { 54 $type = $menu->type; 55 require( $path . $menu->type .'/'. $menu->type .'.menu.php' ); 56 } 57 break; 58 59 case 'save': 60 case 'apply': 61 require( $path . $type .'/'. $type .'.menu.php' ); 62 break; 63 64 case 'publish': 65 case 'unpublish': 66 if ($msg = publishMenuSection( $cid, ($task == 'publish') )) { 67 // proceed no further if the menu item can't be published 68 mosRedirect( 'index2.php?option=com_menus&menutype='. $menutype .'&mosmsg= '.$msg ); 69 } else { 70 mosRedirect( 'index2.php?option=com_menus&menutype='. $menutype ); 71 } 72 break; 73 74 case 'remove': 75 if ($msg = TrashMenusection( $cid )) { 76 mosRedirect( 'index2.php?option=com_menus&menutype='. $menutype .'&mosmsg= '.$msg ); 77 } else { 78 mosRedirect( 'index2.php?option=com_menus&menutype='. $menutype ); 79 } 80 break; 81 82 case 'cancel': 83 cancelMenu( $option ); 84 break; 85 86 case 'orderup': 87 orderMenu( $cid[0], -1, $option ); 88 break; 89 90 case 'orderdown': 91 orderMenu( $cid[0], 1, $option ); 92 break; 93 94 case 'accesspublic': 95 accessMenu( $cid[0], 0, $option, $menutype ); 96 break; 97 98 case 'accessregistered': 99 accessMenu( $cid[0], 1, $option, $menutype ); 100 break; 101 102 case 'accessspecial': 103 accessMenu( $cid[0], 2, $option, $menutype ); 104 break; 105 106 case 'movemenu': 107 moveMenu( $option, $cid, $menutype ); 108 break; 109 110 case 'movemenusave': 111 moveMenuSave( $option, $cid, $menu, $menutype ); 112 break; 113 114 case 'copymenu': 115 copyMenu( $option, $cid, $menutype ); 116 break; 117 118 case 'copymenusave': 119 copyMenuSave( $option, $cid, $menu, $menutype ); 120 break; 121 122 case 'cancelcopymenu': 123 case 'cancelmovemenu': 124 viewMenuItems( $menutype, $option ); 125 break; 126 127 case 'saveorder': 128 saveOrder( $cid, $menutype ); 129 break; 130 131 default: 132 $type = trim( mosGetParam( $_REQUEST, 'type', null ) ); 133 if ($type) { 134 // adding a new item - type selection form 135 require( $path . $type .'/'. $type .'.menu.php' ); 136 } else { 137 viewMenuItems( $menutype, $option ); 138 } 139 break; 140 } 141 142 /** 143 * Shows a list of items for a menu 144 */ 145 function viewMenuItems( $menutype, $option ) { 146 global $database, $mainframe, $mosConfig_list_limit; 147 148 $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ); 149 $limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart$menutype", 'limitstart', 0 ); 150 $levellimit = $mainframe->getUserStateFromRequest( "view{$option}limit$menutype", 'levellimit', 10 ); 151 $search = $mainframe->getUserStateFromRequest( "search{$option}$menutype", 'search', '' ); 152 $search = $database->getEscaped( trim( strtolower( $search ) ) ); 153 154 // select the records 155 // note, since this is a tree we have to do the limits code-side 156 if ($search) { 157 $query = "SELECT m.id" 158 . "\n FROM #__menu AS m" 159 //. "\n LEFT JOIN #__content AS c ON c.id = m.componentid AND type='content_typed'" 160 . "\n WHERE menutype='$menutype'" 161 . "\n AND LOWER(m.name) LIKE '%" . strtolower( $search ) . "%'" 162 ; 163 $database->setQuery( $query ); 164 $search_rows = $database->loadResultArray(); 165 } 166 167 $query = "SELECT m.*, u.name AS editor, g.name AS groupname, c.publish_up, c.publish_down, com.name AS com_name" 168 . "\n FROM #__menu AS m" 169 . "\n LEFT JOIN #__users AS u ON u.id = m.checked_out" 170 . "\n LEFT JOIN #__groups AS g ON g.id = m.access" 171 . "\n LEFT JOIN #__content AS c ON c.id = m.componentid AND m.type='content_typed'" 172 . "\n LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type='components'" 173 . "\n WHERE m.menutype='$menutype'" 174 . "\n AND m.published != -2" 175 . "\n ORDER BY parent,ordering" 176 ; 177 $database->setQuery( $query ); 178 $rows = $database->loadObjectList(); 179 180 // establish the hierarchy of the menu 181 $children = array(); 182 // first pass - collect children 183 if ($rows) foreach ($rows as $v ) { 184 $pt = $v->parent; 185 $list = @$children[$pt] ? $children[$pt] : array(); 186 array_push( $list, $v ); 187 $children[$pt] = $list; 188 } 189 // second pass - get an indent list of the items 190 $list = mosTreeRecurse( 0, '', array(), $children, max( 0, $levellimit-1 ) ); 191 // eventually only pick out the searched items. 192 if ($search) { 193 $list1 = array(); 194 195 foreach ($search_rows as $sid ) { 196 foreach ($list as $item) { 197 if ($item->id == $sid) { 198 $list1[] = $item; 199 } 200 } 201 } 202 // replace full list with found items 203 $list = $list1; 204 } 205 206 $total = count( $list ); 207 208 require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' ); 209 $pageNav = new mosPageNav( $total, $limitstart, $limit ); 210 211 $levellist = mosHTML::integerSelectList( 1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit ); 212 213 // slice out elements based on limits 214 $list = array_slice( $list, $pageNav->limitstart, $pageNav->limit ); 215 216 $i = 0; 217 foreach ( $list as $mitem ) { 218 $edit = ''; 219 switch ( $mitem->type ) { 220 case 'separator': 221 case 'component_item_link': 222 break; 223 224 case 'url': 225 if ( eregi( 'index.php\?', $mitem->link ) ) { 226 if ( !eregi( 'Itemid=', $mitem->link ) ) { 227 $mitem->link .= '&Itemid='. $mitem->id; 228 } 229 } 230 break; 231 232 case 'newsfeed_link': 233 $edit = 'index2.php?option=com_newsfeeds&task=edit&hidemainmenu=1A&id=' . $mitem->componentid; 234 $list[$i]->descrip = 'Edit this News Feed'; 235 $mitem->link .= '&Itemid='. $mitem->id; 236 break; 237 238 case 'contact_item_link': 239 $edit = 'index2.php?option=com_contact&task=editA&hidemainmenu=1&id=' . $mitem->componentid; 240 $list[$i]->descrip = 'Edit this Contact'; 241 $mitem->link .= '&Itemid='. $mitem->id; 242 break; 243 244 case 'content_item_link': 245 $edit = 'index2.php?option=com_content&task=edit&hidemainmenu=1&id=' . $mitem->componentid; 246 $list[$i]->descrip = 'Edit this Content'; 247 break; 248 249 case 'content_typed': 250 $edit = 'index2.php?option=com_typedcontent&task=edit&hidemainmenu=1&id='. $mitem->componentid; 251 $list[$i]->descrip = 'Edit this Static Content'; 252 break; 253 254 default: 255 $mitem->link .= '&Itemid='. $mitem->id; 256 break; 257 } 258 $list[$i]->link = $mitem->link; 259 $list[$i]->edit = $edit; 260 $i++; 261 } 262 263 $i = 0; 264 foreach ( $list as $row ) { 265 // pulls name and description from menu type xml 266 $row = ReadMenuXML( $row->type, $row->com_name ); 267 $list[$i]->type = $row[0]; 268 if (!isset($list[$i]->descrip)) $list[$i]->descrip = $row[1]; 269 $i++; 270 } 271 272 HTML_menusections::showMenusections( $list, $pageNav, $search, $levellist, $menutype, $option ); 273 } 274 275 /** 276 * Displays a selection list for menu item types 277 */ 278 function addMenuItem( &$cid, $menutype, $option, $task ) { 279 global $mosConfig_absolute_path; 280 281 $types = array(); 282 283 // list of directories 284 $dirs = mosReadDirectory( $mosConfig_absolute_path .'/administrator/components/com_menus' ); 285 286 // load files for menu types 287 foreach ( $dirs as $dir ) { 288 // needed within menu type .php files 289 $type = $dir; 290 $dir = $mosConfig_absolute_path .'/administrator/components/com_menus/'. $dir; 291 if ( is_dir( $dir ) ) { 292 $files = mosReadDirectory( $dir, ".\.menu\.php$" ); 293 foreach ($files as $file) { 294 require_once( "$dir/$file" ); 295 // type of menu type 296 $types[]->type = $type; 297 } 298 } 299 } 300 301 $i = 0; 302 foreach ( $types as $type ) { 303 // pulls name and description from menu type xml 304 $row = ReadMenuXML( $type->type ); 305 $types[$i]->name = $row[0]; 306 $types[$i]->descrip = $row[1]; 307 $types[$i]->group = $row[2]; 308 $i++; 309 } 310 311 // sort array of objects alphabetically by name of menu type 312 SortArrayObjects( $types, 'name', 1 ); 313 314 // split into Content 315 $i = 0; 316 foreach ( $types as $type ) { 317 if ( strstr( $type->group, 'Content' ) ) { 318 $types_content[] = $types[$i]; 319 } 320 $i++; 321 } 322 323 // split into Links 324 $i = 0; 325 foreach ( $types as $type ) { 326 if ( strstr( $type->group, 'Link' ) ) { 327 $types_link[] = $types[$i]; 328 } 329 $i++; 330 } 331 332 // split into Component 333 $i = 0; 334 foreach ( $types as $type ) { 335 if ( strstr( $type->group, 'Component' ) ) { 336 $types_component[] = $types[$i]; 337 } 338 $i++; 339 } 340 341 // split into Other 342 $i = 0; 343 foreach ( $types as $type ) { 344 if ( strstr( $type->group, 'Other' ) || !$type->group ) { 345 $types_other[] = $types[$i]; 346 } 347 $i++; 348 } 349 350 HTML_menusections::addMenuItem( $cid, $menutype, $option, $types_content, $types_component, $types_link, $types_other ); 351 } 352 353 354 /** 355 * Generic function to save the menu 356 */ 357 function saveMenu( $option, $task='save' ) { 358 global $database; 359 360 $params = mosGetParam( $_POST, 'params', '' ); 361 if (is_array( $params )) { 362 $txt = array(); 363 foreach ($params as $k=>$v) { 364 $txt[] = "$k=$v"; 365 } 366 $_POST['params'] = mosParameters::textareaHandling( $txt ); 367 } 368 369 $row = new mosMenu( $database ); 370 371 if (!$row->bind( $_POST )) { 372 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 373 exit(); 374 } 375 376 if (!$row->check()) { 377 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 378 exit(); 379 } 380 if (!$row->store()) { 381 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 382 exit(); 383 } 384 $row->checkin(); 385 $row->updateOrder( "menutype='$row->menutype' AND parent='$row->parent'" ); 386 387 $msg = T_('Menu item Saved'); 388 switch ( $task ) { 389 case 'apply': 390 mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype .'&task=edit&id='. $row->id . '&hidemainmenu=1' , $msg ); 391 break; 392 393 case 'save': 394 default: 395 mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype, $msg ); 396 break; 397 } 398 } 399 400 /** 401 * Publishes or Unpublishes one or more menu sections 402 * @param database A database connector object 403 * @param string The name of the category section 404 * @param array An array of id numbers 405 * @param integer 0 if unpublishing, 1 if publishing 406 */ 407 function publishMenuSection( $cid=null, $publish=1 ) { 408 global $database, $mosConfig_absolute_path; 409 410 if (!is_array( $cid ) || count( $cid ) < 1) { 411 $pub = $publish ? T_('publish') : T_('unpublish'); 412 return sprintf(T_('Select an item to %s'), $pub); 413 } 414 415 $menu = new mosMenu( $database ); 416 foreach ($cid as $id) { 417 $menu->load( $id ); 418 $menu->published = $publish; 419 420 if (!$menu->check()) { 421 return $menu->getError(); 422 } 423 if (!$menu->store()) { 424 return $menu->getError(); 425 } 426 427 if ($menu->type) { 428 $database = &$database; 429 $task = $publish ? 'publish' : 'unpublish'; 430 require( $mosConfig_absolute_path . '/administrator/components/com_menus/' . $menu->type . '/' . $menu->type . '.menu.php' ); 431 } 432 } 433 return null; 434 } 435 436 /** 437 * Trashes a menu record 438 */ 439 function TrashMenuSection( $cid=NULL ) { 440 global $database; 441 442 $state = "-2"; 443 //seperate contentids 444 $cids = implode( ',', $cid ); 445 // @RawSQLUse, trivial_implementation, UPDATE 446 $query = "UPDATE #__menu SET published = '". $state ."', ordering = '0'" 447 . "\n WHERE id IN ( ". $cids ." )" 448 ; 449 $database->setQuery( $query ); 450 if ( !$database->query() ) { 451 echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; 452 exit(); 453 } 454 455 $total = count( $cid ); 456 $msg = sprintf(Tn_("%d Item sent to the Trash", "%d Items sent to the Trash", $total), $total); 457 return $msg; 458 } 459 460 /** 461 * Cancels an edit operation 462 */ 463 function cancelMenu( $option ) { 464 global $database; 465 466 $menu = new mosMenu( $database ); 467 $menu->bind( $_POST ); 468 $menuid = mosGetParam( $_POST, 'menuid', 0 ); 469 if ( $menuid ) { 470 $menu->id = $menuid; 471 } 472 // sanitize 473 $row->id = intval($row->id); 474 $menu->checkin(); 475 /* 476 if ( $menu->type == 'content_typed' ) { 477 $contentid = mosGetParam( $_POST, 'id', 0 ); 478 $content = new mosContent( $database ); 479 $content->load( $contentid ); 480 $content->checkin(); 481 } 482 */ 483 mosRedirect( 'index2.php?option='. $option .'&menutype='. $menu->menutype ); 484 } 485 486 /** 487 * Moves the order of a record 488 * @param integer The increment to reorder by 489 */ 490 function orderMenu( $uid, $inc, $option ) { 491 global $database; 492 493 $row = new mosMenu( $database ); 494 $row->load( $uid ); 495 $row->move( $inc, 'menutype="'. $row->menutype .'" AND parent="'. $row->parent .'"' ); 496 497 mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype ); 498 } 499 500 501 /** 502 * changes the access level of a record 503 * @param integer The increment to reorder by 504 */ 505 function accessMenu( $uid, $access, $option, $menutype ) { 506 global $database; 507 508 $menu = new mosMenu( $database ); 509 $menu->load( $uid ); 510 $menu->access = $access; 511 512 if (!$menu->check()) { 513 return $menu->getError(); 514 } 515 if (!$menu->store()) { 516 return $menu->getError(); 517 } 518 519 mosRedirect( 'index2.php?option='. $option .'&menutype='. $menutype ); 520 } 521 522 /** 523 * Form for moving item(s) to a specific menu 524 */ 525 function moveMenu( $option, $cid, $menutype ) { 526 global $database; 527 528 if (!is_array( $cid ) || count( $cid ) < 1) { 529 echo "<script> alert('".T_('Select an item to move')."'); window.history.go(-1);</script>\n"; 530 exit; 531 } 532 533 ## query to list selected menu items 534 $cids = implode( ',', $cid ); 535 // @RawSQLUse, trivial_implementation, SELECT 536 $query = "SELECT a.name FROM #__menu AS a WHERE a.id IN ( ". $cids ." )"; 537 $database->setQuery( $query ); 538 $items = $database->loadObjectList(); 539 540 ## query to choose menu 541 // @RawSQLUse, trivial_implementation, SELECT 542 $query = "SELECT a.params FROM #__modules AS a WHERE a.module = 'mod_mainmenu' ORDER BY a.title"; 543 $database->setQuery( $query ); 544 $modules = $database->loadObjectList(); 545 546 foreach ( $modules as $module) { 547 $pparser = new mosParameters($module->params); 548 $params = $pparser->getParams(); 549 // adds menutype to array 550 $type = trim( @$params->menutype ); 551 $menu[] = mosHTML::makeOption( $type, $type ); 552 } 553 // build the html select list 554 $MenuList = mosHTML::selectList( $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null ); 555 556 HTML_menusections::moveMenu( $option, $cid, $MenuList, $items, $menutype ); 557 } 558 559 /** 560 * Add all descendants to list of meni id's 561 */ 562 function addDescendants($id, &$cid) 563 { 564 global $database; 565 566 // @RawSQLUse, trivial_implementation, SELECT, CONCEPT 567 $database->setQuery("SELECT id FROM #__menu WHERE parent=$id"); 568 $rows = $database->loadObjectList(); 569 if ($database->getErrorNum()) { 570 echo "<script> alert('". $database->getErrorMsg() ."'); window.history.go(-1); </script>\n"; 571 exit(); 572 } // if 573 foreach ($rows as $row) { 574 $found = false; 575 foreach ($cid as $idx) 576 if ($idx == $row->id) { 577 $found = true; 578 break; 579 } // if 580 if (!$found) $cid[] = $row->id; 581 addDescendants($row->id, $cid); 582 } // foreach 583 } // addDescendants 584 585 /** 586 * Save the item(s) to the menu selected 587 */ 588 function moveMenuSave( $option, $cid, $menu, $menutype ) { 589 global $database, $my; 590 591 // add all decendants to the list 592 foreach ($cid as $id) addDescendants($id, $cid); 593 594 $row = new mosMenu( $database ); 595 $ordering = 1000000; 596 $firstroot = 0; 597 foreach ($cid as $id) { 598 $row->load( $id ); 599 600 // is it moved together with his parent? 601 $found = false; 602 if ($row->parent != 0) 603 foreach ($cid as $idx) 604 if ($idx == $row->parent) { 605 $found = true; 606 break; 607 } // if 608 if (!$found) { 609 $row->parent = 0; 610 $row->ordering = $ordering++; 611 if (!$firstroot) $firstroot = $row->id; 612 } // if 613 614 $row->menutype = $menu; 615 if ( !$row->store() ) { 616 echo "<script> alert('". $database->getErrorMsg() ."'); window.history.go(-1); </script>\n"; 617 exit(); 618 } // if 619 } // foreach 620 621 if ($firstroot) { 622 $row->load( $firstroot ); 623 $row->updateOrder( "menutype='". $row->menutype ."' AND parent='". $row->parent ."'" ); 624 } // if 625 626 $msg = sprintf(Tn_('%d Menu Item moved to %s', '%d Menu Items moved to %s', count($cid)), count($cid), $menu); 627 mosRedirect( 'index2.php?option='. $option .'&menutype='. $menutype .'&mosmsg='. $msg ); 628 } // moveMenuSave 629 630 /** 631 * Form for copying item(s) to a specific menu 632 */ 633 function copyMenu( $option, $cid, $menutype ) { 634 global $database; 635 636 if (!is_array( $cid ) || count( $cid ) < 1) { 637 echo "<script> alert('".T_('Select an item to move')."'); window.history.go(-1);</script>\n"; 638 exit; 639 } 640 641 ## query to list selected menu items 642 $cids = implode( ',', $cid ); 643 // @RawSQLUse, trivial_implementation, SELECT, CONCEPT 644 $query = "SELECT a.name FROM #__menu AS a WHERE a.id IN ( ". $cids ." )"; 645 $database->setQuery( $query ); 646 $items = $database->loadObjectList(); 647 648 $menuTypes = mosAdminMenus::menutypes(); 649 650 foreach ( $menuTypes as $menuType ) { 651 $menu[] = mosHTML::makeOption( $menuType, $menuType ); 652 } 653 // build the html select list 654 $MenuList = mosHTML::selectList( $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null ); 655 656 HTML_menusections::copyMenu( $option, $cid, $MenuList, $items, $menutype ); 657 } 658 659 /** 660 * Save the item(s) to the menu selected 661 */ 662 function copyMenuSave( $option, $cid, $menu, $menutype ) { 663 global $database; 664 665 $curr = new mosMenu( $database ); 666 $cidref = array(); 667 foreach( $cid as $id ) { 668 $curr->load( $id ); 669 $curr->id = NULL; 670 if ( !$curr->store() ) { 671 echo "<script> alert('".$curr->getError()."'); window.history.go(-1); </script>\n"; 672 exit(); 673 } 674 $cidref[] = array($id, $curr->id); 675 } 676 foreach ( $cidref as $ref ) { 677 unset($curr); 678 $curr = new mosMenu( $database ); 679 $curr->load( $ref[1] ); 680 if ($curr->parent!=0) { 681 $found = false; 682 foreach ( $cidref as $ref2 ) 683 if ($curr->parent == $ref2[0]) { 684 $curr->parent = $ref2[1]; 685 $found = true; 686 break; 687 } // if 688 if (!$found && $curr->menutype!=$menu) 689 $curr->parent = 0; 690 } // if 691 $curr->menutype = $menu; 692 $curr->ordering = '9999'; 693 if ( !$curr->store() ) { 694 echo "<script> alert('".$curr->getError()."'); window.history.go(-1); </script>\n"; 695 exit(); 696 } 697 $curr->updateOrder( "menutype='". $curr->menutype ."' AND parent='". $curr->parent ."'" ); 698 } // foreach 699 $msg = sprintf(Tn_('%d Menu Item Copied to %s', '%d Menu Items Copied to %s', count($cid)), count($cid), $menu); 700 mosRedirect( 'index2.php?option='. $option .'&menutype='. $menutype .'&mosmsg='. $msg ); 701 } 702 703 function ReadMenuXML( $type, $component=-1 ) { 704 global $mosConfig_absolute_path; 705 706 // xml file for module 707 $xmlfile = $mosConfig_absolute_path .'/administrator/components/com_menus/'. $type .'/'. $type .'.xml'; 708 $parser = new mosXMLDescription ($xmlfile); 709 $name = $parser->getName('menu'); 710 $descrip = $parser->getDescription('menu'); 711 $group = $parser->getGroup('menu'); 712 713 if ( ( $component <> -1 ) && ( $name == 'Component') ) { 714 $name = T_($name) . ' - '. $component; 715 } 716 717 $row[0] = $name; 718 $row[1] = $descrip; 719 $row[2] = $group; 720 721 return $row; 722 } 723 724 function saveOrder( &$cid, $menutype ) { 725 global $database; 726 $order = mosGetParam( $_POST, 'order', array(0) ); 727 $row = new mosMenu( $database ); 728 $parents = array(); 729 // update ordering values 730 foreach ($cid as $i=>$ciditem) { 731 $row->load( $ciditem ); 732 if ($row->ordering != $order[$i]) { 733 $row->ordering = $order[$i]; 734 if (!$row->store()) { 735 echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; 736 exit(); 737 } 738 // remember to updateOrder this group 739 $parents[$row->parent] = $row->id; 740 } 741 } 742 // execute updateOrder for each group 743 foreach ($parents as $parent=>$rowid) { 744 $row->updateOrder("menutype = '$menutype' AND parent = '$parent' AND published >= 0"); 745 } // foreach 746 747 $msg = T_('New ordering saved'); 748 mosRedirect( 'index2.php?option=com_menus&menutype='. $menutype, $msg ); 749 } // saveOrder 750 751 752 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 8 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |