[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

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

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


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1