Changeset 534:1f53e1c7b4c9 for plugins/simpleMenu/index.php
- Timestamp:
- 07/09/11 09:41:16 (14 years ago)
- Branch:
- themes
- Children:
- 535:66f118a563a5, 538:aedf484a0a44
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/simpleMenu/index.php
r533 r534 19 19 $p_url = 'plugin.php?p=simpleMenu'; 20 20 21 # Récupération paramètres postés22 $item_type = isset($_POST['item_type']) ? $_POST['item_type'] : '';23 $item_select = isset($_POST['item_select']) ? $_POST['item_select'] : '';24 25 21 # Liste des catégories 26 22 $categories_combo = array(); … … 115 111 } 116 112 113 # Menu par défaut 114 $blog_url = html::stripHostURL($core->blog->url); 115 $menu_default = array( 116 array('label' => __('Home'), 'descr' => __('Recent posts'), 'url' => $blog_url), 117 array('label' => __('Archives'), 'descr' => __('Old posts'), 'url' => $blog_url.$core->url->getBase('archive')) 118 ); 119 120 # Lecture menu existant 121 $menu = $core->blog->settings->system->get('simpleMenu'); 122 $menu = @unserialize($menu); 123 if (!is_array($menu)) { 124 $menu = $menu_default; 125 $core->blog->settings->system->put('simpleMenu',serialize($menu)); 126 } 127 128 # Récupération paramètres postés 129 $item_type = isset($_POST['item_type']) ? $_POST['item_type'] : ''; 130 $item_select = isset($_POST['item_select']) ? $_POST['item_select'] : ''; 131 117 132 # Traitement 118 133 $step = (!empty($_GET['add']) ? (integer) $_GET['add'] : 0); … … 125 140 switch ($step) { 126 141 case 1: 142 // First step, menu item type to be selected 127 143 $item_type = $item_select = ''; 128 144 break; 129 145 case 2: 130 146 if ($items[$item_type][1] > 0) { 147 // Second step (optional), menu item sub-type to be selected 131 148 $item_select = ''; 132 149 break; 133 150 } 134 151 case 3: 152 // Third step, menu item attributes to be changed or completed if necessary 135 153 $item_select_label = ''; 136 154 $item_label = __('Title'); 137 155 $item_descr = __('Description'); 138 $item_url = html::stripHostURL($core->blog->url);156 $item_url = $blog_url; 139 157 switch ($item_type) { 140 158 case 'home': … … 188 206 } 189 207 break; 208 case 4: 209 // Fourth step, menu item to be added 210 try { 211 if ($item_label && $item_url) 212 { 213 // Add new item menu in menu array 214 $menu[] = array( 215 'label' => $item_label, 216 'descr' => $item_descr, 217 'url' => $item_url 218 ); 219 // Save menu in blog settings 220 $core->blog->settings->system->put('simpleMenu',serialize($menu)); 221 222 // All done successfully, return to menu items list 223 http::redirect($p_url.'&added=1'); 224 } else { 225 throw new Exception(__('Label and URL of menu item are mandatory.')); 226 } 227 } 228 catch (Exception $e) { 229 $core->error->add($e->getMessage()); 230 } 231 break; 190 232 } 191 233 } … … 202 244 203 245 <?php 246 247 if (!empty($_GET['added'])) { 248 echo '<p class="message">'.__('Menu item has been successfully added.').'</p>'; 249 } 250 if (!empty($_GET['removed'])) { 251 echo '<p class="message">'.__('Menu items have been successfully removed.').'</p>'; 252 } 253 if (!empty($_GET['neworder'])) { 254 echo '<p class="message">'.__('Menu items have been successfully updated.').'</p>'; 255 } 204 256 205 257 if ($step)
Note: See TracChangeset
for help on using the changeset viewer.