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