If you have an article that consists of different content parts, this hack will show a listing of all content parts (including links in order to directly jump to them).
You will have to change the "content.article.inc.php" like this:
(Attention: the listing below also includes the frontend-editing hack, discribed in "User Rights Management and Frontend Editing" http://www.phpwcms.de/forum/viewtopic.php?t=10262
Code: Select all
<?php
/*************************************************************************************
Copyright notice
(c) 2002-2005 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
This script is part of PHPWCMS. The PHPWCMS web content management system is
free software; you can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
A copy is found in the textfile GPL.txt and important notices to the license
from the author is found in LICENSE.txt distributed with these scripts.
This script is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
This copyright notice MUST APPEAR in all copies of the script!
*************************************************************************************/
// all for creating article
$sql = "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date ";
$sql .= "FROM ".DB_PREPEND."phpwcms_article LEFT JOIN ".DB_PREPEND."phpwcms_articlecat ON ";
$sql .= DB_PREPEND."phpwcms_article.article_cid=".DB_PREPEND."phpwcms_articlecat.acat_id WHERE ";
$sql .= DB_PREPEND."phpwcms_article.article_id=".$aktion[1]." AND ";
// VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode
switch(VISIBLE_MODE) {
case 0: $sql .= DB_PREPEND."phpwcms_article.article_public=1 AND ";
$sql .= DB_PREPEND."phpwcms_article.article_aktiv=1 AND ";
break;
case 1: $sql .= DB_PREPEND."phpwcms_article.article_uid=".$_SESSION["wcs_user_id"]." AND ";
break;
//case 2: admin mode no additional neccessary
}
$sql .= DB_PREPEND."phpwcms_article.article_deleted=0 AND ".DB_PREPEND."phpwcms_article.article_begin<NOW() ";
$sql .= "AND ".DB_PREPEND."phpwcms_article.article_end>NOW() LIMIT 1;";
if($result = mysql_query($sql, $db) or die("error while reading article datas")) {
if($row = mysql_fetch_assoc($result)) {
//Da max. 1 Datensatz -> sofort Datenbankverbindung kappen
mysql_free_result($result);
// now try to retrieve alias article information
if($row["article_aliasid"]) {
$alias_sql = "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date FROM ".DB_PREPEND."phpwcms_article ";
$alias_sql .= "WHERE article_deleted=0 AND article_id=".intval($row["article_aliasid"]);
if(!$row["article_headerdata"]) {
switch(VISIBLE_MODE) {
case 0: $alias_sql .= " AND article_public=1 AND article_aktiv=1";
break;
case 1: $alias_sql .= " AND article_uid=".$_SESSION["wcs_user_id"];
break;
}
$alias_sql .= " AND article_begin < NOW() AND article_end > NOW()";
}
$alias_sql .= " AND article_deleted=0 LIMIT 1";
if($alias_result = mysql_query($alias_sql, $db)) {
if($alias_row = mysql_fetch_assoc($alias_result)) {
$row["article_id"] = $alias_row["article_id"];
// use alias article header data
if(!$row["article_headerdata"]) {
$row["article_title"] = $alias_row["article_title"];
$row["article_subtitle"] = $alias_row["article_subtitle"];
$row["article_keyword"] = $alias_row["article_keyword"];
$row["article_summary"] = $alias_row["article_summary"];
$row["article_redirect"] = $alias_row["article_redirect"];
$row["article_date"] = $alias_row["article_date"];
$row["article_image"] = $alias_row["article_image"];
}
}
mysql_free_result($alias_result);
}
}
//Kategoriebezeichner
$article["cat"] = ($row["acat_name"]) ? $row["acat_name"] : $indexpage['acat_name'];
$article['cat'] = html_specialchars($article['cat']);
//redirection definition
if($row["article_redirect"]) {
$row["article_redirect"] = str_replace('{SITE}', PHPWCMS_URL, $row["article_redirect"]);
list($content["redirect"]["link"], $content["redirect"]["target"]) = explode(" ", $row["article_redirect"]);
//check how to redirect - new window or self window
if( !$content["redirect"]["target"] || $content["redirect"]["target"] == "_self" ||
$content["redirect"]["target"] == "_top" || $content["redirect"]["target"] == "_parent") {
// direct redirection in the same window
header("Location: ".$content["redirect"]["link"]);
exit();
} else {
// redirection by using a special <meta><javascript> html head part
$content["redirect"]["code"] = "\n<noscript>\n";
$content["redirect"]["code"] .= '<meta http-equiv="refresh" content="0;URL=';
$content["redirect"]["code"] .= $content["redirect"]["link"];
$content["redirect"]["code"] .= "\">\n</noscript>\n";
$content["redirect"]["code"] .= '<script language="JavaScript" type="text/javascript">';
$content["redirect"]["code"] .= "\n<!--\nvar redirectWin;\n";
$content["redirect"]["code"] .= 'window.open("'.$content["redirect"]["link"].'", redirectWin);';
$content["redirect"]["code"] .= "\n//-->\n</script>\n";
}
}
//set cache timeout for this article
if($row['article_cache'] != '') {
$phpwcms['cache_timeout'] = $row['article_cache'];
}
//get value for article search (on/off)
if($row['article_nosearch'] != '') {
$cache_searchable = '1';
}
//add category and article name to $content["pagetitle"]
if($row["acat_name"] && !empty($pagelayout["layout_title_cat"])) {
if($content["pagetitle"]) {
$content["pagetitle"] .= " | ";
}
$content["pagetitle"] .= $row["acat_name"];
}
if($row["article_title"] && !empty($pagelayout["layout_title_article"])) {
if($content["pagetitle"]) {
$content["pagetitle"] .= " | ";
}
$content["pagetitle"] .= $row["article_title"];
}
$content["pagetitle"] = html_specialchars($content["pagetitle"]);
$content['all_keywords'] = $row['article_keyword'];
$content["main"] .= "<a name=\"jump".$row["article_id"]."\"></a>";
// only copy the catname to a special var for multiple for use in any block
$content["cat"] = html_specialchars($article["cat"]);
$content["cat_id"] = $aktion[0] = $row["article_cid"]; //set category ID to actual category value
$content["article_id"] = $row["article_id"];
$content["summary"] = '';
$content["article_date"] = $row["article_date"]; // article date
$content["article_created"] = $row["article_created"]; // article created
//retrieve image info
$row["article_image"] = unserialize($row["article_image"]);
$caption = explode('|', $row["article_image"]["caption"]);
$row["article_image"]["caption"] = $caption[0]; //$caption[0]
//build image/image link
$thumb_image = false;
$thumb_img = '';
if(!empty($row["article_image"]["hash"])) {
$thumb_image = get_cached_image(
array( "target_ext" => $row["article_image"]['ext'],
"image_name" => $row["article_image"]['hash'] . '.' . $row["article_image"]['ext'],
"max_width" => $row["article_image"]['width'],
"max_height" => $row["article_image"]['height'],
"thumb_name" => md5($row["article_image"]['hash'].$row["article_image"]['width'].$row["article_image"]['height'].$GLOBALS['phpwcms']["sharpen_level"])
));
if($thumb_image != false) {
$caption[1] = (!isset($caption[1])) ? '' : html_specialchars($caption[1]);
if(!isset($caption[2])) {
$caption[2] = array('',' target="_blank"');
} else {
//proof target of link
$caption[2] = explode(' ', trim($caption[2]));
$caption[2][1] = (!isset($caption[2][1])) ? '' : ' target="'.$caption[2][1].'"';
}
$thumb_img = '<img src="'.PHPWCMS_IMAGES . $thumb_image[0] .'" border="0" '.$thumb_image[3].' alt="'.$caption[1].'" title="'.$caption[1].'">';
if($row["article_image"]["zoom"]) {
$zoominfo = get_cached_image(
array( "target_ext" => $row["article_image"]['ext'],
"image_name" => $row["article_image"]['hash'] . '.' . $row["article_image"]['ext'],
"max_width" => $GLOBALS['phpwcms']["img_prev_width"],
"max_height" => $GLOBALS['phpwcms']["img_prev_height"],
"thumb_name" => md5($row["article_image"]['hash'].$GLOBALS['phpwcms']["img_prev_width"].$GLOBALS['phpwcms']["img_prev_height"].$GLOBALS['phpwcms']["sharpen_level"])
));
if($zoominfo != false) {
$popup_img = 'image_zoom.php?show='.base64_encode($zoominfo[0].'?'.$zoominfo[3]);
if(!empty($caption[2][0])) {
$open_link = $caption[2][0];
$return_false = '';
} else {
$open_link = $popup_img;
$return_false = 'return false;';
}
$thumb_img = '<a href="'.$popup_img.'" onClick="window.open(\''.$open_link.
"','previewpic','width=".$zoominfo[1].",height=".$zoominfo[2]."');".$return_false.
'"'.$caption[2][1].'>'.$thumb_img.'</a>';
}
} else {
if($caption[2][0]) {
$thumb_img = '<a href="'.$caption[2][0].'"'.$caption[2][1].'>'.$thumb_img.'</a>';
}
}
}
}
// check for custom full article summary template
if(!empty($row["article_image"]['tmplfull']) && $row["article_image"]['tmplfull']!='default') {
// try to read the template files
$row["article_image"]['tmplfull'] = include_ext_php(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article/'.$row["article_image"]['tmplfull'], 1);
if($row["article_image"]['tmplfull']) {
//rendering
$row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'TITLE', html_specialchars($row["article_title"]));
$row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'SUB', html_specialchars($row["article_subtitle"]));
$row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'SUMMARY', $row["article_summary"]);
$row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'IMAGE', $thumb_img);
$row["article_image"]['tmplfull'] = render_cnt_template($row["article_image"]['tmplfull'], 'CAPTION', nl2br(html_specialchars($row["article_image"]["caption"])));
$row["article_image"]['tmplfull'] = render_cnt_date($row["article_image"]['tmplfull'], $content["article_date"]);
$content["summary"] .= $row["article_image"]['tmplfull'];
$row["article_image"]['tmplfull'] = 1;
} else {
$row["article_image"]['tmplfull'] = 0;
}
}
if (empty($row["article_image"]['tmplfull']) || $row["article_image"]['tmplfull'] == 'default') {
//Artikelüberschrift, Subheadline, Summary
if($row["article_title"] && !$row["article_notitle"]) {
$content["summary"] .= $template_default["article"]["title_before"];
$content["summary"] .= html_specialchars($row["article_title"]); //span_class(html_specialchars($row["article_title"]),$template_default["article"]["title_class"]).
$content["summary"] .= $template_default["article"]["title_after"];
}
if($row["article_subtitle"]) {
$content["summary"] .= $template_default["article"]["subtitle_before"];
$content["summary"] .= html_specialchars($row["article_subtitle"]); //span_class(html_specialchars($row["article_subtitle"]),$template_default["article"]["subtitle_class"]).
$content["summary"] .= $template_default["article"]["subtitle_after"];
}
if(($row["article_summary"] || !empty($thumb_img)) && !$row["article_hidesummary"]) {
$content["summary"] .= $template_default["article"]["summary_before"];
if(!empty($thumb_img)) {
$content["summary"] .= '<table width="1%" cellspacing="0" border="0" cellpadding="0" align="left" ';
if($template_default["article"]["image_table_bgcolor"]) {
$content["summary"] .= 'bgcolor="'.$template_default["article"]["image_table_bgcolor"].'" ';
}
$content["summary"] .= 'style="float:left;margin:2px 5px 3px 0;">';
$content["summary"] .= "\n<tr><td";
if($template_default["article"]["image_class"]) {
$content["summary"] .= ' class="'.$template_default["article"]["image_class"].'"';
}
$content["summary"] .= ">".$thumb_img."</td></tr>\n";
if($row["article_image"]["caption"]) {
//$content["summary"] .= '<tr><td><img src="img/leer.gif" alt="" width="1" height="3"></td></tr>';
$content["summary"] .= "\n<tr><td";
if($template_default["article"]["image_caption_class"]) {
$content["summary"] .= ' class="'.$template_default["article"]["image_caption_class"].'"';
}
if($template_default["article"]["image_caption_bgcolor"]) {
$content["summary"] .= ' bgcolor="'.$template_default["article"]["image_caption_bgcolor"].'"';
}
if($template_default["article"]["image_caption_valign"]) {
$content["summary"] .= ' valign="'.$template_default["article"]["image_caption_valign"].'"';
}
if($template_default["article"]["image_caption_align"]) {
$content["summary"] .= ' align="'.$template_default["article"]["image_caption_align"].'"';
}
$content["summary"] .= '>';
$content["summary"] .= $template_default["article"]["image_caption_before"];
$content["summary"] .= nl2br(html_specialchars($row["article_image"]["caption"]));
$content["summary"] .= $template_default["article"]["image_caption_after"];
$content["summary"] .= "</td></tr>\n";
}
$content["summary"] .= '</table>';
}
$content["summary"] .= $row["article_summary"]; //div_class($row["article_summary"],$template_default["article"]["summary_class"]).
$content["summary"] .= $template_default["article"]["summary_after"];
}
}
if($content["summary"]) {
$content["main"] .= $content["summary"];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// add link to edit article basic information / beta_bi
// look if logged in user has got permission to edit category or not / max: 20 users
//echo "cat_rights ist: ".$GLOBALS['content']['struct'][$GLOBALS['content']['cat_id']]['acat_permit'][0];
//echo "user_id ist: ".$_SESSION["wcs_user_id"];
//echo "acat_id ist: ".$GLOBALS['content']['cat_id'];
$hasPermission = false;
if ($GLOBALS['content']['struct'][$GLOBALS['content']['cat_id']]['acat_permit'][0] == '' && $_SESSION["wcs_user_id"] !="") {
// if no permissions are defined
$hasPermission = true;
//echo "keine rechte definiert";
}
else {
for ($loop = 0; $loop < 20; $loop++) {
if ($_SESSION["wcs_user_id"] == $GLOBALS['content']['struct'][$GLOBALS['content']['cat_id']]['acat_permit'][$loop] && $_SESSION["wcs_user_id"] !="") {
$hasPermission = true;
break;
}
}
}
// indexlevel has to be handled differently
if ($GLOBALS['content']['cat_id'] == 0) {
// this only gives acces to the admin / owner
$hasPermission = false;
}
if($row["article_uid"] == $_SESSION["wcs_user_id"] || $_SESSION["wcs_user_admin"] || $hasPermission == true) {
$content["main"] .= "<div ><a style=\"color:#f00; background-color:#fff\" href=\"phpwcms.php?do=articles&p=2&s=1&id=".$GLOBALS['content']['article_id']."&aktion=1\" target=\"_blank\">[edit]</a></div>";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$content["main"] .= $template_default["article"]["head_after"];
}
////////////////////////////
// content-table list
$CTAB_TMP = '<ul id="contTable">'; // temp var to store content table navigation
$CNT_TEMP = ''; // temp vat to stote all content parts
////////////////////////////
// render content parts
$sql_cnt = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent WHERE acontent_aid=".$row["article_id"]." ".
"AND acontent_visible=1 AND acontent_trash=0 ORDER BY acontent_sorting, acontent_id;";
if($cresult = mysql_query($sql_cnt, $db) or die("error while listing contents for this article")) {
while($crow = mysql_fetch_assoc($cresult)) { // 24-07-2005 mysql_fetch_array
// do everything neccessary for alias content part
if($crow["acontent_type"] == 24) {
// first retrieve alias ID information and settings
$content["thisAlias"] = unserialize($crow["acontent_form"]);
if(!empty($content["thisAlias"]['alias_ID'])) {
$content["thisAlias"]['alias_ID'] = intval($content["thisAlias"]['alias_ID']);
$sql_alias = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent WHERE acontent_id=";
$sql_alias .= $content["thisAlias"]['alias_ID'];
$sql_alias .= " AND acontent_trash=0 LIMIT 1"; //AND acontent_visible=1
if($alias_result = mysql_query($sql_alias, $db)) {
if($alias_row = mysql_fetch_assoc($alias_result)) {
if(empty($content["thisAlias"]['alias_block'])) {
$alias_row['acontent_block'] = $crow['acontent_block'];
}
if(empty($content["thisAlias"]['alias_spaces'])) {
$alias_row['acontent_before'] = $crow['acontent_before'];
$alias_row['acontent_after'] = $crow['acontent_after'];
}
if(empty($content["thisAlias"]['alias_title'])) {
$alias_row['acontent_title'] = $crow['acontent_title'];
$alias_row['acontent_subtitle'] = $crow['acontent_subtitle'];
}
if(empty($content["thisAlias"]['alias_toplink'])) {
$alias_row['acontent_top'] = $crow['acontent_top'];
}
}
mysql_free_result($alias_result);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// add link to edit article content parts / beta_bi // neu
// check for special content parts: those without any owner!
// 8 = articlelink
if($crow["acontent_type"] == 8) {
$exclude = true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// every article content will be rendered into temp var
$CNT_TMP = '';
// each content part will get an anchor
if($crow["acontent_anchor"]) {
$CNT_TMP .= '<a name="#cpid'.$crow["acontent_id"].'" id="cpid'.$crow["acontent_id"].'" class="cpidClass"></a>';
////////////////////////////
// content-table list
$CTAB_TMP .= '<li><a href="#cpid'.$crow["acontent_id"].' ">'.headline($crow["acontent_title"]) .' ›</a></li>';
////////////////////////////
}
// Space before
if($crow["acontent_before"]) {
if(!empty($template_default["article"]["div_spacer"])) {
$CNT_TMP .= '<div style="margin:'.$crow["acontent_before"].'px 0 0 0; padding:0 0 0 0; clear:both;"></div>';
} else {
$CNT_TMP .= "<br>".spacer(1,$crow["acontent_before"]);
}
}
// include content part code section
include("include/inc_front/content/cnt".$crow["acontent_type"].".article.inc.php");
//check if top link should be shown
if($crow["acontent_top"]) {
if($template_default["article"]["top_sign_before"].$template_default["article"]["top_sign_after"]) {
$CNT_TMP .= $template_default["article"]["top_sign_before"];
$CNT_TMP .= '<a href="#top">'.$template_default["article"]["top_sign"].'</a>';
$CNT_TMP .= $template_default["article"]["top_sign_after"];
} else {
$CNT_TMP .= '<br><a href="#top">'.$template_default["article"]["top_sign"].'</a>';
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// add link to edit article content parts / beta_bi // neu
if( ($row["article_uid"] == $_SESSION["wcs_user_id"] || $_SESSION["wcs_user_admin"] || $hasPermission == true) && ( $exclude != true)) {
$CNT_TMP .= "<div ><a style=\"color:#ff0000; background-color:#fff\" href=\"phpwcms.php?do=articles&p=2&s=1&id=".$GLOBALS['content']['article_id']."&aktion=2&id=".$row["article_id"]."&acid=".$crow["acontent_id"]."\" target=\"_blank\">[edit]</a></div>";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Space after
if($crow["acontent_after"]) {
if(!empty($template_default["article"]["div_spacer"])) {
$CNT_TMP .= '<div style="margin:0 0 '.$crow["acontent_after"].'px 0; padding:0 0 0 0; clear:both;"></div>';
} else {
$CNT_TMP .= "<br>".spacer(1,$crow["acontent_after"]);
}
}
// now add rendered content part to right frontend content
// var given by block -> $content['CB'][$crow['acontent_block']]
if($crow['acontent_block'] == '' || $crow['acontent_block'] == 'CONTENT') {
// default content block
//$content["main"] .= $CNT_TMP;
//////////////////////////////////////
// bring all temporary contentparts together
$CNT_TEMP .= $CNT_TMP;
//////////////////////////////////////
} else {
// check if content block var is set
if(!isset($content['CB'][$crow['acontent_block']])) {
$content['CB'][$crow['acontent_block']] = '';
}
$content['CB'][$crow['acontent_block']] .= $CNT_TMP;
}
}
//////////////////////////////////////
// bring table of contentparts and contentparts together
// if no table of contentpart should be created
if ($CTAB_TMP == '<ul id="contTable">') {
$CTAB_TMP = '';
$content["main"] .= $CNT_TEMP;
}
else {
$content["main"] .= $CTAB_TMP .'</ul>' .$CNT_TEMP;
}
//////////////////////////////////////
mysql_free_result($cresult);
}
}
}
if(empty($template_default["article"]["div_spacer"])) {
$content["main"] = str_replace("</table>\n<br>", "</table>\n", $content["main"]);
$content["main"] = str_replace("</table><br>", "</table>", $content["main"]);
$content["main"] = str_replace("</div><br>", "</div>", $content["main"]);
}
?>