[ Index ]

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

title

Body

[close]

/include/inc_front/content/ -> cnt29.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  
  37  $image    = @unserialize($crow["acontent_form"]);
  38  
  39  // read template
  40  if(empty($crow["acontent_template"]) && is_file(PHPWCMS_TEMPLATE.'inc_default/images.tmpl')) {
  41  
  42      $image['template']    = @file_get_contents(PHPWCMS_TEMPLATE.'inc_default/images.tmpl');
  43      
  44  } elseif(is_file(PHPWCMS_TEMPLATE.'inc_cntpart/images/'.$crow["acontent_template"])) {
  45  
  46      $image['template']    = @file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/images/'.$crow["acontent_template"]);
  47  
  48  } else {
  49  
  50      $image['template']    = '';
  51  
  52  }
  53  
  54  if($image['template']) {
  55  
  56      $image['tmpl_header']            = get_tmpl_section('IMAGES_HEADER', $image['template']);
  57      $image['tmpl_footer']            = get_tmpl_section('IMAGES_FOOTER', $image['template']);
  58      $image['tmpl_entry']            = get_tmpl_section('IMAGES_ENTRY', $image['template']);
  59      $image['tmpl_entry_space']        = get_tmpl_section('IMAGES_ENTRY_SPACER', $image['template']);
  60      $image['tmpl_row_space']        = get_tmpl_section('IMAGES_ROW_SPACER', $image['template']);
  61      $image['tmpl_thumb_width_max']    = 0;
  62      $image['tmpl_thumb_height_max']    = 0;
  63      $image['tmpl_images']            = array();
  64      
  65      $image['template']  = $image['tmpl_header'];
  66  
  67      if(is_array($image['images']) && ($image['count'] = count($image['images']))) {
  68  
  69          // Start lightbox
  70          if(empty($image['lightbox'])) {
  71              $image['lightbox'] = false;
  72          } else {
  73              initializeLightbox();
  74              $image['lightbox'] = generic_string(5);
  75          }
  76          
  77          if(empty($image['center_image'])) {
  78              $image['center_image'] = 0;
  79          }
  80          
  81          $image['crop'] = empty($image['crop']) ? 0 : 1;
  82          
  83          switch($image['center_image']) {
  84          
  85              case 1:        // center hor/vert
  86                          if(!$image['width'] && !$image['height']) {
  87                              $image['center_image'] = 0;
  88                          } elseif(!$image['width']) {
  89                              $image['center_image'] = 3;
  90                          } elseif(!$image['height']) {
  91                              $image['center_image'] = 2;
  92                          }
  93                          break;
  94                          
  95              case 2:        // center hor
  96                          if(!$image['width']) {
  97                              $image['center_image'] = 0;
  98                          }
  99                          break;
 100              
 101              case 3:        // center vert
 102                          if(!$image['height']) {
 103                              $image['center_image'] = 0;
 104                          }
 105                          break;
 106              
 107              default:    $image['center_image'] = 0;
 108          
 109          
 110          }
 111          
 112          $x   = 0;
 113          $col = 0;
 114  
 115          foreach($image['images'] as $key => $value) {
 116          
 117              $col++;
 118              
 119              // put spacer content between images
 120              if($col > 1) {
 121              
 122                  $image['tmpl_images'][$x] .= $image['tmpl_entry_space'];
 123              
 124              } else {
 125              
 126                  $image['tmpl_images'][$x]  = '';
 127              
 128              }
 129  
 130              $thumb_image = get_cached_image(
 131                          array(    "target_ext"    =>    $image['images'][$key][3],
 132                                  "image_name"    =>    $image['images'][$key][2] . '.' . $image['images'][$key][3],
 133                                  "max_width"        =>    $image['images'][$key][4],
 134                                  "max_height"    =>    $image['images'][$key][5],
 135                                  "thumb_name"    =>    md5(    $image['images'][$key][2].$image['images'][$key][4].
 136                                                              $image['images'][$key][5].$phpwcms["sharpen_level"].
 137                                                              $image['crop']
 138                                                          ),
 139                                  'crop_image'    =>    $image['crop']
 140                                )
 141                          );
 142  
 143              if($image['zoom']) {
 144  
 145                  $zoominfo = get_cached_image(
 146                          array(    "target_ext"    =>    $image['images'][$key][3],
 147                                  "image_name"    =>    $image['images'][$key][2] . '.' . $image['images'][$key][3],
 148                                  "max_width"        =>    $phpwcms["img_prev_width"],
 149                                  "max_height"    =>    $phpwcms["img_prev_height"],
 150                                  "thumb_name"    =>    md5(    $image['images'][$key][2].$phpwcms["img_prev_width"].
 151                                                              $phpwcms["img_prev_height"].$phpwcms["sharpen_level"]
 152                                                          )
 153                                )
 154                          );
 155              }
 156  
 157              // now try to build caption and if neccessary add alt to image or set external link for image
 158              $caption    = getImageCaption($image['images'][$key][6]);
 159              // set caption and ALT Image Text for imagelist
 160              $capt_cur    = html_specialchars($caption[0]);
 161              $caption[3] = empty($caption[3]) ? '' : ' title="'.html_specialchars($caption[3]).'"'; //title
 162              $caption[1] = html_specialchars(empty($caption[1]) ? $image['images'][$key][1] : $caption[1]);
 163  
 164              $list_img_temp  = '<img src="'.PHPWCMS_IMAGES.$thumb_image[0].'" ';
 165              
 166              $img_thumb_name        = $thumb_image[0];
 167              $img_thumb_rel        = PHPWCMS_IMAGES.$thumb_image[0];
 168              $img_thumb_abs        = PHPWCMS_URL.PHPWCMS_IMAGES.$thumb_image[0];
 169              $img_thumb_width    = $thumb_image[1];
 170              $img_thumb_height    = $thumb_image[2];
 171              
 172              if($image['center_image']) {
 173              
 174                  $img_margin_left    = 0;
 175                  $img_margin_right    = 0;
 176                  $img_margin_top        = 0;
 177                  $img_margin_bottom    = 0;
 178  
 179                  // center hor/vert
 180                  if($image['center_image'] == 1 || $image['center_image'] == 2) {
 181                      $img_margin_left    = ceil( ($image['width'] - $thumb_image[1]) / 2 );                
 182                      $img_margin_right    = $image['width'] - $thumb_image[1] - $img_margin_left;
 183                  }
 184                  if($image['center_image'] == 1 || $image['center_image'] == 3) {
 185                      $img_margin_top        = ceil( ($image['height'] - $thumb_image[2]) / 2 );
 186                      $img_margin_bottom    = $image['height'] - $thumb_image[2] - $img_margin_top;
 187                  }
 188                  
 189                  $list_img_style        = 'style="margin:'.$img_margin_top.'px '.$img_margin_right.'px '.$img_margin_bottom.'px '.$img_margin_left.'px;" ';
 190                  $list_ahref_style    = '';
 191                  $list_img_temp       .= $list_img_style;
 192                  
 193              } else {
 194                  $list_img_style        = '';
 195                  $list_ahref_style    = '';
 196              }
 197              $list_img_temp .= $thumb_image[3].' alt="'.$caption[1].'"'.$caption[3].' border="0" />';
 198              $img_a            = '';
 199  
 200              if($image['zoom'] && isset($zoominfo) && $zoominfo != false) {
 201                  // if click enlarge the image
 202                  $open_popup_link = 'image_zoom.php?'.getClickZoomImageParameter($zoominfo[0].'?'.$zoominfo[3]);
 203                  if($caption[2][0]) {
 204                      $open_link = $caption[2][0];
 205                      $return_false = '';
 206                  } else {
 207                      $open_link = $open_popup_link;
 208                      $return_false = 'return false;';
 209                  }
 210                  
 211                  if(!$image['lightbox'] || $caption[2][0]) {
 212                  
 213                      $img_a .= '<a href="'.$open_link."\" onclick=\"checkClickZoom();clickZoom('".$open_popup_link."','previewpic','width=";
 214                      $img_a .= $zoominfo[1].",height=".$zoominfo[2]."');".$return_false.'"'.$caption[2][1];
 215                      $img_a .= $list_ahref_style.'>';
 216                      
 217                  } else {
 218                  
 219                      // lightbox
 220                      $img_a .= '<a href="'.PHPWCMS_IMAGES.$zoominfo[0].'" rel="lightbox['.$image['lightbox'].']" ';
 221                      if($capt_cur) {
 222                          $img_a .= 'title="'.parseLightboxCaption($capt_cur).'" ';
 223                      } elseif(strpos($image['tmpl_entry'], '{IMGNAME}')) {
 224                          $img_a .= 'title="'.parseLightboxCaption( $image['images'][$key][1] ).'" ';
 225                      }
 226                      
 227                      $img_a .= $list_ahref_style.'target="_blank">';
 228                  
 229                  }
 230                  
 231                  $img_a .= $list_img_temp.'</a>';
 232                  
 233                  $img_zoom_name        = $zoominfo[0];
 234                  $img_zoom_rel        = PHPWCMS_IMAGES.$zoominfo[0];
 235                  $img_zoom_abs        = PHPWCMS_URL.PHPWCMS_IMAGES.$zoominfo[0];
 236                  $img_zoom_width        = $zoominfo[1];
 237                  $img_zoom_height    = $zoominfo[2];
 238                  
 239              } else {
 240                  // if not click enlarge
 241                  if($caption[2][0]) {
 242                      $img_a .= '<a href="'.$caption[2][0].'" '.$list_ahref_style.$caption[2][1].'>'.$list_img_temp.'</a>';
 243                  } else {
 244                      $img_a .= $list_img_temp;
 245                  }
 246                  
 247                  $img_zoom_name        = '';
 248                  $img_zoom_rel        = '';
 249                  $img_zoom_abs        = '';
 250                  $img_zoom_width        = 0;
 251                  $img_zoom_height    = 0;
 252              }
 253              
 254              $img_a = str_replace('{IMAGE}', $img_a, $image['tmpl_entry']);
 255              $img_a = str_replace('{IMGID}', $image['images'][$key][0], $img_a);
 256              $img_a = str_replace('{IMAGE_ID}', $image['images'][$key][0], $img_a);
 257              $img_a = str_replace('{IMAGE_HASH}', $image['images'][$key][2], $img_a);
 258              $img_a = str_replace('{IMGNAME}', html_specialchars($image['images'][$key][1]), $img_a);
 259              
 260              // replace thumbnail and zoom image information
 261              $img_a = str_replace('{THUMB_NAME}',    $img_thumb_name, $img_a);
 262              $img_a = str_replace('{THUMB_REL}',        $img_thumb_rel, $img_a);
 263              $img_a = str_replace('{THUMB_ABS}',        $img_thumb_abs, $img_a);
 264              $img_a = str_replace('{THUMB_WIDTH}',    $img_thumb_width, $img_a);
 265              $img_a = str_replace('{THUMB_HEIGHT}',    $img_thumb_height, $img_a);
 266              
 267              $image['tmpl_thumb_width_max']    = max($image['tmpl_thumb_width_max'], $img_thumb_width);
 268              $image['tmpl_thumb_height_max']    = max($image['tmpl_thumb_height_max'], $img_thumb_height);
 269              
 270              $img_a = str_replace('{IMAGE_NAME}',    $img_zoom_name, $img_a);
 271              $img_a = str_replace('{IMAGE_REL}',        $img_zoom_rel, $img_a);
 272              $img_a = str_replace('{IMAGE_ABS}',        $img_zoom_abs, $img_a);
 273              $img_a = str_replace('{IMAGE_WIDTH}',    $img_zoom_width, $img_a);
 274              $img_a = str_replace('{IMAGE_HEIGHT}',    $img_zoom_height, $img_a);
 275              
 276              $img_a = render_cnt_template($img_a, 'ZOOM', ($img_zoom_name ? '<!-- Zoomed -->' : '') );
 277              $img_a = render_cnt_template($img_a, 'COPYRIGHT', $caption[4] );
 278              
 279              if($image['nocaption']) {
 280                  $img_a = render_cnt_template($img_a, 'CAPTION_ELSE', '');
 281                  $img_a = render_cnt_template($img_a, 'CAPTION', '');
 282              } else {
 283                  $img_a = render_cnt_template($img_a, 'CAPTION', $capt_cur);
 284              }
 285              
 286              $image['tmpl_images'][$x] .= $img_a;
 287              
 288              // check if this is the last image in row
 289              if($image['col'] == $col) {
 290                  $x++;
 291                  $col = 0;
 292              }
 293              
 294          }
 295          
 296          $image['template'] .= implode($image['tmpl_row_space'], $image['tmpl_images']);
 297      
 298      }
 299      
 300      $image['template'] .= $image['tmpl_footer'];
 301      
 302      // now do main replacements
 303      $image['template']  = str_replace('{ID}', $crow['acontent_id'], $image['template']);
 304      $image['template']  = str_replace('{SPACE}', $image['space'], $image['template']);
 305      $image['template']  = str_replace('{THUMB_WIDTH_MAX}', $image['tmpl_thumb_width_max'], $image['template']);
 306      $image['template']  = str_replace('{THUMB_HEIGHT_MAX}', $image['tmpl_thumb_height_max'], $image['template']);
 307      $image['template']  = str_replace('{THUMB_COLUMNS}', $image['col'], $image['template']);
 308      $image['template']  = render_cnt_template($image['template'], 'TITLE', html_specialchars($crow['acontent_title']));
 309      $image['template']  = render_cnt_template($image['template'], 'SUBTITLE', html_specialchars($crow['acontent_subtitle']));
 310      $image['template']  = render_cnt_template($image['template'], 'TEXT', $crow['acontent_text']);
 311      
 312      $CNT_TMP .= $image['template'];
 313  
 314  }
 315  
 316  unset($image);
 317  
 318  ?>


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