[ Index ]

PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10)

title

Body

[close]

/include/inc_front/content/ -> cnt31.article.inc.php (source)

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


Generated: Tue Nov 16 22:51:00 2010 Cross-referenced by PHPXref 0.7