// 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!
*************************************************************************************/
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
//specific functions for the frontend
function spacer($width=1, $height=1) {
//creates a placeholder image (transparent gif)
return '';
}
function headline(& $head, & $subhead, & $layout) {
$c = '';
if($head) {
$c .= $layout["content_head_before"];
$c .= html_specialchars($head);
$c .= $layout["content_head_after"];
}
if($subhead) {
$c .= $layout["content_subhead_before"];
$c .= html_specialchars($subhead);
$c .= $layout["content_subhead_after"];
}
return $c;
}
//defines multimedia plugin specific values for width or height
function plugin_size($mediatype, $player, $width, $height) {
switch($mediatype) {
case 0: //Video
switch($player) {
case 0: //Quicktime
$width = ($width) ? $width : "";
$height = ($height) ? $height+16 : "";
break;
case 1: //RealPlayer
$width = ($width) ? $width : "";
$width = ($height) ? $height+36 : "";
break;
case 2: //MediaPlayer
$width = ($width) ? $width : "";
$width = ($height) ? $height : "";
break;
case 3: //Flash
$width = ($width) ? $width : "";
$width = ($height) ? $height : "";
break;
}
break;
case 1: //Audio
break;
case 2: //Flash
break;
}
}
function must_filled($c) {
//spaceholder for form fields that have to be filled
//with some content or has to be marked or like that
return intval($c) ? '' : '';
}
function add_attribute($baseval, $attribute, $val, $space=" ") {
//to add all relevant attributes that contains
//values to a string maybe a html tag
$attribute = isEmpty(strval($val)) ? '' : $attribute.'="'.$val.'"';
$attribute = ($baseval && !isEmpty($val)) ? $space.$attribute : $attribute;
return $attribute;
}
function add_style_attribute($attribute='', $val='') {
//to add all relevant attributes that contains
//values to a string maybe a html tag
$attribute = isEmpty(strval($val)) ? '' : $attribute.': '.$val.';';
return $attribute;
}
function html_attribute($attribute='', $val='') {
//to return only 1 well formatted attributes and values
return isEmpty(strval($val)) ? '' : $attribute.'="'.$val.'"';
}
function html_height_attribute($val=0) {
//to return only 1 well formatted attributes and values
return (intval($val)) ? ' style="height:'.$val.'px;" ' : '';
}
function get_body_attributes(& $values) {
//return a standard list of standard html body attributes
//based on the pagelayout definitions
$body_class = '';
$link_class = '';
if(is_array($values)) {
if(empty($values["layout_noborder"])) {
$body_class .= add_style_attribute(' margin', '0').LF;
$body_class .= add_style_attribute(' padding-top', empty($values["layout_border_top"]) ? '0' : intval($values["layout_border_top"]) .'px').LF;
$body_class .= add_style_attribute(' padding-bottom', empty($values["layout_border_bottom"]) ? '0' : intval($values["layout_border_bottom"]).'px').LF;
$body_class .= add_style_attribute(' padding-left', empty($values["layout_border_left"]) ? '0' : intval($values["layout_border_left"]) .'px').LF;
$body_class .= add_style_attribute(' padding-right', empty($values["layout_border_right"]) ? '0' : intval($values["layout_border_right"]) .'px').LF;
$body_class .= LF;
}
if(!empty($values["layout_bgcolor"])) {
$body_class .= add_style_attribute(' background-color', $values["layout_bgcolor"]);
$body_class .= LF;
}
if(!empty($values["layout_bgimage"])) {
$body_class .= add_style_attribute(' background-image', 'url('.$values["layout_bgimage"].')');
$body_class .= LF;
}
if(!empty($values["layout_textcolor"])) {
$body_class .= add_style_attribute(' color', $values["layout_textcolor"]);
$body_class .= LF;
}
if(!empty($body_class)) {
$body_class = ' body {'.LF.$body_class.' }'.LF;
}
if(!empty($values["layout_linkcolor"])) {
$link_class .= ' a, a:link, a:active, a:visited, a:hover { color: '.$values["layout_linkcolor"].'; }';
$link_class .= LF;
}
if(!empty($values["layout_vcolor"])) {
$link_class .= ' a:visited { color: '.$values["layout_vcolor"].'; }';
$link_class .= LF;
}
if(!empty($values["layout_acolor"])) {
$link_class .= ' a:active { color: '.$values["layout_acolor"].'; }';
$link_class .= LF;
}
if(!empty($body_class) || !empty($link_class)) {
$body_class = ' '.LF;
}
return $body_class;
}
return '';
}
function align_base_layout($value) {
//to get the alignment of the base layout table
switch($value) {
case 1: $align = "center"; break;
case 2: $align = "right"; break;
default: $align = 0;
}
return ($align) ? ' align="'.$align.'"' : '';
}
function get_colspan($value) {
//returns colspan value back to table row
if(!isset($value["layout_type"])) $value["layout_type"] = 0;
switch($value["layout_type"]) {
case 0: $col=3; break;
case 1: $col=2; break;
case 2: $col=2; break;
case 3: $col=0; break;
default: $col=3;
}
if(!empty($value["layout_leftspace_width"])) $col++;
if(!empty($value["layout_rightspace_width"])) $col++;
return ($col) ? (' colspan="'.$col.'"') : '';
}
function colspan_table_row($val, $block, $colspan="", $rowcontent=" ") {
//creates a new table row for header or footer or such rows
return ($rowcontent) ? "
\n
".$rowcontent."
\n
\n" : '';
}
function get_table_block($val, $content="", $leftblock="", $rightblock="") {
//creates the string with all relevant main block data
//$val = $pagelayout array values
$mainblock = "
\n"; //start row
//if 3column or 2column (with left block)
if($val["layout_type"]==0 || $val["layout_type"]==1) {
$mainblock .= "
".$leftblock."
\n";
}
//if there is a spacer column between left and main block
if($val["layout_leftspace_width"]) {
$mainblock .= "
';
$search[35] = '/\[acronym (.*?)\](.*?)\[\/acronym\]/is';
$replace[35] = '$2';
$search[36] = '/\[ID (.*?)\](.*?)\[\/ID\]/s';
$replace[36] = '$2';
$search[49] = '/\[E{0,1}MAIL\](.*?)\[\/E{0,1}MAIL\]/is';
$replace[49] = '$1';
$string = preg_replace($search, $replace, $string);
$string = str_replace(
array(
'\'',
'"',
'-//-'
),
array(
''',
'"',
' '
),
$string
);
return $string;
}
function include_ext_php($inc_file, $t=0) {
// includes an external PHP script file and returns
// the result as string from buffered include content
//check if this is a local file
if(!$t && is_file($inc_file)) {
$this_path = str_replace("\\", '/', dirname(realpath($inc_file)));
$this_path = preg_replace('/\/$/', '', $this_path);
$root_path = str_replace("\\", '/', realpath(PHPWCMS_ROOT));
$root_path = preg_replace('/\/$/', '', $root_path);
if(strpos($this_path, $root_path) === 0) $t = 1;
} elseif(!$t && !empty($GLOBALS['phpwcms']['allow_remote_URL'])) {
//if remote URL is allowed in conf.inc.php
$t = 1;
}
if(!$t) {
return '';
}
ob_start();
@include($inc_file);
return ob_get_clean();;
}
function international_date_format($language="EN", $format="Y/m/d", $date_now=0) {
// formats the given date
// for the specific language
// use the normal date format options
if(!$format) {
$format = "Y/m/d";
}
if(!intval($date_now)) {
$date_now = time();
}
if($language == "EN" || !$language) {
return date($format, $date_now);
} else {
$lang_include = PHPWCMS_ROOT.'/include/inc_lang/date/'.substr(strtolower($language), 0, 2).'.date.lang.php';
if(is_file($lang_include)) {
include($lang_include);
$date_format_function = array ( "a" => 1, "A" => 1, "B" => 1, "d" => 1, "g" => 1, "G" => 1,
"h" => 1, "H" => 1, "i" => 1, "I" => 1, "j" => 1, "m" => 1,
"n" => 1, "s" => 1, "t" => 1, "T" => 1, "U" => 1, "w" => 1,
"Y" => 1, "y" => 1, "z" => 1, "Z" => 1,
"D" => 0, "F" => 0, "l" => 0, "M" => 0, "S" => 0
);
$str_length = strlen($format); $date = "";
for($i = 0; $i < $str_length; $i++) $date_format[$i] = substr($format, $i, 1);
foreach($date_format as $key => $value) {
if(isset($date_format_function[$value])) {
if($date_format_function[$value]) {
$date .= date($value, $date_now);
} else{
switch($value) {
case "D": $date .= $weekday_short[ intval(date("w", $date_now)) ]; break; //short weekday name
case "l": $date .= $weekday_long[ intval(date("w", $date_now)) ]; break; //long weekday name
case "F": $date .= $month_long[ intval(date("n", $date_now)) ]; break; //long month name
case "M": $date .= $month_short[ intval(date("n", $date_now)) ]; break; //long month name
case "S": $date .= ""; break;
}
}
} else {
$date .= $value;
}
}
} else {
$date = date($format, $date_now);
}
}
return $date;
}
function get_random_image_tag($path) {
// returns an random image from the give path
// it looks for image of following type: gif, jpg, jpeg, png
// {RANDOM:path} willl return
// {RANDOM:SRC:path} willl return absolute URI PHPWCMS_URL/path/rand_image
$imgArray = array();
$path = trim($path);
if(strtoupper(substr($path, 0, 4)) == 'SRC:') {
$tag = false;
$path = trim(substr($path, 4));
} else {
$tag = true;
}
$path = trim($path, '/');
$imgpath = PHPWCMS_ROOT . '/' . $path . '/';
$imageinfo = false;
if(is_dir($imgpath)) {
$handle = opendir( $imgpath );
while($file = readdir( $handle )) {
if( $file{0} != '.' && preg_match('/(\.jpg|\.jpeg|\.gif|\.png)$/i', $file)) {
$imgArray[] = $file;
}
}
closedir( $handle );
}
if(count($imgArray) && ($imageinfo = is_random_image($imgArray, $imgpath))) {
if($tag) {
return ' $value) {
if( _getStructureLevelDisplayStatus($key, $struct_id) ) {
$level_entry[$key] = $value;
}
}
}
return $level_entry;
}
function get_active_categories($struct, $act_struct_id) {
// returns an array with all active categories/structure levels
$which_cat_array = array();
$which_category = $act_struct_id;
while($which_category) {
$which_cat_array[$which_category] = 1;
$which_category = $GLOBALS['content']["struct"][$which_category]["acat_struct"];
}
return $which_cat_array;
}
function css_level_list(&$struct, $struct_path, $level, $parent_level_name='', $parent_level=1, $class='') {
// returns list
of the current structure level
// if $parent_level=1 the first list entry will be the parent level
// $parent_level=0 - only the list of all levels in this structure
// if $parent_leve_name != "" then it uses the given string
// predefined class for this menu is "list_level"
if(!trim($class)) {
$class = 'list_level';
}
$parent_level_name = trim($parent_level_name);
$level = intval($level);
$parent_level = intval($parent_level);
$activated = 0;
$css_list = '';
//returns the complete level of NON hidden categories
$level_struct = return_struct_level($struct, $level);
$breadcrumb = get_breadcrumb(key($struct_path), $struct);
foreach($level_struct as $key => $value) {
if(!$level_struct[$key]["acat_redirect"]) {
$link = 'index.php?';
if($level_struct[$key]["acat_alias"]) {
$link .= html_specialchars($level_struct[$key]["acat_alias"]);
} else {
$link .= 'id='.$key;
}
$redirect['target'] = '';
} else {
$redirect = get_redirect_link($level_struct[$key]["acat_redirect"], ' ', '');
$link = $redirect['link'];
}
$css_list .= '