b2evolution PHP Cross Reference Blogging Systems

Source: /skins/forums/_skin.class.php - 396 lines - 11292 bytes - Summary - Text - Print

Description: This file implements a class derived of the generic Skin class in order to provide custom code for the skin in this folder. This file is part of the b2evolution project - {@link http://b2evolution.net/}

   1  <?php
   2  /**

   3   * This file implements a class derived of the generic Skin class in order to provide custom code for

   4   * the skin in this folder.

   5   *

   6   * This file is part of the b2evolution project - {@link http://b2evolution.net/}

   7   *

   8   * @package skins

   9   * @subpackage forums

  10   *

  11   * @version $Id: _skin.class.php 13 2011-10-24 23:42:53Z fplanque $

  12   */
  13  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  14  
  15  /**

  16   * Specific code for this skin.

  17   *

  18   * ATTENTION: if you make a new skin you have to change the class name below accordingly

  19   */
  20  class forums_Skin extends Skin
  21  {
  22    /**

  23       * Get default name for the skin.

  24       * Note: the admin can customize it.

  25       */
  26  	function get_default_name()
  27      {
  28          return 'Forums';
  29      }
  30  
  31  
  32    /**

  33       * Get default type for the skin.

  34       */
  35  	function get_default_type()
  36      {
  37          return 'normal';
  38      }
  39  
  40  
  41      /**

  42       * Get definitions for editable params

  43       *

  44       * @see Plugin::GetDefaultSettings()

  45       * @param local params like 'for_editing' => true

  46       */
  47  	function get_param_definitions( $params )
  48      {
  49          $r = array_merge( array(
  50                  'head_bg_color' => array(
  51                      'label' => T_('Header Background Color'),
  52                      'note' => T_('E-g: #ff0000 for red'),
  53                      'defaultvalue' => '#03699C',
  54                      'type' => 'color',
  55                  ),
  56                  'head_text_color' => array(
  57                      'label' => T_('Header Text Color'),
  58                      'note' => T_('E-g: #00ff00 for green'),
  59                      'defaultvalue' => '#FFFFFF',
  60                      'type' => 'color',
  61                  ),
  62                  'menu_bg_color' => array(
  63                      'label' => T_('Menu Background Color'),
  64                      'note' => T_('E-g: #ff0000 for red'),
  65                      'defaultvalue' => '#74b4d4',
  66                      'type' => 'color',
  67                  ),
  68                  'menu_text_color' => array(
  69                      'label' => T_('Menu Text Color'),
  70                      'note' => T_('E-g: #00ff00 for green'),
  71                      'defaultvalue' => '#000000',
  72                      'type' => 'color',
  73                  ),
  74                  'footer_bg_color' => array(
  75                      'label' => T_('Footer Background Color'),
  76                      'note' => T_('E-g: #0000ff for blue'),
  77                      'defaultvalue' => '#DEE3E7',
  78                      'type' => 'color',
  79                  ),
  80                  'display_post_date' => array(
  81                      'label' => T_('Post date'),
  82                      'note' => T_('Display the date of each post'),
  83                      'defaultvalue' => 1,
  84                      'type' => 'checkbox',
  85                  ),
  86                  'colorbox' => array(
  87                      'label' => T_('Colorbox Image Zoom'),
  88                      'note' => T_('Check to enable javascript zooming on images (using the colorbox script)'),
  89                      'defaultvalue' => 1,
  90                      'type' => 'checkbox',
  91                  ),
  92                  'gender_colored' => array(
  93                      'label' => T_('Display gender'),
  94                      'note' => T_('Use colored usernames to differentiate men & women.'),
  95                      'defaultvalue' => 0,
  96                      'type' => 'checkbox',
  97                  ),
  98                  'bubbletip' => array(
  99                      'label' => T_('Username bubble tips'),
 100                      'note' => T_('Check to enable bubble tips on usernames'),
 101                      'defaultvalue' => 0,
 102                      'type' => 'checkbox',
 103                  ),
 104                  'banner_public' => array(
 105                      'label' => T_('"Public" banner'),
 106                      'note' => T_('Display banner for "Public" posts (posts & comments)'),
 107                      'defaultvalue' => 1,
 108                      'type' => 'checkbox',
 109                  ),
 110              ), parent::get_param_definitions( $params )    );
 111  
 112          return $r;
 113      }
 114  
 115  
 116      /**

 117       * Get current skin post navigation setting. Always use this navigation setting where this skin is applied.

 118       */
 119  	function get_post_navigation()
 120      {
 121          return 'same_category';
 122      }
 123  
 124  
 125      /**

 126       * Get ready for displaying the skin.

 127       *

 128       * This may register some CSS or JS...

 129       */
 130  	function display_init()
 131      {
 132          // call parent:

 133          parent::display_init();
 134  
 135          // Add CSS:

 136          require_css( 'basic_styles.css', 'blog' ); // the REAL basic styles

 137          require_css( 'basic.css', 'blog' ); // Basic styles

 138          require_css( 'blog_base.css', 'blog' ); // Default styles for the blog navigation

 139          require_css( 'item_base.css', 'blog' ); // Default styles for the post CONTENT

 140  
 141          // Make sure standard CSS is called ahead of custom CSS generated below:

 142          require_css( 'style.css', true );
 143  
 144          // Add custom CSS:

 145          $custom_css = '';
 146  
 147          if( $color = $this->get_setting( 'head_bg_color' ) )
 148          { // Custom Header background color:
 149              $custom_css .= '    div.pageHeader { background-color: '.$color." }\n";
 150          }
 151          if( $color = $this->get_setting( 'head_text_color' ) )
 152          { // Custom Header text color:
 153              $custom_css .= '    div.pageHeader, div.pageHeader a { color: '.$color." }\n";
 154          }
 155  
 156          if( $color = $this->get_setting( 'menu_bg_color' ) )
 157          { // Custom Menu background color:
 158              $custom_css .= '    div.top_menu_bg { background-color: '.$color." }\n";
 159          }
 160          if( $color = $this->get_setting( 'menu_text_color' ) )
 161          { // Custom Menu text color:
 162              $custom_css .= '    div.top_menu a { color: '.$color." }\n";
 163          }
 164  
 165          if( $color = $this->get_setting( 'footer_bg_color' ) )
 166          { // Custom Footer background color:
 167              $custom_css .= '    div#pageFooter { background-color: '.$color." }\n";
 168          }
 169  
 170          if( !empty( $custom_css ) )
 171          {
 172              $custom_css = '<style type="text/css">
 173      <!--
 174  '.$custom_css.'    -->
 175      </style>';
 176              add_headline( $custom_css );
 177          }
 178  
 179          // Colorbox (a lightweight Lightbox alternative) allows to zoom on images and do slideshows with groups of images:

 180          if($this->get_setting("colorbox"))
 181          {
 182              require_js_helper( 'colorbox', 'blog' );
 183          }
 184  
 185          // Functions to switch between the width sizes

 186          require_js( '#jquery#', 'blog' );
 187          require_js( 'widthswitcher.js', 'blog' );
 188      }
 189  
 190  
 191      /**

 192       * Display breadcrumbs

 193       *

 194       * @param integer Chapter ID

 195       * @param array Params

 196       */
 197  	function display_breadcrumbs( $chapter_ID, $params = array() )
 198      {
 199          if( $chapter_ID <= 0 )
 200          { // No selected chapter, or an exlcude chapter filter is set
 201              return;
 202          }
 203  
 204          $params = array_merge( array(
 205                  'before'    => '<span class="breadcrumbs">',
 206                  'after'     => '</span>',
 207                  'separator' => ' -> ',
 208              ), $params );
 209  
 210          global $Blog;
 211  
 212          $ChapterCache = & get_ChapterCache();
 213  
 214          $breadcrumbs = array();
 215          do
 216          {    // Get all parent chapters
 217              $Chapter = & $ChapterCache->get_by_ID( $chapter_ID );
 218  
 219              $breadcrumbs[] = '<a href="'.$Chapter->get_permanent_url().'">'.$Chapter->dget( 'name' ).'</a>';
 220  
 221              $chapter_ID = $Chapter->get( 'parent_ID' );
 222          }
 223          while( !empty( $chapter_ID ) );
 224  
 225          $breadcrumbs[] = '<a href="'.$Blog->get( 'blogurl' ).'">'.$Blog->get( 'name' ).'</a>';
 226          $breadcrumbs = array_reverse( $breadcrumbs );
 227  
 228          // Display

 229          echo $params['before'];
 230          echo implode( $params['separator'], $breadcrumbs );
 231          echo $params['after'];
 232      }
 233  
 234  
 235      /**

 236       * Display button to create a new post

 237       *

 238       * @param integer Chapter ID

 239       */
 240  	function display_post_button( $chapter_ID, $Item = NULL )
 241      {
 242          global $Blog;
 243  
 244          $post_button = '';
 245  
 246          $chapter_is_locked = false;
 247  
 248          $write_new_post_url = $Blog->get_write_item_url( $chapter_ID );
 249          if( $write_new_post_url != '' )
 250          { // Display button to write a new post
 251              $post_button = '<a href="'.$write_new_post_url.'"><span class="ficon newTopic" title="'.T_('Post new topic').'"></span></a>';
 252          }
 253          else
 254          { // If a creating of new post is unavailable
 255              $ChapterCache = & get_ChapterCache();
 256              $current_Chapter = $ChapterCache->get_by_ID( $chapter_ID, false, false );
 257  
 258              if( $current_Chapter && $current_Chapter->lock )
 259              { // Display icon to inform that this forum is locked
 260                  $post_button = '<span class="ficon locked" title="'.T_('This forum is locked: you cannot post, reply to, or edit topics.').'"></span>';
 261                  $chapter_is_locked = true;
 262              }
 263          }
 264  
 265          if( !empty( $Item ) )
 266          {
 267              if( $Item->comment_status == 'closed' || $Item->comment_status == 'disabled' || $Item->is_locked() )
 268              { // Display icon to inform that this topic is locked for comments
 269                  if( !$chapter_is_locked )
 270                  { // Display this button only when chapter is not locked, to avoid a duplicate button
 271                      $post_button .= ' <span class="ficon locked" title="'.T_('This topic is locked: you cannot edit posts or make replies.').'"></span>';
 272                  }
 273              }
 274              else
 275              { // Display button to post a reply
 276                  $post_button .= ' <a href="'.$Item->get_feedback_url().'#form_p'.$Item->ID.'"><span class="ficon postReply" title="'.T_('Reply to topic').'"></span></a>';
 277              }
 278          }
 279  
 280          if( !empty( $post_button ) )
 281          { // Display button
 282              echo '<div class="post_button">';
 283              echo $post_button;
 284              echo '</div>';
 285          }
 286      }
 287  
 288      /**

 289       * Get chapters

 290       *

 291       * @param integer Chapter parent ID

 292       */
 293  	function get_chapters( $parent_ID = 0 )
 294      {
 295          global $Blog, $skin_chapters_cache;
 296  
 297          if( isset( $skin_chapters_cache ) )
 298          {    // Get chapters from cache
 299              return $skin_chapters_cache;
 300          }
 301  
 302          $skin_chapters_cache = array();
 303          if( $parent_ID > 0 )
 304          {    // Get children of selected chapter
 305              global $DB, $Settings;
 306  
 307              $skin_chapters_cache = array();
 308  
 309              $SQL = new SQL();
 310              $SQL->SELECT( 'cat_ID' );
 311              $SQL->FROM( 'T_categories' );
 312              $SQL->WHERE( 'cat_parent_ID = '.$DB->quote( $parent_ID ) );
 313              if( $Settings->get( 'chapter_ordering' ) == 'manual' )
 314              {    // Manual order
 315                  $SQL->ORDER_BY( 'cat_meta, cat_order' );
 316              }
 317              else
 318              {    // Alphabetic order
 319                  $SQL->ORDER_BY( 'cat_meta, cat_name' );
 320              }
 321  
 322              $ChapterCache = & get_ChapterCache();
 323  
 324              $categories = $DB->get_results( $SQL->get() );
 325              foreach( $categories as $c => $category )
 326              {
 327                  $skin_chapters_cache[$c] = $ChapterCache->get_by_ID( $category->cat_ID );
 328                  // Get children

 329                  $SQL->WHERE( 'cat_parent_ID = '.$DB->quote( $category->cat_ID ) );
 330                  $children = $DB->get_results( $SQL->get() );
 331                  foreach( $children as $child_Chapter )
 332                  {
 333                      $skin_chapters_cache[$c]->children[$child_Chapter->cat_ID] = $ChapterCache->get_by_ID( $child_Chapter->cat_ID );
 334                  }
 335              }
 336          }
 337          else
 338          {    // Get the all chapters for current blog
 339              $ChapterCache = & get_ChapterCache();
 340              $ChapterCache->load_subset( $Blog->ID );
 341  
 342              if( isset( $ChapterCache->subset_cache[ $Blog->ID ] ) )
 343              {
 344                  $skin_chapters_cache = $ChapterCache->subset_cache[ $Blog->ID ];
 345  
 346                  foreach( $skin_chapters_cache as $c => $Chapter )
 347                  { // Init children
 348                      foreach( $skin_chapters_cache as $child_Chapter )
 349                      { // Again go through all chapters to find a children for current chapter
 350                          if( $Chapter->ID == $child_Chapter->get( 'parent_ID' ) )
 351                          { // Add to array of children
 352                              $skin_chapters_cache[$c]->children[$child_Chapter->ID] = $child_Chapter;
 353                          }
 354                      }
 355                  }
 356  
 357                  foreach( $skin_chapters_cache as $c => $Chapter )
 358                  { // Unset the child chapters
 359                      if( $Chapter->get( 'parent_ID' ) )
 360                      {
 361                          unset( $skin_chapters_cache[$c] );
 362                      }
 363                  }
 364              }
 365          }
 366  
 367          return $skin_chapters_cache;
 368      }
 369  
 370  
 371      /**

 372       * Determine to display status banner or to don't display

 373       *

 374       * @param string Status of Item or Comment

 375       * @return boolean TRUE if we can display status banner for given status

 376       */
 377  	function enabled_status_banner( $status )
 378      {
 379          if( $status != 'published' )
 380          {    // Display status banner everytime when status is not 'published'
 381              return true;
 382          }
 383  
 384          if( is_logged_in() && $this->get_setting( 'banner_public' ) )
 385          {    // Also display status banner if status is 'published'
 386              //   AND current user is logged in

 387              //   AND this feature is enabled in skin settings

 388              return true;
 389          }
 390  
 391          // Don't display status banner

 392          return false;
 393      }
 394  }
 395  
 396  ?>

title

Description

title

Description

title

Description

title

title

Body