[ Index ]

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

title

Body

[close]

/include/inc_front/ -> content.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  // ----------------------------------------------------------------
  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          $content["main"] .= '<a name="jump'.$row["article_id"].'" id="jump'.$row["article_id"].'" class="jump-anchor"></a>';
 158          
 159          // enable frontend edit link
 160          $content["main"] .= getFrontendEditLink('article', $row["article_id"]);
 161          $content["main"] .= getFrontendEditLink('summary', $row["article_id"]);
 162          
 163  
 164          // only copy the catname to a special var for multiple for use in any block
 165          $content["cat"]                    = html_specialchars($article["cat"]);
 166          $content["cat_id"]                = $aktion[0] = $row["article_cid"]; //set category ID to actual category value
 167          $content["article_id"]             = $row["article_id"];
 168          $content["summary"]                = '';
 169          $content['article_title']        = $row["article_title"];
 170          $content['article_summary']        = $row["article_summary"];
 171          
 172          $content["article_date"]        = $row["article_date"]; // article date
 173          $content["article_created"]        = $row["article_created"]; // article created
 174          $content['article_livedate']    = $row['article_livedate'];
 175          $content['article_killdate']    = $row['article_killdate'];
 176          $content['article_username']    = $row["article_username"];
 177  
 178          //retrieve image info
 179          $row["article_image"] = unserialize($row["article_image"]);
 180          $caption = getImageCaption($row["article_image"]["caption"]);
 181          $row["article_image"]["caption"]    = $caption[0];
 182          $row["article_image"]["copyright"]    = $caption[4];
 183                  
 184          //build image/image link
 185          $thumb_image = false;
 186          $thumb_img = '';
 187          $popup_img = '';
 188          
 189          $img_thumb_name        = '';
 190          $img_thumb_rel        = '';
 191          $img_thumb_abs        = '';
 192          $img_thumb_width    = 0;
 193          $img_thumb_height    = 0;
 194          
 195          $img_zoom_name        = '';
 196          $img_zoom_rel        = '';
 197          $img_zoom_abs        = '';
 198          $img_zoom_width        = 0;
 199          $img_zoom_height    = 0;
 200          
 201          if(!empty($row["article_image"]["hash"])) {
 202  
 203              $thumb_image = get_cached_image(
 204              array(    "target_ext"    =>    $row["article_image"]['ext'],
 205                      "image_name"    =>    $row["article_image"]['hash'] . '.' . $row["article_image"]['ext'],
 206                      "max_width"        =>    $row["article_image"]['width'],
 207                      "max_height"    =>    $row["article_image"]['height'],
 208                      "thumb_name"    =>    md5($row["article_image"]['hash'].$row["article_image"]['width'].$row["article_image"]['height'].$GLOBALS['phpwcms']["sharpen_level"])
 209              ));
 210  
 211              if($thumb_image != false) {
 212              
 213                  $thumb_img  = '<img src="'.PHPWCMS_IMAGES . $thumb_image[0] .'" border="0" '.$thumb_image[3];
 214                  $thumb_img .= ' alt="'.html_specialchars($caption[1]).'" title="'.html_specialchars($caption[3]).'" />';
 215                  
 216                  $img_thumb_name        = $thumb_image[0];
 217                  $img_thumb_rel        = PHPWCMS_IMAGES.$thumb_image[0];
 218                  $img_thumb_abs        = PHPWCMS_URL.PHPWCMS_IMAGES.$thumb_image[0];
 219                  $img_thumb_width    = $thumb_image[1];
 220                  $img_thumb_height    = $thumb_image[2];
 221  
 222                  if($row["article_image"]["zoom"]) {
 223  
 224                      $zoominfo = get_cached_image(
 225                      array(    "target_ext"    =>    $row["article_image"]['ext'],
 226                      "image_name"    =>    $row["article_image"]['hash'] . '.' . $row["article_image"]['ext'],
 227                      "max_width"        =>    $GLOBALS['phpwcms']["img_prev_width"],
 228                      "max_height"    =>    $GLOBALS['phpwcms']["img_prev_height"],
 229                      "thumb_name"    =>    md5($row["article_image"]['hash'].$GLOBALS['phpwcms']["img_prev_width"].$GLOBALS['phpwcms']["img_prev_height"].$GLOBALS['phpwcms']["sharpen_level"])
 230                      ));
 231  
 232                      if($zoominfo != false) {
 233                      
 234                          $img_zoom_name        = $zoominfo[0];
 235                          $img_zoom_rel        = PHPWCMS_IMAGES.$zoominfo[0];
 236                          $img_zoom_abs        = PHPWCMS_URL.PHPWCMS_IMAGES.$zoominfo[0];
 237                          $img_zoom_width        = $zoominfo[1];
 238                          $img_zoom_height    = $zoominfo[2];
 239  
 240                          $popup_img = 'image_zoom.php?'.getClickZoomImageParameter($zoominfo[0].'?'.$zoominfo[3]);
 241                      
 242                          if(!empty($caption[2][0])) {
 243                              $open_link = $caption[2][0];
 244                              $return_false = '';
 245                          } else {
 246                              $open_link = $popup_img;
 247                              $return_false = 'return false;';
 248                          }
 249  
 250                          if(empty($row["article_image"]["lightbox"])) {
 251                              $thumb_href  = '<a href="'.$popup_img.'" onclick="window.open(\''.$open_link;
 252                              $thumb_href .= "','previewpic','width=".$zoominfo[1].",height=".$zoominfo[2]."');".$return_false;
 253                              $thumb_href .= '"';
 254                              if(!empty($caption[2][1])) {
 255                                  $thumb_href .= $caption[2][1];
 256                              }
 257                              $thumb_href .= '>';
 258                          } else {
 259                          
 260                              //lightbox
 261                              initSlimbox();
 262                              
 263                              $thumb_href  = '<a href="'.PHPWCMS_IMAGES . $zoominfo[0].'"';
 264                              if($row["article_image"]["caption"]) {
 265                                  $thumb_href .= ' title="'.parseLightboxCaption($row["article_image"]["caption"]).'"';
 266                              }
 267                              $thumb_href .= ' rel="lightbox" target="_blank">';
 268                          }
 269                          
 270                          $thumb_img = $thumb_href.$thumb_img.'</a>';
 271                          $popup_img = $thumb_img;
 272                          
 273                      }
 274                  } else {
 275                          
 276                      if($caption[2][0]) {
 277                          $thumb_img = '<a href="'.$caption[2][0].'"'.$caption[2][1].'>'.$thumb_img.'</a>';
 278                      }
 279                  }
 280              }
 281          } else {
 282          
 283              $row["article_image"]['id']        = 0;
 284              $row["article_image"]['hash']    = '';
 285          
 286          }
 287          
 288  
 289          // make some elementary checks regarding content part pagination
 290          $_CpPaginate = false;
 291          
 292          if($row['article_paginate'] && $aktion[2] != 1) { // no pagination in print mode
 293              
 294              // use an IF because acontent_paginate_page=1 is the same as acontent_paginate_page=0
 295              $sql_cnt  = "SELECT DISTINCT IF(acontent_paginate_page=1, 0, acontent_paginate_page) AS acontent_paginate_page, ";
 296              $sql_cnt .= "acontent_paginate_title ";
 297              $sql_cnt .= "FROM ".DB_PREPEND."phpwcms_articlecontent WHERE ";
 298              $sql_cnt .= "acontent_aid=".$row["article_id"]." AND acontent_visible=1 AND acontent_trash=0 ";
 299              
 300              if( !FEUSER_LOGIN_STATUS ) {
 301                  $sql_cnt .= 'AND acontent_granted=0 ';
 302              }
 303              
 304              $sql_cnt .= "AND acontent_block IN ('', 'CONTENT') ORDER BY acontent_paginate_page DESC";
 305              $sql_cnt  = _dbQuery($sql_cnt);
 306              
 307              if(($paginate_count = count($sql_cnt)) > 1) {
 308              
 309                  $content['CpPages']            = array();
 310                  $content['CpPageTitles']    = array();
 311                  $_CpPaginate                = true;
 312                      
 313                  foreach($sql_cnt as $crow) {
 314      
 315                      $content['CpPages'][ $crow['acontent_paginate_page'] ] = $paginate_count; // set page numbers
 316                      
 317                      // set content part pagination title
 318                      if(!isset($content['CpPageTitles'][ $crow['acontent_paginate_page'] ])) {
 319  
 320                          $content['CpPageTitles'][ $crow['acontent_paginate_page'] ] = $crow['acontent_paginate_title'] == '' ? '#'.$paginate_count : $crow['acontent_paginate_title'];
 321                      
 322                      // check if content part title is set but starts with '#'
 323                      } elseif(isset($content['CpPageTitles'][ $crow['acontent_paginate_page'] ]) && $crow['acontent_paginate_title'] != '' && $content['CpPageTitles'][ $crow['acontent_paginate_page'] ]{0} == '#') { 
 324                          
 325                          $content['CpPageTitles'][ $crow['acontent_paginate_page'] ] = $crow['acontent_paginate_title'];
 326                          
 327                      }
 328  
 329                      $paginate_count--;
 330                  }
 331      
 332                  $content['CpPages']            = array_reverse($content['CpPages'], true);
 333                  $content['CpPageTitles']    = array_reverse($content['CpPageTitles'], true);
 334                  
 335                  // check if given cp paginate page is valid, and reset to page 1 (=0)
 336                  // same happens for 1 because this will always be used like it is 0
 337                  if(!isset($content['CpPages'][ $content['aId_CpPage'] ])) {
 338                      $content['aId_CpPage'] = 0;
 339                  }
 340                  
 341              } else {
 342              
 343                  $content['aId_CpPage'] = 0;
 344              
 345              }
 346              
 347          }        
 348  
 349          // check for custom full article summary template
 350          if(!empty($row["article_image"]['tmplfull']) && $row["article_image"]['tmplfull']!='default' && is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article/'.$row["article_image"]['tmplfull'])) {
 351  
 352              // try to read the template files
 353  
 354              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
 355                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article/paginate/'.$row["article_image"]['tmplfull']);
 356              } else {
 357                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article/'.$row["article_image"]['tmplfull']);
 358              }
 359          
 360          } elseif(is_file(PHPWCMS_TEMPLATE.'inc_default/article_summary.tmpl')) {
 361          
 362              // load default template
 363          
 364              if($_CpPaginate && $content['aId_CpPage'] > 1 && is_file(PHPWCMS_TEMPLATE.'inc_default/article_summary_paginate.tmpl')) { // check for default cp paginate template
 365                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_default/article_summary_paginate.tmpl');
 366              } else {
 367                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_default/article_summary.tmpl');
 368              }
 369          
 370          } else {
 371          
 372              // template fallback
 373              if($_CpPaginate && $content['aId_CpPage'] > 1) {
 374                  $row["article_image"]['tmplfull']  = '[TITLE]<h1>{TITLE}</h1>[/TITLE]'.LF.'<!--CP_PAGINATE_START//-->'.LF;
 375                  $row["article_image"]['tmplfull'] .= '<div class="cpPagination">'.LF;
 376                  $row["article_image"]['tmplfull'] .= '    [CP_PAGINATE_PREV]<a href="{CP_PAGINATE_PREV}" class="cpPaginationPrev">Previous</a>[/CP_PAGINATE_PREV]'.LF;
 377                  $row["article_image"]['tmplfull'] .= '    [CP_PAGINATE]{CP_PAGINATE}[/CP_PAGINATE]'.LF;
 378                  $row["article_image"]['tmplfull'] .= '    [CP_PAGINATE_NEXT]<a href="{CP_PAGINATE_NEXT}" class="cpPaginationNext">Previous</a>[/CP_PAGINATE_NEXT]'.LF;
 379                  $row["article_image"]['tmplfull'] .= '</div><!--CP_PAGINATE_END//-->';
 380              } else {
 381                  $row["article_image"]['tmplfull']  = '[TITLE]<h1>{TITLE}</h1>'.LF.'[/TITLE][SUB]<h3>{SUB}</h3>'.LF.'[/SUB]';
 382                  $row["article_image"]['tmplfull'] .= '[SUMMARY][IMAGE]<span style="float:left;margin:2px 10px 5px 0;">{IMAGE}';
 383                  $row["article_image"]['tmplfull'] .= '[CAPTION]<br />'.LF.'{CAPTION}[/CAPTION]</span>'.LF.'[/IMAGE]{SUMMARY}</div>'.LF.'[/SUMMARY]';
 384              }
 385  
 386          }
 387          
 388          //rendering
 389          if($row["article_image"]['tmplfull']) {
 390          
 391              // replace thumbnail and zoom image information
 392              $row["article_image"]['tmplfull'] = str_replace( 
 393                                  array(    '{THUMB_NAME}', '{THUMB_REL}', '{THUMB_ABS}', '{THUMB_WIDTH}', '{THUMB_HEIGHT}',
 394                                          '{IMAGE_NAME}', '{IMAGE_REL}', '{IMAGE_ABS}', '{IMAGE_WIDTH}', '{IMAGE_HEIGHT}',
 395                                          '{IMAGE_ID}',    '{IMAGE_HASH}' ),
 396                                  array(    $img_thumb_name, $img_thumb_rel, $img_thumb_abs, $img_thumb_width, $img_thumb_height,
 397                                          $img_zoom_name, $img_zoom_rel, $img_zoom_abs, $img_zoom_width, $img_zoom_height,
 398                                          $row["article_image"]['id'], $row["article_image"]['hash'] ),
 399                                  $row["article_image"]['tmplfull'] );
 400              
 401              // check if TITLE should be hidden
 402              if(!$row["article_notitle"]) {
 403                  $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'TITLE', html_specialchars($row["article_title"]));
 404              } else {
 405                  $row["article_image"]['tmplfull'] = replace_cnt_template($row["article_image"]['tmplfull'], 'TITLE', '');
 406              }
 407              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'SUB', html_specialchars($row["article_subtitle"]));
 408              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'EDITOR', html_specialchars($row["article_username"]));
 409              
 410              // when "hide summary" is enabled replace everything between [SUMMARY][/SUMMARY]
 411              if(!$row["article_hidesummary"]) {
 412                  $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'SUMMARY', $row["article_summary"]);
 413              } else {
 414                  $row["article_image"]['tmplfull'] = replace_cnt_template($row["article_image"]['tmplfull'], 'SUMMARY', '');
 415              }
 416              
 417              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'IMAGE', $thumb_img);
 418              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'CAPTION', nl2br(html_specialchars($row["article_image"]["caption"])));
 419              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'COPYRIGHT', html_specialchars($row["article_image"]["copyright"]));
 420              $row["article_image"]['tmplfull'] = render_cnt_date($row["article_image"]['tmplfull'], $content["article_date"], $row['article_livedate'], $row['article_killdate']);
 421              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'ZOOMIMAGE', $popup_img);
 422              
 423              $content["summary"] .= $row["article_image"]['tmplfull'];
 424              $row["article_image"]['tmplfull'] = 1;
 425          
 426          } else {
 427          
 428              $row["article_image"]['tmplfull'] = 0;
 429          
 430          }
 431  
 432          if($content["summary"]) {
 433          
 434              $content["main"] .= $content["summary"];
 435              $content["main"] .= $template_default["article"]["head_after"];
 436          
 437          }
 438  
 439          // render content parts
 440          $sql_cnt  = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent WHERE acontent_aid=".$row["article_id"]." ";
 441          $sql_cnt .=    "AND acontent_visible=1 AND acontent_trash=0 ";
 442          if( !FEUSER_LOGIN_STATUS ) {
 443              $sql_cnt .= 'AND acontent_granted=0 ';
 444          }
 445          $sql_cnt .= "ORDER BY acontent_sorting, acontent_id";
 446          $cresult  = _dbQuery($sql_cnt);
 447          
 448          foreach($cresult as $crow) {
 449          
 450              // check for article content part pagination
 451              if($_CpPaginate && ($crow['acontent_block'] == 'CONTENT' || $crow['acontent_block'] == '')) {
 452      
 453                  // now check which content part should be rendered...
 454                  
 455                  // first - cp page 0 OR 1 = 1st page and the same
 456                  if(($content['aId_CpPage'] == 0 || $content['aId_CpPage'] == 1) && ($crow['acontent_paginate_page'] == 0 || $crow['acontent_paginate_page'] == 1)) {
 457                                          
 458                      // then compare if selected page is same as paginate page
 459                  } elseif($content['aId_CpPage'] == $crow['acontent_paginate_page']) {
 460                                          
 461                      // hm, do not render current content part
 462                  } else {
 463                  
 464                      continue;
 465                  }
 466      
 467              }
 468          
 469              // if type of content part not enabled available 
 470              if(!isset($wcs_content_type[ $crow["acontent_type"] ]) ||  ($crow["acontent_type"] == 30 && !isset($phpwcms['modules'][$crow["acontent_module"]]))) {
 471                  continue;
 472              }
 473          
 474              // do everything neccessary for alias content part
 475              if($crow["acontent_type"] == 24) {
 476                  $crow = getContentPartAlias($crow);
 477              }
 478          
 479              // every article content  will be rendered into temp var 
 480              $CNT_TMP  = '';
 481              
 482              // each content part will get an anchor
 483              if($crow["acontent_anchor"]) {
 484                  $CNT_TMP .= '<a name="cpid'.$crow["acontent_id"].'" id="cpid'.$crow["acontent_id"].'" class="cpidClass"></a>';
 485              }
 486  
 487              // Space before
 488              if($crow["acontent_before"]) {
 489                  if(!empty($template_default["article"]["div_spacer"])) {
 490                      $CNT_TMP .= '<div style="margin:'.$crow["acontent_before"].'px 0 0 0;padding:0;" class="spaceBeforeCP"></div>';
 491                  } else {
 492                      $CNT_TMP .= '<br class="spaceBeforeCP" />'.spacer(1,$crow["acontent_before"]);
 493                  }
 494              }
 495              
 496              // set frontend edit link
 497              $CNT_TMP .= getFrontendEditLink('CP', $crow['acontent_aid'], $crow['acontent_id']);
 498              
 499              // include content part code section
 500              if($crow["acontent_type"] != 30) {
 501  
 502                  @include(PHPWCMS_ROOT."/include/inc_front/content/cnt".$crow["acontent_type"].".article.inc.php");
 503              
 504              } elseif($crow["acontent_type"] == 30 && is_file($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php')) {
 505  
 506                  $CNT_TMP .= getFrontendEditLink('module', $phpwcms['modules'][$crow["acontent_module"]]['name']);
 507                  // now try to include module content part code
 508                  include($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php');
 509              
 510              }
 511  
 512              // check if top link should be shown
 513              $CNT_TMP .= getContentPartTopLink($crow["acontent_top"]);
 514  
 515              // Space after
 516              if($crow["acontent_after"]) {
 517                  if(!empty($template_default["article"]["div_spacer"])) {
 518                      $CNT_TMP .= '<div style="margin:0 0 '.$crow["acontent_after"].'px 0;padding:0;" class="spaceAfterCP"></div>';
 519                  } else {
 520                      $CNT_TMP .= '<br class="spaceAfterCP" />'.spacer(1,$crow["acontent_after"]);
 521                  }
 522              }
 523              
 524              // Maybe content part ID should b used inside templates or for something different
 525              $CNT_TMP = str_replace( array('[%CPID%]', '{CPID}'), $crow["acontent_id"], $CNT_TMP );
 526              
 527              // trigger content part functions
 528              $CNT_TMP = trigger_cp($CNT_TMP, $crow);
 529              
 530              //check if PHP replacent tags are allowed for content
 531              if(empty($phpwcms["allow_cntPHP_rt"])) {
 532                  $CNT_TMP = remove_unsecure_rptags($CNT_TMP);
 533              }
 534              
 535              
 536              // wrap tab 
 537              if(!empty($crow['acontent_tab'])) {
 538                  
 539                  $crow['acontent_tab']            = explode('_', $crow['acontent_tab'], 2);
 540                  $crow['acontent_tab']['num']    = intval($crow['acontent_tab'][0]);
 541                  $crow['acontent_tab']['title']    = empty($crow['acontent_tab'][1]) ? '@@TabTitle@@' : $crow['acontent_tab'][1];
 542                  
 543                  // create a unique Tab ID based on title, content block and section
 544                  $CNT_TAB        = 'TABBOX-' . md5($crow['acontent_block'] . $crow['acontent_tab']['num']);
 545                  $CNT_TAB_ID     = 'TAB-' . md5($crow['acontent_tab']['title'].$crow['acontent_block']);
 546                  $CNT_TAB_TMP    = $CNT_TMP;
 547                  
 548                  // check if Tab ID is registered
 549                  if(!isset($content['cptab'][$CNT_TAB])) {
 550                      
 551                      $content['cptab'][$CNT_TAB] = array();
 552                      
 553                      // write Tab Block Replacer
 554                      $CNT_TMP = '<!-- ' . $CNT_TAB . ' -->';
 555                      
 556                  } else {
 557                  
 558                      $CNT_TMP = '';
 559                      
 560                  }
 561                  if(!isset($content['cptab'][$CNT_TAB][$CNT_TAB_ID])) {
 562                      
 563                      $content['cptab'][$CNT_TAB][$CNT_TAB_ID] = array(
 564                          'title'        => $crow['acontent_tab']['title'],
 565                          'content'    => ''
 566                      );
 567                      
 568                  }
 569                  
 570                  $content['cptab'][$CNT_TAB][$CNT_TAB_ID]['content'] .= $CNT_TAB_TMP;
 571              
 572              }
 573              
 574              // now add rendered content part to right frontend content 
 575              // var given by block -> $content['CB'][$crow['acontent_block']]
 576              if($crow['acontent_block'] == 'CONTENT' || $crow['acontent_block'] == '') {
 577                  // default content block
 578                  $content["main"] .= $CNT_TMP;
 579              } else {
 580                  // check if content block var is set
 581                  if(!isset($content['CB'][$crow['acontent_block']])) {
 582                      $content['CB'][$crow['acontent_block']] = '';
 583                  }
 584                  $content['CB'][$crow['acontent_block']] .= $CNT_TMP;
 585              }
 586              
 587          }
 588          
 589          
 590          // render Tabs
 591          $tab_counter = 0;
 592          foreach($content['cptab'] as $CNT_TAB => $trow) {
 593              
 594              // define helper var
 595              $g = array('wrap' => array(), 'cnt' => array(), 'counter' => 1, 'max' => count($trow));
 596      
 597              $g['wrap'][]    = '<div id="'.$CNT_TAB.'" class="tab-container">';
 598              
 599              $g['wrap'][]    = '    <ul class="tab-navigation">';
 600              
 601              foreach($trow as $tabkey => $tabitem) {
 602                  
 603                  $tabitem['id']        = 'tab-' . uri_sanitize(strtolower($tabitem['title'])) . $tab_counter;
 604                  $tabitem['title']    = html_specialchars($tabitem['title']);
 605                  $tabitem['class']    = '';
 606                  
 607                  if($g['counter'] === 1) {
 608                      $tabitem['class'] .= ' tab-first';
 609                  }
 610                  if($g['counter'] === $g['max']) {
 611                      $tabitem['class'] .= ' tab-last';
 612                  }
 613                  
 614                  $g['wrap'][]    = '        <li class="tab-item-'.$g['counter'].$tabitem['class'].'"><a href="#'.$tabitem['id'].'" title="'.$tabitem['title'].'">'.$tabitem['title'].'</a></li>';
 615                  $g['cnt'][]        = '    <div id="'.$tabitem['id'].'" class="tab-content">' . LF . $tabitem['content'] . LF . '    </div>';
 616                  
 617                  $tab_counter++;
 618                  $g['counter']++;
 619              }
 620              
 621              $g['wrap'][]    = '    </ul>';
 622              $g['wrap'][]    = implode(LF, $g['cnt']);
 623              $g['wrap'][]    = '    <div class="tab-container-clear"></div>';
 624              $g['wrap'][]    = '</div>';
 625              
 626              $content['cptab'][$CNT_TAB] = implode(LF, $g['wrap']);
 627          }
 628          
 629          unset($g);
 630  
 631      }
 632  }
 633  
 634  if(empty($template_default["article"]["div_spacer"])) {
 635      $content["main"] = str_replace("</table>\n<br />", "</table>\n", $content["main"]);
 636      $content["main"] = str_replace("</table><br />", "</table>", $content["main"]);
 637      $content["main"] = str_replace("</div><br />", "</div>", $content["main"]);
 638  }
 639  
 640  // set canonical <link> in page <head> section to avoid lower SEO ranking
 641  // see: http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html
 642  if($content['set_canonical']) {
 643      if($content['aId_CpPage']) {
 644          $content['set_canonical'] = 'aid='.$row["article_id"].'-'.$content['aId_CpPage'];
 645          if(!empty($content['struct'][ $content['cat_id'] ]['acat_alias'])) {
 646              $content['set_canonical'] .= '&amp;'.$content['struct'][ $content['cat_id'] ]['acat_alias'];
 647          }
 648      } else {
 649          $content['set_canonical'] = empty($content['struct'][ $content['cat_id'] ]['acat_alias']) ? 'id='.$content['cat_id'] : $content['struct'][ $content['cat_id'] ]['acat_alias'];
 650      }
 651      $block['custom_htmlhead']['canonical'] = '  <link rel="canonical" href="' . PHPWCMS_URL . 'index.php?' . $content['set_canonical'] . '" />';
 652  }
 653  
 654  if(!defined('PHPWCMS_ALIAS') && !empty($row['article_alias'])) {
 655      define('PHPWCMS_ALIAS', $row['article_alias']);
 656  }
 657  
 658  ?>


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