Annotation of /mambo/branches/4.6/administrator/components/com_menus/content_blog_section/content_blog_section.class.php
Parent Directory
|
Revision Log
Revision 297 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | csouza | 297 | * @package Mambo Open Source |
| 4 : | root | 1 | * @subpackage Menus |
| 5 : | csouza | 297 | * @copyright (C) 2005 - 2006 Mambo Foundation Inc. |
| 6 : | root | 1 | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 7 : | csouza | 297 | * |
| 8 : | * Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure | ||
| 9 : | * that Mambo remained free Open Source software owned and managed by the community. | ||
| 10 : | root | 1 | * Mambo is Free Software |
| 11 : | csouza | 297 | */ |
| 12 : | root | 1 | |
| 13 : | /** ensure this file is being included by a parent file */ | ||
| 14 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 15 : | |||
| 16 : | class content_blog_section { | ||
| 17 : | |||
| 18 : | /** | ||
| 19 : | * @param database A database connector object | ||
| 20 : | * @param integer The unique id of the section to edit (0 if new) | ||
| 21 : | */ | ||
| 22 : | function edit( $uid, $menutype, $option ) { | ||
| 23 : | global $database, $my, $mainframe; | ||
| 24 : | global $mosConfig_absolute_path; | ||
| 25 : | |||
| 26 : | $menu = new mosMenu( $database ); | ||
| 27 : | $menu->load( $uid ); | ||
| 28 : | |||
| 29 : | // fail if checked out not by 'me' | ||
| 30 : | if ($menu->checked_out && $menu->checked_out <> $my->id) { | ||
| 31 : | csouza | 165 | 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"; |
| 32 : | root | 1 | exit(0); |
| 33 : | } | ||
| 34 : | |||
| 35 : | if ($uid) { | ||
| 36 : | $menu->checkout( $my->id ); | ||
| 37 : | // get previously selected Categories | ||
| 38 : | $params =& new mosParameters( $menu->params ); | ||
| 39 : | $secids = $params->def( 'sectionid', '' ); | ||
| 40 : | if ( $secids ) { | ||
| 41 : | $query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`" | ||
| 42 : | . "\n FROM #__sections AS s" | ||
| 43 : | . "\n WHERE s.scope = 'content'" | ||
| 44 : | . "\n AND s.id IN ( ". $secids . ")" | ||
| 45 : | . "\n ORDER BY s.name" | ||
| 46 : | ; | ||
| 47 : | $database->setQuery( $query ); | ||
| 48 : | $lookup = $database->loadObjectList(); | ||
| 49 : | } else { | ||
| 50 : | $lookup = ''; | ||
| 51 : | } | ||
| 52 : | } else { | ||
| 53 : | $menu->type = 'content_blog_section'; | ||
| 54 : | $menu->menutype = $menutype; | ||
| 55 : | $menu->ordering = 9999; | ||
| 56 : | $menu->parent = intval( mosGetParam( $_POST, 'parent', 0 ) ); | ||
| 57 : | $menu->published = 1; | ||
| 58 : | $lookup = ''; | ||
| 59 : | } | ||
| 60 : | |||
| 61 : | // build the html select list for section | ||
| 62 : | csouza | 165 | $rows[] = mosHTML::makeOption( '', T_('All Sections') ); |
| 63 : | root | 1 | $query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`" |
| 64 : | . "\n FROM #__sections AS s" | ||
| 65 : | . "\n WHERE s.scope = 'content'" | ||
| 66 : | . "\n ORDER BY s.name" | ||
| 67 : | ; | ||
| 68 : | $database->setQuery( $query ); | ||
| 69 : | $rows = array_merge( $rows, $database->loadObjectList() ); | ||
| 70 : | $section = mosHTML::selectList( $rows, 'secid[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $lookup ); | ||
| 71 : | $lists['sectionid'] = $section; | ||
| 72 : | |||
| 73 : | // build the html select list for ordering | ||
| 74 : | $lists['ordering'] = mosAdminMenus::Ordering( $menu, $uid ); | ||
| 75 : | // build the html select list for the group access | ||
| 76 : | $lists['access'] = mosAdminMenus::Access( $menu ); | ||
| 77 : | // build the html select list for paraent item | ||
| 78 : | $lists['parent'] = mosAdminMenus::Parent( $menu ); | ||
| 79 : | // build published button option | ||
| 80 : | $lists['published'] = mosAdminMenus::Published( $menu ); | ||
| 81 : | // build the url link output | ||
| 82 : | $lists['link'] = mosAdminMenus::Link( $menu, $uid ); | ||
| 83 : | |||
| 84 : | // get params definitions | ||
| 85 : | csouza | 138 | $params =& new mosAdminParameters( $menu->params, $mainframe->getPath( 'menu_xml', $menu->type ), 'menu' ); |
| 86 : | root | 1 | |
| 87 : | content_blog_section_html::edit( $menu, $lists, $params, $option ); | ||
| 88 : | } | ||
| 89 : | |||
| 90 : | function saveMenu( $option, $task ) { | ||
| 91 : | global $database; | ||
| 92 : | |||
| 93 : | $params = mosGetParam( $_POST, 'params', '' ); | ||
| 94 : | $secids = mosGetParam( $_POST, 'secid', array() ); | ||
| 95 : | $secid = implode( ',', $secids ); | ||
| 96 : | |||
| 97 : | $params[sectionid] = $secid; | ||
| 98 : | if (is_array( $params )) { | ||
| 99 : | $txt = array(); | ||
| 100 : | foreach ($params as $k=>$v) { | ||
| 101 : | $txt[] = "$k=$v"; | ||
| 102 : | } | ||
| 103 : | $_POST['params'] = mosParameters::textareaHandling( $txt ); | ||
| 104 : | } | ||
| 105 : | |||
| 106 : | $row = new mosMenu( $database ); | ||
| 107 : | |||
| 108 : | if (!$row->bind( $_POST )) { | ||
| 109 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 110 : | exit(); | ||
| 111 : | } | ||
| 112 : | |||
| 113 : | if ( count( $secids )== 1 && $secids[0] != '' ) { | ||
| 114 : | $row->link = str_replace( 'id=0','id='. $secids[0], $row->link ); | ||
| 115 : | $row->componentid = $secids[0]; | ||
| 116 : | } | ||
| 117 : | |||
| 118 : | if (!$row->check()) { | ||
| 119 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 120 : | exit(); | ||
| 121 : | } | ||
| 122 : | if (!$row->store()) { | ||
| 123 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 124 : | exit(); | ||
| 125 : | } | ||
| 126 : | $row->checkin(); | ||
| 127 : | $row->updateOrder( "menutype='$row->menutype' AND parent='$row->parent'" ); | ||
| 128 : | |||
| 129 : | $msg = 'Menu item Saved'; | ||
| 130 : | switch ( $task ) { | ||
| 131 : | case 'apply': | ||
| 132 : | mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype .'&task=edit&id='. $row->id, $msg ); | ||
| 133 : | break; | ||
| 134 : | |||
| 135 : | case 'save': | ||
| 136 : | default: | ||
| 137 : | mosRedirect( 'index2.php?option='. $option .'&menutype='. $row->menutype, $msg ); | ||
| 138 : | break; | ||
| 139 : | } | ||
| 140 : | } | ||
| 141 : | |||
| 142 : | } | ||
| 143 : | csouza | 138 | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

