[ Index ] |
PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10) |
[Summary view] [Print] [Text view]
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 //predefine values 31 32 $content['cat'] = ''; 33 $content['metakey'] = ''; 34 $content['struct'] = get_struct_data(); //reads the complete structure as array 35 $content['article_date'] = time(); 36 $content['redirect'] = array('code' => ''); 37 $content['all_keywords'] = ''; 38 $content['globalRT'] = array(); 39 $content['aId_CpPage'] = 0; // set default content part pagination page (0 and 1) are the same 40 $content['CpTrigger'] = array(); // array to hold content part trigger functions 41 $content['404error'] = false; 42 $content['set_canonical'] = false; 43 $content['cptab'] = array(); // array to hold content part based tabs 44 $pagelayout = array(); 45 $no_content_for_this_page = 0; 46 $alias = ''; 47 $PERMIT_ACCESS = true; // by default set all content without permissions 48 $CUSTOM = array(); // var that holds result of content part "php var" 49 50 //method to get the right action values 51 //if there is only the ?alias try to find the right category 52 if(isset($_GET["id"])) { 53 54 $aktion = explode(',', $_GET["id"], 6); 55 $aktion[0] = intval($aktion[0]); //$aktion[0] will be always available 56 $aktion[1] = isset($aktion[1]) ? intval($aktion[1]) : 0; 57 $aktion[2] = isset($aktion[2]) ? intval($aktion[2]) : 0; 58 $aktion[3] = isset($aktion[3]) ? intval($aktion[3]) : 1; 59 $aktion[4] = isset($aktion[4]) ? intval($aktion[4]) : 0; 60 $aktion[5] = isset($aktion[5]) ? intval($aktion[5]) : 0; 61 62 // check if article category is given and available 63 if(!isset($content['struct'][ $aktion[0] ])) { 64 $aktion[0] = 0; 65 // OK in case not we should check if given article ID is correct 66 if($aktion[1]) { 67 $sql = 'SELECT article_id, article_cid FROM '.DB_PREPEND.'phpwcms_article WHERE '; 68 $sql .= 'article_deleted=0 AND article_aktiv=1 AND article_id='.$aktion[1].' LIMIT 1'; 69 $aktion[1] = 0; //reset 70 if($result = mysql_query($sql, $db)) { 71 if($row = mysql_fetch_row($result)) { 72 $aktion[0] = $row[1]; 73 $aktion[1] = $row[0]; 74 } 75 mysql_free_result($result); 76 } 77 } 78 $GLOBALS['_getVar']['id'] = implode(',', $aktion); 79 headerRedirect(PHPWCMS_URL.'index.php'.returnGlobalGET_QueryString(), 404); 80 } 81 82 } elseif(isset($_GET['aid'])) { 83 // try to find correct structure 84 $aktion = array(0,0,0,0,1,0); 85 86 $_GET['aid'] = explode('-', $_GET['aid'], 2); // now check for cp pagination 87 $content['aId_CpPage'] = isset($_GET['aid'][1]) ? intval($_GET['aid'][1]) : 0; // set cp paginate page 88 $_GET['aid'] = intval($_GET['aid'][0]); 89 if($_GET['aid']) { 90 $sql = 'SELECT article_cid FROM '.DB_PREPEND.'phpwcms_article WHERE '; 91 $sql .= 'article_deleted=0 '; 92 if(VISIBLE_MODE !== 2) { 93 $sql .= 'AND article_aktiv=1 AND article_public=1 '; 94 } elseif(VISIBLE_MODE === 1) { 95 $sql .= 'AND article_uid='.intval($_SESSION["wcs_user_id"]).' '; 96 } 97 $sql .= 'AND article_id='.$_GET['aid'].' LIMIT 1'; 98 if($result = mysql_query($sql, $db)) { 99 if($row = mysql_fetch_row($result)) { 100 $aktion[0] = $row[0]; 101 $aktion[1] = $_GET['aid']; 102 } else { 103 $content['404error'] = true; 104 } 105 mysql_free_result($result); 106 } else { 107 $content['404error'] = true; 108 } 109 } 110 if(!$aktion[1]) { 111 $content['aId_CpPage'] = 0; // no article = no pagination 112 } 113 114 } else { 115 // check the alias 116 $aktion = array(0,0,0,1,0,0); 117 118 if(count($GLOBALS['_getVar'])) { 119 reset($GLOBALS['_getVar']); 120 $alias = trim(key($GLOBALS['_getVar'])); 121 if($alias && $GLOBALS['_getVar'][$alias] === '') { // alias must be empty "" 122 123 $where_alias = aporeplace($alias); 124 125 // we have to check against MySQL < 4.0 -> UNION unknown 126 // so use a workaround 127 128 if(PHPWCMS_DB_VERSION < 40000) { 129 130 $sql = "SELECT acat_id, (0) AS article_id, 1 AS aktion3, 0 AS aktion4 FROM " . DB_PREPEND . "phpwcms_articlecat "; 131 $sql .= "WHERE acat_trash=0 AND acat_aktiv=1 AND acat_alias='" . $where_alias . "' LIMIT 1"; 132 133 $row = _dbQuery($sql); 134 135 if(!isset($row[0]['acat_id'])) { 136 137 $sql = "SELECT article_cid AS acat_id, article_id, 0 AS aktion3, 1 AS aktion4 FROM " . DB_PREPEND . "phpwcms_article "; 138 $sql .= "WHERE article_deleted=0 AND article_aktiv=1 AND article_alias='" . $where_alias . "' LIMIT 1"; 139 140 $row = _dbQuery($sql); 141 142 } 143 144 } else { 145 146 $sql = "(SELECT acat_id, (0) AS article_id, 1 AS aktion3, 0 AS aktion4 FROM " . DB_PREPEND . "phpwcms_articlecat "; 147 $sql .= "WHERE acat_trash=0 AND acat_aktiv=1 AND acat_alias='" . $where_alias . "')"; 148 $sql .= " UNION "; 149 $sql .= "(SELECT article_cid AS acat_id, article_id, 0 AS aktion3, 1 AS aktion4 FROM " . DB_PREPEND . "phpwcms_article "; 150 $sql .= "WHERE article_deleted=0 AND article_aktiv=1 AND article_alias='" . $where_alias . "') "; 151 $sql .= "LIMIT 1"; 152 153 $row = _dbQuery($sql); 154 155 } 156 157 if(isset($row[0]['acat_id'])) { 158 159 $aktion[0] = $row[0]['acat_id']; 160 $aktion[1] = $row[0]['article_id']; 161 $aktion[3] = $row[0]['aktion3']; 162 $aktion[4] = $row[0]['aktion4']; 163 164 define('PHPWCMS_ALIAS', $alias); 165 166 } elseif($alias == $indexpage['acat_alias']) { 167 168 define('PHPWCMS_ALIAS', $alias); 169 170 } else { 171 172 $content['404error'] = true; 173 174 } 175 176 } 177 } 178 179 } 180 if(isset($_GET['print'])) { 181 182 $aktion[2] = 1; 183 define('PRINT_PDF', intval($_GET['print']) == 2 ? true : false); 184 unset($_getVar['print'], $_GET['print']); 185 186 } 187 188 // define special OUTPUT format/action 189 $phpwcms['output_action'] = false; 190 if(!empty($_GET['phpwcms_output_action']) || !empty($_POST['phpwcms_output_action'])) { 191 192 // split by function - value: F-function1|function2|function3--S-SECT1|SECT2|SECT3 193 $phpwcms['output_action'] = explode('--', clean_slweg( empty($_GET['phpwcms_output_action']) ? $_POST['phpwcms_output_action'] : $_GET['phpwcms_output_action'] )); 194 unset( 195 $_GET['phpwcms_output_action'], 196 $_POST['phpwcms_output_action'], 197 $_getVar['phpwcms_output_action'] 198 ); 199 200 if(is_array($phpwcms['output_action'])) { 201 202 $phpwcms['output_function'] = array(); 203 $phpwcms['output_section'] = array(); 204 205 foreach($phpwcms['output_action'] as $value) { 206 207 $value = trim($value); 208 if($value{0} == 'F') { 209 $value = explode('|', substr($value, 2)); 210 $output_key = 'output_function'; 211 } elseif($value{0} == 'S') { 212 $value = explode('|', substr($value, 2)); 213 $output_key = 'output_section'; 214 } else { 215 continue; 216 } 217 218 if(is_array($value)) { 219 220 foreach($value as $_value) { 221 222 $_value = trim($_value); 223 224 if($_value != '') { 225 $phpwcms[$output_key][$_value] = $_value; 226 } 227 } 228 } 229 } 230 231 $phpwcms['output_action'] = count($phpwcms['output_function']) || count($phpwcms['output_section']) ? true : false; 232 233 } else { 234 $phpwcms['output_action'] = false; 235 } 236 } 237 238 239 //define the current article category ID 240 $content["cat_id"] = $aktion[0]; 241 $content['body_id'] = $content["cat_id"]; 242 243 // check if current level is a redirect level 244 if(!empty($content['struct'][ $content["cat_id"] ]['acat_redirect'])) { 245 $redirect = get_redirect_link( $content['struct'][ $content["cat_id"] ]['acat_redirect'] ); 246 headerRedirect($redirect['link'], 301); 247 } 248 249 //try to find current tree depth 250 $LEVEL_ID = array(); 251 $LEVEL_KEY = array(); 252 $LEVEL_STRUCT = array(); 253 $level_ID_array = get_breadcrumb($content["cat_id"], $content['struct']); 254 $level_count = 0; 255 foreach($level_ID_array as $key => $value) { 256 $LEVEL_ID[$level_count] = $key; 257 $LEVEL_KEY[$key] = $level_count; 258 $LEVEL_STRUCT[$level_count] = $content['struct'][$key]['acat_name']; 259 if($PERMIT_ACCESS && $content['struct'][$key]['acat_regonly']) { 260 $PERMIT_ACCESS = false; // only users have been logged in get access 261 } 262 $level_count++; 263 } 264 265 define('PERMIT_ACCESS', $PERMIT_ACCESS); 266 // frontend login check 267 _checkFrontendUserAutoLogin(); 268 269 // ------------------------------------------------------------- 270 271 // read the template information for page based on structure 272 if($content["struct"][ $content["cat_id"] ]["acat_template"]) { 273 //if there is a template defined for this structure level 274 //then choose the template information based on this ID 275 $sql = "SELECT template_var FROM ".DB_PREPEND."phpwcms_template WHERE template_trash=0 AND "; 276 $sql .= "template_id=".$content["struct"][ $content["cat_id"] ]["acat_template"]." LIMIT 1;"; 277 if($result = mysql_query($sql, $db)) { 278 if($row = mysql_fetch_row($result)) { 279 $block = unserialize($row[0]); 280 } 281 mysql_free_result($result); 282 } 283 } 284 if(!isset($block)) { 285 // if template ID is not defined or the were a problem with level's template ID then 286 // choose the default template or if no default template defined choose the next one 287 $sql = "SELECT template_var FROM ".DB_PREPEND."phpwcms_template "; 288 $sql .= "WHERE template_trash=0 ORDER BY template_default DESC LIMIT 1;"; 289 if($result = mysql_query($sql, $db)) { 290 if($row = mysql_fetch_row($result)) { 291 $block = unserialize($row[0]); 292 } 293 mysql_free_result($result); 294 } 295 } 296 297 // compatibility for older releases where only 298 // 1 css file could be stored per template 299 if(is_string($block['css'])) { 300 $block['css'] = array($block['css']); 301 } 302 // check if template_defaults should be overwritten 303 if(!empty($block['overwrite'])) { 304 $block['overwrite'] = str_replace('/', '', $block['overwrite']); 305 @include(PHPWCMS_TEMPLATE.'inc_settings/template_default/'.$block['overwrite']); 306 } 307 if(!empty($content['struct'][ $content['cat_id'] ]['acat_overwrite'])) { 308 $block['overwrite'] = str_replace('/', '', $content['struct'][ $content['cat_id'] ]['acat_overwrite']); 309 @include(PHPWCMS_TEMPLATE.'inc_settings/template_default/'.$block['overwrite']); 310 } 311 312 // load frontend JavaScript lib file 313 require PHPWCMS_ROOT.'/include/inc_front/js.inc.php'; 314 315 // ------------------------------------------------------------- 316 317 // retrieve pagelayout info 318 // check how the content should be rendered based on pagelayout render value 319 $block["layout"] = intval($block["layout"]); 320 $sql = "SELECT pagelayout_var FROM ".DB_PREPEND."phpwcms_pagelayout WHERE pagelayout_trash=0 "; 321 $sql .= $block["layout"] ? "AND pagelayout_id=".$block["layout"] : "ORDER BY pagelayout_default DESC"; 322 $sql .= " LIMIT 1"; 323 $result = _dbQuery($sql); 324 if(isset($result[0]['pagelayout_var'])) { 325 $pagelayout = @unserialize($result[0]['pagelayout_var']); 326 // if print action 327 if($aktion[2] === 1) { 328 $pagelayout = array('layout_title' => $pagelayout['layout_title'], 'layout_customblocks' => $pagelayout['layout_customblocks']); 329 } 330 } 331 if(empty($pagelayout)) { 332 // if no pagelayout could be found 333 die('There is no pagelayout available. Please <a href="'. 334 PHPWCMS_URL.get_login_file().'">login</a> to the admin section and <a href="'. 335 PHPWCMS_URL.'phpwcms.php?do=admin&p=8">create one here</a>!'); 336 } 337 // Pagetitle 338 $content["pagetitle"] = empty($pagelayout["layout_title"]) ? '' : $pagelayout["layout_title"]; 339 340 //generate the colspan attribute 341 $colspan = get_colspan($pagelayout); 342 343 // ------------------------------------------------------------- 344 345 // now initialize content blocks like CONTENT, HEADER, LEFT, RIGHT, FOOTER 346 $content['main'] = ''; // {CONTENT} 347 $content['CB']['LEFT'] = ''; // {LEFT} 348 $content['CB']['RIGHT'] = ''; // {RIGHT} 349 $content['CB']['HEADER'] = ''; // {HEADER} 350 $content['CB']['FOOTER'] = ''; // {FOOTER} 351 // and try to add and initialize custom blocks 352 if(!empty($pagelayout['layout_customblocks'])) { 353 $custom_blocks = explode(', ', $pagelayout['layout_customblocks']); 354 foreach($custom_blocks as $value) { 355 if($value != '') $content['CB'][$value] = ''; 356 } 357 unset($custom_blocks); 358 } 359 360 // ------------------------------------------------------------- 361 362 // try to include custom functions or what ever you want to do at this point of the script 363 // default dir: "phpwcms_template/inc_script/frontend_init"; only *.php files are allowed there 364 if($phpwcms["allow_ext_init"]) { 365 if(count($custom_includes = get_tmpl_files(PHPWCMS_TEMPLATE.'inc_script/frontend_init', 'php'))) { 366 foreach($custom_includes as $value) { 367 include_once(PHPWCMS_TEMPLATE.'inc_script/frontend_init/'.$value); 368 } 369 } 370 } 371 // include custom frontend init scripts based on module definitions 372 if(count($phpwcms['modules_fe_init'])) { 373 foreach($phpwcms['modules_fe_init'] as $value) { 374 include_once($value); 375 } 376 } 377 378 // redirect to login form if user is not logged in and has no permission to access level 379 if(!PERMIT_ACCESS && !_getFeUserLoginStatus()) { 380 381 if(!empty($block['feloginurl'])) { 382 $template_default['login_form_url'] = str_replace('{SITE}', PHPWCMS_URL, $block['feloginurl']); 383 } elseif(empty($template_default['login_form_url'])) { 384 $template_default['login_form_url'] = PHPWCMS_URL; 385 } 386 387 // store current URL 388 $_SESSION['LOGIN_REDIRECT'] = decode_entities(FE_CURRENT_URL); 389 390 // redirect to login form 391 headerRedirect($template_default['login_form_url'], 401); 392 } 393 394 // ------------------------------------------------------------- 395 396 //reads all articles for active cat into array 397 $content["articles"] = get_actcat_articles_data($content["cat_id"]); 398 $content["article_list_count"] = count($content["articles"]); 399 400 // ------------------------------------------------------------- 401 402 // generating a list of articles inside the current article category 403 if(!$aktion[4]) { 404 405 if(!$content['404error'] && ($content["article_list_count"] || $content['struct'][ $content['cat_id'] ]['acat_topcount'] == -1)) { 406 407 if($content["article_list_count"] == 1 || $content['struct'][ $content['cat_id'] ]['acat_topcount'] == -1) { 408 // if($temp_counter == 1) { 409 // if only 1 article for this category available 410 // then show this article directly 411 // sets article ID to this only 1 article 412 foreach($content["articles"] as $key => $value) { 413 $aktion[1] = intval($key); 414 break; 415 } 416 $aktion[4] = 1; // this needs to be set to 1 for showing the article 417 418 // enable canonical <link> tag 419 $content['set_canonical'] = true; 420 421 } else { 422 // there is more than 1 article inside this category 423 // -> list all - the 1st will be shown with summary and such stuff 424 $content["main"] .= list_articles_summary(); 425 426 } 427 428 } else { 429 430 $no_content_for_this_page = 1; 431 432 } 433 434 } elseif($content["article_list_count"] === 1) { 435 436 // enable canonical <link> tag 437 $content['set_canonical'] = true; 438 439 } 440 441 // ------------------------------------------------------------- 442 443 // check if current category should be cached 444 if($content['struct'][$content['cat_id']]['acat_timeout'] != '') { 445 $phpwcms['cache_timeout'] = $content['struct'][$content['cat_id']]['acat_timeout']; 446 } 447 // set search status for current category 448 $cache_searchable = $content['struct'][$content['cat_id']]['acat_nosearch']; 449 450 // ------------------------------------------------------------- 451 452 $content['list_mode'] = true; 453 454 if($aktion[1]) { 455 456 // render page based on article 457 include_once (PHPWCMS_ROOT."/include/inc_front/content.article.inc.php"); 458 $content['list_mode'] = false; 459 460 } elseif(!empty($content['struct'][$content['cat_id']]['acat_pagetitle'])) { 461 462 // a custom pagetitle for structure level exists 463 $content["pagetitle"] = $content['struct'][$content['cat_id']]['acat_pagetitle']; 464 465 } else { 466 467 $content["pagetitle"] = setPageTitle($content["pagetitle"], $content['struct'][$content['cat_id']]['acat_name'], ''); 468 469 } 470 471 // ------------------------------------------------------------- 472 473 //check for no content error 474 $content["main"] = trim($content["main"]); 475 if($content['404error'] || $no_content_for_this_page || $content["main"] == '') { 476 header('HTTP/1.0 404 Not Found'); 477 $content["main"] .= $block["errortext"]; 478 } 479 480 // ------------------------------------------------------------- 481 482 //check if one of needed block texts and values are empty and if then fill with content 483 if(!$block["maintext"]) { 484 $block["maintext"] = $content["main"]; 485 } 486 487 // ------------------------------------------------------------- 488 489 //normal page operation 490 if($aktion[2] == 0) { 491 492 switch($pagelayout["layout_render"]) { 493 494 case 0: //create the page layout table (header, left, content, right, footer) 495 $content["all"] = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\""; //start main table 496 $content["all"] .= td_attributes($pagelayout, "all", 0); 497 $content["all"] .= align_base_layout($pagelayout["layout_align"])." summary=\"\">".LF; // align table 498 499 //header 500 $content["all"] .= colspan_table_row($pagelayout, "header", $colspan, $block["headertext"]); //header row 501 if($pagelayout["layout_topspace_height"]) { //header space 502 $content["all"] .= colspan_table_row($pagelayout, "topspace", $colspan, spacer(1, $pagelayout["layout_topspace_height"])); 503 } 504 505 //returns the main blocks: left column, content column, right column 506 $content["all"] .= get_table_block($pagelayout, $block["maintext"], $block["lefttext"], $block["righttext"]); 507 508 //footer 509 if($pagelayout["layout_bottomspace_height"]) { //bottom space 510 $content["all"] .= colspan_table_row($pagelayout, "bottomspace", $colspan, spacer(1, $pagelayout["layout_bottomspace_height"])); 511 } 512 $content["all"] .= colspan_table_row($pagelayout, "footer", $colspan, $block["footertext"]); //footer row 513 $content["all"] .= '</table>'.LF; //end main table 514 515 break; 516 517 518 case 1: //create the page layout based on DIV (layer) 519 520 //contentContainer DIV start 521 $content["all"] = ''; 522 $pagelayout['additional_wrap_div'] = false; 523 switch($pagelayout["layout_align"]) { 524 case 1: $content["all"] .= '<div align="center" style="margin:0;padding:0;">'; 525 $pagelayout['additional_wrap_div'] = true; 526 break; 527 case 2: $content["all"] .= '<div align="right" style="margin:0;padding:0;">'; 528 $pagelayout['additional_wrap_div'] = true; 529 break; 530 } 531 $content["all"] .= '<div id="container">'.LF; 532 533 //header DIV 534 if($block["headertext"] || $pagelayout['layout_header_height']) { 535 $content["all"] .= ' <div id="headerBlock">'.$block["headertext"]."</div>\n"; 536 } 537 //left DIV if 3column or 2column (with left block) 538 if($pagelayout["layout_type"] == 0 || $pagelayout["layout_type"] == 1) { 539 $content["all"] .= ' <div id="leftBlock">'.$block["lefttext"]."</div>\n"; 540 } 541 //right DIV if 3column or 2column (with right block) 542 if($pagelayout["layout_type"] == 0 || $pagelayout["layout_type"] == 2) { 543 $content["all"] .= ' <div id="rightBlock">'.$block["righttext"]."</div>\n"; 544 } 545 //main block 546 $content["all"] .= '<div id="mainBlock">'.$block["maintext"]."</div>\n"; 547 //footer DIV 548 if($block["footertext"] || $pagelayout['layout_footer_height']) { 549 $content["all"] .= ' <div id="footerBlock">'.$block["footertext"]."</div>\n"; 550 } 551 //contentContainer DIV end 552 if($pagelayout['additional_wrap_div']) { 553 $content["all"] .= "</div>"; 554 } 555 $content["all"] .= "</div>\n"; 556 557 break; 558 559 560 case 2: //create the page layout based only on the content of main block 561 $content["all"] = $block["maintext"]; 562 563 break; 564 565 } 566 567 } elseif ($aktion[2] == 1) { 568 569 //if print layout should be shown 570 $_print_tmpl = PRINT_PDF ? 'pdf' : 'print'; 571 $content['all'] = is_file(PHPWCMS_TEMPLATE.'inc_default/'.$_print_tmpl.'.tmpl') ? @file_get_contents(PHPWCMS_TEMPLATE.'inc_default/'.$_print_tmpl.'.tmpl') : '{CONTENT}<hr />{CURRENT_URL}'; 572 if(PRINT_PDF) { 573 $_print_settings = get_tmpl_section('PDF_SETTINGS', $content['all']); 574 $content['all'] = replace_tmpl_section('PDF_SETTINGS', $content['all']); 575 $_print_settings = parse_ini_str($_print_settings, false); 576 } 577 578 if($content['all']) { 579 $content["all"] = str_replace('{CURRENT_URL}', PHPWCMS_URL.'index.php'.returnGlobalGET_QueryString('htmlentities'), $content["all"]); 580 $content["all"] = str_replace('{CONTENT}', $block["maintext"], $content["all"]); 581 } else { 582 $content['all'] = $block["maintext"]; 583 } 584 585 } 586 587 // ------------------------------------------------------------- 588 589 // Render possible PHP Values in category or article keyword field 590 $content["struct"][$aktion[0]]["acat_info"] = render_PHPcode($content["struct"][$aktion[0]]["acat_info"]); 591 if(!empty($content["articles"][$aktion[1]]["article_keyword"]) && strpos($content["articles"][$aktion[1]]["article_keyword"], 'PHP') !== FALSE) { 592 $content["articles"][$aktion[1]]["article_keyword"] = render_PHPcode($content["articles"][$aktion[1]]["article_keyword"]); 593 } 594 595 // ------------------------------------------------------------- 596 597 // put in the complete rendered content 598 $content["all"] = str_replace('{CONTENT}', $content["main"], $content["all"]); 599 // put in custom rendered content 600 foreach($content['CB'] as $key => $value) { 601 //first check content of custom block in current template 602 if(isset($block['customblock_'.$key]) && $block['customblock_'.$key] !== '' && $value !== '') { 603 $value = str_replace('{'.$key.'}', $value, $block['customblock_'.$key]); 604 } 605 $content["all"] = str_replace('{'.$key.'}', $value, $content["all"]); 606 } 607 608 // render Tab replacement code 609 if(count($content['cptab'])) { 610 foreach($content['cptab'] as $CNT_TAB => $trow) { 611 $content['all'] = str_replace('<!-- ' . $CNT_TAB . ' -->', $trow, $content['all']); 612 } 613 } 614 615 // check layout for list mode sections or detail view 616 if(strpos($content['all'], '_LIST_MODE')) { 617 $content['all'] = replace_tmpl_section( ($content['list_mode'] ? 'ELSE_LIST_MODE' : 'IF_LIST_MODE') , $content['all']); 618 $content['all'] = str_replace(array('<!--ELSE_LIST_MODE_START//-->', '<!--ELSE_LIST_MODE_END//-->', '<!--IF_LIST_MODE_START//-->', '<!--IF_LIST_MODE_END//-->'), '', $content['all']); 619 } 620 621 // search for specific article ID and or category ID and replace it 622 $content['all'] = str_replace('{CURRENT_ARTICLEID}', $aktion[1], $content['all']); 623 $content['all'] = str_replace('{CURRENT_CATEGORYID}', $aktion[0], $content['all']); 624 625 // search for level related replacement tags and replace it, sample: {LEVEL2_ID} 626 $content['all'] = preg_replace_callback('/\{LEVEL(\d+)_ID\}/', 'replace_level_id', $content['all']); 627 628 // {SHOW_CONTENT:MODE,id[,id[,...]]} 629 if( ! ( strpos($content["all"],'{SHOW_CONTENT:')===false ) ) { 630 $content["all"] = preg_replace('/\{SHOW_CONTENT:(.*?)\}/e', 'showSelectedContent("$1");', $content["all"]); 631 } 632 633 // ------------------------------------------------------------- 634 635 // include external PHP script (also normal HTML snippets) or return PHP var value 636 if(strpos($content["all"],'PHP') !== false) { 637 $content["all"] = render_PHPcode($content["all"]); 638 } 639 640 // ------------------------------------------------------------- 641 642 //breadcrumb replacement 643 if(strpos($content["all"],'{BREADCRUMB') !== false) { 644 $content["all"] = str_replace('{BREADCRUMB}', '{BREADCRUMB:0}', $content["all"]); 645 $replace = 'breadcrumb($content["cat_id"], $content["struct"], $1, $template_default["breadcrumb_spacer"]);'; 646 $content["all"] = preg_replace('/\{BREADCRUMB:(\d+)\}/e', $replace, $content["all"]); 647 } 648 649 // ------------------------------------------------------------- 650 651 // Simple row based navigation 652 if(strpos($content["all"],'{NAV_ROW') !== false) { 653 $content["all"] = str_replace('{NAV_ROW}', nav_level_row(0), $content["all"]); 654 $content["all"] = preg_replace('/\{NAV_ROW:(\w+|\d+):(0|1)\}/e',"nav_level_row('$1',$2);",$content["all"]); 655 } 656 657 // ------------------------------------------------------------- 658 659 // Simple Navigation table 660 if(strpos($content["all"],'{NAV_TABLE_SIMPLE}') !== false) { 661 $replace = nav_table_simple_struct($content["struct"], $content["cat_id"]); 662 $content["all"] = str_replace('{NAV_TABLE_SIMPLE}', $replace, $content["all"]); 663 } 664 665 // ------------------------------------------------------------- 666 667 // Left table based rollover navigation 668 if(strpos($content["all"],'{NAV_TABLE_COLUMN') !== false) { 669 $content["all"] = str_replace('{NAV_TABLE_COLUMN}', '{NAV_TABLE_COLUMN:0}', $content["all"]); 670 $replace = 'nav_table_struct($content["struct"], $content["cat_id"], "$1", $template_default["nav_table_struct"]);'; 671 $content["all"] = preg_replace('/\{NAV_TABLE_COLUMN:(\d+)\}/e', $replace, $content["all"]); 672 } 673 674 // ------------------------------------------------------------- 675 676 // some list based navigations 677 if(strpos($content["all"],'{NAV_LIST') !== false) { 678 679 //reads all active category IDs beginning with the current cat ID - without HOME 680 $content["cat_path"] = get_active_categories($content["struct"], $content["cat_id"]); 681 682 // some general list replacements first 683 $content["all"] = str_replace('{NAV_LIST}', '{NAV_LIST:0}', $content["all"]); 684 $content["all"] = str_replace('{NAV_LIST_TOP}', css_level_list($content["struct"], $content["cat_path"], 0, '', 1), $content["all"]); 685 $content["all"] = str_replace('{NAV_LIST_CURRENT}', css_level_list($content["struct"],$content["cat_path"],$content["cat_id"]), $content["all"]); 686 687 // build complete menu structure starting at a specific ID 688 // {NAV_LIST_UL:Parameter} Parameter: "menu_type, start_id, class_path, class_active, ul_id_name" 689 $content["all"] = preg_replace('/\{NAV_LIST_UL:(.*?)\}/e', 'buildCascadingMenu("$1");', $content["all"]); 690 691 // list based navigation starting at given level 692 $replace = 'nav_list_struct($content["struct"],$content["cat_id"],"$1", "$2");'; 693 $content["all"] = preg_replace('/\{NAV_LIST:(\d+):{0,1}(.*){0,1}\}/e', $replace, $content["all"]); 694 695 // List based navigation with Top Level - default settings 696 // creates a list styled top nav menu, + optional Home | {NAV_LIST_TOP:home_name:class_name} | default class name = list_top 697 $content["all"] = preg_replace('/\{NAV_LIST_TOP:(.*?):(.*?)\}/e', 'css_level_list($content["struct"], $content["cat_path"], 0, "$1", 1, "$2")', $content["all"]); 698 699 // List based navigation with Top Level - default settings 700 // creates a list styled nav menu of current level {NAV_LIST_CURRENT:1:back_name:class_name} | default class name = list_top 701 $content["all"] = preg_replace('/\{NAV_LIST_CURRENT:(\d+):(.*?):(.*?)\}/e', 'css_level_list($content["struct"],$content["cat_path"],$content["cat_id"],"$2","$1","$3")', $content["all"]); 702 } 703 704 // ------------------------------------------------------------- 705 706 // date replacement 707 if(strpos($content["all"],'{DATE_') !== false) { 708 $content["all"] = str_replace('{DATE_LONG}', international_date_format($template_default["date"]["language"], $template_default["date"]["long"]), $content["all"]); 709 $content["all"] = str_replace('{DATE_MEDIUM}', international_date_format($template_default["date"]["language"], $template_default["date"]["medium"]), $content["all"]); 710 $content["all"] = str_replace('{DATE_SHORT}', international_date_format($template_default["date"]["language"], $template_default["date"]["short"]), $content["all"]); 711 $content["all"] = str_replace('{DATE_ARTICLE}', international_date_format($template_default["date"]["language"], $template_default["date"]["article"], $content["article_date"]), $content["all"]); 712 } 713 714 // ------------------------------------------------------------- 715 716 // time replacement 717 if(strpos($content["all"],'{TIME_') !== false) { 718 $content["all"] = str_replace('{TIME_LONG}', date($template_default["time"]["long"]) , $content["all"] ); 719 $content["all"] = str_replace('{TIME_SHORT}', date($template_default["time"]["short"]), $content["all"] ); 720 $content["all"] = str_replace('{TIME_ARTICLE}', date($template_default["time"]["short"] , $content["article_date"]), $content["all"] ); 721 } 722 723 // ------------------------------------------------------------- 724 725 // replace custom search form input field and action with right target 726 if(strpos($content["all"],'###search_input_action') !== false) { 727 $content["all"] = str_replace('###search_input_field###', 'search_input_field', $content["all"]); 728 $content["all"] = str_replace('###search_input_value###', (empty($content["search_word"]) ? '' : $content["search_word"]), $content["all"]); 729 // create serahc form action 730 if(strpos($content["all"],'###search_input_action:') !== false) { 731 $content["all"] = preg_replace('/###search_input_action:(\d+)###/e','get_search_action("$1", $db);', $content["all"]); 732 } 733 } 734 735 // ------------------------------------------------------------- 736 737 // related articles based on keywords, inspired by Magnar Stav Johanssen 738 if(strpos($content["all"],'{RELATED:') !== false) { 739 if (!$no_content_for_this_page && !empty($content["articles"][$aktion[1]]["article_keyword"])) { 740 $related_keywords = $content["articles"][$aktion[1]]["article_keyword"]; 741 } else { 742 $related_keywords = ''; 743 } 744 $content["all"] = preg_replace('/\{RELATED:(\d+)\}/e','get_related_articles($related_keywords,$aktion[1],$template_default["related"],"$1",$db);',$content["all"]); 745 $content["all"] = preg_replace('/\{RELATED:(\d+):(.*?)\}/e','get_related_articles("$2",$aktion[1],$template_default["related"],"$1",$db);',$content["all"]); 746 } 747 748 // ------------------------------------------------------------- 749 750 // all new article list sorted by date 751 if(strpos($content["all"],'{NEW:') !== false) { 752 $content["all"] = preg_replace('/\{NEW:(\d+):{0,1}(\d+){0,1}\}/e','get_new_articles($template_default["news"],"$1","$2",$db);',$content["all"]); 753 } 754 755 // ------------------------------------------------------------- 756 757 // some more general parsing 758 $content["all"] = str_replace('{SITE}', PHPWCMS_URL, $content["all"]); 759 $content["all"] = str_replace('{RSSIMG}', $template_default["rss"]["image"], $content["all"]); 760 761 $content["all"] = html_parser($content["all"]); 762 763 $content["all"] = preg_replace_callback('/\[img=(\d+)(.*?){0,1}\](.*?)\[\/img\]/i', 'parse_images', $content["all"]); 764 $content["all"] = preg_replace_callback('/\[img=(\d+)(.*?){0,1}\]/i', 'parse_images', $content["all"]); 765 $content["all"] = preg_replace_callback('/\[download=(.*?)\/\]/i', 'parse_downloads', $content["all"]); 766 $content["all"] = preg_replace_callback('/\[download=(.*?)\](.*?)\[\/download\]/is', 'parse_downloads', $content["all"]); 767 768 // ------------------------------------------------------------- 769 770 // create link to articles for found keywords 771 $content["all"] = preg_replace('/\{KEYWORD:(.*?)\}/e', 'get_keyword_link("$1", $db);', $content["all"]); 772 //} 773 774 // ------------------------------------------------------------- 775 776 // include external HTML page but only part between <body></body> 777 $content["all"] = preg_replace_callback('/\{URL:(.*?)\}/i', 'include_url', $content["all"]); 778 779 // ------------------------------------------------------------- 780 781 // special browse the content links: UP, NEXT, PREVIOUS 782 // echo get_index_link_up('UP')." | ".get_index_link_prev('PREV',1).' | '.get_index_link_next('NEXT',1); 783 if(strpos($content["all"],'{BROWSE:') !== false) { 784 $content["all"] = preg_replace('/\{BROWSE:UP:(.*?)\}/e','get_index_link_up("$1");',$content["all"]); 785 $content["all"] = preg_replace('/\{BROWSE:NEXT:(.*?):(0|1)\}/e','get_index_link_next("$1",$2);',$content["all"]); 786 $content["all"] = preg_replace('/\{BROWSE:PREV:(.*?):(0|1)\}/e','get_index_link_prev("$1",$2);',$content["all"]); 787 } 788 789 // ------------------------------------------------------------- 790 791 // replace all "hardcoded" global replacement tags 792 793 if(count($content['globalRT'])) { 794 foreach($content['globalRT'] as $key => $value) { 795 if($key != '') { 796 $content["all"] = str_replace($key, $value, $content["all"]); 797 } 798 } 799 } 800 801 // ------------------------------------------------------------- 802 803 // add possible redirection code (article summary) to $block["htmlhead"]; 804 $block["htmlhead"] = $content["redirect"]["code"] . render_PHPcode($block["htmlhead"]) . LF; 805 806 // ------------------------------------------------------------- 807 808 809 if(!defined('PHPWCMS_ALIAS')) { 810 define('PHPWCMS_ALIAS', empty($content['struct'][ $content["cat_id"] ]['acat_alias']) ? '' : $content['struct'][ $content["cat_id"] ]['acat_alias'] ); 811 } 812 813 // try to include custom functions and replacement tags or what you want to do at this point of the script 814 // default dir: "phpwcms_template/inc_script/frontend_render"; only *.php files are allowed there 815 if($phpwcms["allow_ext_render"]) { 816 if(count($custom_includes = get_tmpl_files(PHPWCMS_TEMPLATE.'inc_script/frontend_render', 'php'))) { 817 foreach($custom_includes as $value) { 818 include_once(PHPWCMS_TEMPLATE.'inc_script/frontend_render/'.$value); 819 } 820 } 821 } 822 if(count($phpwcms['modules_fe_render'])) { 823 foreach($phpwcms['modules_fe_render'] as $value) { 824 include_once($value); 825 } 826 } 827 828 // render frontend edit related content and JavaScript 829 if(FE_EDIT_LINK) { 830 831 init_frontend_edit_js(); 832 $content['all'] .= LF . '<div id="fe-link" class="disabled"></div>' . LF; 833 834 } 835 836 // insert description meta tag if not definied 837 if(empty($block['custom_htmlhead']['meta.description']) && !empty($content["struct"][$aktion[0]]["acat_info"]) && !stristr($block["htmlhead"], '"description"')) { 838 set_meta('description', $content["struct"][$aktion[0]]["acat_info"]); 839 } 840 // add structure level keywords 841 if(!empty($content['struct'][ $content["cat_id"] ]['acat_keywords'])) { 842 $content['all_keywords'] .= ', ' . $content['struct'][ $content["cat_id"] ]['acat_keywords']; 843 } 844 // insert keywords meta tag if not yet definied 845 if(empty($block['custom_htmlhead']['meta.keywords']) && !empty($content['all_keywords']) && !stristr($block["htmlhead"], '"keywords"')) { 846 $content['all_keywords'] = convertStringToArray($content['all_keywords']); 847 if(count($content['all_keywords'])) { 848 set_meta('keywords', implode(', ', $content['all_keywords'])); 849 } 850 } 851 852 // replace Print URL 853 if(strpos($content["all"], '[PRINT]') !== false) { 854 $content["all"] = str_replace('[PRINT]', '<a href="'.rel_url(array('print'=>1),array(), PHPWCMS_ALIAS).'" target="_blank" rel="nofollow">', $content["all"]); 855 $content["all"] = str_replace('[/PRINT]', '</a>', $content["all"]); 856 } 857 if(strpos($content["all"], '[PRINT_PDF]') !== false) { 858 $content["all"] = str_replace('[PRINT_PDF]', '<a href="'.rel_url(array('print'=>2),array(), PHPWCMS_ALIAS).'" target="_blank" rel="nofollow">', $content["all"]); 859 $content["all"] = str_replace('[/PRINT_PDF]', '</a>', $content["all"]); 860 } 861 862 863 // Jérôme's Graphical Text MOD Coypright (C) 2004 864 if($phpwcms["gt_mod"]) { //enabled/disable GT MOD 865 require_once ('include/inc_module/mod_graphical_text/inc_front/gt.func.inc.php'); 866 } 867 868 // some article related "global" replacement tags 869 if(isset($content['article_livedate'])) { 870 871 $content['all'] = render_cnt_template($content['all'], 'AUTHOR', html_specialchars($content['article_username'])); 872 $content['all'] = render_cnt_date($content['all'], $content["article_date"], $content['article_livedate'], $content['article_killdate']); 873 $content['all'] = render_cnt_template($content['all'], 'CATEGORY', $content['cat']); 874 875 } else { 876 877 $content['all'] = render_cnt_template($content['all'], 'AUTHOR', ''); 878 $content['all'] = render_cnt_date($content['all'], now(), now(), now()); 879 $content['all'] = render_cnt_template($content['all'], 'CATEGORY', html_specialchars($content['struct'][ $content['cat_id'] ]['acat_name'])); 880 881 } 882 883 // ------------------------------------------------------------- 884 885 // render JavaScript Plugins and/or JavaScript scripts that should be loaded in <head> 886 $content['all'] = preg_replace_callback('/<!--\s+JS:\s+([a-z0-9%&=?_\-+.\/\{\}:,]+?)\s+.*?-->/i', 'renderHeadJS', $content['all']); 887 888 // test for frontend.js 889 if(!isset($GLOBALS['block']['custom_htmlhead']['frontend.js']) && preg_match('/MM_swapImage|BookMark_Page|clickZoom|mailtoLink/', $content['all'])) { 890 initFrontendJS(); 891 } 892 893 //check for additional template based onLoad JavaScript Code 894 if($block["jsonload"]) { 895 if(empty($pagelayout["layout_jsonload"])) { 896 $pagelayout["layout_jsonload"] = ''; 897 } else { 898 $pagelayout["layout_jsonload"] .= ';'; 899 } 900 $pagelayout["layout_jsonload"] = convertStringToArray($pagelayout["layout_jsonload"] . $block["jsonload"], ';'); 901 $block['js_ondomready'][] = ' ' . implode(';'.LF.' ', $pagelayout["layout_jsonload"]) . ';'; 902 $pagelayout["layout_jsonload"] = ''; 903 } 904 905 // set OnLoad (DomReady) JavaScript 906 if(count($block['js_ondomready'])) { 907 jsOnDomReady(implode(LF, $block['js_ondomready'])); 908 } 909 // set OnUnLoad JavaScript 910 if(count($block['js_onunload'])) { 911 jsOnUnLoad(implode(LF, $block['js_onunload'])); 912 } 913 // set Inline JS 914 if(count($block['js_inline'])) { 915 $block['custom_htmlhead']['inline'] = ' <script type="text/javascript">'.LF.SCRIPT_CDATA_START.LF; 916 $block['custom_htmlhead']['inline'] .= implode(LF, $block['js_inline']); 917 $block['custom_htmlhead']['inline'] .= LF.SCRIPT_CDATA_END.LF.' </script>'; 918 } 919 920 921 // new $block['custom_htmlhead'] var (array) for usage in own rendering stuff. 922 // you will be able to use $GLOBALS['block']['custom_htmlhead']['myheadname'] 923 // always check if you want to use same head code only once 924 if(count($block['custom_htmlhead'])) { 925 $block["htmlhead"] .= implode(LF, $block['custom_htmlhead']).LF; 926 } 927 928 if(!empty($_GET['highlight'])) { 929 $highlight_words = clean_slweg(rawurldecode($_GET['highlight'])); 930 $highlight_words = explode(' ', $highlight_words); 931 $content['all'] = preg_replace_callback("/<!--SEARCH_HIGHLIGHT_START\/\/-->(.*?)<!--SEARCH_HIGHLIGHT_END\/\/-->/si", "pregReplaceHighlightWrapper", $content['all']); 932 } 933 $content['all'] = str_replace(array('<!--SEARCH_HIGHLIGHT_START//-->', '<!--SEARCH_HIGHLIGHT_END//-->'), '', $content['all']); 934 935 // render content part pagination 936 if(!empty($_CpPaginate)) { 937 938 $content['all'] = str_replace(array('<!--CP_PAGINATE_START//-->', '<!--CP_PAGINATE_END//-->'), '', $content['all']); 939 940 unset($_getVar['aid'], $_getVar['id']); 941 $content['CpPaginateNaviGET'] = returnGlobalGET_QueryString('htmlentities', array(), defined('PHPWCMS_ALIAS') ? array(PHPWCMS_ALIAS) : array()); 942 if(!empty($content['CpPaginateNaviGET']) && $content['CpPaginateNaviGET']{0} == '?') { 943 $content['CpPaginateNaviGET'] = '&'.substr($content['CpPaginateNaviGET'], 1); 944 } 945 946 // first build [1][2][3] paginate pages 947 if(strpos($content['all'], '{CP_PAGINATE}')) { 948 $content['CpPaginateNavi'] = array(); 949 foreach($content['CpPages'] as $key => $value) { 950 951 $content['CpPaginateNavi'][ $key ] = ' <a href="index.php?aid='.$aktion[1]; 952 if($key) { 953 $content['CpPaginateNavi'][ $key ] .= '-'.$key; 954 } 955 $content['CpPaginateNavi'][ $key ] .= $content['CpPaginateNaviGET'].'" class="'; 956 $content['CpPaginateNavi'][ $key ] .= ($key == $content['aId_CpPage']) ? 'cpPaginateActive' : 'cpPaginate'; 957 $content['CpPaginateNavi'][ $key ] .= '">'.$value.'</a>'; 958 959 } 960 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE', implode(LF, $content['CpPaginateNavi'])); 961 } 962 963 // is there PREV 964 if(in_array($content['CpPages'][ $content['aId_CpPage'] ] - 1, $content['CpPages'])) { 965 966 $key = array_search($content['CpPages'][ $content['aId_CpPage'] ] - 1, $content['CpPages']); 967 $value = 'index.php?aid='.$aktion[1]; 968 if($key) { $value .= '-'.$key; } 969 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE_PREV', $value); 970 971 } else { 972 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE_PREV'); 973 } 974 975 // is there NEXT 976 if(in_array($content['CpPages'][ $content['aId_CpPage'] ] + 1, $content['CpPages'])) { 977 978 $key = array_search($content['CpPages'][ $content['aId_CpPage'] ] + 1, $content['CpPages']); 979 $value = 'index.php?aid='.$aktion[1]; 980 if($key) { $value .= '-'.$key; } 981 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE_NEXT', $value); 982 983 } else { 984 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE_NEXT'); 985 } 986 987 // search for content part pagination title menu 988 if(strpos($content['all'], '[CP_PAGINATE_MENU')) { 989 990 /** 991 * search for custom cp menu parameters 992 * 993 * [0] => item_prefix 994 * [1] => item_suffix 995 * [2] => active_class 996 * [3] => hide_active 997 * [4] => menu_prefix 998 * [5] => menu_suffix 999 */ 1000 if( preg_match('/\[CP_PAGINATE_MENU:(.*?)\]/', $content['all'], $match) ) { 1001 1002 $content['all'] = str_replace($match[0], '[CP_PAGINATE_MENU]', $content['all']); 1003 $content['CpTitleParams'] = explode('|', $match[1]); 1004 if(!isset($content['CpTitleParams'][1])) { 1005 $content['CpTitleParams'][1] = ''; 1006 } 1007 $content['CpTitleParams'][2] = empty($content['CpTitleParams'][2]) ? '' : trim($content['CpTitleParams'][2]); 1008 $content['CpTitleParams'][3] = empty($content['CpTitleParams'][3]) ? 0 : 1 ; 1009 $content['CpTitleParams'][4] = ''; 1010 $content['CpTitleParams'][5] = ''; 1011 1012 } else { 1013 1014 $content['CpTitleParams'][0] = '<li>'; 1015 $content['CpTitleParams'][1] = '</li>'; 1016 $content['CpTitleParams'][2] = 'active'; 1017 $content['CpTitleParams'][3] = 0; 1018 $content['CpTitleParams'][4] = '<ul class="cpmenu">'; 1019 $content['CpTitleParams'][5] = '</ul>'; 1020 1021 } 1022 1023 $content['CpTitleMenu'] = array(); 1024 1025 // cp menu items 1026 foreach($content['CpPageTitles'] as $key => $value) { 1027 1028 $content['CpItem'] = '<a href="index.php?aid='.$aktion[1]; 1029 1030 if($key) { 1031 $content['CpItem'] .= '-'.$key; 1032 } 1033 1034 $content['CpItem'] .= $content['CpPaginateNaviGET'].'"'; 1035 1036 if($key == $content['aId_CpPage']) { 1037 1038 if(!empty($content['CpTitleParams'][3])) { 1039 continue; 1040 } 1041 1042 if(!empty($content['CpTitleParams'][2])) { 1043 $content['CpItem'] .= ' class="'.$content['CpTitleParams'][2].'"'; 1044 } 1045 1046 } 1047 1048 $content['CpItem'] .= '>'.html_specialchars($value).'</a>'; 1049 $content['CpTitleMenu'][] = $content['CpTitleParams'][0] . $content['CpItem'] . $content['CpTitleParams'][1]; 1050 } 1051 1052 // cp menu prefix/suffix 1053 if(count($content['CpTitleMenu'])) { 1054 $content['CpTitleMenu'][] = $content['CpTitleParams'][5]; 1055 array_unshift($content['CpTitleMenu'], $content['CpTitleParams'][4]); 1056 } 1057 1058 $content['all'] = render_cnt_template($content['all'], 'CP_PAGINATE_MENU', implode(LF, $content['CpTitleMenu'])); 1059 } 1060 1061 1062 } elseif(strpos($content['all'], 'CP_PAGINATE')) { 1063 1064 // remove CP_paginate block 1065 $content['all'] = replace_tmpl_section('CP_PAGINATE', $content['all']); 1066 1067 } 1068 1069 // check if print mode - then try to replace "no-print" sections from source 1070 if(strpos($content['all'], '--NO_PRINT')) { 1071 if($aktion[2] == 1) { 1072 1073 $content['all'] = replace_tmpl_section('NO_PRINT', $content['all']); 1074 $block['css'] = array('print_layout.css'); 1075 1076 } else { 1077 1078 $content['all'] = str_replace(array('<!--NO_PRINT_START//-->', '<!--NO_PRINT_END//-->'), '', $content['all']); 1079 1080 } 1081 } 1082 1083 // now clean up special sections in case user is logged in OR not 1084 if(strpos($content['all'], '--LOGGED_')) { 1085 1086 if( _getFeUserLoginStatus() ) { 1087 // if user IS logged in 1088 $content['all'] = str_replace(array('<!--LOGGED_IN_START//-->', '<!--LOGGED_IN_END//-->'), '', $content['all']); 1089 $content['all'] = replace_tmpl_section('LOGGED_OUT', $content['all']); 1090 } else { 1091 // user is NOT logged 1092 $content['all'] = str_replace(array('<!--LOGGED_OUT_START//-->', '<!--LOGGED_OUT_END//-->'), '', $content['all']); 1093 $content['all'] = replace_tmpl_section('LOGGED_IN', $content['all']); 1094 } 1095 1096 } 1097 1098 $content['all'] = preg_replace_callback('/\[HTML\](.*?)\[\/HTML\]/s', 'convert2html', $content['all'] ); 1099 $content['all'] = preg_replace_callback('/\[HTML_SPECIAL\](.*?)\[\/HTML_SPECIAL\]/s', 'convert2htmlspecialchars' , $content['all'] ); 1100 1101 // cleanup document to enhance XHTML Strict compatibility 1102 if($phpwcms['mode_XHTML'] == 2) { 1103 1104 $content['all'] = preg_replace(array('/ border="[0-9]+?"/', '/ target=".+?"/'), '', $content['all'] ); 1105 1106 } 1107 1108 // remove all useless replacement tags 1109 $content["pagetitle"] = sanitize_replacement_tags($content["pagetitle"]); 1110 1111 // now we should search all ?aid=123 and/or ?id=123 and replace'em by the real alias if available 1112 $match = array(); 1113 preg_match_all('/index.php\?(aid|id)=([\d\,]+)(["|&])/', $content['all'], $match); 1114 1115 if( isset($match[1]) && isset($match[2]) ) { 1116 1117 $all_id = array(); 1118 $sql_id = ''; 1119 1120 $all_aid = array(); 1121 $sql_aid = ''; 1122 1123 $old_style = false; 1124 1125 foreach($match[2] as $key => $value) { 1126 1127 if($match[1][$key] == 'id') { 1128 1129 if(strpos($match[2][$key], ',')) { 1130 1131 $old_style = true; 1132 1133 $this_id = 0; 1134 $this_aid = 0; 1135 1136 list($this_id, $this_aid) = explode(',', $match[2][$key]); 1137 1138 if( $this_aid = intval($this_aid) ) { 1139 1140 $all_aid[ $this_aid ] = $this_aid; 1141 1142 } elseif( $this_id = intval($this_id) ) { 1143 1144 $all_id[ $this_id ] = $this_id; 1145 1146 } 1147 1148 } else { 1149 1150 $all_id[ $match[2][$key] ] = $match[2][$key]; 1151 1152 } 1153 1154 } else { 1155 1156 $all_aid[ $match[2][$key] ] = $match[2][$key]; 1157 1158 } 1159 } 1160 1161 if(count($all_id)) { 1162 $sql_id = "SELECT 'id' AS alias_type, acat_id AS id, 0 AS aid, acat_alias AS alias FROM ".DB_PREPEND.'phpwcms_articlecat '; 1163 $sql_id .= 'WHERE acat_id IN (' . implode(',', $all_id) . ") AND acat_alias != ''"; 1164 } 1165 1166 if(count($all_aid)) { 1167 $sql_aid = "SELECT 'aid' AS alias_type, article_cid AS id, article_id AS aid, article_alias AS alias FROM ".DB_PREPEND.'phpwcms_article '; 1168 $sql_aid .= 'WHERE article_id IN (' . implode(',', $all_aid) . ") AND article_alias != ''"; 1169 } 1170 1171 if($sql_id && $sql_aid) { 1172 1173 $sql = '(' . $sql_id . ') UNION (' . $sql_aid . ')'; 1174 1175 } else { 1176 1177 $sql = $sql_id . $sql_aid ; 1178 1179 } 1180 1181 $match = _dbQuery($sql); 1182 1183 if(isset($match[0])) { 1184 1185 foreach($match as $value) { 1186 1187 $value['alias'] = html_specialchars($value['alias']); 1188 1189 if($value['alias_type'] == 'id') { 1190 1191 $content['all'] = str_replace('index.php?id=' . $value['id'] . '"', 'index.php?' . $value['alias'] . '"', $content['all']); 1192 $content['all'] = str_replace('index.php?id=' . $value['id'] . '&', 'index.php?' . $value['alias'] . '&', $content['all']); 1193 1194 } else { 1195 1196 $content['all'] = str_replace('index.php?aid=' . $value['aid'] . '"', 'index.php?' . $value['alias'] . '"', $content['all']); 1197 $content['all'] = str_replace('index.php?aid=' . $value['aid'] . '&', 'index.php?' . $value['alias'] . '&', $content['all']); 1198 1199 } 1200 1201 // search also for id=0,0,... 1202 if( $old_style == true ) { 1203 1204 $value['id'] = $value['id'] . ',' . $value['aid'] . ',0,1,0,0'; 1205 1206 $content['all'] = str_replace('index.php?id=' . $value['id'] . '"', 'index.php?' . $value['alias'] . '"', $content['all']); 1207 $content['all'] = str_replace('index.php?id=' . $value['id'] . '&', 'index.php?' . $value['alias'] . '&', $content['all']); 1208 1209 } 1210 1211 } 1212 1213 } 1214 1215 } 1216 1217 // Global parsing for i18 @@Text@@ replacements 1218 if(!empty($phpwcms['i18n_parse'])) { 1219 $content['all'] = i18n_substitute_text($content['all']); 1220 $content["pagetitle"] = i18n_substitute_text($content['pagetitle']); 1221 } 1222 1223 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Nov 16 22:51:00 2010 | Cross-referenced by PHPXref 0.7 |