b2evolution PHP Cross Reference Blogging Systems

Source: /inc/links/model/_link.class.php - 151 lines - 3447 bytes - Summary - Text - Print

Description: This file implements the Link class, which manages extra links on items. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the Link class, which manages extra links on items.
   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-2014 by Francois Planque - {@link http://fplanque.com/}
   9   *
  10   * {@internal License choice
  11   * - If you have received this file as part of a package, please find the license.txt file in
  12   *   the same folder or the closest folder above for complete license terms.
  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  14   *   then you must choose one of the following licenses before using the file:
  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  17   * }}
  18   *
  19   * {@internal Open Source relicensing agreement:
  20   * }}
  21   *
  22   * @package evocore
  23   *
  24   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  25   * @author fplanque: Francois PLANQUE.
  26   *
  27   * @version $Id: _link.class.php 6136 2014-03-08 07:59:48Z manuel $
  28   */
  29  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  30  
  31  load_class( '_core/model/dataobjects/_dataobject.class.php', 'DataObject' );
  32  
  33  /**
  34   * Item Link
  35   *
  36   * @package evocore
  37   */
  38  class Link extends DataObject
  39  {
  40      var $ltype_ID = 0;
  41      var $file_ID = 0;
  42      /**
  43       * @var Link owner object
  44       */
  45      var $LinkOwner;
  46      /**
  47       * @access protected Use {@link get_File()}
  48       */
  49      var $File;
  50  
  51  
  52      /**
  53       * Constructor
  54       *
  55       * @param table Database row
  56       */
  57  	function Link( $db_row = NULL )
  58      {
  59          // Call parent constructor:
  60          parent::DataObject( 'T_links', 'link_', 'link_ID',
  61                                                      'datecreated', 'datemodified', 'creator_user_ID', 'lastedit_user_ID' );
  62  
  63          if( $db_row != NULL )
  64          {
  65              $this->ID       = $db_row->link_ID;
  66              $this->ltype_ID = $db_row->link_ltype_ID;
  67  
  68              // source of link:
  69              if( $db_row->link_itm_ID != NULL )
  70              { // Item
  71                  $this->LinkOwner = & get_link_owner( 'item', $db_row->link_itm_ID );
  72              }
  73              elseif( $db_row->link_cmt_ID != NULL )
  74              { // Comment
  75                  $this->LinkOwner = & get_link_owner( 'comment', $db_row->link_cmt_ID );
  76              }
  77              else
  78              { // User
  79                  $this->LinkOwner = & get_link_owner( 'user', $db_row->link_usr_ID );
  80              }
  81  
  82              $this->file_ID = $db_row->link_file_ID;
  83  
  84              // TODO: dh> deprecated, check where it's used, and fix it.
  85              $this->File = & $this->get_File();
  86  
  87              $this->position = $db_row->link_position;
  88              $this->order = $db_row->link_order;
  89          }
  90          else
  91          {    // New object:
  92  
  93          }
  94      }
  95  
  96  
  97      /**
  98       * Get (@link LinkOwner) of the link
  99       * 
 100       * @return LinkOwner
 101       */
 102      function & get_LinkOwner()
 103      {
 104          return $this->LinkOwner;
 105      }
 106  
 107  
 108      /**
 109       * Get {@link File} of the link.
 110       *
 111       * @return File
 112       */
 113      function & get_File()
 114      {
 115          if( ! isset($this->File) )
 116          {
 117              if( isset($GLOBALS['files_Module']) )
 118              {
 119                  $FileCache = & get_FileCache();
 120                  // fp> do not halt on error. For some reason (ahem bug) a file can disappear and if we fail here then we won't be
 121                  // able to delete the link
 122                  $this->File = & $FileCache->get_by_ID( $this->file_ID, false, false );
 123              }
 124              else
 125              {
 126                  $this->File = NULL;
 127              }
 128          }
 129          return $this->File;
 130      }
 131  
 132  
 133      /**
 134       * Return type of target for this Link:
 135       *
 136       * @todo incomplete
 137       */
 138  	function target_type()
 139      {
 140           if( !is_null($this->File) )
 141          {
 142              return 'file';
 143          }
 144  
 145  
 146          return 'unkown';
 147      }
 148  
 149  }
 150  
 151  ?>

title

Description

title

Description

title

Description

title

title

Body