[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_lib/ -> imagegallery.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4  
   5     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6  
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11  
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15  
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19  
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  /*
  24   * phpwcmsImageGallery
  25   *
  26   * A file center driven gallery for phpwcms
  27   *
  28   */
  29  
  30  class phpwcmsImageGallery {
  31  
  32      var $url                = '';
  33      var $alias                = '';
  34      var $images                = array();
  35      var $query_separator    = '/';
  36      var $download            = false;
  37      var $download_direct    = false;
  38  
  39      // string defines the sorting mode
  40      // ASC/DESC = get images sorted by date 
  41      // RAND = get images by random)
  42      var $image_sort        = 'DESC';
  43      
  44      var $image_src        = '';
  45  
  46      // integer the limit of how many images should be retrieved
  47      var $image_limit    = 0;
  48      
  49      var $thumb_width    = 200;
  50      var $thumb_height    = 150;
  51      var $width            = 600;
  52      var $height            = 400;
  53      var $zoom            = true;
  54      var $lightbox        = true;
  55  
  56      var $galleries        = array();
  57      var $gallery        = array();
  58      
  59      // define what kind of file storage folders should be taken
  60      // true = only folders marked as gallery root or sub directory
  61      var $gallery_only    = true;
  62      
  63      // define the root ID of gallery = where to start recursive search
  64      // by default root ID = 0 which is top level
  65      var $gallery_rootid    = 0;
  66      
  67      // integer the max depth of recursive folder search, THREAD mode only 
  68      var $depth            = 0;
  69      
  70      // string defines the sorting mode:
  71      // NAME-ASC, NAME-DESC, CREATE-ASC, CREATE-DESC
  72      // get images sorted by name or create date
  73      var $gallery_sort    = 'NAME-DESC';
  74      var $_sort            = '';
  75      
  76      // string the search mode - FLAT/THREAD (FLAT = default)
  77      var $gallery_mode    = 'FLAT';
  78      
  79      // gallery name can be prefixed by date YYYY-MM-DD,
  80      // use sort by NAME-ASC or NAME-DESC,
  81      // this date will be used as gallery date then and
  82      // is stripped from name if $use_name_date = true
  83      var $use_name_date    = true;
  84      
  85      // template definitions
  86      var $list_header                = '    <div class="galleries">';
  87      var $list_footer                = '</div>';
  88      var $list_template                = '[TAB]<div class="gallery">[LF][TAB][TAB]{TITLE} [LF][TAB][TAB]{THUMBNAIL} [LF][TAB][TAB] {DESCRIPTION}[LF][TAB]</div>';
  89      var $list_title_prefix            = '<h3>[LINK]';
  90      var $list_title_suffix            = '[/LINK]</h3>';
  91      var $list_descr_prefix            = '<div><strong>{DATE:m/d/y lang=EN}</strong> &#8211; ';
  92      var $list_descr_suffix            = '</div>';
  93      // define if an gallery thumbnail should be shown
  94      // 0 = show none, 1 show first ...
  95      var $list_thumbnail                = 1;
  96      var $list_thumbnail_width        = 150;
  97      var $list_thumbnail_height        = 150;
  98      var $list_thumbnail_crop        = 0;
  99      var $list_thumbnail_prefix        = '<div class="thumbnail">';
 100      var $list_thumbnail_suffix        = '</div>';
 101      
 102      var $detail_header                = '<div class="gallery">';
 103      var $detail_footer                = '</div>';
 104      var $detail_title_prefix        = '<h2><strong>{DATE:m/d/y lang=EN}</strong> &#8211; ';
 105      var $detail_title_suffix        = '</h2>';
 106      var $detail_descr_prefix        = '<div>';
 107      var $detail_descr_suffix        = '</div>';
 108      var $detail_thumbnail_crop        = 0;
 109      var $detail_thumbnail_prefix    = '<div class="thumbnail">';
 110      var $detail_thumbnail_suffix    = '{DOWNLOAD}</div>';
 111      var $detail_thumbnail_caption    = false;
 112      var $detail_zoom_crop            = false;
 113      var $detail_caption_prefix        = '<div class="caption">';
 114      var $detail_caption_suffix        = '</div>';
 115      var $detail_gallery_back        = '<div class="backlink">[LINK]Show all galleries[/LINK]</div>';
 116      
 117      
 118      var $item_template                = '[TAB]{TITLE} [LF][TAB][TAB]{THUMBNAIL} [LF][TAB][TAB] {DESCRIPTION}';
 119      var $item_header                = '<div class="gallery">';
 120      var $item_footer                = '</div>';
 121      var $item_title_prefix            = '<h3>[LINK]';
 122      var $item_title_suffix            = '[/LINK]</h3>';
 123      var $item_descr_prefix            = '<div><strong>{DATE:m/d/y lang=EN}</strong> &#8211; ';
 124      var $item_descr_suffix            = '</div>';
 125      var $item_download_template        = 'default';
 126      // define if an gallery thumbnail should be shown
 127      // 0 = show none, 1 show first ...
 128      var $item_thumbnail                = 1;
 129      var $item_thumbnail_width        = 150;
 130      var $item_thumbnail_height        = 150;
 131      var $item_thumbnail_crop        = 0;
 132      var $item_thumbnail_prefix        = '<div class="thumbnail">';
 133      var $item_thumbnail_suffix        = '</div>';
 134      
 135      var $list_image_header            = '<div class="gallery-image-list">';
 136      var $list_image_footer            = '</div>';
 137      var $list_image_prefix            = '<div class="image">[LINK]';
 138      var $list_image_suffix            = '[/LINK]</div>';
 139      var $list_image_width            = 100;
 140      var $list_image_height            = 100;
 141      var $list_image_crop            = 0;
 142  
 143      var $line_break                    = "\n\t";
 144      
 145      /*
 146       * Initialize some defaults
 147       */    
 148  	function phpwcmsImageGallery() {
 149      
 150          $this->_getGallerySortString();
 151      
 152          if($this->alias === '') {
 153              global $aktion;
 154              $this->alias = defined('PHPWCMS_ALIAS') ? PHPWCMS_ALIAS : ( $aktion[1] == 0 ? 'id='.$aktion[0] : 'aid='.$aktion[1] );
 155          }
 156          
 157          $this->setAlias( $this->alias );
 158      
 159          $this->image_src = PHPWCMS_URL.'img/cmsimage.php'.$this->query_separator;
 160      
 161      }
 162      
 163  	function setQuerySeparator($query_separator) {
 164      
 165          $this->image_src = PHPWCMS_URL.'img/cmsimage.php'.$query_separator;
 166      
 167      }
 168      
 169  	function setAlias($alias='') {
 170          if($alias !== '') {
 171              $this->alias = $alias;
 172          }
 173          $this->url = PHPWCMS_URL.'index.php'.returnGlobalGET_QueryString('htmlentities', array(), array('gallery'), $this->alias);
 174      }
 175      
 176  	function setGallerySort($sort='') {
 177      
 178          $this->gallery_sort = $sort;
 179          $this->_getGallerySortString();
 180      
 181      }
 182  
 183  
 184      /*
 185       * get images
 186       *
 187       * Dive into phpwcms's db file storage and get all 
 188       * images based on given mode, starting at folder ID.
 189       *
 190       * @param mixed use integer value for 1 folder or array for multiple 
 191       */
 192  	function getImages($folder=0) {
 193      
 194          $folders        = array();
 195          $this->images    = array();
 196  
 197          if( is_array($folder) ) {
 198              foreach($folder as $item) {
 199                  $item = intval($item);
 200                  $folders[ $item ] = $item;
 201              }
 202          } else {
 203              $folders[] = intval($folder);    
 204          }
 205          
 206          if(count($folders)) {
 207              $folders = implode(',', $folders);
 208          }
 209      
 210          // check if folder(s) is(are) live
 211          $sql  = 'SELECT COUNT(*) FROM '.DB_PREPEND.'phpwcms_file WHERE ';
 212          $sql .= 'f_id IN (' . $folders . ') AND f_kid=0 AND f_trash=0 AND f_aktiv=1 AND f_public=1';
 213          if(_dbCount($sql) > 0) {
 214          
 215              $this->image_limit    = intval($this->image_limit);
 216              $this->image_sort    = strtoupper($this->image_sort);
 217          
 218              switch($this->image_sort) {
 219                  case 'ASC':                    $order_by = ' ORDER BY f_created ASC';                    break;
 220                  case 'RAND':                $order_by = ' ORDER BY RAND()';                            break;
 221                  case 'SORT-ASC':            $order_by = ' ORDER BY f_sort ASC';                        break;
 222                  case 'SORT-DESC':            $order_by = ' ORDER BY f_sort DESC';                    break;
 223                  case 'SORT-NAME-ASC':        $order_by = ' ORDER BY f_sort ASC, f_name ASC';            break;
 224                  case 'SORT-NAME-DESC':        $order_by = ' ORDER BY f_sort DESC, f_name DESC';        break;
 225                  case 'SORT-CREATE-ASC':        $order_by = ' ORDER BY f_sort ASC, f_created ASC';        break;
 226                  case 'SORT-CREATE-DESC':    $order_by = ' ORDER BY f_sort DESC, f_created DESC';    break;
 227                  default:                    $order_by = ' ORDER BY f_created DESC';
 228              }
 229              $sql  = 'SELECT * FROM '.DB_PREPEND.'phpwcms_file WHERE ';
 230              $sql .= 'f_pid IN (' . $folders . ') AND f_kid=1 AND ';
 231              $sql .= 'f_trash=0 AND f_aktiv=1 AND f_public=1 AND ';
 232              $sql .= "f_ext IN ('jpg', 'jpeg', 'gif', 'png')";
 233              $sql .= $order_by;
 234              if($this->image_limit > 0) { 
 235                  $sql .= ' LIMIT ' . $this->image_limit;
 236              }
 237              $result = _dbQuery($sql);
 238              if(isset($result[0])) {
 239                  $this->images = $result;
 240              }
 241          }
 242      }
 243      
 244  
 245      /*
 246       * get galleries
 247       *
 248       * Starting with given folder ID an array with all folder
 249       * information inside are returned.
 250       *
 251       */
 252  	function getGalleries($folder_id = 0) {
 253      
 254          $folder_id            = intval($folder_id);
 255  
 256          /* yet unsupported         
 257          $this->depth        = intval($this->depth);
 258  
 259          if(strtoupper($this->gallery_mode) === 'THREAD' && $this->depth > 0) {
 260              $this->gallery_mode    = 'THREAD';
 261          } else {
 262              $this->gallery_mode    = 'FLAT';
 263              $this->depth        = 0;
 264          }
 265          */
 266          
 267          $sql  = 'SELECT * FROM '.DB_PREPEND.'phpwcms_file WHERE ';
 268          $sql .= 'f_pid='.$folder_id.' AND f_kid=0 AND f_trash=0 AND f_aktiv=1 AND f_public=1';
 269          $sql .= $this->gallery_sort;
 270      
 271          $this->galleries = _dbQuery($sql);
 272          $this->proofGallery();
 273      }
 274  
 275  
 276      /*
 277       * check gallery array and set names
 278       */
 279  	 function proofGallery() {
 280          if(!isset($this->galleries[0])) {
 281              $this->galleries = array();
 282              return;
 283          }
 284          if($this->use_name_date === true) {
 285              foreach($this->galleries as $key => $row) {
 286                  $this->_stripDateFromName( $this->galleries[$key] );                            
 287              }
 288          }
 289      }
 290  
 291  
 292      /*
 293       * search for gallery name date and strip it.
 294       * if some date is found set gallery create date to it
 295       */    
 296  	function _stripDateFromName(&$gallery) {
 297      
 298          // search gallery name for matching date YYYY-MM-DD
 299          if( preg_match('/^([0-9]{2}|[0-9]{4})\-([0]{0,1}[0-9])\-([0-9]{1,2})(.+)/', $gallery['f_name'], $match) ) {
 300  
 301              $name                = trim($match[4]);
 302              $gallery['f_name']    = $name;
 303              
 304              $year    = intval($match[1]);
 305              $month    = intval($match[2]);
 306              $day    = intval($match[3]);
 307              
 308              if($month > 12 || $month == 0) {
 309                  $month = 1;
 310              }            
 311              if($day > 31 || $day == 0) {
 312                  $day = 1;
 313              }
 314  
 315              $date = mktime(11 , 59, 59, $month, $day, $year);
 316              if($date) {
 317                  $gallery['f_created'] = $date;
 318              }
 319          }
 320      }
 321  
 322      
 323  	function getGalleriesFolderId($folder=NULL) {
 324      
 325          if( $folder !== NULL ) {
 326              $this->getGalleries( intval($folder) );
 327          }
 328          
 329          $folderId = array();
 330          
 331          foreach($this->galleries as $item) {
 332          
 333              $folderId[] = $item['f_id'];
 334          
 335          }
 336          
 337          return $folderId;
 338      
 339      }
 340  
 341  
 342      /*
 343       * get gallery information
 344       */    
 345  	function getGallery($folder_id=0) {
 346          
 347          $folder_id            = intval($folder_id);
 348          
 349          $sql  = 'SELECT * FROM '.DB_PREPEND.'phpwcms_file WHERE ';
 350          $sql .= 'f_id='.$folder_id.' AND f_kid=0 AND f_trash=0 AND f_aktiv=1 AND f_public=1';
 351          $sql .= $this->gallery_sort;
 352      
 353          $this->galleries = _dbQuery($sql);
 354          $this->proofGallery();
 355          
 356          if( count($this->galleries) && isset($this->galleries[0]['f_id']) ) {
 357          
 358              $this->gallery = $this->galleries[0];
 359          
 360          } else {
 361          
 362              $this->gallery = array();
 363          
 364          }
 365      
 366      }
 367  
 368      
 369  	function _getGallerySortString() {
 370          
 371          if( $this->_sort === '' || !is_string( $this->_sort ) ) {
 372          
 373              $this->gallery_sort    = strtoupper($this->gallery_sort);
 374              
 375              switch($this->gallery_sort) {
 376              
 377                  case 'NAME-DESC':
 378                      $this->gallery_sort = ' ORDER BY f_name DESC';
 379                      break;
 380                      
 381                  case 'SORT-DESC':
 382                      $this->gallery_sort = ' ORDER BY f_sort DESC';
 383                      break;
 384                      
 385                  case 'SORT-ASC':
 386                      $this->gallery_sort = ' ORDER BY f_sort ASC';
 387                      break;
 388                      
 389                  case 'SORT-NAME-DESC':
 390                      $this->gallery_sort = ' ORDER BY f_sort DESC, f_name DESC';
 391                      break;
 392                      
 393                  case 'SORT-NAME-ASC':
 394                      $this->gallery_sort = ' ORDER BY f_sort ASC, f_name ASC';
 395                      break;
 396                      
 397                  case 'SORT-CREATE-DESC':
 398                      $this->gallery_sort = ' ORDER BY f_sort DESC, f_created DESC';
 399                      break;
 400                      
 401                  case 'SORT-CREATE-ASC':
 402                      $this->gallery_sort = ' ORDER BY f_sort ASC, f_created ASC';
 403                      break;
 404              
 405                  case 'CREATE-ASC':
 406                      $this->gallery_sort = ' ORDER BY f_created ASC';
 407                      break;
 408                              
 409                  case 'CREATE-DESC':
 410                      $this->gallery_sort = ' ORDER BY f_created DESC';
 411                      break;
 412              
 413                  default: // NAME-ASC
 414                      $this->gallery_sort = ' ORDER BY f_name ASC';
 415  
 416              }
 417          }
 418      }
 419  
 420      
 421  	function listGalleries($folder=NULL) {
 422      
 423          if( $folder !== NULL) {
 424              $this->getGalleries( intval($folder) );
 425          }
 426      
 427          $listing = array();
 428          
 429          // loop galleries
 430          foreach($this->galleries as $item) {
 431              
 432              $listing[] = $this->parse($item);
 433              
 434          }
 435          
 436          if(count($listing)) {
 437          
 438              // add gallery listing header
 439              array_unshift($listing, $this->list_header);
 440          
 441              // add gallery listing footer
 442              array_push($listing, $this->list_footer);
 443  
 444              return implode($this->line_break, $listing);
 445          }
 446          
 447          // return empty string
 448          return '';
 449      }
 450      
 451  	function showGallery($folder=NULL) {
 452      
 453          if( $folder !== NULL ) {
 454              $this->getGallery( $folder );
 455          }
 456          
 457          if( count($this->gallery) ) {
 458          
 459              $gallery    = array();
 460              
 461              $gallery[]    = $this->detail_header;
 462          
 463              $gallery[]    = $this->detail_title_prefix . html_specialchars($this->gallery['f_name']) . $this->detail_title_suffix;
 464              
 465              if( trim( $this->gallery['f_longinfo'] ) != '' ) {
 466                  $gallery[]    = $this->detail_descr_prefix . ( plaintext_htmlencode($this->gallery['f_longinfo']) ) . $this->detail_descr_suffix;
 467              }
 468              
 469              $gallery[]    = $this->listGalleryImages( $this->gallery['f_id'] );
 470              
 471                          // replaces gallery linking
 472              $this->detail_gallery_back    = str_replace('[/LINK]', '</a>', $this->detail_gallery_back);
 473              $this->detail_gallery_back    = str_replace('[LINK]', '<a href="' . $this->url . '">', $this->detail_gallery_back);
 474              $gallery[]    = $this->detail_gallery_back;
 475              
 476              $gallery[]    = $this->detail_footer;
 477              
 478              $gallery    = implode($this->line_break, $gallery);
 479              
 480              $gallery    = render_cnt_date($gallery, $this->gallery['f_created']);
 481  
 482              return $this->parseGeneral( $gallery );
 483          
 484          }
 485          
 486          return '';
 487      }
 488      
 489  	function listGalleryImages($folder, $sort=NULL) {
 490      
 491          if($sort !== NULL) {
 492              $temp_sort    = $this->image_sort;
 493              $this->image_sort    = $sort;
 494          }
 495          
 496          $this->getImages( $folder );
 497  
 498          if($sort !== NULL) {
 499              $this->image_sort    = $temp_sort;
 500          }
 501  
 502          $images = array();
 503  
 504          foreach($this->images as $image) {
 505          
 506              $name = html_specialchars( $image['f_name'] );
 507              $image['f_longinfo'] = trim($image['f_longinfo']);
 508   
 509              $img  = '<img src="';
 510              $img .= $this->image_src . $this->thumb_width . 'x' . $this->thumb_height;
 511              if($this->detail_thumbnail_crop == 1) {
 512                  $img .= 'x1';
 513              }
 514              $img .= '/' . $image['f_hash'] . '.' . $image['f_ext'];
 515              $img .= '" alt="' . $name . '" border="0" />';
 516              
 517              // create zoom
 518              if($this->zoom === true || $this->lightbox === true) {
 519                  
 520                  $a = '<a href="' . $this->image_src . $this->width . 'x' . $this->height;
 521                  if($this->detail_zoom_crop == 1) {
 522                      $a .= 'x1';
 523                  }
 524                  $a .= '/' . $image['f_hash'] . '.' . $image['f_ext'] . '" target="_blank"';
 525                  
 526                  if($this->lightbox === true) {
 527                      $a .= ' rel="lightbox[gallery'.$folder.']"';
 528                  }
 529                  if($image['f_longinfo'] != '') {
 530                  
 531                      $a .= ' title="' . parseLightboxCaption($image['f_longinfo']) . '"';
 532                  
 533                  }
 534                  
 535                  $a .= '>';
 536                  
 537                  $img = $a . $img .'</a>';
 538  
 539              }
 540              
 541              if( $this->detail_thumbnail_caption === true && $image['f_longinfo'] != '' ) {
 542              
 543                  $img .= $this->line_break;
 544                  $img .= $this->detail_caption_prefix . ( plaintext_htmlencode($image['f_longinfo']) ) . $this->detail_caption_suffix;
 545              
 546              }
 547              
 548              $img = $this->detail_thumbnail_prefix . $img . $this->detail_thumbnail_suffix;
 549              
 550              // prepare item download
 551              if($this->download) {
 552              
 553                  if(!isset($phpwcms)) {
 554                      global $phpwcms;
 555                  }
 556                  
 557                  $IS_NEWS_CP                            = true;
 558                  $crow                                = array();
 559                  $value                                = array();
 560                  $value['cnt_object']                = array();
 561                  $value['cnt_object']['cnt_files']    = array( 'id' => array($image['f_id']), 'caption' => $image['f_copyright'] );
 562  
 563                  $value['files_direct_download']        = $this->download_direct ? 1 : 0;
 564                  $value['files_template']            = $this->item_download_template == 'default' ? '' : $this->item_download_template;
 565                  
 566                  $news                                 = array('files_result' => '');
 567                  $content                            = array();
 568                  $content['file_static_result'][0]    = $image;
 569                  
 570                  // include content part files renderer
 571                  include (PHPWCMS_ROOT.'/include/inc_front/content/cnt7.article.inc.php');
 572                  
 573                  $img = render_cnt_template($img, 'DOWNLOAD', $news['files_result'] );
 574              
 575                  unset($IS_NEWS_CP);
 576              
 577              } else {
 578                  
 579                  $img = render_cnt_template($img, 'DOWNLOAD', '' );
 580              
 581              }
 582              
 583              $images[] = $img;
 584  
 585          }
 586          
 587          if($this->lightbox === true) {
 588          
 589              initializeLightbox();
 590          
 591          }
 592  
 593          return implode($this->line_break, $images);
 594      }
 595      
 596      
 597  	function listImages($folder, $limit=NULL, $sort=NULL) {
 598      
 599          if($limit !== NULL) {
 600              $temp_limit    = $this->image_limit;
 601              $this->image_limit    = $limit;
 602          }
 603          if($sort !== NULL) {
 604              $temp_sort    = $this->image_sort;
 605              $this->image_sort    = $sort;
 606          }
 607          
 608          $this->getImages( $folder );
 609  
 610          if($limit !== NULL) {
 611              $this->image_limit    = $temp_limit;
 612          }
 613          if($sort !== NULL) {
 614              $this->image_sort    = $temp_sort;
 615          }
 616  
 617          $images = array();
 618  
 619          foreach($this->images as $image) {
 620          
 621              $name = html_specialchars( $image['f_name'] );
 622  
 623              $img  = '<img src="';
 624              $img .= $this->image_src . $this->list_image_width . 'x' . $this->list_image_height;
 625              if($this->list_image_crop == 1) {
 626                  $img .= 'x1';
 627              }
 628              $img .= '/' . $image['f_hash'] . '.' . $image['f_ext'];
 629              $img .= '" alt="' . $name . '" border="0" />';
 630              
 631              $images[] = $this->list_image_prefix . $img . $this->list_image_suffix;
 632  
 633          }
 634          
 635          if(count($images)) {
 636  
 637              // add gallery listing header
 638              array_unshift($images, $this->list_image_header);
 639          
 640              // add gallery listing footer
 641              array_push($images, $this->list_image_footer);
 642              
 643              $images = implode($this->line_break, $images);
 644              
 645              // replaces gallery linking
 646              $images = str_replace('[/LINK]', '</a>', $images);
 647              $images    = str_replace('[LINK]', '<a href="' . $this->url . '">', $images);
 648  
 649              return $images;
 650          }
 651          
 652          // nothing to return than empty string
 653          return '';
 654      }
 655      
 656      
 657  	function parse($item, $type='GALLERY_ITEM') {
 658      
 659          if($type === 'GALLERY_ITEM') {
 660          
 661              $entry    = $this->list_template;
 662              
 663              $name    = html_specialchars( $item['f_name'] );
 664              $link    = $this->url . '&amp;gallery=' . $item['f_id'];
 665              $title    = $this->list_title_prefix . $name . $this->list_title_suffix;
 666              $descr    = trim( $item['f_longinfo'] );
 667              if($descr !== '') {
 668                  $descr = $this->list_descr_prefix . ( plaintext_htmlencode( $descr ) ) . $this->list_descr_suffix;
 669              }
 670              $thumbs = array();
 671              
 672              // get preview/thumbnail image(s) for this gallery
 673              if($this->list_thumbnail > 0) {
 674                  
 675                  $temp_limit    = $this->image_limit;
 676                  $temp_sort    = $this->image_sort;
 677                  
 678                  $this->image_limit    = $this->list_thumbnail;
 679                  $this->image_sort    = 'DESC';
 680                  $this->getImages( $item['f_id'] );
 681                  
 682                  foreach($this->images as $image) {
 683                  
 684                      $img  = '<img src="';
 685                      $img .= $this->image_src . $this->list_thumbnail_width . 'x' . $this->list_thumbnail_height;
 686                      if($this->list_thumbnail_crop == 1) {
 687                          $img .= 'x1';
 688                      }
 689                      $img .= '/' . $image['f_hash'] . '.' . $image['f_ext'];
 690                      $img .= '" alt="' . $name . '" border="0" />';
 691                      
 692                      $thumbs[] = $this->list_thumbnail_prefix . $img . $this->list_thumbnail_suffix;
 693              
 694                  }
 695                  
 696                  $this->image_limit    = $temp_limit;
 697                  $this->image_sort    = $temp_sort;
 698              
 699              }
 700  
 701              $thumbs    = implode(LF, $thumbs);
 702              
 703              $entry    = str_replace('{TITLE}', $title, $entry);
 704              $entry    = str_replace('{DESCRIPTION}', $descr, $entry);
 705              $entry    = str_replace('{THUMBNAIL}', $thumbs, $entry);
 706              $entry    = str_replace('[/LINK]', '</a>', $entry);
 707              $entry    = str_replace('[LINK]', '<a href="' . $link . '" title="' . $name . '">', $entry);
 708              $entry    = render_cnt_date($entry, $item['f_created']);
 709              
 710              return $this->parseGeneral( $entry );
 711          }
 712      
 713      }
 714      
 715  	function parseGeneral($string='') {
 716      
 717          $string = str_replace( '[LF]', LF, $string);
 718          $string = str_replace( '[TAB]', "\t", $string);
 719      
 720          return $string;
 721      }
 722      
 723  
 724  	function getGalleryTree() {
 725      
 726          $sql  = 'SELECT * FROM '.DB_PREPEND.'phpwcms_file ';
 727          $sql .= 'WHERE f_kid=0 AND f_aktiv=1 AND f_public=1';
 728          if($this->gallery_only) {
 729              $sql .= ' AND f_gallerystatus=2';
 730          }
 731          $this->gallery_rootid = intval($this->gallery_rootid);
 732          if($this->gallery_rootid > 0) {
 733              $sql .= ' AND f_pid='.$this->gallery_rootid;
 734          }
 735          $sql .= $this->gallery_sort;
 736      
 737          return _dbQuery($sql);
 738      
 739      }
 740      
 741  	function getGallerySub($parent=0) {
 742  
 743          $sql  = 'SELECT * FROM '.DB_PREPEND.'phpwcms_file ';
 744          $sql .= 'WHERE f_kid=0 AND f_aktiv=1 AND f_public=1';
 745          if($this->gallery_only) {
 746              $sql .= ' AND f_gallerystatus IN(3,2)';
 747          }
 748          $sql .= ' AND f_pid='.intval($parent);
 749          $sql .= $this->gallery_sort;
 750      
 751          return _dbQuery($sql);
 752      
 753      }
 754      
 755  }
 756  
 757  ?>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7