| [ 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 class content_blog_category { 21 22 /** 23 * @param database A database connector object 24 * @param integer The unique id of the category to edit (0 if new) 25 */ 26 function edit( &$uid, $menutype, $option ) { 27 global $database, $my, $mainframe; 28 global $mosConfig_absolute_path; 29 30 $menu = new mosMenu( $database ); 31 $menu->load( $uid ); 32 33 // fail if checked out not by 'me' 34 if ($menu->checked_out && $menu->checked_out <> $my->id) { 35 echo "<script>alert('".sprintf(T_('The module % is currently being edited by another administrator'), $menu->title)."'); document.location.href='index2.php?option=$option'</script>\n"; 36 exit(0); 37 } 38 39 if ($uid) { 40 $menu->checkout( $my->id ); 41 // get previously selected Categories 42 $params =& new mosParameters( $menu->params ); 43 $catids = $params->def( 'categoryid', '' ); 44 if ( $catids ) { 45 $query = "SELECT c.id AS `value`, c.section AS `id`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" 46 . "\n FROM #__sections AS s" 47 . "\n INNER JOIN #__categories AS c ON c.section = s.id" 48 . "\n WHERE s.scope = 'content'" 49 . "\n AND c.id IN ( ". $catids . ")" 50 . "\n ORDER BY s.name,c.name" 51 ; 52 $database->setQuery( $query ); 53 $lookup = $database->loadObjectList(); 54 } else { 55 $lookup = ''; 56 } 57 } else { 58 $menu->type = 'content_blog_category'; 59 $menu->menutype = $menutype; 60 $menu->ordering = 9999; 61 $menu->parent = intval( mosGetParam( $_POST, 'parent', 0 ) ); 62 $menu->published = 1; 63 $lookup = ''; 64 } 65 66 // build the html select list for category 67 $rows[] = mosHTML::makeOption( '', 'All Categories' ); 68 $query = "SELECT c.id AS `value`, c.section AS `id`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" 69 . "\n FROM #__sections AS s" 70 . "\n INNER JOIN #__categories AS c ON c.section = s.id" 71 . "\n WHERE s.scope = 'content'" 72 . "\n ORDER BY s.name,c.name" 73 ; 74 $database->setQuery( $query ); 75 $rows = array_merge( $rows, $database->loadObjectList() ); 76 $category = mosHTML::selectList( $rows, 'catid[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $lookup ); 77 $lists['categoryid'] = $category; 78 79 // build the html select list for ordering 80 $lists['ordering'] = mosAdminMenus::Ordering( $menu, $uid ); 81 // build the html select list for the group access 82 $lists['access'] = mosAdminMenus::Access( $menu ); 83 // build the html select list for paraent item 84 $lists['parent'] = mosAdminMenus::Parent( $menu ); 85 // build published button option 86 $lists['published'] = mosAdminMenus::Published( $menu ); 87 // build the url link output 88 $lists['link'] = mosAdminMenus::Link( $menu, $uid ); 89 90 // get params definitions 91 $params =& new mosAdminParameters( $menu->params, $mainframe->getPath( 'menu_xml', $menu->type ), 'menu' ); 92 93 /* chipjack: passing $sectCatList (categories) instead of $slist (sections) */ 94 content_blog_category_html::edit( $menu, $lists, $params, $option ); 95 } 96 97 function saveMenu( $option, $task ) { 98 global $database; 99 100 $params = mosGetParam( $_POST, 'params', '' ); 101 $catids = mosGetParam( $_POST, 'catid', array() ); 102 $catid = implode( ',', $catids ); 103 104 $params[categoryid] = $catid; 105 if (is_array( $params )) { 106 $txt = array(); 107 foreach ($params as $k=>$v) { 108 $txt[] = "$k=$v"; 109 } 110 $_POST['params'] = mosParameters::textareaHandling( $txt ); 111 } 112 113 $row = new mosMenu( $database ); 114 115 if (!$row->bind( $_POST )) { 116 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 117 exit(); 118 } 119 120 if (count($catids)==1 && $catids[0]!="") { 121 $row->link = str_replace("id=0","id=".$catids[0],$row->link); 122 $row->componentid = $catids[0]; 123 } 124 125 if (!$row->check()) { 126 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 127 exit(); 128 } 129 if (!$row->store()) { 130 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 131 exit(); 132 } 133 $row->checkin(); 134 $row->updateOrder( "menutype='$row->menutype' AND parent='$row->parent'" ); 135 136 $msg = 'Menu item Saved'; 137 switch ( $task ) { 138 case 'apply': 139 mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype .'&task=edit&id='. $row->id, $msg ); 140 break; 141 142 case 'save': 143 default: 144 mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype, $msg ); 145 break; 146 } 147 } 148 149 } 150 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed May 23 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 |