';
}
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 = '';
$onload_js = '';
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($values["layout_jsonload"])) {
$onload_js = ' '.LF;
}
if(!empty($body_class) || !empty($link_class)) {
$body_class = ' '.LF;
}
return $onload_js.$body_class;
}
}
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[49] = '/\[E{0,1}MAIL\](.*?)\[\/E{0,1}MAIL\]/is';
$replace[49] = '$1';
$string = preg_replace($search, $replace, $string);
$string = str_replace('\'', ''', $string);
$string = str_replace('"', '"', $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
$ext_php_content = '';
//check if this is a local file
if(is_file($inc_file) && !$t) {
$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) {
ob_start();
@include($inc_file);
$ext_php_content = ob_get_contents();
ob_end_clean();
}
return $ext_php_content;
}
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 ' better tests for image info
$imageinfo = @getimagesize($file);
//if $imageinfo is not true repeat function and count smaller count all images
if(!$imageinfo && $count < count($imgArray)) {
$imageinfo = is_random_image($imgArray, $imagepath, $count);
} else {
$imageinfo["imagename"] = $imgArray[ $randval ];
}
return $imageinfo;
}
function return_struct_level(&$struct, $struct_id) {
// walk through the given struct level and returns an array with available levels
$level_entry = array();
if(is_array($struct)) {
foreach($struct as $key => $value) {
if( _getStructureLevelDisplayStatus($key, $struct_id) ) {
//if($key && $struct[$key]["acat_struct"] == $struct_id && (!$struct[$key]['acat_hidden'] || ($struct[$key]["acat_hidden"] == 2 && isset($GLOBALS['LEVEL_KEY'][$key])))) {
$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; //',0,0,1,0,0';
}
$redirect['target'] = '';
} else {
$redirect = get_redirect_link($level_struct[$key]["acat_redirect"], ' ', '');
$link = $redirect['link'];
}
$css_list .= '
'.LF; // remove $li_ul from this line of code if $ie_patch is used
$x++;
}
}
// also check if $parent
if($li || ($parent && isset($GLOBALS['content']['struct'][$start_id]))) {
switch($wrap_ul_div) {
case 1: $ul = LF.$TAB.'