[ Index ]

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

title

Body

[close]

/include/inc_front/content/ -> cnt31.article.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  // 2009-07-22 Thumbnail max width and max height replacement tag implemented
  24  //            Thanks to Gerd Müller for proposal and code sample
  25  
  26  // ----------------------------------------------------------------
  27  // obligate check for phpwcms constants
  28  if (!defined('PHPWCMS_ROOT')) {
  29     die("You Cannot Access This Script Directly, Have a Nice Day.");
  30  }
  31  // ----------------------------------------------------------------
  32  
  33  
  34  //images (gallery)
  35  
  36  $image    = @unserialize($crow["acontent_form"]);
  37  
  38  // read template
  39  if(empty($crow["acontent_template"]) && is_file(PHPWCMS_TEMPLATE.'inc_default/imagespecial.tmpl')) {
  40  
  41      $image['template']    = @file_get_contents(PHPWCMS_TEMPLATE.'inc_default/imagespecial.tmpl');
  42      
  43  } elseif(is_file(PHPWCMS_TEMPLATE.'inc_cntpart/imagespecial/'.$crow["acontent_template"])) {
  44  
  45      $image['template']    = @file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/imagespecial/'.$crow["acontent_template"]);
  46  
  47  } else {
  48  
  49      $image['template']    = '';
  50  
  51  }
  52  
  53  if($image['template']) {
  54  
  55      $image['tmpl_header']            = get_tmpl_section('IMAGES_HEADER', $image['template']);
  56      $image['tmpl_footer']            = get_tmpl_section('IMAGES_FOOTER', $image['template']);
  57      $image['tmpl_entry']            = get_tmpl_section('IMAGES_ENTRY', $image['template']);
  58      $image['tmpl_entry_space']        = get_tmpl_section('IMAGES_ENTRY_SPACER', $image['template']);
  59      $image['tmpl_row_space']        = get_tmpl_section('IMAGES_ROW_SPACER', $image['template']);
  60      $image['tmpl_thumb_width_max']    = 0;
  61      $image['tmpl_thumb_height_max']    = 0;
  62      $image['tmpl_images']            = array();
  63      
  64      $image['template']  = $image['tmpl_header'];
  65  
  66      if(is_array($image['images']) && ($image['count'] = count($image['images']))) {
  67  
  68          // Start lightbox
  69          if(empty($image['lightbox'])) {
  70              $image['lightbox'] = false;
  71          } else {
  72              initializeLightbox();
  73              $image['lightbox'] = generic_string(5);
  74          }
  75          
  76          switch($image['center']) {
  77          
  78              case 1:        // center hor/vert
  79                          if(!$image['width'] && !$image['height']) {
  80                              $image['center'] = 0;
  81                          } elseif(!$image['width']) {
  82                              $image['center'] = 3;
  83                          } elseif(!$image['height']) {
  84                              $image['center'] = 2;
  85                          }
  86                          break;
  87                          
  88              case 2:        // center hor
  89                          if(!$image['width']) {
  90                              $image['center'] = 0;
  91                          }
  92                          break;
  93              
  94              case 3:        // center vert
  95                          if(!$image['height']) {
  96                              $image['center'] = 0;
  97                          }
  98                          break;
  99              
 100              default:    $image['center'] = 0;
 101          
 102          
 103          }
 104          
 105          $x   = 0;
 106          $col = 0;
 107  
 108          foreach($image['images'] as $key => $value) {
 109          
 110              $thumb_image        = false;
 111              $zoominfo            = false;
 112              
 113              if($value['thumb_hash']) {
 114  
 115                  $thumb_image = get_cached_image(
 116                              array(    "target_ext"    =>    $value['thumb_ext'],
 117                                      "image_name"    =>    $value['thumb_hash'] . '.' . $value['thumb_ext'],
 118                                      "max_width"        =>    $image['width'],
 119                                      "max_height"    =>    $image['height'],
 120                                      "thumb_name"    =>    md5(    $value['thumb_hash'].$image['width'].
 121                                                                  $image['height'].$phpwcms["sharpen_level"].
 122                                                                  $image['crop']
 123                                                              ),
 124                                      'crop_image'    =>    $image['crop']
 125                                    )
 126                              );
 127              }
 128              
 129              if(!$value['thumb_hash'] || !$thumb_image) {
 130                  continue;
 131              }
 132              
 133              $img_zoom_id        = '';
 134              $img_zoom_hash        = '';
 135              $img_zoom_ext        = '';
 136              $img_zoom_name        = '';
 137              $img_zoom_filename    = '';
 138              $img_zoom_rel        = '';
 139              $img_zoom_abs        = '';
 140              $img_zoom_width        = '';
 141              $img_zoom_height    = '';
 142              
 143              $col++;
 144              
 145              // put spacer content between images
 146              if($col > 1) {
 147              
 148                  $image['tmpl_images'][$x] .= $image['tmpl_entry_space'];
 149              
 150              } else {
 151              
 152                  $image['tmpl_images'][$x]  = '';
 153              
 154              }
 155  
 156              if($value['zoom_hash'] && $image['zoom']) {
 157  
 158                  $zoominfo = get_cached_image(
 159                          array(    "target_ext"    =>    $value['zoom_ext'],
 160                                  "image_name"    =>    $value['zoom_hash'] . '.' . $value['zoom_ext'],
 161                                  "max_width"        =>    $image['width_zoom'],
 162                                  "max_height"    =>    $image['height_zoom'],
 163                                  "thumb_name"    =>    md5(    $value['zoom_hash'].$image['width_zoom'].
 164                                                              $image['height_zoom'].$phpwcms["sharpen_level"].
 165                                                              $image['crop_zoom']
 166                                                          ),
 167                                  'crop_image'    =>    $image['crop_zoom']
 168                                )
 169                          );
 170              }
 171  
 172              // set caption and ALT Image Text for imagelist
 173              $capt_cur            = html_specialchars($value['caption']);
 174              $caption            = array();
 175              $caption[1]         = html_specialchars($value['thumb_name']);
 176              $caption[2]            = explode(' ', $value['url']);
 177              $caption[2][1]        = empty($caption[2][1]) ? '' : ' target="'.$caption[2][1].'"';
 178              $caption[3]         = empty($value['caption']) ? '' : ' title="'.$capt_cur.'"'; //title
 179  
 180              $list_img_temp      = '<img src="'.PHPWCMS_IMAGES.$thumb_image[0].'" ';
 181              
 182              $img_thumb_name        = $thumb_image[0];
 183              $img_thumb_rel        = PHPWCMS_IMAGES.$thumb_image[0];
 184              $img_thumb_abs        = PHPWCMS_URL.PHPWCMS_IMAGES.$thumb_image[0];
 185              $img_thumb_width    = $thumb_image[1];
 186              $img_thumb_height    = $thumb_image[2];
 187              $img_thumb_filename    = $value['thumb_name'];
 188              
 189              if($image['center']) {
 190              
 191                  $img_margin_left    = 0;
 192                  $img_margin_right    = 0;
 193                  $img_margin_top        = 0;
 194                  $img_margin_bottom    = 0;
 195  
 196                  // center hor/vert
 197                  if($image['center'] == 1 || $image['center'] == 2) {
 198                      $img_margin_left    = ceil( ($image['width'] - $thumb_image[1]) / 2 );                
 199                      $img_margin_right    = $image['width'] - $thumb_image[1] - $img_margin_left;
 200                  }
 201                  if($image['center'] == 1 || $image['center'] == 3) {
 202                      $img_margin_top        = ceil( ($image['height'] - $thumb_image[2]) / 2 );
 203                      $img_margin_bottom    = $image['height'] - $thumb_image[2] - $img_margin_top;
 204                  }
 205                  
 206                  $list_img_style        = 'style="margin:'.$img_margin_top.'px '.$img_margin_right.'px '.$img_margin_bottom.'px '.$img_margin_left.'px;" ';
 207                  $list_ahref_style    = '';
 208                  $list_img_temp       .= $list_img_style;
 209                  
 210              } else {
 211                  $list_img_style        = '';
 212                  $list_ahref_style    = '';
 213              }
 214              $list_img_temp .= $thumb_image[3].' alt="'.$caption[1].'"'.$caption[3].' border="0" />';
 215              $img_a            = '';
 216              $lightbox_capt  = '';
 217  
 218              if($image['zoom'] && isset($zoominfo) && $zoominfo != false) {
 219                  // if click enlarge the image
 220                  $open_popup_link = 'image_zoom.php?'.getClickZoomImageParameter($zoominfo[0].'?'.$zoominfo[3]);
 221                  if($caption[2][0]) {
 222                      $open_link = $caption[2][0];
 223                      $return_false = '';
 224                  } else {
 225                      $open_link = $open_popup_link;
 226                      $return_false = 'return false;';
 227                  }
 228                  
 229                  if($image['lightbox'] && $capt_cur) {
 230                      $lightbox_capt = 'title="'.parseLightboxCaption($capt_cur).'" ';
 231                  }
 232                  
 233                  if(!$image['lightbox'] || $caption[2][0]) {
 234                  
 235                      $img_a .= '<a href="'.$open_link."\" onclick=\"checkClickZoom();clickZoom('".$open_popup_link."','previewpic','width=";
 236                      $img_a .= $zoominfo[1].",height=".$zoominfo[2]."');".$return_false.'"'.$caption[2][1];
 237                      $img_a .= $list_ahref_style.'>';
 238                      
 239                  } else {
 240                  
 241                      // lightbox
 242                      $img_a .= '<a href="'.PHPWCMS_IMAGES.$zoominfo[0].'" rel="lightbox['.$image['lightbox'].']" ';
 243                      $img_a .= $lightbox_capt;
 244                      $img_a .= $list_ahref_style.'target="_blank">';
 245                  
 246                  }
 247                  
 248                  $img_a .= $list_img_temp.'</a>';
 249                  
 250                  $img_zoom_id        = $value['zoom_id'];
 251                  $img_zoom_hash        = $value['zoom_hash'];
 252                  $img_zoom_ext        = $value['zoom_ext'];
 253                  $img_zoom_name        = $zoominfo[0];
 254                  $img_zoom_rel        = PHPWCMS_IMAGES.$zoominfo[0];
 255                  $img_zoom_abs        = PHPWCMS_URL.PHPWCMS_IMAGES.$zoominfo[0];
 256                  $img_zoom_width        = $zoominfo[1];
 257                  $img_zoom_height    = $zoominfo[2];
 258                  $img_zoom_filename    = $value['zoom_name'];
 259                  
 260              } else {
 261                  // if not click enlarge
 262                  if($caption[2][0]) {
 263                      $img_a .= '<a href="'.$caption[2][0].'" '.$list_ahref_style.$caption[2][1].'>'.$list_img_temp.'</a>';
 264                  } else {
 265                      $img_a .= $list_img_temp;
 266                  }
 267              }
 268              
 269              $img_a = str_replace('{IMAGE}', $img_a, $image['tmpl_entry']);
 270              $img_a = str_replace('{IMGID}', $key, $img_a);
 271              $img_a = str_replace('{IMGNAME}', html_specialchars($image['images'][$key]['thumb_name']), $img_a);
 272          
 273              // replace thumbnail and zoom image information
 274              $img_a = str_replace('{THUMB_ID}',            $value['thumb_id'], $img_a);
 275              $img_a = str_replace('{THUMB_HASH}',        $value['thumb_hash'], $img_a);
 276              $img_a = str_replace('{THUMB_EXT}',            $value['thumb_ext'], $img_a);
 277              $img_a = str_replace('{THUMB_NAME}',        $img_thumb_name, $img_a);
 278              $img_a = str_replace('{THUMB_FILENAME}',    $img_thumb_filename, $img_a);
 279              $img_a = str_replace('{THUMB_REL}',            $img_thumb_rel, $img_a);
 280              $img_a = str_replace('{THUMB_ABS}',            $img_thumb_abs, $img_a);
 281              $img_a = str_replace('{THUMB_WIDTH}',        $img_thumb_width, $img_a);
 282              $img_a = str_replace('{THUMB_HEIGHT}',        $img_thumb_height, $img_a);
 283              
 284              $image['tmpl_thumb_width_max']    = max($image['tmpl_thumb_width_max'], $img_thumb_width);
 285              $image['tmpl_thumb_height_max']    = max($image['tmpl_thumb_height_max'], $img_thumb_height);
 286              
 287              $img_a = str_replace('{IMAGE_ID}',            $img_zoom_id, $img_a);
 288              $img_a = str_replace('{IMAGE_HASH}',        $img_zoom_hash, $img_a);
 289              $img_a = str_replace('{IMAGE_EXT}',            $img_zoom_ext, $img_a);
 290              $img_a = str_replace('{IMAGE_NAME}',        $img_zoom_name, $img_a);
 291              $img_a = str_replace('{IMAGE_FILENAME}',    $img_zoom_filename, $img_a);
 292              $img_a = str_replace('{IMAGE_REL}',            $img_zoom_rel, $img_a);
 293              $img_a = str_replace('{IMAGE_ABS}',            $img_zoom_abs, $img_a);
 294              $img_a = str_replace('{IMAGE_WIDTH}',        $img_zoom_width, $img_a);
 295              $img_a = str_replace('{IMAGE_HEIGHT}',        $img_zoom_height, $img_a);
 296              
 297              $img_a = render_cnt_template($img_a, 'IMAGE_URL', $caption[2][0]);
 298              $img_a = str_replace('{IMAGE_TARGET}',    $caption[2][1], $img_a);
 299              $img_a = str_replace('{LIGHTBOX}',    ($image['lightbox'] !== false ? ' rel="lightbox['.$image['lightbox'].']"' : '' ), $img_a);
 300              $img_a = str_replace('{LIGHTBOX_CAPTION}', $lightbox_capt, $img_a);
 301              
 302              $img_a = render_cnt_template($img_a, 'ZOOM', ($img_zoom_name ? '<!-- Zoomed -->' : '') );
 303              $img_a = render_cnt_template($img_a, 'COPYRIGHT', $caption[4] );
 304              
 305              // new freetext value
 306              $value['freetext'] = empty($value['freetext']) ? '' : trim($value['freetext']);
 307              $img_a = render_cnt_template($img_a, 'INFOTEXT', plaintext_htmlencode($value['freetext'], 'html_entities') );
 308              $img_a = render_cnt_template($img_a, 'INFOHTML', $value['freetext'] );
 309              
 310              if($image['nocaption']) {
 311                  $img_a = render_cnt_template($img_a, 'CAPTION_ELSE', '');
 312                  $img_a = render_cnt_template($img_a, 'CAPTION', '');
 313              } else {
 314                  $img_a = render_cnt_template($img_a, 'CAPTION', $capt_cur);
 315              }
 316              
 317              $image['tmpl_images'][$x] .= $img_a;
 318              
 319              // check if this is the last image in row
 320              if($image['col'] == $col) {
 321                  $x++;
 322                  $col = 0;
 323              }
 324              
 325          }
 326          
 327          $image['template'] .= implode($image['tmpl_row_space'], $image['tmpl_images']);
 328      
 329      }
 330      
 331      $image['template'] .= $image['tmpl_footer'];
 332      
 333      // now do main replacements
 334      $image['template']  = str_replace('{ID}', $crow['acontent_id'], $image['template']);
 335      $image['template']  = str_replace('{SPACE}', $image['space'], $image['template']);
 336      $image['template']  = str_replace('{THUMB_WIDTH_MAX}', $image['tmpl_thumb_width_max'], $image['template']);
 337      $image['template']  = str_replace('{THUMB_HEIGHT_MAX}', $image['tmpl_thumb_height_max'], $image['template']);
 338      $image['template']  = str_replace('{THUMB_COLUMNS}', $image['col'], $image['template']);
 339      $image['template']  = render_cnt_template($image['template'], 'TITLE', html_specialchars($crow['acontent_title']));
 340      $image['template']  = render_cnt_template($image['template'], 'SUBTITLE', html_specialchars($crow['acontent_subtitle']));
 341      $image['template']  = render_cnt_template($image['template'], 'TEXT', $crow['acontent_html']);
 342      $image['template']  = render_cnt_template($image['template'], 'EFFECT_1', ($image['fx1'] ? '<!-- FX 1 -->' : '') );
 343      $image['template']  = render_cnt_template($image['template'], 'EFFECT_2', ($image['fx2'] ? '<!-- FX 2 -->' : '') );
 344      $image['template']  = render_cnt_template($image['template'], 'EFFECT_3', ($image['fx3'] ? '<!-- FX 3 -->' : '') );
 345      
 346      $CNT_TMP .= $image['template'];
 347  
 348  }
 349  
 350  unset($image);
 351  
 352  ?>


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