Dotclear


Ignore:
Timestamp:
11/16/13 19:33:23 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
2.6
Message:

Add blog URL before relative lang URL in lang widget, fixes #1871

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/widgets/_widgets_functions.php

    r2198 r2565  
    1010# 
    1111# -- END LICENSE BLOCK ----------------------------------------- 
     12 
    1213if (!defined('DC_RC_PATH')) { return; } 
    1314 
     
    1718     { 
    1819          global $core; 
    19            
     20 
    2021          if (($w->homeonly == 1 && $core->url->type != 'default') || 
    2122               ($w->homeonly == 2 && $core->url->type == 'default')) { 
     
    2425 
    2526          $value = isset($GLOBALS['_search']) ? html::escapeHTML($GLOBALS['_search']) : ''; 
    26            
     27 
    2728          return 
    2829          ($w->content_only ? '' : '<div id="search"'.($w->class ? ' class="'.html::escapeHTML($w->class).'"' : '').'>'). 
     
    3637          ($w->content_only ? '' : '</div>'); 
    3738     } 
    38       
     39 
    3940     public static function navigation($w) 
    4041     { 
    4142          global $core; 
    42            
     43 
    4344          if (($w->homeonly == 1 && $core->url->type != 'default') || 
    4445               ($w->homeonly == 2 && $core->url->type == 'default')) { 
     
    5051          ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 
    5152          '<ul>'; 
    52            
     53 
    5354          if ($core->url->type != 'default') { 
    5455               $res .= 
     
    5758               '<span> - </span></li>'; 
    5859          } 
    59            
     60 
    6061          $res .= 
    6162          '<li class="topnav-arch">'. 
     
    6465          '</ul>'. 
    6566          ($w->content_only ? '' : '</div>'); 
    66            
    67           return $res; 
    68      } 
    69       
     67 
     68          return $res; 
     69     } 
     70 
    7071     public static function categories($w) 
    7172     { 
    7273          global $core, $_ctx; 
    73            
     74 
    7475          if (($w->homeonly == 1 && $core->url->type != 'default') || 
    7576               ($w->homeonly == 2 && $core->url->type == 'default')) { 
     
    8182               return; 
    8283          } 
    83            
     84 
    8485          $res = 
    8586          ($w->content_only ? '' : '<div class="categories'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 
    8687          ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''); 
    87            
     88 
    8889          $ref_level = $level = $rs->level-1; 
    8990          while ($rs->fetch()) 
     
    9495                    $class = ' class="category-current"'; 
    9596               } 
    96                 
     97 
    9798               if ($rs->level > $level) { 
    9899                    $res .= str_repeat('<ul><li'.$class.'>',$rs->level - $level); 
     
    100101                    $res .= str_repeat('</li></ul>',-($rs->level - $level)); 
    101102               } 
    102                 
     103 
    103104               if ($rs->level <= $level) { 
    104105                    $res .= '</li><li'.$class.'>'; 
    105106               } 
    106                 
     107 
    107108               $res .= 
    108109               '<a href="'.$core->blog->url.$core->url->getURLFor('category', $rs->cat_url).'">'. 
    109110               html::escapeHTML($rs->cat_title).'</a>'. 
    110111               ($w->postcount ? ' <span>('.($w->subcatscount ? $rs->nb_total : $rs->nb_post).')</span>' : ''); 
    111                 
    112                 
     112 
     113 
    113114               $level = $rs->level; 
    114115          } 
    115            
     116 
    116117          if ($ref_level - $level < 0) { 
    117118               $res .= str_repeat('</li></ul>',-($ref_level - $level)); 
    118119          } 
    119120          $res .= ($w->content_only ? '' : '</div>'); 
    120            
    121           return $res; 
    122      } 
    123       
     121 
     122          return $res; 
     123     } 
     124 
    124125     public static function bestof($w) 
    125126     { 
    126127          global $core; 
    127            
    128           if (($w->homeonly == 1 && $core->url->type != 'default') || 
    129                ($w->homeonly == 2 && $core->url->type == 'default')) { 
    130                return; 
    131           } 
    132            
     128 
     129          if (($w->homeonly == 1 && $core->url->type != 'default') || 
     130               ($w->homeonly == 2 && $core->url->type == 'default')) { 
     131               return; 
     132          } 
     133 
    133134          $params = array( 
    134135               'post_selected'     => true, 
     
    136137               'order'             => 'post_dt '.strtoupper($w->orderby) 
    137138          ); 
    138            
     139 
    139140          $rs = $core->blog->getPosts($params); 
    140            
     141 
    141142          if ($rs->isEmpty()) { 
    142143               return; 
    143144          } 
    144            
     145 
    145146          $res = 
    146147          ($w->content_only ? '' : '<div class="selected'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 
    147148          ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 
    148149          '<ul>'; 
    149            
     150 
    150151          while ($rs->fetch()) { 
    151152               $res .= ' <li><a href="'.$rs->getURL().'">'.html::escapeHTML($rs->post_title).'</a></li> '; 
    152153          } 
    153            
    154           $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
    155            
    156           return $res; 
    157      } 
    158       
     154 
     155          $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
     156 
     157          return $res; 
     158     } 
     159 
    159160     public static function langs($w) 
    160161     { 
    161162          global $core, $_ctx; 
    162            
     163 
    163164          if (($w->homeonly == 1 && $core->url->type != 'default' && $core->url->type != 'lang') || 
    164165               ($w->homeonly == 2 && ($core->url->type == 'default' || $core->url->type == 'lang'))) { 
    165166               return; 
    166167          } 
    167            
     168 
    168169          $rs = $core->blog->getLangs(); 
    169            
     170 
    170171          if ($rs->count() <= 1) { 
    171172               return; 
    172173          } 
    173            
     174 
    174175          $langs = l10n::getISOcodes(); 
    175176          $res = 
     
    177178          ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 
    178179          '<ul>'; 
    179            
     180 
    180181          while ($rs->fetch()) 
    181182          { 
    182183               $l = ($_ctx->cur_lang == $rs->post_lang) ? '<strong>%s</strong>' : '%s'; 
    183                 
     184 
    184185               $lang_name = isset($langs[$rs->post_lang]) ? $langs[$rs->post_lang] : $rs->post_lang; 
    185                 
     186 
    186187               $res .= 
    187188               ' <li>'. 
    188189               sprintf($l, 
    189                     '<a href="'.$core->url->getURLFor('lang',$rs->post_lang).'" '. 
     190                    '<a href="'.$core->blog->url.$core->url->getURLFor('lang',$rs->post_lang).'" '. 
    190191                    'class="lang-'.$rs->post_lang.'">'. 
    191192                    $lang_name.'</a>'). 
    192193               ' </li>'; 
    193194          } 
    194            
    195           $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
    196            
    197           return $res; 
    198      } 
    199       
     195 
     196          $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
     197 
     198          return $res; 
     199     } 
     200 
    200201     public static function subscribe($w) 
    201202     { 
    202203          global $core; 
    203            
    204           if (($w->homeonly == 1 && $core->url->type != 'default') || 
    205                ($w->homeonly == 2 && $core->url->type == 'default')) { 
    206                return; 
    207           } 
    208            
     204 
     205          if (($w->homeonly == 1 && $core->url->type != 'default') || 
     206               ($w->homeonly == 2 && $core->url->type == 'default')) { 
     207               return; 
     208          } 
     209 
    209210          $type = ($w->type == 'atom' || $w->type == 'rss2') ? $w->type : 'rss2'; 
    210211          $mime = $type == 'rss2' ? 'application/rss+xml' : 'application/atom+xml'; 
    211            
     212 
    212213          $p_title = __('This blog\'s entries %s feed'); 
    213214          $c_title = __('This blog\'s comments %s feed'); 
    214            
     215 
    215216          $res = 
    216217          ($w->content_only ? '' : '<div class="syndicate'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 
    217218          ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 
    218219          '<ul>'; 
    219            
     220 
    220221          $res .= 
    221222          '<li><a type="'.$mime.'" '. 
     
    223224          'title="'.sprintf($p_title,($type == 'atom' ? 'Atom' : 'RSS')).'" class="feed">'. 
    224225          __('Entries feed').'</a></li>'; 
    225            
     226 
    226227          if ($core->blog->settings->system->allow_comments || $core->blog->settings->system->allow_trackbacks) 
    227228          { 
     
    232233               __('Comments feed').'</a></li>'; 
    233234          } 
    234            
    235           $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
    236            
    237           return $res; 
    238      } 
    239       
     235 
     236          $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
     237 
     238          return $res; 
     239     } 
     240 
    240241     public static function feed($w) 
    241242     { 
     
    243244               return; 
    244245          } 
    245            
    246           global $core; 
    247            
    248           if (($w->homeonly == 1 && $core->url->type != 'default') || 
    249                ($w->homeonly == 2 && $core->url->type == 'default')) { 
    250                return; 
    251           } 
    252            
     246 
     247          global $core; 
     248 
     249          if (($w->homeonly == 1 && $core->url->type != 'default') || 
     250               ($w->homeonly == 2 && $core->url->type == 'default')) { 
     251               return; 
     252          } 
     253 
    253254          $limit = abs((integer) $w->limit); 
    254            
     255 
    255256          try { 
    256257               $feed = feedReader::quickParse($w->url,DC_TPL_CACHE); 
     
    261262               return; 
    262263          } 
    263            
     264 
    264265          $res = 
    265266          ($w->content_only ? '' : '<div class="feed'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 
    266267          ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 
    267268          '<ul>'; 
    268            
     269 
    269270          $i = 0; 
    270271          foreach ($feed->items as $item) { 
    271272               $title = isset($item->title) && strlen(trim($item->title)) ? $item->title : ''; 
    272273               $link = isset($item->link) && strlen(trim($item->link)) ? $item->link : ''; 
    273                 
     274 
    274275               if (!$link && !$title) { 
    275276                    continue; 
    276277               } 
    277                 
     278 
    278279               if (!$title) { 
    279280                    $title = substr($link,0,25).'...'; 
    280281               } 
    281                 
     282 
    282283               $li = $link ? '<a href="'.html::escapeHTML($item->link).'">'.$title.'</a>' : $title; 
    283284               $res .= ' <li>'.$li.'</li> '; 
     
    287288               } 
    288289          } 
    289            
    290           $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
    291            
    292           return $res; 
    293      } 
    294       
     290 
     291          $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
     292 
     293          return $res; 
     294     } 
     295 
    295296     public static function text($w) 
    296297     { 
    297298          global $core; 
    298            
    299           if (($w->homeonly == 1 && $core->url->type != 'default') || 
    300                ($w->homeonly == 2 && $core->url->type == 'default')) { 
    301                return; 
    302           } 
    303            
     299 
     300          if (($w->homeonly == 1 && $core->url->type != 'default') || 
     301               ($w->homeonly == 2 && $core->url->type == 'default')) { 
     302               return; 
     303          } 
     304 
    304305          $res = 
    305306          ($w->content_only ? '' : '<div class="text'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 
     
    307308          $w->text. 
    308309          ($w->content_only ? '' : '</div>'); 
    309            
    310           return $res; 
    311      } 
    312       
     310 
     311          return $res; 
     312     } 
     313 
    313314     public static function lastposts($w) 
    314315     { 
    315316          global $core; 
    316            
    317           if (($w->homeonly == 1 && $core->url->type != 'default') || 
    318                ($w->homeonly == 2 && $core->url->type == 'default')) { 
    319                return; 
    320           } 
    321            
     317 
     318          if (($w->homeonly == 1 && $core->url->type != 'default') || 
     319               ($w->homeonly == 2 && $core->url->type == 'default')) { 
     320               return; 
     321          } 
     322 
    322323          $params['limit'] = abs((integer) $w->limit); 
    323324          $params['order'] = 'post_dt desc'; 
    324325          $params['no_content'] = true; 
    325            
     326 
    326327          if ($w->category) 
    327328          { 
     
    334335               } 
    335336          } 
    336            
     337 
    337338          if ($w->tag) 
    338339          { 
     
    344345               $rs = $core->blog->getPosts($params); 
    345346          } 
    346            
     347 
    347348          if ($rs->isEmpty()) { 
    348349               return; 
    349350          } 
    350            
     351 
    351352          $res = 
    352353          ($w->content_only ? '' : '<div class="lastposts'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 
    353354          ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 
    354355          '<ul>'; 
    355            
     356 
    356357          while ($rs->fetch()) { 
    357358               $res .= '<li><a href="'.$rs->getURL().'">'. 
    358359               html::escapeHTML($rs->post_title).'</a></li>'; 
    359360          } 
    360            
    361           $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
    362            
    363           return $res; 
    364      } 
    365       
     361 
     362          $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
     363 
     364          return $res; 
     365     } 
     366 
    366367     public static function lastcomments($w) 
    367368     { 
    368369          global $core; 
    369            
    370           if (($w->homeonly == 1 && $core->url->type != 'default') || 
    371                ($w->homeonly == 2 && $core->url->type == 'default')) { 
    372                return; 
    373           } 
    374            
     370 
     371          if (($w->homeonly == 1 && $core->url->type != 'default') || 
     372               ($w->homeonly == 2 && $core->url->type == 'default')) { 
     373               return; 
     374          } 
     375 
    375376          $params['limit'] = abs((integer) $w->limit); 
    376377          $params['order'] = 'comment_dt desc'; 
    377378          $rs = $core->blog->getComments($params); 
    378            
     379 
    379380          if ($rs->isEmpty()) { 
    380381               return; 
    381382          } 
    382            
     383 
    383384          $res = ($w->content_only ? '' : '<div class="lastcomments'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 
    384385          ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 
    385386          '<ul>'; 
    386            
     387 
    387388          while ($rs->fetch()) 
    388389          { 
     
    394395               '</a></li>'; 
    395396          } 
    396            
    397           $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
    398            
     397 
     398          $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
     399 
    399400          return $res; 
    400401     } 
    401402} 
    402 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map