Changeset 534:1f53e1c7b4c9 for plugins
- Timestamp:
- 07/09/11 09:41:16 (14 years ago)
- Branch:
- themes
- Children:
- 535:66f118a563a5, 538:aedf484a0a44
- Location:
- plugins/simpleMenu
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/simpleMenu/_admin.php
r532 r534 16 16 function simpleMenu_dashboard($core,$icons) 17 17 { 18 $icons['simpleMenu'] = new ArrayObject(array(__(' simpleMenu'),'plugin.php?p=simpleMenu','index.php?pf=simpleMenu/icon.png'));18 $icons['simpleMenu'] = new ArrayObject(array(__('Simple menu'),'plugin.php?p=simpleMenu','index.php?pf=simpleMenu/icon.png')); 19 19 } 20 20 function simpleMenu_dashboard_favs($core,$favs) … … 25 25 } 26 26 27 $_menu['Plugins']->addItem(__(' simpleMenu'),'plugin.php?p=simpleMenu','index.php?pf=simpleMenu/icon-small.png',27 $_menu['Plugins']->addItem(__('Simple menu'),'plugin.php?p=simpleMenu','index.php?pf=simpleMenu/icon-small.png', 28 28 preg_match('/plugin.php\?p=simpleMenu(&.*)?$/',$_SERVER['REQUEST_URI']), 29 29 $core->auth->check('usage,contentadmin',$core->blog->id)); -
plugins/simpleMenu/_define.php
r532 r534 14 14 $this->registerModule( 15 15 /* Name */ "simpleMenu", 16 /* Description*/ "Simple menu barfor DC",16 /* Description*/ "Simple menu for DC", 17 17 /* Author */ "Franck Paul", 18 /* Version */ '0. 1',18 /* Version */ '0.2', 19 19 array( 20 20 'permissions' => 'admin' -
plugins/simpleMenu/_public.php
r532 r534 29 29 { 30 30 $ret = ''; 31 32 $menu = $GLOBALS['core']->blog->settings->system->get('simpleMenu'); 33 $menu = @unserialize($menu); 34 35 if (is_array($menu)) 36 { 37 // Current relative URL 38 $url = $_SERVER['REQUEST_URI']; 39 $abs_url = http::getHost().$url; 31 40 32 # Current relative URL 33 $url = $_SERVER['REQUEST_URI']; 34 $abs_url = http::getHost().$url; 35 36 # For detect if home 37 $home_url = html::stripHostURL($GLOBALS['core']->blog->url); 38 $home_directory = dirname($home_url); 39 if ($home_directory != '/') 40 $home_directory = $home_directory.'/'; 41 42 # $href = lien de l'item de menu 43 $href = 'archive'; 44 $href = html::escapeHTML($href); 41 // Home recognition var 42 $home_url = html::stripHostURL($GLOBALS['core']->blog->url); 43 $home_directory = dirname($home_url); 44 if ($home_directory != '/') 45 $home_directory = $home_directory.'/'; 45 46 46 # Active item test 47 $active = false; 48 if (($url == $href) || 49 ($abs_url == $href) || 50 ($_SERVER['URL_REQUEST_PART'] == $href) || 51 (($_SERVER['URL_REQUEST_PART'] == '') && (($href == $home_url) || ($href == $home_directory)))) { 52 $active = true; 47 // Menu items loop 48 foreach ($menu as $i => $m) { 49 # $href = lien de l'item de menu 50 $href = $m['url']; 51 $href = html::escapeHTML($href); 52 53 # Active item test 54 $active = false; 55 if (($url == $href) || 56 ($abs_url == $href) || 57 ($_SERVER['URL_REQUEST_PART'] == $href) || 58 (($_SERVER['URL_REQUEST_PART'] == '') && (($href == $home_url) || ($href == $home_directory)))) { 59 $active = true; 60 } 61 $ret .= '<li class="li'.$i.($active ? ' active' : '').'">'. 62 '<a href="'.$href.'">'.$m['label'].($m['descr'] ? '<span>'.$m['descr'].'</span>' : '').'</a>'. 63 '</li>'; 64 } 65 66 // Final rendering 67 if ($ret) { 68 $ret = '<ul class="simple-menu'.($class ? ' '.$class : '').'">'."\n".$ret."\n".'</ul>'; 69 } 53 70 } 54 55 $ret = '<p>Archives ? '.($active ? 'Oui' : 'Non').'</p>'; 56 $ret .= '<p>$class ? '.($class ? $class : '').'</p>'; 57 /* 58 $ret .= '<p>'.'$_SERVER[\'REQUEST_URI\']'.' = '.$_SERVER['REQUEST_URI'].'</p>'; 59 $ret .= '<p>'.'$_SERVER[\'URL_REQUEST_PART\']'.' = '.$_SERVER['URL_REQUEST_PART'].'</p>'; 60 $ret .= '<p>'.'$url'.' = '.$url.'</p>'; 61 $ret .= '<p>'.'$abs_url'.' = '.$abs_url.'</p>'; 62 $ret .= '<p>'.'$home_url'.' = '.$home_url.'</p>'; 63 $ret .= '<p>'.'$home_directory'.' = '.$home_directory.'</p>'; 64 $ret .= '<p>'.'$href'.' = '.$href.'</p>'; 65 */ 71 66 72 return $ret; 67 73 } -
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.