Changeset 2566:9bf417837888 for plugins/blogroll/_public.php
- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/blogroll/_public.php
r1179 r2566 27 27 $block='<ul>%s</ul>'; 28 28 $item='<li%2$s>%1$s</li>'; 29 29 30 30 if (isset($attr['category'])) { 31 31 $category = addslashes($attr['category']); 32 32 } 33 33 34 34 if (isset($attr['block'])) { 35 35 $block = addslashes($attr['block']); 36 36 } 37 37 38 38 if (isset($attr['item'])) { 39 39 $item = addslashes($attr['item']); 40 40 } 41 41 42 42 $only_cat = 'null'; 43 43 if (!empty($attr['only_category'])) { 44 44 $only_cat = "'".addslashes($attr['only_category'])."'"; 45 45 } 46 46 47 47 return 48 48 '<?php '. … … 50 50 '?>'; 51 51 } 52 52 53 53 public static function blogrollXbelLink($attr) 54 54 { … … 56 56 return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getURLFor("xbel")').'; ?>'; 57 57 } 58 58 59 59 public static function getList($cat_title='<h3>%s</h3>',$block='<ul>%s</ul>',$item='<li>%s</li>',$category=null) 60 60 { 61 61 $blogroll = new dcBlogroll($GLOBALS['core']->blog); 62 62 63 63 try { 64 64 $links = $blogroll->getLinks(); … … 66 66 return false; 67 67 } 68 68 69 69 $res = ''; 70 70 71 71 $hierarchy = $blogroll->getLinksHierarchy($links); 72 72 73 73 if ($category) { 74 74 if (!isset($hierarchy[$category])) { … … 77 77 $hierarchy = array($hierarchy[$category]); 78 78 } 79 79 80 80 foreach ($hierarchy as $k => $v) 81 81 { … … 83 83 $res .= sprintf($cat_title,html::escapeHTML($k))."\n"; 84 84 } 85 85 86 86 $res .= self::getLinksList($v,$block,$item); 87 87 } 88 88 89 89 return $res; 90 90 } 91 91 92 92 private static function getLinksList($links,$block='<ul>%s</ul>',$item='<li%2$s>%1$s</li>') 93 93 { 94 94 $list = ''; 95 95 96 96 # Find current link item if any 97 97 $current = -1; 98 98 $current_size = 0; 99 99 $self_uri = http::getSelfURI(); 100 100 101 101 foreach ($links as $k => $v) 102 102 { … … 109 109 } 110 110 } 111 111 112 112 foreach ($links as $k => $v) 113 113 { … … 117 117 $lang = $v['link_lang']; 118 118 $xfn = $v['link_xfn']; 119 119 120 120 $link = 121 121 '<a href="'.html::escapeHTML($href).'"'. … … 126 126 html::escapeHTML($title). 127 127 '</a>'; 128 128 129 129 $current_class = $current == $k ? ' class="active"' : ''; 130 130 131 131 $list .= sprintf($item,$link,$current_class)."\n"; 132 132 } 133 133 134 134 return sprintf($block,$list)."\n"; 135 135 } 136 136 137 137 # Widget function 138 138 public static function linksWidget($w) 139 139 { 140 140 global $core; 141 141 142 142 if (($w->homeonly == 1 && $core->url->type != 'default') || 143 143 ($w->homeonly == 2 && $core->url->type == 'default')) { 144 144 return; 145 145 } 146 146 147 147 $links = self::getList('<h3>%s</h3>','<ul>%s</ul>','<li%2$s>%1$s</li>',$w->category); 148 148 149 149 if (empty($links)) { 150 150 return; 151 151 } 152 152 153 153 return 154 154 ($w->content_only ? '' : '<div class="links'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). … … 164 164 { 165 165 $blogroll = new dcBlogroll($GLOBALS['core']->blog); 166 166 167 167 try { 168 168 $links = $blogroll->getLinks(); … … 171 171 return; 172 172 } 173 173 174 174 if ($args) { 175 175 self::p404(); 176 176 return; 177 177 } 178 178 179 179 http::cache($GLOBALS['mod_files'],$GLOBALS['mod_ts']); 180 180 181 181 header('Content-Type: text/xml; charset=UTF-8'); 182 182 183 183 echo 184 184 '<?xml version="1.0" encoding="UTF-8"?>'."\n". … … 188 188 '<xbel version="1.0">'."\n". 189 189 '<title>'.html::escapeHTML($GLOBALS['core']->blog->name)." blogroll</title>\n"; 190 190 191 191 $i = 1; 192 192 foreach ($blogroll->getLinksHierarchy($links) as $cat_title => $links) … … 197 197 "<title>".html::escapeHTML($cat_title)."</title>\n"; 198 198 } 199 199 200 200 foreach ($links as $k => $v) 201 201 { 202 202 $lang = $v['link_lang'] ? ' xml:lang="'.$v['link_lang'].'"' : ''; 203 203 204 204 echo 205 205 '<bookmark href="'.$v['link_href'].'"'.$lang.'>'."\n". 206 206 '<title>'.html::escapeHTML($v['link_title'])."</title>\n"; 207 207 208 208 if ($v['link_desc']) { 209 209 echo '<desc>'.html::escapeHTML($v['link_desc'])."</desc>\n"; 210 210 } 211 211 212 212 if ($v['link_xfn']) { 213 213 echo … … 216 216 "</info>\n"; 217 217 } 218 218 219 219 echo 220 220 "</bookmark>\n"; 221 221 } 222 222 223 223 if ($cat_title != '') { 224 224 echo "</folder>\n"; 225 225 } 226 226 227 227 $i++; 228 228 } 229 229 230 230 echo 231 231 '</xbel>'; 232 232 } 233 233 } 234 ?>
Note: See TracChangeset
for help on using the changeset viewer.