Changeset 3730:5c45a5df9a59 for plugins/breadcrumb
- Timestamp:
- 03/08/18 17:58:39 (8 years ago)
- Branch:
- default
- Location:
- plugins/breadcrumb
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/breadcrumb/_admin.php
r3333 r3730 11 11 # -- END LICENSE BLOCK ------------------------------------ 12 12 13 if (!defined('DC_CONTEXT_ADMIN')) { return;}13 if (!defined('DC_CONTEXT_ADMIN')) {return;} 14 14 15 15 // dead but useful code, in order to have translations 16 __('Breadcrumb') .__('Breadcrumb for Dotclear');16 __('Breadcrumb') . __('Breadcrumb for Dotclear'); 17 17 18 $core->addBehavior('adminBlogPreferencesForm', array('breadcrumbBehaviors','adminBlogPreferencesForm'));19 $core->addBehavior('adminBeforeBlogSettingsUpdate', array('breadcrumbBehaviors','adminBeforeBlogSettingsUpdate'));18 $core->addBehavior('adminBlogPreferencesForm', array('breadcrumbBehaviors', 'adminBlogPreferencesForm')); 19 $core->addBehavior('adminBeforeBlogSettingsUpdate', array('breadcrumbBehaviors', 'adminBeforeBlogSettingsUpdate')); 20 20 21 21 class breadcrumbBehaviors 22 22 { 23 public static function adminBlogPreferencesForm($core,$settings)24 25 26 27 '<div class="fieldset"><h4 id="breadcrumb_params">'.__('Breadcrumb').'</h4>'.28 '<p><label class="classic">'.29 form::checkbox('breadcrumb_enabled','1',$settings->breadcrumb->breadcrumb_enabled).30 __('Enable breadcrumb for this blog').'</label></p>'.31 '<p class="form-note">'.__('The {{tpl:Breadcrumb [separator=" &rsaquo; "]}} tag should be present (or inserted if not) in the template.').'</p>'.32 form::checkbox('breadcrumb_alone','1',$settings->breadcrumb->breadcrumb_alone).33 __('Do not encapsulate breadcrumb in a <p id="breadcrumb">...</p> tag.').'</label></p>'.34 35 23 public static function adminBlogPreferencesForm($core, $settings) 24 { 25 $settings->addNameSpace('breadcrumb'); 26 echo 27 '<div class="fieldset"><h4 id="breadcrumb_params">' . __('Breadcrumb') . '</h4>' . 28 '<p><label class="classic">' . 29 form::checkbox('breadcrumb_enabled', '1', $settings->breadcrumb->breadcrumb_enabled) . 30 __('Enable breadcrumb for this blog') . '</label></p>' . 31 '<p class="form-note">' . __('The {{tpl:Breadcrumb [separator=" &rsaquo; "]}} tag should be present (or inserted if not) in the template.') . '</p>' . 32 form::checkbox('breadcrumb_alone', '1', $settings->breadcrumb->breadcrumb_alone) . 33 __('Do not encapsulate breadcrumb in a <p id="breadcrumb">...</p> tag.') . '</label></p>' . 34 '</div>'; 35 } 36 36 37 38 39 40 $settings->breadcrumb->put('breadcrumb_enabled',!empty($_POST['breadcrumb_enabled']),'boolean');41 $settings->breadcrumb->put('breadcrumb_alone',!empty($_POST['breadcrumb_alone']),'boolean');42 37 public static function adminBeforeBlogSettingsUpdate($settings) 38 { 39 $settings->addNameSpace('breadcrumb'); 40 $settings->breadcrumb->put('breadcrumb_enabled', !empty($_POST['breadcrumb_enabled']), 'boolean'); 41 $settings->breadcrumb->put('breadcrumb_alone', !empty($_POST['breadcrumb_alone']), 'boolean'); 42 } 43 43 } -
plugins/breadcrumb/_define.php
r3333 r3730 11 11 # -- END LICENSE BLOCK ------------------------------------ 12 12 13 if (!defined('DC_RC_PATH')) { return;}13 if (!defined('DC_RC_PATH')) {return;} 14 14 15 15 $this->registerModule( 16 /* Name */ "Breadcrumb", 17 /* Description*/ "Breadcrumb for Dotclear", 18 /* Author */ "Franck Paul", 19 /* Version */ '0.7', 20 21 /* Permissions */ 'permissions' => 'usage,contentadmin', 22 /* Type */ 'type' => 'plugin', 23 'settings' =>array(24 25 26 16 "Breadcrumb", // Name 17 "Breadcrumb for Dotclear", // Description 18 "Franck Paul", // Author 19 '0.7', // Version 20 array( 21 'permissions' => 'usage,contentadmin', // Permissions 22 'type' => 'plugin', // Type 23 'settings' => array( 24 'blog' => '#params.breadcrumb_params' 25 ) 26 ) 27 27 ); -
plugins/breadcrumb/_public.php
r3541 r3730 11 11 # -- END LICENSE BLOCK ------------------------------------ 12 12 13 if (!defined('DC_RC_PATH')) { return;}13 if (!defined('DC_RC_PATH')) {return;} 14 14 15 15 # Breadcrumb template functions 16 $core->tpl->addValue('Breadcrumb', array('tplBreadcrumb','breadcrumb'));16 $core->tpl->addValue('Breadcrumb', array('tplBreadcrumb', 'breadcrumb')); 17 17 18 18 class tplBreadcrumb 19 19 { 20 21 22 23 20 # Template function 21 public static function breadcrumb($attr) 22 { 23 $separator = isset($attr['separator']) ? $attr['separator'] : ''; 24 24 25 return '<?php echo tplBreadcrumb::displayBreadcrumb('.26 "'".addslashes($separator)."'".27 28 25 return '<?php echo tplBreadcrumb::displayBreadcrumb(' . 26 "'" . addslashes($separator) . "'" . 27 '); ?>'; 28 } 29 29 30 31 32 global $core,$_ctx;30 public static function displayBreadcrumb($separator) 31 { 32 global $core, $_ctx; 33 33 34 34 $ret = ''; 35 35 36 37 38 39 40 36 # Check if breadcrumb enabled for the current blog 37 $core->blog->settings->addNameSpace('breadcrumb'); 38 if (!$core->blog->settings->breadcrumb->breadcrumb_enabled) { 39 return $ret; 40 } 41 41 42 if ($separator == '') $separator = ' › '; 42 if ($separator == '') { 43 $separator = ' › '; 44 } 43 45 44 45 46 // Get current page if set 47 $page = isset($GLOBALS['_page_number']) ? (integer) $GLOBALS['_page_number'] : 0; 46 48 47 49 switch ($core->url->type) { 48 50 49 50 51 $ret = '<span id="bc-home">'.__('Home').'</span>';52 51 case 'default': 52 // Home (first page only) 53 $ret = '<span id="bc-home">' . __('Home') . '</span>'; 54 break; 53 55 54 55 56 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>';57 $ret .= $separator.sprintf(__('page %d'),$page);58 56 case 'default-page': 57 // Home`(page 2 to n) 58 $ret = '<a id="bc-home" href="' . $core->blog->url . '">' . __('Home') . '</a>'; 59 $ret .= $separator . sprintf(__('page %d'), $page); 60 break; 59 61 60 61 62 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>';63 64 65 $ret .= $separator.'<a href="'.$core->blog->url.$core->url->getURLFor('category',$categories->cat_url).'">'.$categories->cat_title.'</a>';66 67 68 $ret .= $separator.$_ctx->categories->cat_title;69 70 $ret .= $separator.'<a href="'.$core->blog->url.$core->url->getURLFor('category',$_ctx->categories->cat_url).'">'.$_ctx->categories->cat_title.'</a>';71 $ret .= $separator.sprintf(__('page %d'),$page);72 73 62 case 'category': 63 // Category 64 $ret = '<a id="bc-home" href="' . $core->blog->url . '">' . __('Home') . '</a>'; 65 $categories = $core->blog->getCategoryParents($_ctx->categories->cat_id); 66 while ($categories->fetch()) { 67 $ret .= $separator . '<a href="' . $core->blog->url . $core->url->getURLFor('category', $categories->cat_url) . '">' . $categories->cat_title . '</a>'; 68 } 69 if ($page == 0) { 70 $ret .= $separator . $_ctx->categories->cat_title; 71 } else { 72 $ret .= $separator . '<a href="' . $core->blog->url . $core->url->getURLFor('category', $_ctx->categories->cat_url) . '">' . $_ctx->categories->cat_title . '</a>'; 73 $ret .= $separator . sprintf(__('page %d'), $page); 74 } 75 break; 74 76 75 76 77 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>';78 79 80 81 82 $ret .= $separator.'<a href="'.$core->blog->url.$core->url->getURLFor('category',$categories->cat_url).'">'.$categories->cat_title.'</a>';83 84 85 86 $ret .= $separator.'<a href="'.$core->blog->url.$core->url->getURLFor('category',$categories->cat_url).'">'.$categories->cat_title.'</a>';87 88 $ret .= $separator.$_ctx->posts->post_title;89 77 case 'post': 78 // Post 79 $ret = '<a id="bc-home" href="' . $core->blog->url . '">' . __('Home') . '</a>'; 80 if ($_ctx->posts->cat_id) { 81 // Parents cats of post's cat 82 $categories = $core->blog->getCategoryParents($_ctx->posts->cat_id); 83 while ($categories->fetch()) { 84 $ret .= $separator . '<a href="' . $core->blog->url . $core->url->getURLFor('category', $categories->cat_url) . '">' . $categories->cat_title . '</a>'; 85 } 86 // Post's cat 87 $categories = $core->blog->getCategory($_ctx->posts->cat_id); 88 $ret .= $separator . '<a href="' . $core->blog->url . $core->url->getURLFor('category', $categories->cat_url) . '">' . $categories->cat_title . '</a>'; 89 } 90 $ret .= $separator . $_ctx->posts->post_title; 91 break; 90 92 91 92 93 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>';94 95 $ret .= $separator.(isset($langs[$_ctx->cur_lang]) ? $langs[$_ctx->cur_lang] : $_ctx->cur_lang);96 93 case 'lang': 94 // Lang 95 $ret = '<a id="bc-home" href="' . $core->blog->url . '">' . __('Home') . '</a>'; 96 $langs = l10n::getISOCodes(); 97 $ret .= $separator . (isset($langs[$_ctx->cur_lang]) ? $langs[$_ctx->cur_lang] : $_ctx->cur_lang); 98 break; 97 99 98 99 100 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>';101 102 103 $ret .= $separator.__('Archives');104 105 106 $ret .= $separator.'<a href="'.$core->blog->url.$core->url->getURLFor("archive").'">'.__('Archives').'</a>';107 $ret .= $separator.dt::dt2str('%B %Y',$_ctx->archives->dt);108 109 100 case 'archive': 101 // Archives 102 $ret = '<a id="bc-home" href="' . $core->blog->url . '">' . __('Home') . '</a>'; 103 if (!$_ctx->archives) { 104 // Global archives 105 $ret .= $separator . __('Archives'); 106 } else { 107 // Month archive 108 $ret .= $separator . '<a href="' . $core->blog->url . $core->url->getURLFor("archive") . '">' . __('Archives') . '</a>'; 109 $ret .= $separator . dt::dt2str('%B %Y', $_ctx->archives->dt); 110 } 111 break; 110 112 111 112 113 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>';114 $ret .= $separator.$_ctx->posts->post_title;115 113 case 'pages': 114 // Page 115 $ret = '<a id="bc-home" href="' . $core->blog->url . '">' . __('Home') . '</a>'; 116 $ret .= $separator . $_ctx->posts->post_title; 117 break; 116 118 117 118 119 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>';120 $ret .= $separator.__('All tags');121 119 case 'tags': 120 // All tags 121 $ret = '<a id="bc-home" href="' . $core->blog->url . '">' . __('Home') . '</a>'; 122 $ret .= $separator . __('All tags'); 123 break; 122 124 123 124 125 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>';126 $ret .= $separator.'<a href="'.$core->blog->url.$core->url->getURLFor("tags").'">'.__('All tags').'</a>';127 128 $ret .= $separator.$_ctx->meta->meta_id;129 130 $ret .= $separator.'<a href="'.$core->blog->url.$core->url->getURLFor("tag",rawurlencode($_ctx->meta->meta_id)).'">'.$_ctx->meta->meta_id.'</a>';131 $ret .= $separator.sprintf(__('page %d'),$page);132 133 125 case 'tag': 126 // Tag 127 $ret = '<a id="bc-home" href="' . $core->blog->url . '">' . __('Home') . '</a>'; 128 $ret .= $separator . '<a href="' . $core->blog->url . $core->url->getURLFor("tags") . '">' . __('All tags') . '</a>'; 129 if ($page == 0) { 130 $ret .= $separator . $_ctx->meta->meta_id; 131 } else { 132 $ret .= $separator . '<a href="' . $core->blog->url . $core->url->getURLFor("tag", rawurlencode($_ctx->meta->meta_id)) . '">' . $_ctx->meta->meta_id . '</a>'; 133 $ret .= $separator . sprintf(__('page %d'), $page); 134 } 135 break; 134 136 135 136 137 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>';138 139 $ret .= $separator.__('Search:').' '.$GLOBALS['_search'];140 141 $ret .= $separator.'<a href="'.$core->blog->url.'?q='.rawurlencode($GLOBALS['_search']).'">'.__('Search:').' '.$GLOBALS['_search'].'</a>';142 $ret .= $separator.sprintf(__('page %d'),$page);143 144 137 case 'search': 138 // Search 139 $ret = '<a id="bc-home" href="' . $core->blog->url . '">' . __('Home') . '</a>'; 140 if ($page == 0) { 141 $ret .= $separator . __('Search:') . ' ' . $GLOBALS['_search']; 142 } else { 143 $ret .= $separator . '<a href="' . $core->blog->url . '?q=' . rawurlencode($GLOBALS['_search']) . '">' . __('Search:') . ' ' . $GLOBALS['_search'] . '</a>'; 144 $ret .= $separator . sprintf(__('page %d'), $page); 145 } 146 break; 145 147 146 147 148 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>';149 $ret .= $separator.__('404');150 148 case '404': 149 // 404 150 $ret = '<a id="bc-home" href="' . $core->blog->url . '">' . __('Home') . '</a>'; 151 $ret .= $separator . __('404'); 152 break; 151 153 152 153 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>';154 155 156 $special = $core->callBehavior('publicBreadcrumb',$core->url->type,$separator);157 158 $ret .= $separator.$special;159 160 161 154 default: 155 $ret = '<a id="bc-home" href="' . $core->blog->url . '">' . __('Home') . '</a>'; 156 # --BEHAVIOR-- publicBreadcrumb 157 # Should specific breadcrumb if any, will be added after home page url 158 $special = $core->callBehavior('publicBreadcrumb', $core->url->type, $separator); 159 if ($special) { 160 $ret .= $separator . $special; 161 } 162 break; 163 } 162 164 163 164 165 $ret = '<p id="breadcrumb">'.$ret.'</p>';166 165 # Encapsulate breadcrumb in <p>…</p> 166 if (!$core->blog->settings->breadcrumb->breadcrumb_alone) { 167 $ret = '<p id="breadcrumb">' . $ret . '</p>'; 168 } 167 169 168 169 170 return $ret; 171 } 170 172 }
Note: See TracChangeset
for help on using the changeset viewer.