[ Index ] |
PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved. 6 7 This script is part of PHPWCMS. The PHPWCMS web content management system is 8 free software; you can redistribute it and/or modify it under the terms of 9 the GNU General Public License as published by the Free Software Foundation; 10 either version 2 of the License, or (at your option) any later version. 11 12 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 13 A copy is found in the textfile GPL.txt and important notices to the license 14 from the author is found in LICENSE.txt distributed with these scripts. 15 16 This script is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 18 PARTICULAR PURPOSE. See the GNU General Public License for more details. 19 20 This copyright notice MUST APPEAR in all copies of the script! 21 *************************************************************************************/ 22 23 // ---------------------------------------------------------------- 24 // obligate check for phpwcms constants 25 if (!defined('PHPWCMS_ROOT')) { 26 die("You Cannot Access This Script Directly, Have a Nice Day."); 27 } 28 // ---------------------------------------------------------------- 29 30 31 // Teaser (link article) content part 32 33 $content['alink'] = unserialize($crow["acontent_form"]); 34 35 if(!isset($content['alink']['alink_id'])) { 36 37 $content['alink']['alink_id'] = explode(':', $crow['acontent_alink']); 38 39 } 40 41 if( 42 (is_array($content['alink']['alink_id']) && count($content['alink']['alink_id'])) 43 || 44 (!empty($content['alink']['alink_type']) 45 && 46 ( 47 (is_array($content['alink']['alink_level']) && count($content['alink']['alink_level'])) 48 || 49 (isset($content['alink']['alink_category']) && count($content['alink']['alink_category'])) 50 ) 51 ) 52 ) { 53 54 if(!isset($content['UNIQUE_ALINK'])) { 55 $content['UNIQUE_ALINK'] = array(); 56 } 57 58 if(!empty($content['alink']['alink_template']) && is_file(PHPWCMS_TEMPLATE.'inc_cntpart/teaser/'.$content['alink']['alink_template'])) { 59 60 $content['alink']['alink_template'] = @file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/teaser/'.$content['alink']['alink_template']); 61 62 } elseif(is_file(PHPWCMS_TEMPLATE.'inc_default/teaser.tmpl')) { 63 64 $content['alink']['alink_template'] = @file_get_contents(PHPWCMS_TEMPLATE.'inc_default/teaser.tmpl'); 65 66 } else { 67 68 $content['alink']['alink_template'] = '<!--TEASER_HEAD_START//--><ul{LINK_ARTICLE_CLASS}>'.LF.'<!--TEASER_HEAD_END//-->'; 69 $content['alink']['alink_template'] .= '<!--TEASER_ENTRY_START//--> <li><a href="{ARTICLELINK}">{TITLE}</a></li><!--TEASER_ENTRY_END//-->'; 70 $content['alink']['alink_template'] .= '<!--TEASER_ENTRY_SPACER_START//-->'.LF.'<!--TEASER_ENTRY_SPACER_END//-->'; 71 $content['alink']['alink_template'] .= '<!--TEASER_FOOTER_START//-->'.LF.'</ul><!--TEASER_FOOTER_END//-->'; 72 73 } 74 75 76 $content['alink']['tags_group_by'] = ''; 77 $content['alink']['tags_where'] = ''; 78 $content['alink']['date_basis'] = 'article_date'; 79 80 $alink_sql = "SELECT ar.*, UNIX_TIMESTAMP(ar.article_tstamp) AS article_date FROM ".DB_PREPEND."phpwcms_article ar "; 81 82 83 // select by category 84 if(count($content['alink']['alink_category'])) { 85 86 $content['alink']['tags_sql'] = array(); 87 88 // and/or/not mode 89 switch($content['alink']['alink_andor']) { 90 91 case 'AND': $content['alink']['alink_andor'] = ' AND '; 92 $content['alink']['alink_compare'] = '='; 93 break; 94 95 case 'NOT': $content['alink']['alink_andor'] = ' AND '; 96 $content['alink']['alink_compare'] = '!='; 97 break; 98 99 default: //OR 100 $content['alink']['alink_andor'] = ' OR '; 101 $content['alink']['alink_compare'] = '='; 102 } 103 104 foreach($content['alink']['alink_category'] as $value) { 105 106 $content['alink']['tags_sql'][] = 'pcat.cat_name' . $content['alink']['alink_compare'] . "'" . aporeplace($value) . "'"; 107 108 } 109 110 // JOIN with tags/categories for articles 111 $alink_sql .= "LEFT JOIN ".DB_PREPEND."phpwcms_categories pcat ON (pcat.cat_type='article' AND pcat.cat_pid=ar.article_id) "; 112 $content['alink']['tags_where'] = 'AND (' . implode($content['alink']['alink_andor'], $content['alink']['tags_sql']) . ') '; 113 114 // group by article ID 115 $content['alink']['tags_group_by'] = ' GROUP BY ar.article_id'; 116 117 } 118 119 120 $alink_sql .= "WHERE ar.article_public=1 AND ar.article_aktiv=1 AND ar.article_deleted=0 "; 121 $alink_sql .= "AND ar.article_begin < NOW() AND ar.article_end > NOW() "; 122 123 // add possible WHERE clauses when tags/categories are used 124 $alink_sql .= $content['alink']['tags_where']; 125 126 if(empty($content['alink']['alink_type'])) { 127 128 if(!empty($content['alink']['alink_unique']) && count($content['UNIQUE_ALINK'])) { 129 130 $content['alink']['alink_id'] = array_diff($content['alink']['alink_id'], $content['UNIQUE_ALINK']); 131 $alink_sql .= count($content['alink']['alink_id']) ? 'AND ar.article_id IN ('.implode(',', $content['alink']['alink_id']) . ')' : ' AND 0 '; 132 133 } else { 134 $alink_sql .= 'AND ar.article_id IN ('.implode(',', $content['alink']['alink_id']) . ')'; 135 } 136 137 // group by - when used with categories/tags 138 $alink_sql .= $content['alink']['tags_group_by']; 139 140 } else { 141 142 if(is_array($content['alink']['alink_level']) && count($content['alink']['alink_level'])) { 143 144 $alink_sql .= 'AND ar.article_cid IN ('.implode(',', $content['alink']['alink_level']) . ')'; 145 if(!empty($content['alink']['alink_unique']) && count($content['UNIQUE_ALINK'])) { 146 $alink_sql .= ' AND ar.article_id NOT IN ('.implode(',', $content['UNIQUE_ALINK']) . ')'; 147 } 148 } 149 150 // group by - when used with categories/tags 151 $alink_sql .= $content['alink']['tags_group_by']; 152 153 // don't use SQL UNION 154 $sql_union = ''; 155 156 // add prio sorting value 157 if(empty($content['alink']['alink_prio'])) { 158 $sql_prio = ''; 159 $sql_union_prio = ''; 160 } else { 161 $sql_prio = 'ar.article_priorize DESC, '; 162 $sql_union_prio = 'article_priorize DESC, '; 163 } 164 165 switch($content['alink']['alink_type']) { 166 167 case 1: // create date, DESC 168 $content['alink']['date_basis'] = 'article_created'; 169 $alink_sql .= " ORDER BY ".$sql_prio."ar.article_created DESC"; break; 170 171 case 2: // create date, ASC 172 $content['alink']['date_basis'] = 'article_created'; 173 $alink_sql .= " ORDER BY ".$sql_prio."ar.article_created ASC"; break; 174 175 case 3: // change date, DESC 176 $alink_sql .= " ORDER BY ".$sql_prio."ar.article_tstamp DESC"; break; 177 178 case 4: // change date, ASC 179 $alink_sql .= " ORDER BY ".$sql_prio."ar.article_tstamp ASC"; break; 180 181 case 5: // live date, DESC 182 $alink_sql .= " ORDER BY ".$sql_prio."ar.article_begin DESC"; break; 183 184 case 6: // live date, ASC 185 $alink_sql .= " ORDER BY ".$sql_prio."ar.article_begin ASC"; break; 186 187 case 7: // kill date, DESC 188 $alink_sql .= " ORDER BY ".$sql_prio."ar.article_end DESC"; break; 189 190 case 8: // kill date, ASC 191 $alink_sql .= " ORDER BY ".$sql_prio."ar.article_end ASC"; break; 192 193 case 18: // article title, DESC 194 $alink_sql .= " ORDER BY ".$sql_prio."ar.article_title DESC"; break; 195 196 case 19: // article title, ASC 197 $alink_sql .= " ORDER BY ".$sql_prio."ar.article_title ASC"; break; 198 199 200 case 9: // random 201 $alink_sql .= " ORDER BY RAND()"; break; 202 203 case 10: // random, create date, DESC 204 $alink_sql .= " ORDER BY RAND()"; 205 $sql_union .= " ORDER BY ".$sql_union_prio."article_created DESC"; break; 206 207 case 11: // random, create date, ASC 208 $alink_sql .= " ORDER BY RAND()"; 209 $sql_union .= " ORDER BY ".$sql_union_prio."article_created ASC"; break; 210 211 case 12: // random, change date, DESC 212 $alink_sql .= " ORDER BY RAND()"; 213 $sql_union .= " ORDER BY ".$sql_union_prio."article_tstamp DESC"; break; 214 215 case 13: // random, change date, ASC 216 $alink_sql .= " ORDER BY RAND()"; 217 $sql_union .= " ORDER BY ".$sql_union_prio."article_tstamp ASC"; break; 218 219 case 14: // random, live date, DESC 220 $alink_sql .= " ORDER BY RAND()"; 221 $sql_union .= " ORDER BY ".$sql_union_prio."article_begin DESC"; break; 222 223 case 15: // random, live date, ASC 224 $alink_sql .= " ORDER BY RAND()"; 225 $sql_union .= " ORDER BY ".$sql_union_prio."article_begin ASC"; break; 226 227 case 16: // random, kill date, DESC 228 $alink_sql .= " ORDER BY RAND()"; 229 $sql_union .= " ORDER BY ".$sql_union_prio."article_end DESC"; break; 230 231 case 17: // random, kill date, ASC 232 $alink_sql .= " ORDER BY RAND()"; 233 $sql_union .= " ORDER BY ".$sql_union_prio."article_end ASC"; break; 234 235 case 20: // random, kill date, DESC 236 $alink_sql .= " ORDER BY RAND()"; 237 $sql_union .= " ORDER BY ".$sql_union_prio."article_title DESC"; break; 238 239 case 21: // random, kill date, ASC 240 $alink_sql .= " ORDER BY RAND()"; 241 $sql_union .= " ORDER BY ".$sql_union_prio."article_title ASC"; break; 242 243 } 244 245 if(!empty($content['alink']['alink_max']) && intval($content['alink']['alink_max'])) { 246 $alink_sql .= " LIMIT ".intval($content['alink']['alink_max']); 247 } 248 249 if($sql_union != '') { 250 251 $alink_sql = '('.$alink_sql.') UNION DISTINCT ('.$alink_sql.')'.$sql_union; 252 if(!empty($content['alink']['alink_max']) && intval($content['alink']['alink_max'])) { 253 $alink_sql .= " LIMIT ".intval($content['alink']['alink_max']); 254 } 255 256 } 257 258 } 259 260 $content['alink']['tr'] = array(); 261 262 $content['alink']['alink_template_head'] = get_tmpl_section('TEASER_HEAD', $content['alink']['alink_template']); 263 $content['alink']['alink_template_footer'] = get_tmpl_section('TEASER_FOOTER', $content['alink']['alink_template']); 264 $content['alink']['alink_template_entry'] = get_tmpl_section('TEASER_ENTRY', $content['alink']['alink_template']); 265 $content['alink']['alink_template_space'] = get_tmpl_section('TEASER_SPACER', $content['alink']['alink_template']); 266 267 $content['alink']['alink_template_head'] = str_replace('{LINK_ARTICLE_CLASS}', get_class_attrib($template_default["article"]["link_article_class"]), $content['alink']['alink_template_head']); 268 269 $content['alink']['result'] = _dbQuery($alink_sql); 270 271 if(count($content['alink']['result'])) { 272 273 // before finding a faster solution... 274 if(!empty($content['alink']['alink_type'])) { 275 $content['alink']['alink_id'] = array(); 276 foreach($content['alink']['result'] as $value) { 277 $content['alink']['alink_id'][] = $value['article_id']; 278 } 279 } 280 281 foreach($content['alink']['alink_id'] as $key => $value) { 282 283 $content['UNIQUE_ALINK'][$value] = $value; //save UNIQUE Teaser ID 284 285 foreach($content['alink']['result'] as $row) { 286 287 if($value == $row['article_id'] && isset($content['struct'][ $row['article_cid'] ])) { 288 289 // enable frontend edit link 290 $content['alink']['tr'][$key] = getFrontendEditLink('summary', $row["article_id"]); 291 292 $content['alink']['tr'][$key] .= $content['alink']['alink_template_entry']; 293 294 $content['alink']['tr'][$key] = str_replace('{ARTICLEID}', $row['article_id'], $content['alink']['tr'][$key]); 295 $content['alink']['tr'][$key] = str_replace('{CATEGORYID}', $row['article_cid'], $content['alink']['tr'][$key]); 296 $content['alink']['tr'][$key] = render_cnt_template($content['alink']['tr'][$key], 'MENUTITLE', html_specialchars($row['article_menutitle'])); 297 $content['alink']['tr'][$key] = render_cnt_template($content['alink']['tr'][$key], 'TITLE', html_specialchars($row['article_title'])); 298 $content['alink']['tr'][$key] = render_cnt_template($content['alink']['tr'][$key], 'SUBTITLE', html_specialchars($row['article_subtitle'])); 299 $content['alink']['tr'][$key] = render_cnt_date($content['alink']['tr'][$key], $row[ $content['alink']['date_basis'] ], strtotime($row['article_begin']), strtotime($row['article_end'])); 300 $content['alink']['tr'][$key] = render_cnt_template($content['alink']['tr'][$key], 'PRIO', empty($row['article_priorize']) ? '' : $row['article_priorize']); 301 302 $row['article_image'] = unserialize( $row['article_image'] ); 303 304 // article list image 305 if(strpos($content['alink']['tr'][$key], 'IMAGE') !== false) { 306 307 $img_thumb_name = ''; 308 $img_thumb_rel = ''; 309 $img_thumb_abs = ''; 310 $img_thumb_width = 0; 311 $img_thumb_height = 0; 312 313 $row['article_image'] = setArticleSummaryImageData( $row['article_image'] ); 314 315 // check if image available 316 if(!empty($row['article_image']['list_id'])) { 317 318 if(!empty($content['alink']['alink_width'])) $row['article_image']['list_width'] = $content['alink']['alink_width']; 319 if(!empty($content['alink']['alink_height'])) $row['article_image']['list_height'] = $content['alink']['alink_height']; 320 321 // build image/image link 322 $content['alink']['poplink'] = ''; 323 $thumb_image = false; 324 $thumb_img = ''; 325 $content['alink']['caption'] = getImageCaption($row['article_image']['list_caption']); 326 $row['article_image']['list_caption'] = $content['alink']['caption'][0]; // caption text 327 328 329 if(!empty($row['article_image']['list_hash'])) { 330 331 $content['alink']['alink_crop'] = empty($content['alink']['alink_crop']) ? 0 : 1; 332 333 $thumb_image = get_cached_image( 334 array( "target_ext" => $row['article_image']['list_ext'], 335 "image_name" => $row['article_image']['list_hash'] . '.' . $row['article_image']['list_ext'], 336 "max_width" => $row['article_image']['list_width'], 337 "max_height" => $row['article_image']['list_height'], 338 "thumb_name" => md5( $row['article_image']['list_hash']. 339 $row['article_image']['list_width']. 340 $row['article_image']['list_height']. 341 $GLOBALS['phpwcms']['sharpen_level']. 342 $content['alink']['alink_crop'] 343 ), 344 'crop_image' => $content['alink']['alink_crop'] 345 )); 346 347 if($thumb_image != false) { 348 349 $content['alink']['caption'][3] = empty($content['alink']['caption'][3]) ? '' : ' title="'.html_specialchars($content['alink']['caption'][3]).'"'; 350 $content['alink']['caption'][1] = html_specialchars($content['alink']['caption'][1]); 351 352 $thumb_img = '<img src="'.PHPWCMS_IMAGES . $thumb_image[0] .'" border="0" '.$thumb_image[3].' alt="'.$content['alink']['caption'][1].'"'.$content['alink']['caption'][3].' />'; 353 354 $img_thumb_name = $thumb_image[0]; 355 $img_thumb_rel = PHPWCMS_IMAGES.$thumb_image[0]; 356 $img_thumb_abs = PHPWCMS_URL.PHPWCMS_IMAGES.$thumb_image[0]; 357 $img_thumb_width = $thumb_image[1]; 358 $img_thumb_height = $thumb_image[2]; 359 } 360 } 361 362 $content['alink']['tr'][$key] = render_cnt_template($content['alink']['tr'][$key], 'IMAGE', $thumb_img); 363 364 } else { 365 366 $content['alink']['tr'][$key] = render_cnt_template($content['alink']['tr'][$key], 'IMAGE', ''); 367 368 } 369 370 // replace thumbnail and zoom image information 371 $content['alink']['tr'][$key] = str_replace( 372 373 array( '{THUMB_NAME}', '{THUMB_REL}', '{THUMB_ABS}', '{THUMB_WIDTH}', '{THUMB_HEIGHT}' ), 374 array( $img_thumb_name, $img_thumb_rel, $img_thumb_abs, $img_thumb_width, $img_thumb_height ), 375 $content['alink']['tr'][$key] 376 ); 377 378 // Image Caption 379 $content['alink']['tr'][$key] = render_cnt_template($content['alink']['tr'][$key], 'CAPTION', empty($row['article_image']['list_caption']) ? '' : html_specialchars($row['article_image']['list_caption'])); 380 381 } 382 383 // article summary 384 if(strpos($content['alink']['tr'][$key], 'SUMMARY') !== false) { 385 386 if(empty($content['alink']['alink_wordlimit']) && !empty($row['article_image']['list_maxwords'])) { 387 $content['alink']['alink_wordlimit'] = $row['article_image']['list_maxwords']; 388 } 389 $row['article_summary'] = empty($content['alink']['alink_allowedtags']) ? strip_tags($row['article_summary']) : strip_tags($row['article_summary'], $content['alink']['alink_allowedtags']); 390 if(!empty($content['alink']['alink_wordlimit'])) { 391 $row['article_summary'] = getCleanSubString($row['article_summary'], $content['alink']['alink_wordlimit'], $template_default['ellipse_sign'], 'word'); 392 } 393 $content['alink']['tr'][$key] = render_cnt_template($content['alink']['tr'][$key], 'SUMMARY', $row['article_summary']); 394 } 395 396 $content['alink']['tr'][$key] = str_replace('{ARTICLELINK}', 'index.php?'.setGetArticleAid($row), $content['alink']['tr'][$key]); 397 398 // article category 399 $content['alink']['tr'][$key] = render_cnt_template($content['alink']['tr'][$key], 'CATEGORY', html_specialchars($content['struct'][ $row['article_cid'] ]['acat_name'])); 400 401 break; 402 403 } 404 405 } 406 } 407 408 } 409 410 // combine all teaser items 411 if(count($content['alink']['tr'])) { 412 $content['alink']['tr'] = implode($content['alink']['alink_template_space'], $content['alink']['tr']); 413 $content['alink']['teaser'] = ' '; 414 } else { 415 $content['alink']['tr'] = ''; 416 $content['alink']['teaser'] = ''; 417 } 418 419 // put all template and content into one 420 $content['alink']['alink_template'] = LF . $content['alink']['alink_template_head'] . $content['alink']['tr'] . $content['alink']['alink_template_footer'] . LF; 421 422 // render teaser elements - throw everything between [TEASER]...[/TEASER] 423 $content['alink'] = render_cnt_template($content['alink']['alink_template'], 'TEASER', $content['alink']['teaser']); 424 425 // render title 426 $content['alink'] = render_cnt_template($content['alink'], 'TITLE', html_specialchars($crow['acontent_title'])); 427 $content['alink'] = render_cnt_template($content['alink'], 'SUBTITLE', html_specialchars($crow['acontent_subtitle'])); 428 429 $CNT_TMP .= $content['alink']; 430 431 432 } 433 434 435 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 30 05:55:15 2009 | Cross-referenced by PHPXref 0.7 |