[ Index ]

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

title

Body

[close]

/include/inc_front/content/ -> cnt29.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  
  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']    = render_device( @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']    = render_device( @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              $img_thumb_ext        = which_ext($thumb_image[0]);
 182              
 183              if($image['center_image']) {
 184              
 185                  $img_margin_left    = 0;
 186                  $img_margin_right    = 0;
 187                  $img_margin_top        = 0;
 188                  $img_margin_bottom    = 0;
 189  
 190                  // center hor/vert
 191                  if($image['center_image'] == 1 || $image['center_image'] == 2) {
 192                      $img_margin_left    = ceil( ($image['width'] - $thumb_image[1]) / 2 );                
 193                      $img_margin_right    = $image['width'] - $thumb_image[1] - $img_margin_left;
 194                  }
 195                  if($image['center_image'] == 1 || $image['center_image'] == 3) {
 196                      $img_margin_top        = ceil( ($image['height'] - $thumb_image[2]) / 2 );
 197                      $img_margin_bottom    = $image['height'] - $thumb_image[2] - $img_margin_top;
 198                  }
 199                  
 200                  $list_img_style        = 'style="margin:'.$img_margin_top.'px '.$img_margin_right.'px '.$img_margin_bottom.'px '.$img_margin_left.'px;" ';
 201                  $list_ahref_style    = '';
 202                  $list_img_temp       .= $list_img_style;
 203                  
 204              } else {
 205                  $list_img_style        = '';
 206                  $list_ahref_style    = '';
 207              }
 208              $list_img_temp .= $thumb_image[3].' alt="'.$caption[1].'"'.$caption[3].' border="0" />';
 209              $img_a            = '';
 210  
 211              if($image['zoom'] && isset($zoominfo) && $zoominfo != false) {
 212                  // if click enlarge the image
 213                  $open_popup_link = 'image_zoom.php?'.getClickZoomImageParameter($zoominfo[0].'?'.$zoominfo[3]);
 214                  if($caption[2][0]) {
 215                      $open_link = $caption[2][0];
 216                      $return_false = '';
 217                  } else {
 218                      $open_link = $open_popup_link;
 219                      $return_false = 'return false;';
 220                  }
 221                  
 222                  if(!$image['lightbox'] || $caption[2][0]) {
 223                      
 224                      $img_thumb_link  = '<a href="'.$open_link."\" onclick=\"checkClickZoom();clickZoom('".$open_popup_link."','previewpic','width=";
 225                      $img_thumb_link .= $zoominfo[1].",height=".$zoominfo[2]."');".$return_false.'"'.$caption[2][1];
 226                      $img_thumb_link .= $list_ahref_style.'>';
 227                      
 228                      $img_a .= $img_thumb_link;
 229                      
 230                      
 231                  } else {
 232                  
 233                      // lightbox
 234                      $img_thumb_link  = '<a href="'.PHPWCMS_IMAGES.$zoominfo[0].'" rel="lightbox['.$image['lightbox'].']" ';
 235                      if($capt_cur) {
 236                          $img_thumb_link .= 'title="'.parseLightboxCaption($capt_cur).'" ';
 237                      } elseif(strpos($image['tmpl_entry'], '{IMGNAME}')) {
 238                          $img_thumb_link .= 'title="'.parseLightboxCaption( $image['images'][$key][1] ).'" ';
 239                      }
 240                      
 241                      $img_thumb_link .= $list_ahref_style.'target="_blank">';
 242                      
 243                      $img_a .= $img_thumb_link;
 244                  
 245                  }
 246                  
 247                  $img_a .= $list_img_temp.'</a>';
 248                  
 249                  $img_zoom_name        = $zoominfo[0];
 250                  $img_zoom_rel        = PHPWCMS_IMAGES.$zoominfo[0];
 251                  $img_zoom_abs        = PHPWCMS_URL.PHPWCMS_IMAGES.$zoominfo[0];
 252                  $img_zoom_width        = $zoominfo[1];
 253                  $img_zoom_height    = $zoominfo[2];
 254                  
 255              } else {
 256                  // if not click enlarge
 257                  if($caption[2][0]) {
 258                      $img_thumb_link = '<a href="'.$caption[2][0].'" '.$list_ahref_style.$caption[2][1].'>';
 259                      $img_a .= $img_thumb_link.$list_img_temp.'</a>';
 260                  } else {
 261                      $img_a .= $list_img_temp;
 262                  }
 263                  
 264                  $img_zoom_name        = '';
 265                  $img_zoom_rel        = '';
 266                  $img_zoom_abs        = '';
 267                  $img_zoom_width        = 0;
 268                  $img_zoom_height    = 0;
 269              }
 270              
 271              $img_a = str_replace('{IMAGE}', $img_a, $image['tmpl_entry']);
 272              $img_a = str_replace('{IMGID}', $key, $img_a);
 273              $img_a = str_replace('{IMAGE_ID}', $image['images'][$key][0], $img_a);
 274              $img_a = str_replace('{IMAGE_HASH}', $image['images'][$key][2], $img_a);
 275              $img_a = str_replace('{IMGNAME}', html_specialchars($image['images'][$key][1]), $img_a);
 276              
 277              // replace thumbnail and zoom image information
 278              $img_a = str_replace('{THUMB_NAME}',    $img_thumb_name, $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_NAME}',    $img_zoom_name, $img_a);
 288              $img_a = str_replace('{IMAGE_REL}',        $img_zoom_rel, $img_a);
 289              $img_a = str_replace('{IMAGE_ABS}',        $img_zoom_abs, $img_a);
 290              $img_a = str_replace('{IMAGE_WIDTH}',    $img_zoom_width, $img_a);
 291              $img_a = str_replace('{IMAGE_HEIGHT}',    $img_zoom_height, $img_a);
 292              
 293              $img_a = str_replace('{IMAGE_EXT}',    $img_thumb_ext, $img_a);
 294              
 295              $img_a = render_cnt_template($img_a, 'ZOOM', ($img_zoom_name ? '<!-- Zoomed -->' : '') );
 296              $img_a = render_cnt_template($img_a, 'COPYRIGHT', $caption[4] );
 297              $img_a = render_cnt_template($img_a, 'FIRST', ($col > 1 ? '' : $col) );
 298              $img_a = render_cnt_template($img_a, 'ROW', ($x+1) );
 299              
 300              if($image['nocaption']) {
 301                  $img_a = render_cnt_template($img_a, 'CAPTION_ELSE', '');
 302                  $img_a = render_cnt_template($img_a, 'CAPTION', '');
 303              } else {
 304                  $img_a = render_cnt_template($img_a, 'CAPTION', $capt_cur);
 305              }
 306              $img_a = render_cnt_template($img_a, 'TITLE', $capt_cur);
 307              $img_a = render_cnt_template($img_a, 'ALT', $caption[1]);
 308              $img_a = render_cnt_template($img_a, 'LINK', $img_thumb_link);
 309              
 310              
 311              // check if this is the last image in row
 312              if($image['col'] == $col || $image['count'] == $total) {
 313                  
 314                  $img_a = render_cnt_template($img_a, 'LAST', $col);
 315                  
 316                  $image['tmpl_images'][$x] .= $img_a;
 317                  
 318                  $x++;
 319                  $col = 0;
 320                  
 321              } else {
 322                  
 323                  $img_a = render_cnt_template($img_a, 'LAST', '');
 324                  
 325                  $image['tmpl_images'][$x] .= $img_a;
 326                  
 327              }
 328              
 329          }
 330          
 331          $image['template'] .= implode($image['tmpl_row_space'], $image['tmpl_images']);
 332      
 333      }
 334      
 335      $image['template'] .= $image['tmpl_footer'];
 336      
 337      // now do main replacements
 338      $image['template']  = str_replace('{ID}', $crow['acontent_id'], $image['template']);
 339      $image['template']  = str_replace('{SPACE}', $image['space'], $image['template']);
 340      $image['template']  = str_replace('{THUMB_WIDTH_MAX}', $image['tmpl_thumb_width_max'], $image['template']);
 341      $image['template']  = str_replace('{THUMB_HEIGHT_MAX}', $image['tmpl_thumb_height_max'], $image['template']);
 342      $image['template']  = str_replace('{THUMB_COLUMNS}', $image['col'], $image['template']);
 343      $image['template']  = render_cnt_template($image['template'], 'TITLE', html_specialchars($crow['acontent_title']));
 344      $image['template']  = render_cnt_template($image['template'], 'SUBTITLE', html_specialchars($crow['acontent_subtitle']));
 345      $image['template']  = render_cnt_template($image['template'], 'TEXT', $crow['acontent_text']);
 346      
 347      $CNT_TMP .= $image['template'];
 348  
 349  }
 350  
 351  unset($image);
 352  
 353  ?>


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