[ Index ]

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

title

Body

[close]

/include/inc_front/ -> content.article.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // ----------------------------------------------------------------
  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                      }
  84                  }
  85                  mysql_free_result($alias_result);
  86              }
  87          }
  88  
  89          //Kategoriebezeichner
  90          $article['cat'] = $content['struct'][$row["article_cid"]]['acat_name'];
  91  
  92          //redirection definition
  93          if($row["article_redirect"]) {
  94  
  95              $row["article_redirect"]        = str_replace('{SITE}', PHPWCMS_URL, $row["article_redirect"]);
  96              $content["redirect"]            = explode(' ', $row["article_redirect"]);
  97              $content["redirect"]["link"]    = $content["redirect"][0];
  98              $content["redirect"]["target"]    = isset($content["redirect"][1]) ? $content["redirect"][1] : '';
  99              $content["redirect"]["timeout"]    = isset($content["redirect"][2]) ? intval($content["redirect"][2]) : 0;
 100  
 101              //check how to redirect - new window or self window
 102              if(    !$content["redirect"]["target"]    || $content["redirect"]["target"] == "_self" ||    $content["redirect"]["target"] == "_top" ||    $content["redirect"]["target"] == "_parent") {
 103                  // direct redirection in the same window
 104                  headerRedirect($content["redirect"]["link"], 301);
 105              } else {
 106                  // redirection by using a special <meta><javascript> html head part
 107                  $content["redirect"]["code"]  = LF . '  <noscript>' . LF;
 108                  $content["redirect"]["code"] .= '    <meta http-equiv="refresh" content="'.$content["redirect"]["timeout"].';URL=';
 109                  $content["redirect"]["code"] .= $content["redirect"]["link"];
 110                  $content["redirect"]["code"] .= '" />'.LF.'  </noscript>' . LF;
 111                  $content["redirect"]["code"] .= '  <script type="text/javascript">' . LF . '  <!--' . LF;
 112                  $content["redirect"]["code"] .= '    var redirectWin;' . LF;
 113                  if($content["redirect"]["timeout"]) {
 114                      $content["redirect"]["code"] .= '    window.setTimeout(\'window.open("'.$content["redirect"]["link"].'", redirectWin)\', ';
 115                      $content["redirect"]["code"] .= $content["redirect"]["timeout"] * 1000;
 116                      $content["redirect"]["code"] .= ');';
 117                  } else {
 118                      $content["redirect"]["code"] .= '    window.open("'.$content["redirect"]["link"].'", redirectWin);';
 119                  }
 120                  $content["redirect"]["code"] .= LF . '  //-->' . LF . '  </script>' . LF;
 121              }
 122          }
 123  
 124  
 125          // UNIQUE article ID as used for teaser content part
 126          if(!isset($content['UNIQUE_ALINK'])) {
 127              $content['UNIQUE_ALINK'] = array();
 128          }
 129          
 130          $content['UNIQUE_ALINK'][ $row["article_id"] ] = $row["article_id"];
 131  
 132  
 133          //set cache timeout for this article
 134          if($row['article_cache'] != '') {
 135              $phpwcms['cache_timeout'] = $row['article_cache'];
 136          }
 137          //get value for article search (on/off)
 138          if($row['article_nosearch'] != '') {
 139              $cache_searchable = '1';
 140          }
 141  
 142          //check if article has custom pagetitle
 143          if(!empty($row["article_pagetitle"])) {
 144          
 145              $content["pagetitle"] = $row["article_pagetitle"];
 146          
 147          } else {
 148              
 149              $content["pagetitle"] = setPageTitle($content["pagetitle"], $article['cat'], $row["article_title"]);
 150          
 151          }
 152          
 153          $content['all_keywords'] = $row['article_keyword'];
 154  
 155          $content["main"] .= '<a name="jump'.$row["article_id"].'" id="jump'.$row["article_id"].'"></a>';
 156          
 157          // enable frontend edit link
 158          $content["main"] .= getFrontendEditLink('article', $row["article_id"]);
 159          $content["main"] .= getFrontendEditLink('summary', $row["article_id"]);
 160          
 161  
 162          // only copy the catname to a special var for multiple for use in any block
 163          $content["cat"]                    = html_specialchars($article["cat"]);
 164          $content["cat_id"]                = $aktion[0] = $row["article_cid"]; //set category ID to actual category value
 165          $content["article_id"]             = $row["article_id"];
 166          $content["summary"]                = '';
 167          $content['article_title']        = $row["article_title"];
 168          $content['article_summary']        = $row["article_summary"];
 169          
 170          $content["article_date"]        = $row["article_date"]; // article date
 171          $content["article_created"]        = $row["article_created"]; // article created
 172          $content['article_livedate']    = $row['article_livedate'];
 173          $content['article_killdate']    = $row['article_killdate'];
 174          $content['article_username']    = $row["article_username"];
 175  
 176          //retrieve image info
 177          $row["article_image"] = unserialize($row["article_image"]);
 178          $caption = getImageCaption($row["article_image"]["caption"]);
 179          $row["article_image"]["caption"]    = $caption[0];
 180          $row["article_image"]["copyright"]    = $caption[4];
 181                  
 182          //build image/image link
 183          $thumb_image = false;
 184          $thumb_img = '';
 185          $popup_img = '';
 186          
 187          $img_thumb_name        = '';
 188          $img_thumb_rel        = '';
 189          $img_thumb_abs        = '';
 190          $img_thumb_width    = 0;
 191          $img_thumb_height    = 0;
 192          
 193          $img_zoom_name        = '';
 194          $img_zoom_rel        = '';
 195          $img_zoom_abs        = '';
 196          $img_zoom_width        = 0;
 197          $img_zoom_height    = 0;
 198          
 199          if(!empty($row["article_image"]["hash"])) {
 200  
 201              $thumb_image = get_cached_image(
 202              array(    "target_ext"    =>    $row["article_image"]['ext'],
 203                      "image_name"    =>    $row["article_image"]['hash'] . '.' . $row["article_image"]['ext'],
 204                      "max_width"        =>    $row["article_image"]['width'],
 205                      "max_height"    =>    $row["article_image"]['height'],
 206                      "thumb_name"    =>    md5($row["article_image"]['hash'].$row["article_image"]['width'].$row["article_image"]['height'].$GLOBALS['phpwcms']["sharpen_level"])
 207              ));
 208  
 209              if($thumb_image != false) {
 210              
 211                  $thumb_img  = '<img src="'.PHPWCMS_IMAGES . $thumb_image[0] .'" border="0" '.$thumb_image[3];
 212                  $thumb_img .= ' alt="'.html_specialchars($caption[1]).'" title="'.html_specialchars($caption[3]).'" />';
 213                  
 214                  $img_thumb_name        = $thumb_image[0];
 215                  $img_thumb_rel        = PHPWCMS_IMAGES.$thumb_image[0];
 216                  $img_thumb_abs        = PHPWCMS_URL.PHPWCMS_IMAGES.$thumb_image[0];
 217                  $img_thumb_width    = $thumb_image[1];
 218                  $img_thumb_height    = $thumb_image[2];
 219  
 220                  if($row["article_image"]["zoom"]) {
 221  
 222                      $zoominfo = get_cached_image(
 223                      array(    "target_ext"    =>    $row["article_image"]['ext'],
 224                      "image_name"    =>    $row["article_image"]['hash'] . '.' . $row["article_image"]['ext'],
 225                      "max_width"        =>    $GLOBALS['phpwcms']["img_prev_width"],
 226                      "max_height"    =>    $GLOBALS['phpwcms']["img_prev_height"],
 227                      "thumb_name"    =>    md5($row["article_image"]['hash'].$GLOBALS['phpwcms']["img_prev_width"].$GLOBALS['phpwcms']["img_prev_height"].$GLOBALS['phpwcms']["sharpen_level"])
 228                      ));
 229  
 230                      if($zoominfo != false) {
 231                      
 232                          $img_zoom_name        = $zoominfo[0];
 233                          $img_zoom_rel        = PHPWCMS_IMAGES.$zoominfo[0];
 234                          $img_zoom_abs        = PHPWCMS_URL.PHPWCMS_IMAGES.$zoominfo[0];
 235                          $img_zoom_width        = $zoominfo[1];
 236                          $img_zoom_height    = $zoominfo[2];
 237  
 238                          $popup_img = 'image_zoom.php?'.getClickZoomImageParameter($zoominfo[0].'?'.$zoominfo[3]);
 239                      
 240                          if(!empty($caption[2][0])) {
 241                              $open_link = $caption[2][0];
 242                              $return_false = '';
 243                          } else {
 244                              $open_link = $popup_img;
 245                              $return_false = 'return false;';
 246                          }
 247  
 248                          if(empty($row["article_image"]["lightbox"])) {
 249                              $thumb_href  = '<a href="'.$popup_img.'" onclick="window.open(\''.$open_link;
 250                              $thumb_href .= "','previewpic','width=".$zoominfo[1].",height=".$zoominfo[2]."');".$return_false;
 251                              $thumb_href .= '"';
 252                              if(!empty($caption[2][1])) {
 253                                  $thumb_href .= $caption[2][1];
 254                              }
 255                              $thumb_href .= '>';
 256                          } else {
 257                          
 258                              //lightbox
 259                              initializeLightbox();
 260                              
 261                              $thumb_href  = '<a href="'.PHPWCMS_IMAGES . $zoominfo[0].'"';
 262                              if($row["article_image"]["caption"]) {
 263                                  $thumb_href .= ' title="'.parseLightboxCaption($row["article_image"]["caption"]).'"';
 264                              }
 265                              $thumb_href .= ' rel="lightbox" target="_blank">';
 266                          }
 267                          
 268                          $thumb_img = $thumb_href.$thumb_img.'</a>';
 269                          $popup_img = $thumb_img;
 270                          
 271                      }
 272                  } else {
 273                          
 274                      if($caption[2][0]) {
 275                          $thumb_img = '<a href="'.$caption[2][0].'"'.$caption[2][1].'>'.$thumb_img.'</a>';
 276                      }
 277                  }
 278              }
 279          } else {
 280          
 281              $row["article_image"]['id']        = 0;
 282              $row["article_image"]['hash']    = '';
 283          
 284          }
 285          
 286  
 287          // make some elementary checks regarding content part pagination
 288          $_CpPaginate = false;
 289          
 290          if($row['article_paginate'] && $aktion[2] != 1) { // no pagination in print mode
 291              
 292              // use an IF because acontent_paginate_page=1 is the same as acontent_paginate_page=0
 293              $sql_cnt  = "SELECT DISTINCT IF(acontent_paginate_page=1, 0, acontent_paginate_page) AS acontent_paginate_page, ";
 294              $sql_cnt .= "acontent_paginate_title ";
 295              $sql_cnt .= "FROM ".DB_PREPEND."phpwcms_articlecontent WHERE ";
 296              $sql_cnt .= "acontent_aid=".$row["article_id"]." AND acontent_visible=1 AND acontent_trash=0 ";
 297              
 298              if( !FEUSER_LOGIN_STATUS ) {
 299                  $sql_cnt .= 'AND acontent_granted=0 ';
 300              }
 301              
 302              $sql_cnt .= "AND acontent_block IN ('', 'CONTENT') ORDER BY acontent_paginate_page DESC";
 303              $sql_cnt  = _dbQuery($sql_cnt);
 304              
 305              if(($paginate_count = count($sql_cnt)) > 1) {
 306              
 307                  $content['CpPages']            = array();
 308                  $content['CpPageTitles']    = array();
 309                  $_CpPaginate                = true;
 310                      
 311                  foreach($sql_cnt as $crow) {
 312      
 313                      $content['CpPages'][ $crow['acontent_paginate_page'] ] = $paginate_count; // set page numbers
 314                      
 315                      // set content part pagination title
 316                      if(!isset($content['CpPageTitles'][ $crow['acontent_paginate_page'] ])) {
 317  
 318                          $content['CpPageTitles'][ $crow['acontent_paginate_page'] ] = $crow['acontent_paginate_title'] == '' ? '#'.$paginate_count : $crow['acontent_paginate_title'];
 319                      
 320                      // check if content part title is set but starts with '#'
 321                      } elseif(isset($content['CpPageTitles'][ $crow['acontent_paginate_page'] ]) && $crow['acontent_paginate_title'] != '' && $content['CpPageTitles'][ $crow['acontent_paginate_page'] ]{0} == '#') { 
 322                          
 323                          $content['CpPageTitles'][ $crow['acontent_paginate_page'] ] = $crow['acontent_paginate_title'];
 324                          
 325                      }
 326  
 327                      $paginate_count--;
 328                  }
 329      
 330                  $content['CpPages']            = array_reverse($content['CpPages'], true);
 331                  $content['CpPageTitles']    = array_reverse($content['CpPageTitles'], true);
 332                  
 333                  // check if given cp paginate page is valid, and reset to page 1 (=0)
 334                  // same happens for 1 because this will always be used like it is 0
 335                  if(!isset($content['CpPages'][ $content['aId_CpPage'] ])) {
 336                      $content['aId_CpPage'] = 0;
 337                  }
 338                  
 339              } else {
 340              
 341                  $content['aId_CpPage'] = 0;
 342              
 343              }
 344              
 345          }        
 346  
 347          // check for custom full article summary template
 348          if(!empty($row["article_image"]['tmplfull']) && $row["article_image"]['tmplfull']!='default' && is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article/'.$row["article_image"]['tmplfull'])) {
 349  
 350              // try to read the template files
 351  
 352              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
 353                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article/paginate/'.$row["article_image"]['tmplfull']);
 354              } else {
 355                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article/'.$row["article_image"]['tmplfull']);
 356              }
 357          
 358          } elseif(is_file(PHPWCMS_TEMPLATE.'inc_default/article_summary.tmpl')) {
 359          
 360              // load default template
 361          
 362              if($_CpPaginate && $content['aId_CpPage'] > 1 && is_file(PHPWCMS_TEMPLATE.'inc_default/article_summary_paginate.tmpl')) { // check for default cp paginate template
 363                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_default/article_summary_paginate.tmpl');
 364              } else {
 365                  $row["article_image"]['tmplfull'] = file_get_contents(PHPWCMS_TEMPLATE.'inc_default/article_summary.tmpl');
 366              }
 367          
 368          } else {
 369          
 370              // template fallback
 371              if($_CpPaginate && $content['aId_CpPage'] > 1) {
 372                  $row["article_image"]['tmplfull']  = '[TITLE]<h1>{TITLE}</h1>[/TITLE]'.LF.'<!--CP_PAGINATE_START//-->'.LF;
 373                  $row["article_image"]['tmplfull'] .= '<div class="cpPagination">'.LF;
 374                  $row["article_image"]['tmplfull'] .= '    [CP_PAGINATE_PREV]<a href="{CP_PAGINATE_PREV}" class="cpPaginationPrev">Previous</a>[/CP_PAGINATE_PREV]'.LF;
 375                  $row["article_image"]['tmplfull'] .= '    [CP_PAGINATE]{CP_PAGINATE}[/CP_PAGINATE]'.LF;
 376                  $row["article_image"]['tmplfull'] .= '    [CP_PAGINATE_NEXT]<a href="{CP_PAGINATE_NEXT}" class="cpPaginationNext">Previous</a>[/CP_PAGINATE_NEXT]'.LF;
 377                  $row["article_image"]['tmplfull'] .= '</div><!--CP_PAGINATE_END//-->';
 378              } else {
 379                  $row["article_image"]['tmplfull']  = '[TITLE]<h1>{TITLE}</h1>'.LF.'[/TITLE][SUB]<h3>{SUB}</h3>'.LF.'[/SUB]';
 380                  $row["article_image"]['tmplfull'] .= '[SUMMARY][IMAGE]<span style="float:left;margin:2px 10px 5px 0;">{IMAGE}';
 381                  $row["article_image"]['tmplfull'] .= '[CAPTION]<br />'.LF.'{CAPTION}[/CAPTION]</span>'.LF.'[/IMAGE]{SUMMARY}</div>'.LF.'[/SUMMARY]';
 382              }
 383  
 384          }
 385          
 386          //rendering
 387          if($row["article_image"]['tmplfull']) {
 388          
 389              // replace thumbnail and zoom image information
 390              $row["article_image"]['tmplfull'] = str_replace( 
 391                                  array(    '{THUMB_NAME}', '{THUMB_REL}', '{THUMB_ABS}', '{THUMB_WIDTH}', '{THUMB_HEIGHT}',
 392                                          '{IMAGE_NAME}', '{IMAGE_REL}', '{IMAGE_ABS}', '{IMAGE_WIDTH}', '{IMAGE_HEIGHT}',
 393                                          '{IMAGE_ID}',    '{IMAGE_HASH}' ),
 394                                  array(    $img_thumb_name, $img_thumb_rel, $img_thumb_abs, $img_thumb_width, $img_thumb_height,
 395                                          $img_zoom_name, $img_zoom_rel, $img_zoom_abs, $img_zoom_width, $img_zoom_height,
 396                                          $row["article_image"]['id'], $row["article_image"]['hash'] ),
 397                                  $row["article_image"]['tmplfull'] );
 398              
 399              // check if TITLE should be hidden
 400              if(!$row["article_notitle"]) {
 401                  $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'TITLE', html_specialchars($row["article_title"]));
 402              } else {
 403                  $row["article_image"]['tmplfull'] = replace_cnt_template($row["article_image"]['tmplfull'], 'TITLE', '');
 404              }
 405              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'SUB', html_specialchars($row["article_subtitle"]));
 406              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'EDITOR', html_specialchars($row["article_username"]));
 407              
 408              // when "hide summary" is enabled replace everything between [SUMMARY][/SUMMARY]
 409              if(!$row["article_hidesummary"]) {
 410                  $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'SUMMARY', $row["article_summary"]);
 411              } else {
 412                  $row["article_image"]['tmplfull'] = replace_cnt_template($row["article_image"]['tmplfull'], 'SUMMARY', '');
 413              }
 414              
 415              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'IMAGE', $thumb_img);
 416              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'CAPTION', nl2br(html_specialchars($row["article_image"]["caption"])));
 417              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'COPYRIGHT', html_specialchars($row["article_image"]["copyright"]));
 418              $row["article_image"]['tmplfull'] = render_cnt_date($row["article_image"]['tmplfull'], $content["article_date"], $row['article_livedate'], $row['article_killdate']);
 419              $row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'ZOOMIMAGE', $popup_img);
 420              
 421              $content["summary"] .= $row["article_image"]['tmplfull'];
 422              $row["article_image"]['tmplfull'] = 1;
 423          
 424          } else {
 425          
 426              $row["article_image"]['tmplfull'] = 0;
 427          
 428          }
 429  
 430          if($content["summary"]) {
 431          
 432              $content["main"] .= $content["summary"];
 433              $content["main"] .= $template_default["article"]["head_after"];
 434          
 435          }
 436  
 437          // render content parts
 438          $sql_cnt  = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent WHERE acontent_aid=".$row["article_id"]." ";
 439          $sql_cnt .=    "AND acontent_visible=1 AND acontent_trash=0 ";
 440          if( !FEUSER_LOGIN_STATUS ) {
 441              $sql_cnt .= 'AND acontent_granted=0 ';
 442          }
 443          $sql_cnt .= "ORDER BY acontent_sorting, acontent_id";
 444          $cresult  = _dbQuery($sql_cnt);
 445          
 446          foreach($cresult as $crow) {
 447          
 448              // check for article content part pagination
 449              if($_CpPaginate && ($crow['acontent_block'] == 'CONTENT' || $crow['acontent_block'] == '')) {
 450      
 451                  // now check which content part should be rendered...
 452                  
 453                  // first - cp page 0 OR 1 = 1st page and the same
 454                  if(($content['aId_CpPage'] == 0 || $content['aId_CpPage'] == 1) && ($crow['acontent_paginate_page'] == 0 || $crow['acontent_paginate_page'] == 1)) {
 455                                          
 456                      // then compare if selected page is same as paginate page
 457                  } elseif($content['aId_CpPage'] == $crow['acontent_paginate_page']) {
 458                                          
 459                      // hm, do not render current content part
 460                  } else {
 461                  
 462                      continue;
 463                  }
 464      
 465              }
 466          
 467              // if type of content part not enabled available 
 468              if(!isset($wcs_content_type[ $crow["acontent_type"] ]) ||  ($crow["acontent_type"] == 30 && !isset($phpwcms['modules'][$crow["acontent_module"]]))) {
 469                  continue;
 470              }
 471          
 472              // do everything neccessary for alias content part
 473              if($crow["acontent_type"] == 24) {
 474                  $crow = getContentPartAlias($crow);
 475              }
 476          
 477              // every article content  will be rendered into temp var 
 478              $CNT_TMP  = '';
 479              
 480              // each content part will get an anchor
 481              if($crow["acontent_anchor"]) {
 482                  $CNT_TMP .= '<a name="cpid'.$crow["acontent_id"].'" id="cpid'.$crow["acontent_id"].'" class="cpidClass"></a>';
 483              }
 484  
 485              // Space before
 486              if($crow["acontent_before"]) {
 487                  if(!empty($template_default["article"]["div_spacer"])) {
 488                      $CNT_TMP .= '<div style="margin:'.$crow["acontent_before"].'px 0 0 0;padding:0;" class="spaceBeforeCP"></div>';
 489                  } else {
 490                      $CNT_TMP .= '<br class="spaceBeforeCP" />'.spacer(1,$crow["acontent_before"]);
 491                  }
 492              }
 493              
 494              // set frontend edit link
 495              $CNT_TMP .= getFrontendEditLink('CP', $crow['acontent_aid'], $crow['acontent_id']);
 496              
 497              // include content part code section
 498              if($crow["acontent_type"] != 30) {
 499  
 500                  @include(PHPWCMS_ROOT."/include/inc_front/content/cnt".$crow["acontent_type"].".article.inc.php");
 501              
 502              } elseif($crow["acontent_type"] == 30 && is_file($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php')) {
 503  
 504                  $CNT_TMP .= getFrontendEditLink('module', $phpwcms['modules'][$crow["acontent_module"]]['name']);
 505                  // now try to include module content part code
 506                  include($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php');
 507              
 508              }
 509  
 510              //check if top link should be shown
 511              $CNT_TMP .= getContentPartTopLink($crow["acontent_top"]);
 512  
 513              // Space after
 514              if($crow["acontent_after"]) {
 515                  if(!empty($template_default["article"]["div_spacer"])) {
 516                      $CNT_TMP .= '<div style="margin:0 0 '.$crow["acontent_after"].'px 0;padding:0;" class="spaceAfterCP"></div>';
 517                  } else {
 518                      $CNT_TMP .= '<br class="spaceAfterCP" />'.spacer(1,$crow["acontent_after"]);
 519                  }
 520              }
 521              
 522              //Maybe content part ID should b used inside templates or for something different
 523              $CNT_TMP = str_replace( array('[%CPID%]', '{CPID}'), $crow["acontent_id"], $CNT_TMP );
 524              
 525              // trigger content part functions
 526              $CNT_TMP = trigger_cp($CNT_TMP, $crow);
 527              
 528              //check if PHP replacent tags are allowed for content
 529              if(empty($phpwcms["allow_cntPHP_rt"])) {
 530                  $CNT_TMP = remove_unsecure_rptags($CNT_TMP);
 531              }
 532              
 533              // now add rendered content part to right frontend content 
 534              // var given by block -> $content['CB'][$crow['acontent_block']]
 535              if($crow['acontent_block'] == 'CONTENT' || $crow['acontent_block'] == '') {
 536                  // default content block
 537                  $content["main"] .= $CNT_TMP;
 538              } else {
 539                  // check if content block var is set
 540                  if(!isset($content['CB'][$crow['acontent_block']])) {
 541                      $content['CB'][$crow['acontent_block']] = '';
 542                  }
 543                  $content['CB'][$crow['acontent_block']] .= $CNT_TMP;
 544              }
 545              
 546              
 547          }
 548      }
 549  }
 550  
 551  if(empty($template_default["article"]["div_spacer"])) {
 552      $content["main"] = str_replace("</table>\n<br />", "</table>\n", $content["main"]);
 553      $content["main"] = str_replace("</table><br />", "</table>", $content["main"]);
 554      $content["main"] = str_replace("</div><br />", "</div>", $content["main"]);
 555  }
 556  
 557  if(!defined('PHPWCMS_ALIAS') && !empty($row['article_alias'])) {
 558      define('PHPWCMS_ALIAS', $row['article_alias']);
 559  }
 560  
 561  ?>


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