[ Index ]

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

title

Body

[close]

/include/inc_front/content/ -> cnt33.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  // News
  31  
  32  $news    = @unserialize($crow["acontent_form"]);
  33  
  34  //$CNT_TMP .= dumpVar($news, 2);
  35  
  36  // read template
  37  if(empty($crow["acontent_template"]) && is_file(PHPWCMS_TEMPLATE.'inc_default/news.tmpl')) {
  38  
  39      $news['template']    = @file_get_contents(PHPWCMS_TEMPLATE.'inc_default/news.tmpl');
  40      
  41  } elseif(is_file(PHPWCMS_TEMPLATE.'inc_cntpart/news/'.$crow["acontent_template"])) {
  42  
  43      $news['template']    = @file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/news/'.$crow["acontent_template"]);
  44  
  45  } else {
  46  
  47      $news['template']    = '';
  48  
  49  }
  50  
  51  
  52  // build SQL query first
  53  $news['sql_where']        = array();
  54  $news['now']            = now();
  55  $news['list_mode']        = true;
  56  $news['listing_page']    = array();
  57  
  58  $news['cnt_ts_livedate'] = 'IF(UNIX_TIMESTAMP(pc.cnt_livedate) > 0, UNIX_TIMESTAMP(pc.cnt_livedate), pc.cnt_created)';
  59  $news['cnt_ts_killdate'] = 'IF(UNIX_TIMESTAMP(pc.cnt_killdate) > 0, UNIX_TIMESTAMP(pc.cnt_killdate), ' . ( $news['now'] + 3600 ) . ')'; // set end date to current time + 1 hour
  60  $news['cnt_ts_sortdate'] = 'IF(pc.cnt_sort=0, IF(UNIX_TIMESTAMP(pc.cnt_livedate) > 0, UNIX_TIMESTAMP(pc.cnt_livedate), pc.cnt_created), pc.cnt_sort)';
  61  
  62  // define the general SELECT query part
  63  $news['sql_query']  = 'SELECT pc.*, ';
  64  $news['sql_query'] .= $news['cnt_ts_livedate'] . ' AS cnt_ts_livedate, ';
  65  $news['sql_query'] .= $news['cnt_ts_killdate'] . ' AS cnt_ts_killdate, ';
  66  $news['sql_query'] .= $news['cnt_ts_sortdate'] . ' AS cnt_ts_sortdate ';
  67  
  68  // define the COUNT all query part
  69  $news['sql_count']            = 'SELECT COUNT(pc.cnt_id) ';
  70  $news['sql_joined_count']    = 'SELECT pc.cnt_id ';
  71  
  72  $sql  = 'FROM '.DB_PREPEND.'phpwcms_content pc ';
  73  
  74  $news['sql_group_by']    = '';
  75  $news['sql_where'][]    = 'pc.cnt_status=1';
  76  $news['sql_where'][]    = "AND pc.cnt_module='news'";
  77  
  78  // check if detail mode is active
  79  // and select the related news item
  80  
  81  if(isset($_getVar['newsdetail'])) {
  82  
  83      $news['match'] = array();
  84      
  85      preg_match('/^\d{8}\-(\d+)_(.*?)$/', clean_slweg($_getVar['newsdetail']), $news['match']);
  86      
  87      if(isset($news['match'][2])) {
  88      
  89          $news['match'] = trim($news['match'][2]);
  90      
  91          if(is_numeric($news['match'])) {
  92              $news['sql_where'][]    = "AND pc.cnt_id=" . intval($news['match']);
  93          } else {
  94              $news['sql_where'][]    = "AND pc.cnt_alias='" . aporeplace($news['match']) . "'";
  95          }
  96          
  97          $news['list_mode']    = false;
  98          
  99      }
 100  
 101  }
 102  
 103  // filters necessary only when in news list mode
 104  if($news['list_mode']) {
 105  
 106      // archived 
 107      switch($news['news_archive']) {
 108      
 109          case 0:    // include archived
 110                  $news['sql_where'][] = 'AND ' . $news['cnt_ts_livedate'] . ' < ' . $news['now'];
 111                  $news['sql_where'][] = 'AND (' . $news['cnt_ts_killdate'] . ' > ' . $news['now'] . ' OR cnt_archive_status = 1)';
 112                  break;
 113                  
 114          case 1:    // exclude archived
 115                  $news['sql_where'][] = 'AND ' . $news['cnt_ts_livedate'] . ' < ' . $news['now'];
 116                  $news['sql_where'][] = 'AND ' . $news['cnt_ts_killdate'] . ' > ' . $news['now'];
 117                  break;
 118                  
 119          case 2:    // archived only
 120                  $news['sql_where'][] = 'AND ' . $news['cnt_ts_killdate'] . ' < ' . $news['now'];
 121                  $news['sql_where'][] = 'AND cnt_archive_status = 1';
 122                  break;
 123                  
 124          case 3:    // all items
 125                  $news['sql_where'][] = 'AND ' . $news['cnt_ts_livedate'] . ' < ' . $news['now'];
 126                  break;
 127      
 128      }
 129      
 130      // choose by category
 131      if(count($news['news_category'])) {
 132          
 133          $news['news_joined_sql']        = true;
 134          $news['news_category_sql']        = array();
 135      
 136          foreach($news['news_category'] as $value) {
 137              
 138              $news['news_category_sql'][] = 'pcat.cat_name LIKE ' . _dbEscape($value);
 139              
 140          }
 141          
 142          //$sql .= "LEFT JOIN ".DB_PREPEND."phpwcms_categories pcat ON (pcat.cat_type='news' AND pcat.cat_pid=pc.cnt_id) ";
 143          //$news['sql_where'][] = 'AND (' . implode($news['news_andor'], $news['news_category_sql']) . ')';
 144          
 145          // use sub query instead of JOIN to compare against AND / OR / NOT
 146                  
 147          if($news['news_andor'] != 'NOT') {
 148              
 149              $news['sql_where_cat']  = '(';
 150              $news['sql_where_cat'] .=     'SELECT COUNT(pcat.cat_pid) ';
 151              $news['sql_where_cat'] .=     'FROM '.DB_PREPEND.'phpwcms_categories pcat WHERE ';
 152              $news['sql_where_cat'] .=     "pcat.cat_type='news' AND pcat.cat_pid=pc.cnt_id AND (";
 153              $news['sql_where_cat'] .=     implode(' OR ', $news['news_category_sql']);
 154              $news['sql_where_cat'] .=     ') GROUP BY pcat.cat_pid';
 155              $news['sql_where_cat'] .= ')';
 156              
 157              if($news['news_andor'] == 'AND') {
 158  
 159                      // count must be identical
 160                      $news['sql_where'][] = 'AND ' . $news['sql_where_cat'] . ' = ' . count($news['news_category_sql']);
 161              
 162              } else {
 163              
 164                      //OR
 165                      // only single matching category needed
 166                      $news['sql_where'][] = 'AND ' . $news['sql_where_cat'] . ' > 0';
 167              }
 168          
 169          } else {
 170              
 171              // no category is allowed
 172              $news['sql_where_cat'] .= 'SELECT pcat.cat_pid ';
 173              $news['sql_where_cat'] .= 'FROM '.DB_PREPEND.'phpwcms_categories pcat WHERE ';
 174              $news['sql_where_cat'] .= "pcat.cat_type='news' AND (";
 175              $news['sql_where_cat'] .= implode(' OR ', $news['news_category_sql']);
 176              $news['sql_where_cat'] .= ') GROUP BY pcat.cat_pid';
 177              
 178              // catch all cat_id having not allowed category
 179              $news['not_allowed'] = _dbQuery($news['sql_where_cat']);
 180              
 181              if(isset($news['not_allowed'][0])) {
 182              
 183                  $news['not_allowed_id'] = array();
 184                  
 185                  foreach($news['not_allowed'] as $cat_key => $cat_pid) {
 186                  
 187                      $news['not_allowed_id'][] = $cat_pid['cat_pid'];
 188                  
 189                  }
 190                  
 191                  $news['sql_where'][] = 'AND pc.cnt_id NOT IN (' . implode(',', $news['not_allowed_id']) . ')';
 192                  
 193              }
 194              
 195          }
 196          
 197          $news['sql_group_by'] = 'GROUP BY pc.cnt_id ';
 198          
 199      } else {
 200      
 201          // for joined SQL the COUNT() query is used in different way
 202          $news['news_joined_sql'] = false;
 203      
 204      }
 205      
 206      // language selection
 207      if(count($news['news_lang'])) {
 208      
 209          $news['sql_where'][] = "AND pc.cnt_lang IN ('". str_replace('#', "','", aporeplace( implode('#', $news['news_lang']) ) ) . "')";
 210      
 211      }
 212  
 213  }
 214  
 215  
 216  $sql .= 'WHERE ' . implode(' ', $news['sql_where']) . ' ';
 217  
 218  // group by
 219  $sql .= $news['sql_group_by'];
 220  
 221  // order by - only necessary in list mode
 222  if($news['list_mode']) {
 223      
 224      $news['news_skip']    = intval($news['news_skip']);
 225      $news['news_limit']    = intval($news['news_limit']);
 226      
 227      if($news['news_skip']) {
 228          
 229          $news['sql_limit']  = ' LIMIT '.$news['news_skip'].', ';
 230          $news['sql_limit'] .= $news['news_limit'] ? $news['news_limit'] : 99999999;
 231  
 232      } elseif($news['news_limit']) {
 233  
 234          $news['sql_limit']  = ' LIMIT ';
 235          $news['sql_limit'] .= $news['news_skip'] ? $news['news_skip'] : 0;
 236          $news['sql_limit'] .= ', ' . $news['news_limit'];
 237  
 238      } else {
 239  
 240          $news['sql_limit'] = '';
 241  
 242      }
 243      
 244      // set defaults
 245      $news['current_page']    = 1;
 246      $news['total_pages']    = 1;
 247      $news['page_next']        = '';
 248      $news['page_prev']        = '';
 249      
 250      // pagination - no LIMIT, no ORDER BY
 251      if($news['news_paginate'] == 1) {
 252  
 253          // count all news based on current query
 254          if($news['news_joined_sql']) {
 255          
 256              $news['count_all'] = count( _dbQuery($news['sql_joined_count'] . $sql . $news['sql_limit']) );
 257          
 258          } else {
 259              
 260              $news['count_all'] = _dbCount($news['sql_count'] . $sql);
 261              
 262              // handle skipped items
 263              if($news['news_skip']) {
 264                  $news['count_all'] = $news['count_all'] - $news['news_skip'];
 265                  if($news['count_all'] < 0) {
 266                      $news['count_all'] = 0;
 267                  }
 268              }
 269              
 270              // check if less news should be used than news in db
 271              if($news['news_limit'] && $news['news_limit'] < $news['count_all']) {
 272                  $news['count_all'] = $news['news_limit'];
 273              }
 274              
 275          }
 276          
 277          // test and set page
 278          if(isset($_getVar['newspage'])) {
 279              $_getVar['newspage'] = intval($_getVar['newspage']);
 280          }
 281          $news['current_page']    = $_getVar['newspage'] > 0 ? $_getVar['newspage'] : 1;
 282          $news['total_pages']    = ceil( $news['count_all'] / $news['news_paginate_count'] );
 283          
 284          if($news['current_page'] > $news['total_pages']) {
 285              $news['current_page'] = $news['total_pages'];
 286          }
 287  
 288          if($news['current_page'] > 1 && $news['total_pages'] > 1) {
 289              if($news['current_page'] == 2) {
 290                  $news['page_prev'] = rel_url( array(), array('newspage') );
 291              } else {
 292                  $news['page_prev'] = rel_url( array( 'newspage' => $news['current_page']-1 ) );
 293              }
 294              
 295              // set pagination page info for detail link too
 296              $news['listing_page'] = array( 'newspage' => $news['current_page'] );
 297          }
 298  
 299          if($news['total_pages'] > 1 && $news['current_page'] < $news['total_pages']) {
 300              $news['page_next'] = rel_url( array( 'newspage' => $news['current_page']+1 ) );
 301          }
 302          
 303          // set LIMIT
 304          $news['sql_limit']  = ' LIMIT ';
 305          $news['sql_limit'] .= (($news['current_page'] - 1) *  $news['news_paginate_count']) + $news['news_skip'];
 306          $news['sql_limit'] .= ', ' . $news['news_paginate_count'];
 307      
 308      }
 309      
 310      
 311      $sql .= 'ORDER BY ';
 312      
 313      // add prio sorting value
 314      if( !empty($news['news_prio']) ) {
 315          $sql .= 'pc.cnt_prio DESC, ';
 316      }
 317  
 318      switch($news['news_sort']) {
 319      
 320          case 1:        // create date, DESC
 321                      $sql .= 'pc.cnt_created DESC';
 322                      break;
 323          
 324          case 2:        // create date, ASC
 325                      $sql .= 'pc.cnt_created ASC';
 326                      break;
 327          
 328          case 3:        // change date, DESC
 329                      $sql .= 'pc.cnt_changed DESC';
 330                      break;
 331          
 332          case 4:        // change date, ASC
 333                      $sql .= 'pc.cnt_changed ASC';
 334                      break;
 335  
 336          case 5:        // live date, DESC
 337                      $sql .= 'cnt_ts_livedate DESC';
 338                      break;
 339          
 340          case 6:        // live date, ASC
 341                      $sql .= 'cnt_ts_livedate ASC';
 342                      break;
 343          
 344          case 7:        // kill date, DESC
 345                      $sql .= 'cnt_ts_killdate DESC';
 346                      break;
 347          
 348          case 8:        // kill date, ASC
 349                      $sql .= 'cnt_ts_killdate ASC';
 350                      break;
 351                      
 352          case 10:    // sort date, ASC
 353                      $sql .= 'cnt_ts_sortdate ASC';
 354                      break;
 355          
 356          case 9:
 357          default:    // sort date, DESC
 358                      $sql .= 'cnt_ts_sortdate DESC';
 359      
 360      }
 361      
 362      $sql .= $news['sql_limit'];
 363  }
 364  
 365  //dumpVar( wordwrap($news['sql_query'] . $sql) );
 366  
 367  // get db query result
 368  $news['result'] = _dbQuery($news['sql_query'] . $sql);
 369  
 370  // now render
 371  if($news['template']) {
 372  
 373      $news['entries']            = array();
 374  
 375      // check if news is in list mode
 376      if($news['list_mode']) {
 377          $news['tmpl_news']            = get_tmpl_section('NEWS_LIST', $news['template']);
 378          $news['tmpl_entry']            = get_tmpl_section('NEWS_LIST_ENTRY', $news['template']);
 379          $news['tmpl_entry_space']    = get_tmpl_section('NEWS_LIST_ENTRY_SPACE', $news['template']);
 380          $news['tmpl_row_space']        = get_tmpl_section('NEWS_LIST_ROW_SPACE', $news['template']);
 381      
 382      // or not in list mode
 383      } else {
 384      
 385          $news['tmpl_news']            = '[NEWS_ENTRIES]{NEWS_ENTRIES}[/NEWS_ENTRIES]';
 386          $news['tmpl_entry']            = get_tmpl_section('NEWS_DETAIL', $news['template']);
 387          $news['tmpl_entry_space']    = '';
 388          $news['tmpl_row_space']        = '';
 389      
 390      }
 391  
 392      // get template based config and merge with defaults
 393      $news['config']    = array_merge(    array(    'news_per_row'                => 1,
 394                                              'news_teaser_text'            => 'p',
 395                                              'news_teaser_limit_chars'    => 0,
 396                                              'news_teaser_limit_words'    => 0,
 397                                              'news_teaser_limit_ellipse'    => $GLOBALS['template_default']['ellipse_sign'],
 398                                              'files_template_list'    => 'default',
 399                                              'files_template_detail'    => 'default',
 400                                              'files_direct_download'    => 0
 401                                            ),
 402                                      parse_ini_str( get_tmpl_section('NEWS_SETTINGS', $news['template']), false )
 403                                    );
 404  
 405      $news['config']['news_per_row']                = abs(intval($news['config']['news_per_row']));
 406      $news['config']['news_teaser_limit_chars']    = intval($news['config']['news_teaser_limit_chars']);
 407      $news['config']['news_teaser_limit_words']    = intval($news['config']['news_teaser_limit_words']);
 408      $news['config']['news_teaser_text']            = trim($news['config']['news_teaser_text']);
 409      
 410      // set function used to render teaser text, custom can be registered
 411      switch( $news['config']['news_teaser_text'] ) {
 412          case 'br':
 413          case 'BR':    $news['config']['news_teaser_text'] = 'br_htmlencode';
 414                      break;
 415          case 'p':
 416          case 'P':    $news['config']['news_teaser_text'] = 'plaintext_htmlencode';
 417                      break;
 418          default:    if(!function_exists($news['config']['news_teaser_text'])) {
 419                          $news['config']['news_teaser_text'] = 'plaintext_htmlencode';
 420                      }
 421      }
 422  
 423      // start parsing news entries    
 424      $news['row_count']            = 1;
 425      $news['total_count']        = 1;
 426      $news['entry_count']        = count($news['result']);
 427      
 428      // set new target if necessary
 429      if(empty($news['news_detail_link'])) {
 430          $news['base_href'] = rel_url($news['listing_page'], array('newsdetail'));
 431      } else {
 432          if(is_intval($news['news_detail_link'])) {
 433              $news['news_detail_link'] = 'aid='.$news['news_detail_link'];
 434          }
 435          $news['base_href'] = rel_url($news['listing_page'], array('newsdetail'), $news['news_detail_link']);
 436      }
 437      
 438      foreach($news['result'] as $key => $value) {
 439      
 440          $value['cnt_object']    = @unserialize($value['cnt_object']);
 441      
 442          $news['entries'][$key]    = $news['tmpl_entry'];
 443          
 444          if($news['config']['news_teaser_limit_chars']) {
 445              $value['cnt_teasertext'] = getCleanSubString($value['cnt_teasertext'], $news['config']['news_teaser_limit_chars'], $news['config']['news_teaser_limit_ellipse'], 'char');
 446          } elseif($news['config']['news_teaser_limit_words']) {
 447              $value['cnt_teasertext'] = getCleanSubString($value['cnt_teasertext'], $news['config']['news_teaser_limit_words'], $news['config']['news_teaser_limit_ellipse'], 'word');
 448          }
 449          
 450          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'NEWS_TITLE', html_specialchars($value['cnt_title']));
 451          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'NEWS_TOPIC', html_specialchars($value['cnt_name']));
 452          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'NEWS_SUBTITLE', html_specialchars($value['cnt_subtitle']));
 453          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'NEWS_TEASER', $news['config']['news_teaser_text']($value['cnt_teasertext']));
 454          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'NEWS_TEXT', $value['cnt_text']);
 455          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'AUTHOR', html_specialchars($value['cnt_editor']));
 456          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'PLACE', html_specialchars($value['cnt_place']));
 457          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'PRIO', empty($value['cnt_prio']) ? '' : $value['cnt_prio'] );
 458          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'FIRST', $news['row_count'] === 1 ? ' ' : '');
 459          
 460          // news detail link (read)
 461          if($news['list_mode']) {
 462          
 463              if(empty($value['cnt_object']['cnt_readmore'])) {
 464                  $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'NEWS_DETAIL_LINK', '');
 465              } else {
 466                  $value['detail_link']    = date('Ymd', $value['cnt_ts_livedate']) . '-' . $crow['acontent_aid'] . '_' ;
 467                  $value['detail_link']  .= empty($value['cnt_alias']) ? $value['cnt_id'] : urlencode( $value['cnt_alias'] );
 468                  $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'NEWS_DETAIL_LINK', $news['base_href'] . '&amp;newsdetail=' . $value['detail_link']);
 469              }
 470              
 471          // news list link (back)
 472          } else {
 473              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'NEWS_LIST_LINK', $news['base_href']);
 474          }
 475          
 476          // Image
 477          if(empty($value['cnt_object']['cnt_image']['id'])) {
 478              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'IMAGE', '');
 479              $news['entries'][$key]    = str_replace('{IMAGE_ID}', '', $news['entries'][$key]);
 480          } else {
 481              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'IMAGE', html_specialchars($value['cnt_object']['cnt_image']['name']));
 482              $news['entries'][$key]    = str_replace('{IMAGE_ID}', $value['cnt_object']['cnt_image']['id'], $news['entries'][$key]);
 483          }
 484          
 485          // Zoom Image
 486          if(empty($value['cnt_object']['cnt_image']['zoom'])) {
 487              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'ZOOM', '' );
 488          } else {
 489              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'ZOOM', 'zoom' );
 490          }
 491          // Lightbox
 492          if(empty($value['cnt_object']['cnt_image']['lightbox'])) {
 493              $news['entries'][$key]    = str_replace('{LIGHTBOX}', '', $news['entries'][$key]);
 494          } else {
 495              initSlimbox();
 496              $news['entries'][$key]    = str_replace('{LIGHTBOX}', ' rel="lightbox"', $news['entries'][$key]);
 497          }
 498          // Caption
 499          if(empty($value['cnt_object']['cnt_image']['caption'])) {
 500              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'CAPTION', '' );
 501              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'LIGHTBOX_CAPTION', '' );
 502          } else {
 503              $value['cnt_caption']    = getImageCaption($value['cnt_object']['cnt_image']['caption'], '');
 504              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'CAPTION', html_specialchars($value['cnt_caption']['caption_text']) );
 505              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'LIGHTBOX_CAPTION', parseLightboxCaption($value['cnt_caption']['caption_text']) );
 506          }
 507          
 508          // Image URL
 509          if(empty($value['cnt_object']['cnt_image']['link'])) {
 510              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'IMAGE_URL', '');
 511              $news['entries'][$key]    = str_replace('{IMAGE_URL_TARGET}', '', $news['entries'][$key]);
 512          } else {
 513              $value['image_url']        = get_redirect_link($value['cnt_object']['cnt_image']['link'], ' ', '');
 514              $news['entries'][$key]    = str_replace('{IMAGE_URL_TARGET}', $value['image_url']['target'], $news['entries'][$key]);
 515              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'IMAGE_URL', html_specialchars($value['image_url']['link']) );
 516          }
 517          // Check for Zoom
 518          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'ZOOM', empty($value['cnt_object']['cnt_image']['zoom']) ? '' : 'zoom' );
 519          
 520          // news entry URL
 521          $value['news_url']        = $value['cnt_object']['cnt_link'] == '' ? array('link'=>'', 'target'=>'') : get_redirect_link($value['cnt_object']['cnt_link'], ' ', '');
 522          $news['entries'][$key]    = str_replace('{URL_TARGET}', $value['news_url']['target'], $news['entries'][$key]);
 523          if(is_numeric($value['news_url']['link']) && intval($value['news_url']['link'])) {
 524              $value['news_url']['link'] = 'index.php?aid='.intval($value['news_url']['link']);
 525          }
 526          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'URL', html_specialchars($value['news_url']['link']) );
 527          $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'URL_TEXT', html_specialchars($value['cnt_object']['cnt_linktext']) );
 528          
 529          // Dates
 530          $news['entries'][$key]    = render_cnt_date($news['entries'][$key], $value['cnt_changed'], $value['cnt_ts_livedate'], $value['cnt_ts_killdate']);
 531          $news['entries'][$key]    = render_date($news['entries'][$key], $value['cnt_ts_sortdate'], 'SORTDATE');
 532          
 533          $news['files_result']    = '';
 534          
 535          // Files
 536          if(isset($value['cnt_object']['cnt_files']['id']) && is_array($value['cnt_object']['cnt_files']['id']) && count($value['cnt_object']['cnt_files']['id'])) {
 537          
 538              $IS_NEWS_CP = true;
 539          
 540              $value['files_direct_download'] = intval($news['config']['files_direct_download']) ? 1 : 0;
 541              
 542              // set correct template for files based on list or detail mode
 543              if($news['list_mode']) {
 544                  $value['files_template']    = $news['config']['files_template_list'] == 'default' ? '' : $news['config']['files_template_list'];
 545              } else {
 546                  $value['files_template']    = $news['config']['files_template_detail'] == 'default' ? '' : $news['config']['files_template_detail'];
 547              }
 548              
 549              // include content part files renderer
 550              include (PHPWCMS_ROOT.'/include/inc_front/content/cnt7.article.inc.php');
 551              
 552              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'FILES', $news['files_result'] );
 553              
 554              unset($IS_NEWS_CP);
 555          
 556          } else {
 557              $news['entries'][$key]    = render_cnt_template($news['entries'][$key], 'FILES', '' );
 558          }
 559          
 560          
 561          //$news['entries'][$key]    = $news['entries'][$key];
 562          
 563          // row and entry spacer
 564          if($news['list_mode']) {
 565  
 566              if( $news['row_count'] == $news['config']['news_per_row'] || $news['config']['news_per_row'] == 0 ) {
 567      
 568                  if($news['total_count'] < $news['entry_count']) {
 569                      $news['entries']['row'.$key] = $news['tmpl_row_space'];
 570                  }
 571                  $news['row_count']    = 1;
 572              
 573              } else {
 574      
 575                  if($news['total_count'] < $news['entry_count']) {
 576                      $news['entries']['entry'.$key] = $news['tmpl_entry_space'];
 577                  }
 578                  $news['row_count']++;
 579              
 580              }
 581              
 582              $news['total_count']++;
 583          }
 584      
 585      }
 586      
 587      $news['tmpl_news']    = render_cnt_template($news['tmpl_news'], 'NEWS_ENTRIES', implode('', $news['entries']) );
 588      $news['tmpl_news']    = render_cnt_template($news['tmpl_news'], 'TITLE', html_specialchars($crow['acontent_title']));
 589      $news['tmpl_news']    = render_cnt_template($news['tmpl_news'], 'SUBTITLE', html_specialchars($crow['acontent_subtitle']));
 590      
 591      // render news pagination
 592      if($news['list_mode']) {
 593          if($news['news_paginate'] == 1) {
 594              $news['tmpl_news']    = render_cnt_template($news['tmpl_news'], 'PAGINATE', true);
 595              $news['tmpl_news']    = render_cnt_template($news['tmpl_news'], 'PAGE_PREV', $news['page_prev']);
 596              $news['tmpl_news']    = render_cnt_template($news['tmpl_news'], 'PAGE_NEXT', $news['page_next']);
 597              $news['tmpl_news']    = str_replace('{PAGE_CURRENT}', $news['current_page'], $news['tmpl_news']);
 598              $news['tmpl_news']    = str_replace('{PAGE_TOTAL}', $news['total_pages'], $news['tmpl_news']);
 599          } else {
 600              $news['tmpl_news']    = render_cnt_template($news['tmpl_news'], 'PAGINATE', '');
 601          }
 602      } else {
 603          $news['tmpl_news']    = replace_cnt_template($news['tmpl_news'], 'PAGINATE', '');
 604          $news['tmpl_news']    = replace_cnt_template($news['tmpl_news'], 'PAGINATE_ELSE', '');
 605      }
 606      
 607      $CNT_TMP .= $news['tmpl_news'];
 608  
 609  }
 610  
 611  
 612  ?>


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