[ Index ]

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

title

Body

[close]

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


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