[ Index ]

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

title

Body

[close]

/include/inc_front/ -> content.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  // ----------------------------------------------------------------
  24  // obligate check for phpwcms constants
  25  if (!defined('PHPWCMS_ROOT')) {
  26     die("You Cannot Access This Script Directly, Have a Nice Day.");
  27  }
  28  // ----------------------------------------------------------------
  29  
  30  
  31  $sql  =    "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date, ";
  32  $sql .= "UNIX_TIMESTAMP(article_begin) AS article_livedate, ";
  33  $sql .= "UNIX_TIMESTAMP(article_end) AS article_killdate ";
  34  $sql .=    "FROM ".DB_PREPEND."phpwcms_article ar LEFT JOIN ".DB_PREPEND."phpwcms_articlecat ac ON ";
  35  $sql .=    "ar.article_cid = ac.acat_id WHERE ";
  36  $sql .= "ar.article_id=".$aktion[1]." AND ";
  37  // VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode
  38  switch(VISIBLE_MODE) {
  39      case 0: $sql .= "ar.article_public=1 AND ";
  40              $sql .= "ar.article_aktiv=1 AND ";
  41              break;
  42      case 1: $sql .= "ar.article_uid=".$_SESSION["wcs_user_id"]." AND ";
  43              break;
  44  }
  45  $sql .= "ar.article_deleted=0 AND ar.article_begin<NOW() ";
  46  $sql .= "AND IF(ac.acat_archive=1 AND ar.article_archive_status=1, 1, ar.article_end>NOW()) LIMIT 1";
  47  
  48  if($result = mysql_query($sql, $db) or die("error while reading article datas")) {
  49      if($row = mysql_fetch_assoc($result)) {
  50          //Da max. 1 Datensatz -> sofort Datenbankverbindung kappen
  51          mysql_free_result($result);
  52          
  53          // now try to retrieve alias article information
  54          if($row["article_aliasid"]) {
  55              $alias_sql  = "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date, ";
  56              $alias_sql .= "UNIX_TIMESTAMP(article_begin) AS article_livedate, ";
  57              $alias_sql .= "UNIX_TIMESTAMP(article_end) AS article_killdate ";
  58              $alias_sql .= "FROM ".DB_PREPEND."phpwcms_article ";
  59              $alias_sql .= "WHERE article_deleted=0 AND article_id=".intval($row["article_aliasid"]);
  60              if(!$row["article_headerdata"]) {
  61                  switch(VISIBLE_MODE) {
  62                      case 0: $alias_sql .= " AND article_public=1 AND article_aktiv=1";
  63                                  break;
  64                      case 1: $alias_sql .= " AND article_uid=".$_SESSION["wcs_user_id"];
  65                                  break;
  66                  }
  67                  $alias_sql .= " AND article_begin < NOW() AND article_end > NOW()";
  68              }
  69              $alias_sql .= " AND article_deleted=0 LIMIT 1";
  70              if($alias_result = mysql_query($alias_sql, $db)) {
  71                  if($alias_row = mysql_fetch_assoc($alias_result)) {
  72                      $row["article_id"] = $alias_row["article_id"];
  73                      // use alias article header data
  74                      if(!$row["article_headerdata"]) {
  75                          $row["article_title"]        = $alias_row["article_title"];
  76                          $row["article_subtitle"]    = $alias_row["article_subtitle"];
  77                          $row["article_keyword"]        = $alias_row["article_keyword"];
  78                          $row["article_summary"]        = $alias_row["article_summary"];
  79                          $row["article_redirect"]    = $alias_row["article_redirect"];
  80                          $row["article_date"]        = $alias_row["article_date"];
  81                          $row["article_image"]        = $alias_row["article_image"];
  82                          $row["article_pagetitle"]    = $alias_row["article_pagetitle"];
  83                          $row['article_description']    = $alias_row['article_description'];
  84                      }
  85                  }
  86                  mysql_free_result($alias_result);
  87              }
  88          }
  89  
  90          //Kategoriebezeichner
  91          $article['cat'] = $content['struct'][$row["article_cid"]]['acat_name'];
  92  
  93          //redirection definition
  94          if($row["article_redirect"]) {
  95  
  96              $row["article_redirect"]        = str_replace('{SITE}', PHPWCMS_URL, $row["article_redirect"]);
  97              $content["redirect"]            = explode(' ', $row["article_redirect"]);
  98              $content["redirect"]["link"]    = $content["redirect"][0];
  99              $content["redirect"]["target"]    = isset($content["redirect"][1]) ? $content["redirect"][1] : '';
 100              $content["redirect"]["timeout"]    = isset($content["redirect"][2]) ? intval($content["redirect"][2]) : 0;
 101  
 102              //check how to redirect - new window or self window
 103              if(    !$content["redirect"]["target"]    || $content["redirect"]["target"] == "_self" ||    $content["redirect"]["target"] == "_top" ||    $content["redirect"]["target"] == "_parent") {
 104                  // direct redirection in the same window
 105                  headerRedirect($content["redirect"]["link"], 301);
 106              } else {
 107                  // redirection by using a special <meta><javascript> html head part
 108                  $content["redirect"]["code"]  = LF . '  <noscript>' . LF;
 109                  $content["redirect"]["code"] .= '    <meta http-equiv="refresh" content="'.$content["redirect"]["timeout"].';URL=';
 110                  $content["redirect"]["code"] .= $content["redirect"]["link"];
 111                  $content["redirect"]["code"] .= '" />'.LF.'  </noscript>' . LF;
 112                  $content["redirect"]["code"] .= '  <script type="text/javascript">' . LF;
 113                  $content["redirect"]["code"] .= '    var redirectWin;' . LF;
 114                  if($content["redirect"]["timeout"]) {
 115                      $content["redirect"]["code"] .= '    window.setTimeout(\'window.open("'.$content["redirect"]["link"].'", redirectWin)\', ';
 116                      $content["redirect"]["code"] .= $content["redirect"]["timeout"] * 1000;
 117                      $content["redirect"]["code"] .= ');';
 118                  } else {
 119                      $content["redirect"]["code"] .= '    window.open("'.$content["redirect"]["link"].'", redirectWin);';
 120                  }
 121                  $content["redirect"]["code"] .= LF . '  </script>' . LF;
 122              }
 123          }
 124  
 125  
 126          // UNIQUE article ID as used for teaser content part
 127          if(!isset($content['UNIQUE_ALINK'])) {
 128              $content['UNIQUE_ALINK'] = array();
 129          }
 130          
 131          $content['UNIQUE_ALINK'][ $row["article_id"] ] = $row["article_id"];
 132  
 133  
 134          //set cache timeout for this article
 135          if($row['article_cache'] != '') {
 136              $phpwcms['cache_timeout'] = $row['article_cache'];
 137          }
 138          //get value for article search (on/off)
 139          if($row['article_nosearch'] != '') {
 140              $cache_searchable = '1';
 141          }
 142  
 143          //check if article has custom pagetitle
 144          if(!empty($row["article_pagetitle"])) {
 145              $content["pagetitle"] = $row["article_pagetitle"];
 146          } else {
 147              $content["pagetitle"] = setPageTitle($content["pagetitle"], $article['cat'], $row["article_title"]);
 148          }
 149          
 150          // check description
 151          if(!empty($row['article_description'])) {
 152              set_meta('description', $row['article_description']);
 153          }
 154          
 155          $content['all_keywords'] = $row['article_keyword'];
 156  
 157          if(!empty($template_default['article_render_anchor'])) {
 158              $content["main"] .= '<a name="jump'.$row["article_id"].'" id="jump'.$row["article_id"].'" class="jump-anchor"></a>';
 159          }
 160          
 161          // enable frontend edit link
 162          $content["main"] .= getFrontendEditLink('article', $row["article_id"]);
 163          $content["main"] .= getFrontendEditLink('summary', $row["article_id"]);
 164          
 165  
 166          // only copy the catname to a special var for multiple for use in any block
 167          $content["cat"]                    = html_specialchars($article["cat"]);
 168          $content["cat_id"]                = $aktion[0] = $row["article_cid"]; //set category ID to actual category value
 169          $content["article_id"]             = $row["article_id"];
 170          $content["summary"]                = '';
 171          $content['article_title']        = $row["article_title"];
 172          $content['article_summary']        = $row["article_summary"];
 173          
 174          $content["article_date"]        = $row["article_date"]; // article date
 175          $content["article_created"]        = $row["article_created"]; // article created
 176          $content['article_livedate']    = $row['article_livedate'];
 177          $content['article_killdate']    = $row['article_killdate'];
 178          $content['article_username']    = $row["article_username"];
 179  
 180          //retrieve image info
 181          $row["article_image"] = unserialize($row["article_image"]);
 182          $caption = getImageCaption($row["article_image"]["caption"]);
 183          $row["article_image"]["caption"]    = $caption[0];
 184          $row["article_image"]["copyright"]    = $caption[4];
 185                  
 186          //build image/image link
 187          $thumb_image = false;
 188          $thumb_img = '';
 189          $popup_img = '';
 190          
 191          $img_thumb_name        = '';
 192          $img_thumb_rel        = '';
 193          $img_thumb_abs        = '';
 194          $img_thumb_width    = 0;
 195          $img_thumb_height    = 0;
 196          
 197          $img_zoom_name        = '';
 198          $img_zoom_rel        = '';
 199          $img_zoom_abs        = '';
 200          $img_zoom_width        = 0;
 201          $img_zoom_height    = 0;
 202          
 203          if(!empty($row["article_image"]["hash"])) {
 204  
 205              $thumb_image = get_cached_image(
 206              array(    "target_ext"    =>    $row["article_image"]['ext'],
 207                      "image_name"    =>    $row["article_image"]['hash'] . '.' . $row["article_image"]['ext'],
 208                      "max_width"        =>    $row["article_image"]['width'],
 209                      "max_height"    =>    $row["article_image"]['height'],
 210                      "thumb_name"    =>    md5($row["article_image"]['hash'].$row["article_image"]['width'].$row["article_image"]['height'].$GLOBALS['phpwcms']["sharpen_level"])
 211              ));
 212  
 213              if($thumb_image != false) {
 214              
 215                  $thumb_img  = '<img src="'.PHPWCMS_IMAGES . $thumb_image[0] .'" border="0" '.$thumb_image[3];
 216                  $thumb_img .= ' alt="'.html_specialchars($caption[1]).'" title="'.html_specialchars($caption[3]).'" />';
 217                  
 218                  $img_thumb_name        = $thumb_image[0];
 219                  $img_thumb_rel        = PHPWCMS_IMAGES.$thumb_image[0];
 220                  $img_thumb_abs        = PHPWCMS_URL.PHPWCMS_IMAGES.$thumb_image[0];
 221                  $img_thumb_width    = $thumb_image[1];
 222                  $img_thumb_height    = $thumb_image[2];
 223  
 224                  if($row["article_image"]["zoom"]) {
 225  
 226                      $zoominfo = get_cached_image(
 227                      array(    "target_ext"    =>    $row["article_image"]['ext'],
 228                      "image_name"    =>    $row["article_image"]['hash'] . '.' . $row["article_image"]['ext'],
 229                      "max_width"        =>    $GLOBALS['phpwcms']["img_prev_width"],
 230                      "max_height"    =>    $GLOBALS['phpwcms']["img_prev_height"],
 231                      "thumb_name"    =>    md5($row["article_image"]['hash'].$GLOBALS['phpwcms']["img_prev_width"].$GLOBALS['phpwcms']["img_prev_height"].$GLOBALS['phpwcms']["sharpen_level"])
 232                      ));
 233  
 234                      if($zoominfo != false) {
 235                      
 236                          $img_zoom_name        = $zoominfo[0];
 237                          $img_zoom_rel        = PHPWCMS_IMAGES.$zoominfo[0];
 238                          $img_zoom_abs        = PHPWCMS_URL.PHPWCMS_IMAGES.$zoominfo[0];
 239                          $img_zoom_width        = $zoominfo[1];
 240                          $img_zoom_height    = $zoominfo[2];
 241  
 242                          $popup_img = 'image_zoom.php?'.getClickZoomImageParameter($zoominfo[0].'?'.$zoominfo[3]);
 243                      
 244                          if(!empty($caption[2][0])) {
 245                              $open_link = $caption[2][0];
 246                              $return_false = '';
 247                          } else {
 248                              $open_link = $popup_img;
 249                              $return_false = 'return false;';
 250                          }
 251  
 252                          if(empty($row["article_image"]["lightbox"])) {
 253                              $thumb_href  = '<a href="'.$popup_img.'" onclick="window.open(\''.$open_link;
 254                              $thumb_href .= "','previewpic','width=".$zoominfo[1].",height=".$zoominfo[2]."');".$return_false;
 255                              $thumb_href .= '"';
 256                              if(!empty($caption[2][1])) {
 257                                  $thumb_href .= $caption[2][1];
 258                              }
 259                              $thumb_href .= '>';
 260                          } else {
 261                          
 262                              //lightbox
 263                              initSlimbox();
 264                              
 265                              $thumb_href  = '<a href="'.PHPWCMS_IMAGES . $zoominfo[0].'"';
 266                              if($row["article_image"]["caption"]) {
 267                                  $thumb_href .= ' title="'.parseLightboxCaption($row["article_image"]["caption"]).'"';
 268                              }
 269                              $thumb_href .= ' rel="lightbox" target="_blank">';
 270                          }
 271                          
 272                          $thumb_img = $thumb_href.$thumb_img.'</a>';
 273                          $popup_img = $thumb_img;
 274                          
 275                      }
 276                  } else {
 277                          
 278                      if($caption[2][0]) {
 279                          $thumb_img = '<a href="'.$caption[2][0].'"'.$caption[2][1].'>'.$thumb_img.'</a>';
 280                      }
 281                  }
 282              }
 283          } else {
 284          
 285              $row["article_image"]['id']        = 0;
 286              $row["article_image"]['hash']    = '';
 287          
 288          }
 289          
 290  
 291          // make some elementary checks regarding content part pagination
 292          $_CpPaginate = false;
 293          
 294          if($row['article_paginate'] && $aktion[2] != 1) { // no pagination in print mode
 295              
 296              // use an IF because acontent_paginate_page=1 is the same as acontent_paginate_page=0
 297              $sql_cnt  = "SELECT DISTINCT IF(acontent_paginate_page=1, 0, acontent_paginate_page) AS acontent_paginate_page, ";
 298              $sql_cnt .= "acontent_paginate_title ";
 299              $sql_cnt .= "FROM ".DB_PREPEND."phpwcms_articlecontent WHERE ";
 300              $sql_cnt .= "acontent_aid=".$row["article_id"]." AND acontent_visible=1 AND acontent_trash=0 ";
 301              
 302              if( !FEUSER_LOGIN_STATUS ) {
 303                  $sql_cnt .= 'AND acontent_granted=0 ';
 304              }
 305              
 306              $sql_cnt .= "AND acontent_block IN ('', 'CONTENT') ORDER BY acontent_paginate_page DESC";
 307              $sql_cnt  = _dbQuery($sql_cnt);
 308              
 309              if(($paginate_count = count($sql_cnt)) > 1) {
 310              
 311                  $content['CpPages']            = array();
 312                  $content['CpPageTitles']    = array();
 313                  $_CpPaginate                = true;
 314                      
 315                  foreach($sql_cnt as $crow) {
 316      
 317                      $content['CpPages'][ $crow['acontent_paginate_page'] ] = $paginate_count; // set page numbers
 318                      
 319                      // set content part pagination title
 320                      if(!isset($content['CpPageTitles'][ $crow['acontent_paginate_page'] ])) {
 321  
 322                          $content['CpPageTitles'][ $crow['acontent_paginate_page'] ] = $crow['acontent_paginate_title'] == '' ? '#'.$paginate_count : $crow['acontent_paginate_title'];
 323                      
 324                      // check if content part title is set but starts with '#'
 325                      } elseif(isset($content['CpPageTitles'][ $crow['acontent_paginate_page'] ]) && $crow['acontent_paginate_title'] != '' && $content['CpPageTitles'][ $crow['acontent_paginate_page'] ]{0} == '#') { 
 326                          
 327                          $content['CpPageTitles'][ $crow['acontent_paginate_page'] ] = $crow['acontent_paginate_title'];
 328                          
 329                      }
 330  
 331                      $paginate_count--;
 332                  }
 333      
 334                  $content['CpPages']            = array_reverse($content['CpPages'], true);
 335                  $content['CpPageTitles']    = array_reverse($content['CpPageTitles'], true);
 336                  
 337                  // check if given cp paginate page is valid, and reset to page 1 (=0)
 338                  // same happens for 1 because this will always be used like it is 0
 339                  if(!isset($content['CpPages'][ $content['aId_CpPage'] ])) {
 340                      $content['aId_CpPage'] = 0;
 341                  }
 342                  
 343              } else {
 344              
 345                  $content['aId_CpPage'] = 0;
 346              
 347              }
 348              
 349          }        
 350  
 351          // check for custom full article summary template
 352          if(!empty($row["article_image"]['tmplfull']) && $row["article_image"]['tmplfull']!='default' && is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article/'.$row["article_image"]['tmplfull'])) {
 353  
 354              // try to read the template files
 355  
 356              if($_CpPaginate && $content['aId_CpPage'] > 1 && is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article/paginate/'.$row["article_image"]['tmplfull'])) { // check for default cp paginate template
 357                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article/paginate/'.$row["article_image"]['tmplfull']);
 358              } else {
 359                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article/'.$row["article_image"]['tmplfull']);
 360              }
 361          
 362          } elseif(is_file(PHPWCMS_TEMPLATE.'inc_default/article_summary.tmpl')) {
 363          
 364              // load default template
 365          
 366              if($_CpPaginate && $content['aId_CpPage'] > 1 && is_file(PHPWCMS_TEMPLATE.'inc_default/article_summary_paginate.tmpl')) { // check for default cp paginate template
 367                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_default/article_summary_paginate.tmpl');
 368              } else {
 369                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_default/article_summary.tmpl');
 370              }
 371          
 372          } else {
 373          
 374              // template fallback
 375              if($_CpPaginate && $content['aId_CpPage'] > 1) {
 376                  $row["article_image"]['tmplfull']  = '[TITLE]<h1>{TITLE}</h1>[/TITLE]'.LF.'<!--CP_PAGINATE_START//-->'.LF;
 377                  $row["article_image"]['tmplfull'] .= '<div class="cpPagination">'.LF;
 378                  $row["article_image"]['tmplfull'] .= '    [CP_PAGINATE_PREV]<a href="{CP_PAGINATE_PREV}" class="cpPaginationPrev">Previous</a>[/CP_PAGINATE_PREV]'.LF;
 379                  $row["article_image"]['tmplfull'] .= '    [CP_PAGINATE]{CP_PAGINATE}[/CP_PAGINATE]'.LF;
 380                  $row["article_image"]['tmplfull'] .= '    [CP_PAGINATE_NEXT]<a href="{CP_PAGINATE_NEXT}" class="cpPaginationNext">Previous</a>[/CP_PAGINATE_NEXT]'.LF;
 381                  $row["article_image"]['tmplfull'] .= '</div><!--CP_PAGINATE_END//-->';
 382              } else {
 383                  $row["article_image"]['tmplfull']  = '[TITLE]<h1>{TITLE}</h1>'.LF.'[/TITLE][SUB]<h3>{SUB}</h3>'.LF.'[/SUB]';
 384                  $row["article_image"]['tmplfull'] .= '[SUMMARY][IMAGE]<span style="float:left;margin:2px 10px 5px 0;">{IMAGE}';
 385                  $row["article_image"]['tmplfull'] .= '[CAPTION]<br />'.LF.'{CAPTION}[/CAPTION]</span>'.LF.'[/IMAGE]{SUMMARY}</div>'.LF.'[/SUMMARY]';
 386              }
 387  
 388          }
 389          
 390          //rendering
 391          if($row["article_image"]['tmplfull']) {
 392          
 393              // replace thumbnail and zoom image information
 394              $row["article_image"]['tmplfull'] = str_replace( 
 395                                  array(    '{THUMB_NAME}', '{THUMB_REL}', '{THUMB_ABS}', '{THUMB_WIDTH}', '{THUMB_HEIGHT}',
 396                                          '{IMAGE_NAME}', '{IMAGE_REL}', '{IMAGE_ABS}', '{IMAGE_WIDTH}', '{IMAGE_HEIGHT}',
 397                                          '{IMAGE_ID}',    '{IMAGE_HASH}' ),
 398                                  array(    $img_thumb_name, $img_thumb_rel, $img_thumb_abs, $img_thumb_width, $img_thumb_height,
 399                                          $img_zoom_name, $img_zoom_rel, $img_zoom_abs, $img_zoom_width, $img_zoom_height,
 400                                          $row["article_image"]['id'], $row["article_image"]['hash'] ),
 401                                  $row["article_image"]['tmplfull'] );
 402              
 403              // check if TITLE should be hidden
 404              if(!$row["article_notitle"]) {
 405                  $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'TITLE', html_specialchars($row["article_title"]));
 406              } else {
 407                  $row["article_image"]['tmplfull'] = replace_cnt_template($row["article_image"]['tmplfull'], 'TITLE', '');
 408              }
 409              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'SUB', html_specialchars($row["article_subtitle"]));
 410              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'EDITOR', html_specialchars($row["article_username"]));
 411              
 412              // when "hide summary" is enabled replace everything between [SUMMARY][/SUMMARY]
 413              if(!$row["article_hidesummary"]) {
 414                  $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'SUMMARY', $row["article_summary"]);
 415              } else {
 416                  $row["article_image"]['tmplfull'] = replace_cnt_template($row["article_image"]['tmplfull'], 'SUMMARY', '');
 417              }
 418              
 419              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'IMAGE', $thumb_img);
 420              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'CAPTION', nl2br(html_specialchars($row["article_image"]["caption"])));
 421              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'COPYRIGHT', html_specialchars($row["article_image"]["copyright"]));
 422              $row["article_image"]['tmplfull'] = render_cnt_date($row["article_image"]['tmplfull'], $content["article_date"], $row['article_livedate'], $row['article_killdate']);
 423              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'ZOOMIMAGE', $popup_img);
 424              
 425              $content["summary"] .= $row["article_image"]['tmplfull'];
 426              $row["article_image"]['tmplfull'] = 1;
 427          
 428          } else {
 429          
 430              $row["article_image"]['tmplfull'] = 0;
 431          
 432          }
 433  
 434          if($content["summary"]) {
 435          
 436              $content["main"] .= $content["summary"];
 437              $content["main"] .= $template_default["article"]["head_after"];
 438          
 439          }
 440  
 441          // render content parts
 442          $sql_cnt  = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent WHERE acontent_aid=".$row["article_id"]." ";
 443          $sql_cnt .=    "AND acontent_visible=1 AND acontent_trash=0 ";
 444          if( !FEUSER_LOGIN_STATUS ) {
 445              $sql_cnt .= 'AND acontent_granted=0 ';
 446          }
 447          $sql_cnt .= "ORDER BY acontent_sorting, acontent_id";
 448          $cresult  = _dbQuery($sql_cnt);
 449          
 450          foreach($cresult as $crow) {
 451          
 452              // check for article content part pagination
 453              if($_CpPaginate && ($crow['acontent_block'] == 'CONTENT' || $crow['acontent_block'] == '')) {
 454      
 455                  // now check which content part should be rendered...
 456                  
 457                  // first - cp page 0 OR 1 = 1st page and the same
 458                  if(($content['aId_CpPage'] == 0 || $content['aId_CpPage'] == 1) && ($crow['acontent_paginate_page'] == 0 || $crow['acontent_paginate_page'] == 1)) {
 459                                          
 460                      // then compare if selected page is same as paginate page
 461                  } elseif($content['aId_CpPage'] == $crow['acontent_paginate_page']) {
 462                                          
 463                      // hm, do not render current content part
 464                  } else {
 465                  
 466                      continue;
 467                  }
 468      
 469              }
 470          
 471              // if type of content part not enabled available 
 472              if(!isset($wcs_content_type[ $crow["acontent_type"] ]) ||  ($crow["acontent_type"] == 30 && !isset($phpwcms['modules'][$crow["acontent_module"]]))) {
 473                  continue;
 474              }
 475          
 476              // do everything neccessary for alias content part
 477              if($crow["acontent_type"] == 24) {
 478                  $crow = getContentPartAlias($crow);
 479              }
 480          
 481              // every article content  will be rendered into temp var 
 482              $CNT_TMP  = '';
 483              
 484              // each content part will get an anchor
 485              if($crow["acontent_anchor"]) {
 486                  $CNT_TMP .= '<a name="cpid'.$crow["acontent_id"].'" id="cpid'.$crow["acontent_id"].'" class="cpidClass"></a>';
 487              }
 488  
 489              // Space before
 490              if($crow["acontent_before"]) {
 491                  if(!empty($template_default["article"]["div_spacer"])) {
 492                      $CNT_TMP .= '<div style="margin:'.$crow["acontent_before"].'px 0 0 0;padding:0;" class="spaceBeforeCP"></div>';
 493                  } else {
 494                      $CNT_TMP .= '<br class="spaceBeforeCP" />'.spacer(1,$crow["acontent_before"]);
 495                  }
 496              }
 497              
 498              // set frontend edit link
 499              $CNT_TMP .= getFrontendEditLink('CP', $crow['acontent_aid'], $crow['acontent_id']);
 500              
 501              // include content part code section
 502              if($crow["acontent_type"] != 30) {
 503  
 504                  @include(PHPWCMS_ROOT."/include/inc_front/content/cnt".$crow["acontent_type"].".article.inc.php");
 505              
 506              } elseif($crow["acontent_type"] == 30 && is_file($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php')) {
 507  
 508                  $CNT_TMP .= getFrontendEditLink('module', $phpwcms['modules'][$crow["acontent_module"]]['name']);
 509                  // now try to include module content part code
 510                  include($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php');
 511              
 512              }
 513  
 514              // check if top link should be shown
 515              $CNT_TMP .= getContentPartTopLink($crow["acontent_top"]);
 516  
 517              // Space after
 518              if($crow["acontent_after"]) {
 519                  if(!empty($template_default["article"]["div_spacer"])) {
 520                      $CNT_TMP .= '<div style="margin:0 0 '.$crow["acontent_after"].'px 0;padding:0;" class="spaceAfterCP"></div>';
 521                  } else {
 522                      $CNT_TMP .= '<br class="spaceAfterCP" />'.spacer(1,$crow["acontent_after"]);
 523                  }
 524              }
 525              
 526              // Maybe content part ID should b used inside templates or for something different
 527              $CNT_TMP = str_replace( array('[%CPID%]', '{CPID}'), $crow["acontent_id"], $CNT_TMP );
 528              
 529              // trigger content part functions
 530              $CNT_TMP = trigger_cp($CNT_TMP, $crow);
 531              
 532              //check if PHP replacent tags are allowed for content
 533              if(empty($phpwcms["allow_cntPHP_rt"])) {
 534                  $CNT_TMP = remove_unsecure_rptags($CNT_TMP);
 535              }
 536              
 537              
 538              // wrap tab 
 539              if(!empty($crow['acontent_tab'])) {
 540                  
 541                  $crow['acontent_tab']            = explode('_', $crow['acontent_tab'], 2);
 542                  $crow['acontent_tab']['num']    = intval($crow['acontent_tab'][0]);
 543                  $crow['acontent_tab']['title']    = empty($crow['acontent_tab'][1]) ? '@@TabTitle@@' : $crow['acontent_tab'][1];
 544                  
 545                  // create a unique Tab ID based on title, content block and section
 546                  $CNT_TAB        = 'TABBOX-' . md5($crow['acontent_block'] . $crow['acontent_tab']['num']);
 547                  $CNT_TAB_ID     = 'TAB-' . md5($crow['acontent_tab']['title'].$crow['acontent_block']);
 548                  $CNT_TAB_TMP    = $CNT_TMP;
 549                  
 550                  // check if Tab ID is registered
 551                  if(!isset($content['cptab'][$CNT_TAB])) {
 552                      
 553                      $content['cptab'][$CNT_TAB] = array();
 554                      
 555                      // write Tab Block Replacer
 556                      $CNT_TMP = '<!-- ' . $CNT_TAB . ' -->';
 557                      
 558                  } else {
 559                  
 560                      $CNT_TMP = '';
 561                      
 562                  }
 563                  if(!isset($content['cptab'][$CNT_TAB][$CNT_TAB_ID])) {
 564                      
 565                      $content['cptab'][$CNT_TAB][$CNT_TAB_ID] = array(
 566                          'title'        => $crow['acontent_tab']['title'],
 567                          'content'    => ''
 568                      );
 569                      
 570                  }
 571                  
 572                  $content['cptab'][$CNT_TAB][$CNT_TAB_ID]['content'] .= $CNT_TAB_TMP;
 573              
 574              }
 575              
 576              // now add rendered content part to right frontend content 
 577              // var given by block -> $content['CB'][$crow['acontent_block']]
 578              if($crow['acontent_block'] == 'CONTENT' || $crow['acontent_block'] == '') {
 579                  // default content block
 580                  $content["main"] .= $CNT_TMP;
 581              } else {
 582                  // check if content block var is set
 583                  if(!isset($content['CB'][$crow['acontent_block']])) {
 584                      $content['CB'][$crow['acontent_block']] = '';
 585                  }
 586                  $content['CB'][$crow['acontent_block']] .= $CNT_TMP;
 587              }
 588              
 589          }
 590          
 591          
 592          // render Tabs
 593          $tab_counter = 0;
 594          foreach($content['cptab'] as $CNT_TAB => $trow) {
 595              
 596              // define helper var
 597              $g = array('wrap' => array(), 'cnt' => array(), 'counter' => 1, 'max' => count($trow));
 598      
 599              $g['wrap'][]    = '<div id="'.$CNT_TAB.'" class="tab-container">';
 600              
 601              $g['wrap'][]    = '    <ul class="tab-navigation">';
 602              
 603              foreach($trow as $tabkey => $tabitem) {
 604                  
 605                  $tabitem['id']        = 'tab-' . uri_sanitize(strtolower($tabitem['title'])) . $tab_counter;
 606                  $tabitem['title']    = html_specialchars($tabitem['title']);
 607                  $tabitem['class']    = '';
 608                  
 609                  if($g['counter'] === 1) {
 610                      $tabitem['class'] .= ' tab-first';
 611                  }
 612                  if($g['counter'] === $g['max']) {
 613                      $tabitem['class'] .= ' tab-last';
 614                  }
 615                  
 616                  $g['wrap'][]    = '        <li class="tab-item-'.$g['counter'].$tabitem['class'].'"><a href="#'.$tabitem['id'].'" title="'.$tabitem['title'].'">'.$tabitem['title'].'</a></li>';
 617                  $g['cnt'][]        = '    <div id="'.$tabitem['id'].'" class="tab-content">' . LF . $tabitem['content'] . LF . '    </div>';
 618                  
 619                  $tab_counter++;
 620                  $g['counter']++;
 621              }
 622              
 623              $g['wrap'][]    = '    </ul>';
 624              $g['wrap'][]    = implode(LF, $g['cnt']);
 625              $g['wrap'][]    = '    <div class="tab-container-clear"></div>';
 626              $g['wrap'][]    = '</div>';
 627              
 628              $content['cptab'][$CNT_TAB] = implode(LF, $g['wrap']);
 629          }
 630          
 631          unset($g);
 632  
 633      }
 634  }
 635  
 636  if(empty($template_default["article"]["div_spacer"])) {
 637      $content["main"] = str_replace("</table>\n<br />", "</table>\n", $content["main"]);
 638      $content["main"] = str_replace("</table><br />", "</table>", $content["main"]);
 639      $content["main"] = str_replace("</div><br />", "</div>", $content["main"]);
 640  }
 641  
 642  // set canonical <link> in page <head> section to avoid lower SEO ranking
 643  // see: http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html
 644  if($content['set_canonical']) {
 645      if($content['aId_CpPage']) {
 646          $content['set_canonical'] = 'aid='.$row["article_id"].'-'.$content['aId_CpPage'];
 647          if(!empty($content['struct'][ $content['cat_id'] ]['acat_alias'])) {
 648              $content['set_canonical'] .= '&amp;'.$content['struct'][ $content['cat_id'] ]['acat_alias'];
 649          }
 650      } else {
 651          // set canonical only for single article in this category
 652          $content['set_canonical'] = get_structurelevel_single_article_alias($content['cat_id']);
 653      }
 654      if($content['set_canonical']) {
 655          $block['custom_htmlhead']['canonical'] = '  <link rel="canonical" href="' . PHPWCMS_URL . 'index.php?' . $content['set_canonical'] . '" />';
 656      }
 657  }
 658  
 659  if(!defined('PHPWCMS_ALIAS') && !empty($row['article_alias'])) {
 660      define('PHPWCMS_ALIAS', $row['article_alias']);
 661  }
 662  
 663  ?>


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