b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (0.9.x) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Source for file _functions_template.php

Documentation is available at _functions_template.php

  1. <?php
  2. /**
  3.  * Misc Functions to be called from the template
  4.  *
  5.  * b2evolution - {@link http://b2evolution.net/}
  6.  * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  7.  * @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
  8.  *
  9.  * @package evocore
  10.  * @author This file built upon code from original b2 - http://cafelog.com/
  11.  */
  12. if!defined('DB_USER') ) die'Please, do not access this page directly.' );
  13.  
  14. /**
  15.  * Includes:
  16.  */
  17. require_oncedirname(__FILE__).'/_functions_cats.php' );
  18. require_oncedirname(__FILE__).'/_functions_blogs.php' );
  19. require_oncedirname(__FILE__).'/_functions_bposts.php' );
  20. require_oncedirname(__FILE__).'/_functions_comments.php' );
  21. require_oncedirname(__FILE__).'/_functions_trackback.php' );
  22. require_oncedirname(__FILE__).'/_functions_pingback.php' );
  23.  
  24.  
  25. /**
  26.  * Template function: output base URL to b2evo's image folder
  27.  *
  28.  * {@internal imgbase(-)}}
  29.  */
  30. function imgbase()
  31. {
  32.     global $img_url;
  33.     echo $img_url'/';
  34. }
  35.  
  36. /**
  37.  * single_month_title(-)
  38.  *
  39.  * fplanque: 0.8.3: changed defaults
  40.  *
  41.  * @todo Respect locales datefmt
  42.  *
  43.  * @param string prefix to display, default is 'Archives for: '
  44.  * @param string format to output, default 'htmlbody'
  45.  * @param boolean show the year as link to year's archive (in monthly mode)
  46.  */
  47. function single_month_title$prefix '#'$display 'htmlbody'$linktoyeararchive true$blogurl ''$params '' )
  48. {
  49.     global $m$w$month;
  50.  
  51.     if$prefix == '#' $prefix ' '.T_('Archives for').': ';
  52.  
  53.     if!empty($m&& $display )
  54.     {
  55.         $my_year substr($m,0,4);
  56.         ifstrlen($m)
  57.             $my_month T_($month[substr($m,4,2)]);
  58.         else
  59.             $my_month '';
  60.         $my_day substr($m,6,2);
  61.  
  62.         if$display == 'htmlbody' && !empty$my_month && $linktoyeararchive )
  63.         // display year as link to year's archive
  64.             $my_year '<a href="' archive_link$my_year''''''false$blogurl$params '">' $my_year '</a>';
  65.         }
  66.  
  67.  
  68.         $title $prefix.$my_month.' '.$my_year;
  69.  
  70.         if!empty$my_day ) )
  71.         {    // We also want to display a day
  72.             $title .= "$my_day";
  73.         }
  74.  
  75.         if!empty($w&& ($w>=0) ) // Note: week # can be 0
  76.         {    // We also want to display a week number
  77.             $title .= ", week $w";
  78.         }
  79.  
  80.         echo format_to_output$title$display );
  81.     }
  82. }
  83.  
  84.  
  85. /**
  86.  * Display "Archive Directory" title if it has been requested
  87.  *
  88.  * {@internal arcdir_title(-) }}
  89.  *
  90.  * @param string Prefix to be displayed if something is going to be displayed
  91.  * @param mixed Output format, see {@link format_to_output()} or false to
  92.  *                                 return value instead of displaying it
  93.  */
  94. function arcdir_title$prefix ' '$display 'htmlbody' )
  95. {
  96.     global $disp;
  97.  
  98.     if$disp == 'arcdir' )
  99.     {
  100.         $info $prefix.T_('Archive Directory');
  101.         if ($display)
  102.             echo format_to_output$info$display );
  103.         else
  104.             return $info;
  105.     }
  106. }
  107.  
  108.  
  109. /**
  110.  * Create a link to archive
  111.  *
  112.  * {@internal archive_link(-)}}
  113.  *
  114.  * @param string year
  115.  * @param string month
  116.  * @param string day
  117.  * @param string week
  118.  * @param boolean show or return
  119.  * @param string link, instead of blogurl
  120.  * @param string GET params for 'file'
  121.  */
  122. function archive_link$year$month$day ''$week ''$show true$file ''$params '' )
  123. {
  124.     global $Settings;
  125.  
  126.     ifempty($file) )
  127.         $link get_bloginfo('blogurl');
  128.     else
  129.         $link $file;
  130.  
  131.     if( ($Settings->get('links_extrapath')) || (!empty($params)) )
  132.     {    // We reference by Query: Dirty but explicit permalinks
  133.         $link url_add_param$link$params );
  134.         $link url_add_param$link'm=' );
  135.         $separator '';
  136.     }
  137.     else
  138.     {
  139.         $link .= '/';
  140.         $separator '/';
  141.     }
  142.  
  143.     $link .= $year;
  144.  
  145.     if!empty$month ) )
  146.     {
  147.         $link .= $separator.zeroise($month,2);
  148.         if!empty$day ) )
  149.         {
  150.             $link .= $separator.zeroise($day,2);
  151.         }
  152.     }
  153.     elseif$week !== '' )  // Note: week # can be 0 !
  154.     {
  155.         if$Settings->get('links_extrapath') )
  156.         {    // We reference by Query: Dirty but explicit permalinks
  157.             $link url_add_param$link'w='.$week );
  158.         }
  159.         else
  160.         {
  161.             $link .= '/w'.zeroise($week,2);
  162.         }
  163.     }
  164.  
  165.     $link .= $separator;
  166.  
  167.     if$show )
  168.     {
  169.         echo $link;
  170.     }
  171.     return $link;
  172. }
  173.  
  174. ?>

Documentation generated on Tue, 20 May 2008 01:55:04 +0200 by phpDocumentor 1.4.2