[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/items/model/ -> _itemlight.class.php (source)

   1  <?php
   2  /**

   3   * This file implements the ItemLight class.

   4   *

   5   * This file is part of the evoCore framework - {@link http://evocore.net/}

   6   * See also {@link http://sourceforge.net/projects/evocms/}.

   7   *

   8   * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}

   9   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.

  10   *

  11   * {@internal License choice

  12   * - If you have received this file as part of a package, please find the license.txt file in

  13   *   the same folder or the closest folder above for complete license terms.

  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)

  15   *   then you must choose one of the following licenses before using the file:

  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php

  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php

  18   * }}

  19   *

  20   * {@internal Open Source relicensing agreement:

  21   * Daniel HAHLER grants Francois PLANQUE the right to license

  22   * Daniel HAHLER's contributions to this file and the b2evolution project

  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  24   * }}

  25   *

  26   * @package evocore

  27   *

  28   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  29   * @author fplanque: Francois PLANQUE.

  30   *

  31   * @version $Id: _itemlight.class.php,v 1.6 2007/11/03 23:54:38 fplanque Exp $

  32   */
  33  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  34  
  35  load_class('_core/model/dataobjects/_dataobject.class.php');
  36  
  37  /**

  38   * ItemLight Class

  39   *

  40   * Basically, all we want to achieve here is:

  41   * - permalinks

  42   * - last mod dates

  43   *

  44   * This object SHOULD NOT be saved.

  45   *

  46   * @package evocore

  47   */
  48  class ItemLight extends DataObject
  49  {
  50      /**

  51       * Publish date ("Y-m-d H:i:s"). This may be in the future.

  52       * This should get compared to {@link $localtimenow}.

  53       * @var string

  54       */
  55      var $issue_date;
  56      var $mod_date;
  57  
  58       var $title;
  59  
  60       var $excerpt;
  61  
  62      var $urltitle;
  63  
  64      /**

  65       * External URL the item links to (if any).

  66       * @var string

  67       */
  68      var $url;
  69  
  70       var $ptyp_ID;
  71  
  72      /**

  73       * @var integer

  74       */
  75      var $main_cat_ID = 0;
  76      /**

  77       * @var Chapter

  78       */
  79      var $main_Chapter;
  80  
  81      /**

  82       * Derived from $main_cat_ID

  83       *

  84       * @var integer

  85       */
  86      var $blog_ID;
  87      /**

  88       * The Blog of the Item (lazy filled, use {@link get_Blog()} to access it.

  89       * @access protected

  90       * @var Blog

  91       */
  92      var $Blog;
  93  
  94  
  95      /**

  96       * Constructor

  97       *

  98       * @param object table Database row

  99       * @param string

 100       * @param string

 101       * @param string

 102       * @param string for derived classes

 103       * @param string datetime field name

 104       * @param string datetime field name

 105       * @param string User ID field name

 106       * @param string User ID field name

 107       */
 108  	function ItemLight( $db_row = NULL, $dbtable = 'T_items__item', $dbprefix = 'post_', $dbIDname = 'post_ID', $objtype = 'ItemLight',
 109                     $datecreated_field = '', $datemodified_field = 'datemodified',
 110                     $creator_field = '', $lasteditor_field = '' )
 111      {
 112          global $localtimenow, $default_locale, $current_User;
 113  
 114          // Call parent constructor:

 115          parent::DataObject( $dbtable, $dbprefix, $dbIDname, $datecreated_field, $datemodified_field,
 116                                                  $creator_field, $lasteditor_field );
 117  
 118          $this->delete_restrictions = array(
 119                  array( 'table'=>'T_links', 'fk'=>'link_dest_itm_ID', 'msg'=>T_('%d links to source items') ),
 120                  array( 'table'=>'T_items__item', 'fk'=>'post_parent_ID', 'msg'=>T_('%d links to child items') ),
 121              );
 122  
 123          $this->delete_cascades = array(
 124                  array( 'table'=>'T_links', 'fk'=>'link_itm_ID', 'msg'=>T_('%d links to destination items') ),
 125                  array( 'table'=>'T_postcats', 'fk'=>'postcat_post_ID', 'msg'=>T_('%d links to extra categories') ),
 126                  array( 'table'=>'T_comments', 'fk'=>'comment_post_ID', 'msg'=>T_('%d comments') ),
 127              );
 128  
 129          $this->objtype = $objtype;
 130  
 131          if( $db_row == NULL )
 132          { // New item:
 133              $this->ID = 0;
 134              $this->set( 'issue_date', date('Y-m-d H:i:s', $localtimenow) );
 135          }
 136          else
 137          {
 138              $this->ID = $db_row->$dbIDname;
 139              $this->datemodified = $db_row->post_datemodified; // Needed for history display

 140              $this->issue_date = $db_row->post_datestart;
 141              $this->mod_date = $db_row->post_datemodified;
 142              $this->main_cat_ID = $db_row->post_main_cat_ID;
 143              $this->urltitle = $db_row->post_urltitle;
 144              $this->title = $db_row->post_title;
 145              $this->excerpt = $db_row->post_excerpt;
 146              $this->ptyp_ID = $db_row->post_ptyp_ID;
 147              $this->url = $db_row->post_url;
 148  
 149              // Derived vars

 150              $ChapterCache = & get_Cache( 'ChapterCache' );
 151              $this->main_Chapter = & $ChapterCache->get_by_ID( $this->main_cat_ID );
 152  
 153              $this->blog_ID = $this->main_Chapter->blog_ID;
 154          }
 155      }
 156  
 157  
 158    /**

 159       * Generate a single post link for the item

 160       *

 161       * @param boolean allow redir to permalink, true | false | 'auto' to prevent redit only if single isn't the current permalink type

 162        * @param string base url to use

 163       * @param string glue between url params

 164       */
 165  	function get_single_url( $allow_redir = true, $blogurl = '', $glue = '&amp;' )
 166      {
 167          $this->get_Blog();
 168  
 169          if( empty( $blogurl ) )
 170          {
 171              $blogurl = $this->Blog->gen_blogurl();
 172          }
 173  
 174          $single_links = $this->Blog->get_setting('single_links');
 175  
 176           if( !empty( $this->urltitle ) && $single_links != 'param_num' )
 177          {    // We can and we want to use the url title:
 178              $urlparam = 'title='.$this->urltitle;
 179              $urltail = $this->urltitle;
 180          }
 181          else
 182          {
 183              $urlparam = 'p='.$this->ID;
 184              $urltail = 'p'.$this->ID;
 185          }
 186  
 187          switch( $single_links )
 188          {
 189              case 'param_num':
 190              case 'param_title':
 191                  $permalink = url_add_param( $blogurl, $urlparam.$glue.'more=1'.$glue.'c=1'.$glue.'tb=1'.$glue.'pb=1', $glue );
 192                  break;
 193  
 194              case 'y':
 195                  $permalink = url_add_tail( $blogurl, mysql2date('/Y/', $this->issue_date).$urltail );
 196                  break;
 197  
 198              case 'ym':
 199                  $permalink = url_add_tail( $blogurl, mysql2date('/Y/m/', $this->issue_date).$urltail );
 200                  break;
 201  
 202              case 'ymd':
 203                  $permalink = url_add_tail( $blogurl, mysql2date('/Y/m/d/', $this->issue_date).$urltail );
 204                  break;
 205  
 206               case 'subchap':
 207                  $permalink = url_add_tail( $blogurl, '/'.$this->main_Chapter->urlname.'/'.$urltail );
 208                  break;
 209  
 210               case 'chapters':
 211                  $permalink = url_add_tail( $blogurl, '/'.$this->main_Chapter->get_url_path().$urltail );
 212                  break;
 213  
 214              case 'short':
 215              default:
 216                  $permalink = url_add_tail( $blogurl, '/'.$urltail );
 217                  break;
 218          }
 219  
 220          if( $allow_redir == 'auto' )
 221          {    // We allow redir only if the permalink is already single.
 222              // In other words: we implicitely allow redir if there is no need to redir!

 223              // and more useful: we explicitely prevent redir if we know it would take place.

 224              $allow_redir = ($this->Blog->get_setting( 'permalinks' ) == 'single');
 225          }
 226  
 227          if( ! $allow_redir )
 228          {
 229              $permalink = url_add_param( $permalink, 'redir=no', $glue );
 230          }
 231  
 232          return $permalink;
 233      }
 234  
 235  
 236    /**

 237       * Generate a link to the post in the archives

 238       *

 239        * @param string base url to use

 240       * @param string glue between url params

 241       */
 242  	function get_archive_url( $blogurl = '', $glue = '&amp;' )
 243      {
 244          $this->get_Blog();
 245  
 246          if( empty( $blogurl ) )
 247          {
 248              $blogurl = $this->Blog->gen_blogurl();
 249          }
 250  
 251          $permalink = $this->Blog->get_archive_url( $this->issue_date, $glue );
 252  
 253          return $permalink.'#item_'.$this->ID;
 254      }
 255  
 256  
 257    /**

 258       * Generate a link to the post in the category

 259       *

 260        * @param string base url to use

 261       * @param string glue between url params

 262       */
 263  	function get_chapter_url( $blogurl = '', $glue = '&amp;' )
 264      {
 265          if( empty( $blogurl ) )
 266          {
 267              $this->get_Blog();
 268              $blogurl = $this->Blog->gen_blogurl();
 269          }
 270  
 271          $permalink = url_add_tail( $blogurl, '/'.$this->main_Chapter->get_url_path() );
 272  
 273          return $permalink.'#item_'.$this->ID;
 274      }
 275  
 276  
 277      /**

 278       * Generate the permalink for the item.

 279       *

 280       * Note: Each item has an unique permalink at any given time.

 281       * Some admin settings may however change the permalinks for previous items.

 282       * Note: This actually only returns the URL, to get a real link, use {@link Item::get_permanent_link()}

 283       *

 284       * @todo archives modes in clean URL mode

 285       *

 286       * @param string single, archive, subchap

 287       * @param string base url to use

 288       * @param string glue between url params

 289       */
 290  	function get_permanent_url( $permalink_type = '', $blogurl = '', $glue = '&amp;' )
 291      {
 292          global $DB, $cacheweekly, $Settings;
 293  
 294          if( $this->ptyp_ID == 1000 )
 295          {    // Page: force use of single url:
 296              $permalink_type = 'single';
 297          }
 298          elseif( empty( $permalink_type ) )
 299          { // Use default from collection settings:
 300              $this->get_Blog();
 301              $permalink_type = $this->Blog->get_setting( 'permalinks' );
 302          }
 303  
 304          switch( $permalink_type )
 305          {
 306              case 'archive':
 307                  return $this->get_archive_url( $blogurl, $glue );
 308  
 309              case 'subchap':
 310                  return $this->get_chapter_url( $blogurl, $glue );
 311  
 312              case 'single':
 313              default:
 314                  return $this->get_single_url( true, $blogurl, $glue );
 315          }
 316      }
 317  
 318  
 319      /**

 320       * Template function: list all the category names

 321       *

 322       * @param string Output format for each cat, see {@link format_to_output()}

 323       */
 324  	function categories( $params = array() )
 325      {
 326          // Make sure we are not missing any param:

 327          $params = array_merge( array(
 328                  'before'          => ' ',
 329                  'after'           => ' ',
 330                  'include_main'    => true,
 331                  'include_other'   => true,
 332                  'include_external'=> true,
 333                  'before_main'     => '',       // string fo display before the MAIN category,
 334                  'after_main'      => '',       // string fo display after the MAIN category
 335                  'before_other'    => '',       // string fo display before OTHER categories
 336                  'after_other'     => '',       // string fo display after OTHER categories
 337                  'before_external' => '<em>',   // string fo display before EXTERNAL categories
 338                  'after_external'  => '</em>',  // string fo display after EXTERNAL categories,
 339                  'separator'       => ', ',
 340                  'link_categories' => true,
 341                  'link_title'      => '#',
 342                  'format'          => 'htmlbody',
 343              ), $params );
 344  
 345  
 346          if( $params['link_title'] == '#' )
 347          { /* TRANS: When the categories for a specific post are displayed, the user can click

 348                      on these cats to browse them, this is the default href title displayed there */
 349              $params['link_title'] = T_('Browse category');
 350          }
 351  
 352          $categoryNames = array();
 353          foreach( $this->get_Chapters() as $Chapter )
 354          {
 355              $cat_name = $Chapter->dget( 'name' );
 356  
 357              if( $params['link_categories'] )
 358              { // we want to display links
 359                  $lBlog = & $Chapter->get_Blog();
 360                  $cat_name = '<a href="'.$Chapter->get_permanent_url().'" title="'.htmlspecialchars($params['link_title']).'">'.$cat_name.'</a>';
 361              }
 362  
 363              if( $Chapter->ID == $this->main_cat_ID )
 364              { // We are displaying the main cat!
 365                  if( !$params['include_main'] )
 366                  { // ignore main cat !!!
 367                      continue;
 368                  }
 369                  $cat_name = $params['before_main'].$cat_name.$params['after_main'];
 370              }
 371              elseif( $Chapter->blog_ID == $this->blog_ID )
 372              { // We are displaying another cat in the same blog
 373                  if( !$params['include_other'] )
 374                  { // ignore main cat !!!
 375                      continue;
 376                  }
 377                  $cat_name = $params['before_other'].$cat_name.$params['after_other'];
 378              }
 379              else
 380              { // We are displaying an external cat (in another blog)
 381                  if( !$params['include_external'] )
 382                  { // ignore main cat !!!
 383                      continue;
 384                  }
 385                  $cat_name = $params['before_external'].$cat_name.$params['after_external'];
 386              }
 387  
 388              $categoryNames[] = $cat_name;
 389          }
 390  
 391          echo $params['before'];
 392          echo format_to_output( implode( $params['separator'], $categoryNames ), $params['format'] );
 393           echo $params['after'];
 394      }
 395  
 396  
 397      /**

 398       * Template function: display main category name

 399       *

 400       * @param string Output format, see {@link format_to_output()}

 401       */
 402  	function main_category( $format = 'htmlbody' )
 403      {
 404          $Chapter = & $this->get_main_Chapter();
 405          $Chapter->disp( 'name', $format );
 406      }
 407  
 408  
 409      /**

 410       * Get list of Chapter objects.

 411       *

 412       * @return array of {@link Chapter chapters} (references)

 413       */
 414  	function get_Chapters()
 415      {
 416          global $cache_postcats;
 417  
 418          $ChapterCache = & get_Cache( 'ChapterCache' );
 419  
 420          // Load cache for category associations with current posts

 421          cat_load_postcats_cache();
 422  
 423          if( isset($cache_postcats[$this->ID]) )
 424          { // dh> may not be set! (demo logs)
 425              $categoryIDs = $cache_postcats[$this->ID];
 426          }
 427          else $categoryIDs = array();
 428  
 429          $chapters = array();
 430          foreach( $categoryIDs as $cat_ID )
 431          {
 432              $chapters[] = & $ChapterCache->get_by_ID( $cat_ID );
 433          }
 434  
 435          return $chapters;
 436      }
 437  
 438  
 439      /**

 440       * Get the main Chapter.

 441       *

 442       * @return Chapter

 443       */
 444      function & get_main_Chapter()
 445      {
 446          $ChapterCache = & get_Cache( 'ChapterCache' );
 447          /**

 448           * @var Chapter

 449           */
 450          return $ChapterCache->get_by_ID( $this->main_cat_ID );
 451      }
 452  
 453  
 454      /**

 455       * returns issue date (datetime) of Item

 456       *

 457       */
 458  	function get_issue_date( $params = array() )
 459      {
 460          // Make sure we are not missing any param:

 461          $params = array_merge( array(
 462                  'before'      => ' ',
 463                  'after'       => ' ',
 464                  'date_format' => '#',
 465                  'use_GMT'     => false,
 466              ), $params );
 467  
 468          if( $params['date_format'] == '#' )
 469          {
 470              $params['date_format'] = locale_datefmt();
 471          }
 472  
 473          return $params['before'].mysql2date( $params['date_format'], $this->issue_date, $params['use_GMT'] ).$params['after'];
 474      }
 475  
 476  
 477      /**

 478       * Template function: display issue date (datetime) of Item

 479       *

 480       */
 481  	function issue_date( $params = array() )
 482      {
 483          echo $this->get_issue_date( $params );
 484      }
 485  
 486  
 487      /**

 488       * Template function: display issue time (datetime) of Item

 489       *

 490       */
 491  	function issue_time( $params = array() )
 492      {
 493          // Make sure we are not missing any param:

 494          $params = array_merge( array(
 495                  'time_format' => '#',
 496              ), $params );
 497  
 498          if( !isset($params['date_format']) )
 499          {
 500              $params['date_format'] = $params['time_format'];
 501          }
 502  
 503          if( $params['date_format'] == '#' )
 504          {
 505              $params['date_format'] = locale_timefmt();
 506          }
 507  
 508          echo $this->get_issue_date( $params );
 509      }
 510  
 511  
 512      /**

 513       * Template function: display locale for item

 514       */
 515  	function lang()
 516      {
 517          $this->disp( 'locale', 'raw' );
 518      }
 519  
 520  
 521      /**

 522       * Template function: display locale for item

 523       */
 524  	function locale()
 525      {
 526          $this->disp( 'locale', 'raw' );
 527      }
 528  
 529  
 530      /**

 531       * Template tag

 532       */
 533  	function locale_flag( $params = array() )
 534      {
 535          // Make sure we are not missing any param:

 536          $params = array_merge( array(
 537                  'before'      => ' ',
 538                  'after'       => ' ',
 539                  'collection'  => 'h10px',
 540                  'format'      => 'htmlbody',
 541                  'class'       => 'flag',
 542                  'align'       => '',
 543              ), $params );
 544  
 545          echo $params['before'];
 546          echo locale_flag( $this->locale, $params['collection'], $params['class'], $params['align'] );
 547          echo $params['after'];
 548      }
 549  
 550  
 551      /**

 552       * Template function: Temporarily switch to this post's locale

 553       */
 554  	function locale_temp_switch()
 555      {
 556          locale_temp_switch( $this->locale );
 557      }
 558  
 559  
 560      /**

 561       * Template function: display language name for item

 562       *

 563       * @param string Output format, see {@link format_to_output()}

 564       */
 565  	function language( $format = 'htmlbody' )
 566      {
 567          global $locales;
 568          $locale = $locales[ $this->locale ];
 569          echo format_to_output( $locale['name'], $format );
 570      }
 571  
 572  
 573      /**

 574       * Template function: display last mod date (datetime) of Item

 575       *

 576       * @param string date/time format: leave empty to use locale default date format

 577       * @param boolean true if you want GMT

 578       */
 579  	function mod_date( $format = '', $useGM = false )
 580      {
 581          if( empty($format) )
 582              echo mysql2date( locale_datefmt(), $this->mod_date, $useGM );
 583          else
 584              echo mysql2date( $format, $this->mod_date, $useGM );
 585      }
 586  
 587  
 588      /**

 589       * Template function: display last mod time (datetime) of Item

 590       *

 591       * @param string date/time format: leave empty to use locale default time format

 592       * @param boolean true if you want GMT

 593       */
 594  	function mod_time( $format = '', $useGM = false )
 595      {
 596          if( empty($format) )
 597              echo mysql2date( locale_timefmt(), $this->mod_date, $useGM );
 598          else
 599              echo mysql2date( $format, $this->mod_date, $useGM );
 600      }
 601  
 602  
 603      /**

 604       * Template function: display permalink for item

 605       *

 606       * Note: This actually only outputs the URL, to display a real link, use {@link Item::permanent_link()}

 607       *

 608       * @param string 'post', 'archive#id' or 'archive#title'

 609       * @param string url to use

 610       */
 611  	function permanent_url( $mode = '', $blogurl='' )
 612      {
 613          echo $this->get_permanent_url( $mode, $blogurl );
 614      }
 615  
 616  
 617      /**

 618       * Returns a permalink link to the Item

 619       *

 620       * Note: If you only want the permalink URL, use {@link Item::get_permanent_url()}

 621       *

 622       * @param string link text or special value: '#', '#icon#', '#text#', '#title#' '... $title$ ...'

 623       * @param string link title

 624       * @param string class name

 625       */
 626  	function get_permanent_link( $text = '#', $title = '#', $class = '' )
 627      {
 628          global $current_User;
 629  
 630          switch( $text )
 631          {
 632              case '#':
 633                  $text = get_icon( 'permalink', 'imgtag', array('class'=>'icon') ).T_('Permalink');
 634                  break;
 635  
 636              case '#icon#':
 637                  $text = get_icon( 'permalink', 'imgtag', array('class'=>'icon') );
 638                  break;
 639  
 640              case '#text#':
 641                  $text = T_('Permalink');
 642                  break;
 643  
 644              case '#title#':
 645                  $text = format_to_output( $this->title );
 646                  break;
 647          }
 648  
 649          if( $title == '#' ) $title = T_('Permanent link to full entry');
 650  
 651          $url = $this->get_permanent_url();
 652  
 653          // Display as link

 654          $r = '<a href="'.$url.'" title="'.$title.'"';
 655          if( !empty( $class ) ) $r .= ' class="'.$class.'"';
 656          $r .= '>'.str_replace( '$title$', format_to_output( $this->title ), $text ).'</a>';
 657  
 658          return $r;
 659      }
 660  
 661  
 662      /**

 663       * Displays a permalink link to the Item

 664       *

 665       * Note: If you only want the permalink URL, use {@link Item::permanent_url()}

 666       *

 667       * @param string link text or special value:

 668       * @param string link title

 669       * @param string class name

 670       */
 671  	function permanent_link( $params = array() )
 672      {
 673          // Make sure we are not missing any param:

 674          $params = array_merge( array(
 675                  'before'      => '',
 676                  'after'       => '',
 677                  'text'        => '#',    // possible special values: '#', '#icon#', '#text#', '#title#'
 678                  'title'       => '#',
 679                  'class'       => '',
 680              //    'format'      => 'htmlbody',

 681              ), $params );
 682  
 683          $link = $this->get_permanent_link( $params['text'], $params['title'], $params['class'] );
 684  
 685          if( !empty( $link ) )
 686          {
 687              echo $params['before'];
 688              echo $link;
 689              echo $params['after'];
 690          }
 691      }
 692  
 693  
 694      /**

 695       * Template function: display title for item and link to related URL

 696       */
 697  	function title( $params = array() )
 698      {
 699          // Make sure we are not missing any param:

 700          $params = array_merge( array(
 701                  'before'      => '',
 702                  'after'       => '',
 703                  'format'      => 'htmlbody',
 704                  'link_type'   => '#',
 705              ), $params );
 706  
 707          $title = format_to_output( $this->title, $params['format'] );
 708  
 709          if( empty( $title ) )
 710          {
 711              return;
 712          }
 713  
 714          if( $params['link_type'] == '#' )
 715          {    // Use default link type from settings:
 716              $this->get_Blog();
 717              $params['link_type'] = $this->Blog->get_setting( 'title_link_type' );
 718          }
 719  
 720          switch( $params['link_type'] )
 721          {
 722              case 'permalink':
 723                  $url = $this->get_permanent_url();
 724                  break;
 725  
 726              case 'linkto_url':
 727                  $url = $this->url;
 728                  break;
 729  
 730              case 'admin_view':
 731            $url = '?ctrl=items&amp;blog='.$this->blog_ID.'&amp;p='.$this->ID;
 732                  break;
 733  
 734              case 'none':
 735              default:
 736          }
 737  
 738          echo $params['before'];
 739          if( !empty($url) )
 740          {
 741              echo '<a href="'.$url.'">'.$title.'</a>';
 742          }
 743          else
 744          {
 745              echo $title;
 746          }
 747          echo $params['after'];
 748      }
 749  
 750  
 751      /**

 752       * Template function: display type of item

 753       *

 754       * @param string

 755       * @param string

 756       * @param string Output format, see {@link format_to_output()}

 757       */
 758  	function type( $before = '', $after = '', $format = 'htmlbody' )
 759      {
 760          $ItemTypeCache = & get_Cache( 'ItemTypeCache' );
 761          $Element = & $ItemTypeCache->get_by_ID( $this->ptyp_ID, true, false );
 762          if( !$Element )
 763          { // No status:
 764              return;
 765          }
 766  
 767          $extra_status = $Element->get('name');
 768  
 769          if( $format == 'raw' )
 770          {
 771              $this->disp( $extra_status, 'raw' );
 772          }
 773          else
 774          {
 775              echo $before.format_to_output( T_( $extra_status ), $format ).$after;
 776          }
 777      }
 778  
 779  
 780      /**

 781       * Template function: get excerpt

 782       *

 783       * @todo do we want excerpts in itemLight or not?

 784       *

 785       * @param string filename to use to display more

 786       * @return string

 787       */
 788  	function get_excerpt( $format = 'htmlbody' )
 789      {
 790          // Character conversions

 791          return format_to_output( $this->excerpt, $format );
 792      }
 793  
 794  
 795      /**

 796       * Set param value

 797       *

 798       * By default, all values will be considered strings

 799       *

 800       * @todo extra_cat_IDs recording

 801       *

 802       * @param string parameter name

 803       * @param mixed parameter value

 804       * @param boolean true to set to NULL if empty value

 805       * @return boolean true, if a value has been set; false if it has not changed

 806       */
 807  	function set( $parname, $parvalue, $make_null = false )
 808      {
 809          switch( $parname )
 810          {
 811              case 'main_cat_ID':
 812                  $r = $this->set_param( 'main_cat_ID', 'number', $parvalue, false );
 813                  // make sure main cat is in extracat list and there are no duplicates

 814                  $this->extra_cat_IDs[] = $this->main_cat_ID;
 815                  $this->extra_cat_IDs = array_unique( $this->extra_cat_IDs );
 816                  // Update derived property:

 817                  $this->blog_ID = get_catblog( $this->main_cat_ID ); // This is a derived var

 818                  return $r;
 819  
 820              case 'extra_cat_IDs':
 821                  // ARRAY! We do not record this change (yet)

 822                  $this->extra_cat_IDs = $parvalue;
 823                  // make sure main cat is in extracat list and there are no duplicates

 824                  $this->extra_cat_IDs[] = $this->main_cat_ID;
 825                  $this->extra_cat_IDs = array_unique( $this->extra_cat_IDs );
 826                  break;
 827  
 828              case 'issue_date':
 829              case 'datestart':
 830                  $this->issue_date = $parvalue;
 831                  return $this->set_param( 'datestart', 'date', $parvalue, false );
 832  
 833              case 'ptyp_ID':
 834                  return $this->set_param( $parname, 'number', $parvalue, true );
 835  
 836              default:
 837                  return $this->set_param( $parname, 'string', $parvalue, $make_null );
 838          }
 839      }
 840  
 841  
 842      /**

 843       * Get the Blog object for the Item.

 844       *

 845       * @return Blog

 846       */
 847      function & get_Blog()
 848      {
 849          if( is_null($this->Blog) )
 850          {
 851              $this->load_Blog();
 852          }
 853  
 854          return $this->Blog;
 855      }
 856  
 857  
 858      /**

 859       * Load the Blog object for the Item, without returning it.

 860       *

 861       * This is needed for {@link Results} object callbacks.

 862       */
 863  	function load_Blog()
 864      {
 865          if( is_null($this->Blog) )
 866          {
 867              $BlogCache = & get_Cache( 'BlogCache' );
 868              $this->Blog = & $BlogCache->get_by_ID( $this->blog_ID );
 869          }
 870      }
 871  
 872  }
 873  
 874  
 875  /*

 876   * $Log: _itemlight.class.php,v $

 877   * Revision 1.6  2007/11/03 23:54:38  fplanque

 878   * skin cleanup continued

 879   *

 880   * Revision 1.5  2007/11/03 21:04:27  fplanque

 881   * skin cleanup

 882   *

 883   * Revision 1.4  2007/11/03 04:56:04  fplanque

 884   * permalink / title links cleanup

 885   *

 886   * Revision 1.3  2007/09/09 12:51:58  fplanque

 887   * cleanup

 888   *

 889   * Revision 1.2  2007/09/09 09:15:59  yabs

 890   * validation

 891   *

 892   * Revision 1.1  2007/06/25 11:00:26  fplanque

 893   * MODULES (refactored MVC)

 894   *

 895   * Revision 1.9  2007/06/21 00:44:37  fplanque

 896   * linkblog now a widget

 897   *

 898   * Revision 1.8  2007/05/14 02:47:23  fplanque

 899   * (not so) basic Tags framework

 900   *

 901   * Revision 1.7  2007/05/13 22:53:31  fplanque

 902   * allow feeds restricted to post excerpts

 903   *

 904   * Revision 1.6  2007/05/13 22:02:07  fplanque

 905   * removed bloated $object_def

 906   *

 907   * Revision 1.5  2007/04/26 00:11:12  fplanque

 908   * (c) 2007

 909   *

 910   * Revision 1.4  2007/03/26 12:59:18  fplanque

 911   * basic pages support

 912   *

 913   * Revision 1.3  2007/03/24 20:41:16  fplanque

 914   * Refactored a lot of the link junk.

 915   * Made options blog specific.

 916   * Some junk still needs to be cleaned out. Will do asap.

 917   *

 918   * Revision 1.2  2007/03/18 03:49:20  fplanque

 919   * fix

 920   *

 921   * Revision 1.1  2007/03/18 03:43:19  fplanque

 922   * EXPERIMENTAL

 923   * Splitting Item/ItemLight and ItemList/ItemListLight

 924   * Goal: Handle Items with less footprint than with their full content

 925   * (will be even worse with multiple languages/revisions per Item)

 926   *

 927   * Revision 1.162  2007/03/11 23:57:07  fplanque

 928   * item editing: allow setting to 'redirected' status

 929   *

 930   * Revision 1.161  2007/03/06 12:18:08  fplanque

 931   * got rid of dirty Item::content()

 932   * Advantage: the more link is now independant. it can be put werever people want it

 933   *

 934   * Revision 1.160  2007/03/05 04:52:42  fplanque

 935   * better precision for viewcounts

 936   *

 937   * Revision 1.159  2007/03/05 04:49:17  fplanque

 938   * better precision for viewcounts

 939   *

 940   * Revision 1.158  2007/03/05 02:13:26  fplanque

 941   * improved dashboard

 942   *

 943   * Revision 1.157  2007/03/05 01:47:50  fplanque

 944   * splitting up Item::content() - proof of concept.

 945   * needs to be optimized.

 946   *

 947   * Revision 1.156  2007/03/03 01:14:11  fplanque

 948   * new methods for navigating through posts in single item display mode

 949   *

 950   * Revision 1.155  2007/03/02 04:40:38  fplanque

 951   * fixed/commented a lot of stuff with the feeds

 952   *

 953   * Revision 1.154  2007/03/02 03:09:12  fplanque

 954   * rss length doesn't make sense since it doesn't apply to html format anyway.

 955   * clean solutionwould be to handle an "excerpt" field separately

 956   *

 957   * Revision 1.153  2007/02/23 19:16:07  blueyed

 958   * MFB: Fixed handling of Item::content for pre-rendering (it gets passed by reference!)

 959   *

 960   * Revision 1.152  2007/02/18 22:51:26  waltercruz

 961   * Fixing a little confusion with quotes and string concatenation

 962   *

 963   * Revision 1.151  2007/02/08 03:45:40  waltercruz

 964   * Changing double quotes to single quotes

 965   *

 966   * Revision 1.150  2007/02/05 13:32:49  waltercruz

 967   * Changing double quotes to single quotes

 968   *

 969   * Revision 1.149  2007/01/26 04:52:53  fplanque

 970   * clean comment popups (skins 2.0)

 971   *

 972   * Revision 1.148  2007/01/26 02:12:06  fplanque

 973   * cleaner popup windows

 974   *

 975   * Revision 1.147  2007/01/23 03:46:24  fplanque

 976   * cleaned up presentation

 977   *

 978   * Revision 1.146  2007/01/19 10:45:42  fplanque

 979   * images everywhere :D

 980   * At this point the photoblogging code can be considered operational.

 981   *

 982   * Revision 1.145  2007/01/11 19:29:50  blueyed

 983   * Fixed E_NOTICE when using the "excerpt" feature

 984   *

 985   * Revision 1.144  2006/12/26 00:08:29  fplanque

 986   * wording

 987   *

 988   * Revision 1.143  2006/12/21 22:35:28  fplanque

 989   * No regression. But a change in usage. The more link must be configured in the skin.

 990   * Renderers cannot side-effect on the more tag any more and that actually makes the whole thing safer.

 991   *

 992   * Revision 1.142  2006/12/20 13:57:34  blueyed

 993   * TODO about regression because of pre-rendering and the <!--more--> tag

 994   *

 995   * Revision 1.141  2006/12/18 13:31:12  fplanque

 996   * fixed broken more tag

 997   *

 998   * Revision 1.140  2006/12/16 01:30:46  fplanque

 999   * Setting to allow/disable email subscriptions on a per blog basis

1000   *

1001   * Revision 1.139  2006/12/15 22:59:05  fplanque

1002   * doc

1003   *

1004   * Revision 1.138  2006/12/14 22:26:31  blueyed

1005   * Fixed E_NOTICE and displaying of pings into $Messages (though "hackish")

1006   *

1007   * Revision 1.137  2006/12/12 02:53:56  fplanque

1008   * Activated new item/comments controllers + new editing navigation

1009   * Some things are unfinished yet. Other things may need more testing.

1010   *

1011   * Revision 1.136  2006/12/07 23:13:11  fplanque

1012   * @var needs to have only one argument: the variable type

1013   * Otherwise, I can't code!

1014   *

1015   * Revision 1.135  2006/12/06 23:55:53  fplanque

1016   * hidden the dead body of the sidebar plugin + doc

1017   *

1018   * Revision 1.134  2006/12/05 14:28:29  blueyed

1019   * Fixed wordcount==0 handling; has been saved as NULL

1020   *

1021   * Revision 1.133  2006/12/05 06:38:40  blueyed

1022   * doc

1023   *

1024   * Revision 1.132  2006/12/05 00:39:56  fplanque

1025   * fixed some more permalinks/archive links

1026   *

1027   * Revision 1.131  2006/12/05 00:34:39  blueyed

1028   * Implemented custom "None" option text in DataObjectCache; Added for $ItemStatusCache, $GroupCache, UserCache and BlogCache; Added custom text for Item::priority_options()

1029   *

1030   * Revision 1.130  2006/12/04 20:52:40  blueyed

1031   * typo

1032   *

1033   * Revision 1.129  2006/12/04 19:57:58  fplanque

1034   * How often must I fix the weekly archives until they stop bugging me?

1035   *

1036   * Revision 1.128  2006/12/04 19:41:11  fplanque

1037   * Each blog can now have its own "archive mode" settings

1038   *

1039   * Revision 1.127  2006/12/03 18:15:32  fplanque

1040   * doc

1041   *

1042   * Revision 1.126  2006/12/01 20:04:31  blueyed

1043   * Renamed Plugins_admin::validate_list() to validate_renderer_list()

1044   *

1045   * Revision 1.125  2006/12/01 19:46:42  blueyed

1046   * Moved Plugins::validate_list() to Plugins_admin class; added stub in Plugins, because at least the starrating_plugin uses it

1047   *

1048   * Revision 1.124  2006/11/28 20:04:11  blueyed

1049   * No edit link, if ID==0 to avoid confusion in preview, see http://forums.b2evolution.net/viewtopic.php?p=47422#47422

1050   *

1051   * Revision 1.123  2006/11/24 18:27:24  blueyed

1052   * Fixed link to b2evo CVS browsing interface in file docblocks

1053   *

1054   * Revision 1.122  2006/11/22 20:48:58  blueyed

1055   * Added Item::get_Chapters() and Item::get_main_Chapter(); refactorized

1056   *

1057   * Revision 1.121  2006/11/22 20:12:18  blueyed

1058   * Use $format param in Item::categories()

1059   *

1060   * Revision 1.120  2006/11/19 22:17:42  fplanque

1061   * minor / doc

1062   *

1063   * Revision 1.119  2006/11/19 16:07:31  blueyed

1064   * Fixed saving empty renderers list. This should also fix the saving of "default" instead of the explicit renderer list

1065   *

1066   * Revision 1.118  2006/11/17 18:36:23  blueyed

1067   * dbchanges param for AfterItemUpdate, AfterItemInsert, AfterCommentUpdate and AfterCommentInsert

1068   *

1069   * Revision 1.117  2006/11/13 20:49:52  fplanque

1070   * doc/cleanup :/

1071   *

1072   * Revision 1.116  2006/11/10 20:14:11  blueyed

1073   * doc, fix

1074   *

1075   * Revision 1.115  2006/11/02 16:12:49  blueyed

1076   * MFB

1077   *

1078   * Revision 1.114  2006/11/02 16:01:00  blueyed

1079   * doc

1080   *

1081   * Revision 1.113  2006/10/29 18:33:23  blueyed

1082   * doc fix

1083   *

1084   * Revision 1.112  2006/10/23 22:19:02  blueyed

1085   * Fixed/unified encoding of redirect_to param. Use just rawurlencode() and no funky &amp; replacements

1086   *

1087   * Revision 1.111  2006/10/18 00:03:51  blueyed

1088   * Some forgotten url_rel_to_same_host() additions

1089   */
1090  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics