<?php
/**
 * pragmaMx  Content Management System
 * Copyright (c) 2005 pragmaMx Dev Team - http://pragmaMx.org
 * 
 * This program 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.
 * 
 * $Source: /home/www/dps3311/home/cvsroot/pragmamx/html/themes/mx-rainbow/theme.php,v $
 * $Revision: 1.1.4.3 $
 * $Author: tora60 $
 * $Date: 2006/12/17 09:01:39 $
 */

if (!defined("mxMainFileLoaded")) die ("You can't access this file directly...");

/**
 * alles beginnt, mit dem include der mx_themes.php am Ende dieser Datei
 */

/**
 * in $newheader ist der gesamte angepasste header enthalten
 */
function theme_header($newheader)
{
    global $theme_template; 
    // / die Javascript-Datei von Overlib, falls vorhanden, einbinden
    if (class_exists('Overlib')) {
        $newheader .= "<!-- overLIB (c) Erik Bosrup, http://www.bosrup.com -->\n<script language=\"javascript\" src=\"includes/javascript/overlib.js\" type=\"text/javascript\"></script>\n<script language=\"javascript\" src=\"includes/javascript/overlib_hideform.js\" type=\"text/javascript\"></script>\n";
    } 
    // / den body-Tag hinter head-Ende setzen
    $newheader .= "\n</head>\n\n" . $theme_template['body_tag'] . "\n\n"; 
    // / den fuer die Overlib-Funktionen gebrauchten div-layer direkt nach den Bodytag setzen
    if (class_exists('Overlib')) {
        $newheader .= "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index: 1200; background: transparent;\"></div>\n";
        // / verhindern, dass die Funktion printOverlibDiv() nochmal verwendet wird
        if (!defined("_Overlib_Div")) {
            define("_Overlib_Div", 1);
        } 
    } 
    // / ersetzen von eigenen Theme-Elementen, kann veraendert und ergaenzt werden
    // / diese Teile werden vor der Ausgabe des headers im Headbereich ersetzt
    if (function_exists('theme_replace_header')) {
        $newheader = theme_replace_header($newheader);
    } 
    return $newheader;
} 

/**
 * info
 */
function themesidebox($title, $content, $block = array(), $noecho = 0)
{
    global $theme_template;
    if (empty($block)) {
        $block['position'] = "l";
    } 
    $out = ($block['position'] == "r") ? $theme_template['block_right'] : $theme_template['block_left'];
    $out = str_replace('{BLOCK_CONTENT}' , $content , $out);
    $out = str_replace('{BLOCK_TITLE}' , $title , $out);
    if ($noecho) {
        return $out;
    } else {
        echo $out;
    } 
} 

/**
 * info
 */
function thememiddlebox($title, $content, $block = array(), $noecho = 0)
{
    global $theme_template;
    if (empty($block)) {
        $block['position'] = "c";
    } 
    $out = ($block['position'] == "d") ? $theme_template['block_center_down'] : $theme_template['block_center_top'];
    $out = str_replace('{BLOCK_CONTENT}' , $content , $out);
    $out = str_replace('{BLOCK_TITLE}' , $title , $out);
    if ($noecho) {
        return $out;
    } else {
        echo $out;
    } 
} 

/**
 * info
 */
function themeindex($x, $x, $x, $x, $x, $x, $x, $x, $x, $x, $x, $x, $story = array())
{ 
    // / $x bedeutet: nicht verwendet, nur zur nuke-Modulkompatibilitaet
    global $theme_template;
    static $viewcounter; 
    // nur eine Spalte zulassen :-)
    $GLOBALS['storyhome_cols'] = 1;
    if (!isset($viewcounter) || ($viewcounter == 2)) $viewcounter = 0;
    $viewcounter++; 
    // mxDebugFuncVars($story);
    $buttons = getThemeIndexButtons($story);
    $story['buttons'] = "<table width='20' border='0' cellspacing='0' cellpadding='0'><tr><td width='1%' valign='top'>" . implode("</td>\n<td width='1%' valign='top'>", $buttons) . "</tr></table>";
    $bmore = ($story['allmorelink']['bodycount']) ? "(" . $story['allmorelink']['bodycount'] . " " . _BYTESMORE . ")" : "";
    $story['readmore'] = (empty($bmore)) ? "" : "<span title='" . $bmore . "'>" . $story['allmorelink']['more'] . "</span>";
    $topicimage_pos = ($viewcounter == 1) ? 'left' : 'right';
    $topicimage = ($GLOBALS['storyhome_cols'] == 1) ? mxCreateImage($GLOBALS['tipath'] . $story['topicimage'], _TOPIC . ": " . $story['topictext'], 0, "align=\"" . $topicimage_pos . "\" style='padding: 5px; padding-bottom: 3px;'") : "";
    $cattitle = (empty($story['cattitle'])) ? "" : " <span style='font-weight: normal;'>(" . $story['allmorelink']['categorie'] . ")</span>";
    $authorinfo = (empty($story['informant']) || $story['informant'] == $GLOBALS['anonymous']) ? getThemeAdminname($story) : " " . $story['allmorelink']['informantlink'] . $story['informant'] . "</a>";
    $story['content'] = "<a href='modules.php?name=News&amp;new_topic=" . $story['topic'] . "'>" . $topicimage . "</a>\n" . $story['hometext'] . "\n";
    $story['infoline'] = ($GLOBALS['storyhome_cols'] == 1) ? _NEWSSUBMITED . " " . $authorinfo . " " . $story['allmorelink']['datetime'] : $story['datetime'];
    $story['title'] = strip_tags($story['title']) . $cattitle; 
    // die oben definierten Variablen in dem passenden templateteil ersetzen
    $artvars = theme_define_content();
    echo theme_replace_vars($theme_template[$artvars['themeindex'][$viewcounter]], $story);
    return;
} 

/**
 * info
 */
function themearticle($x, $x, $x, $x, $x, $x, $x, $x, $x, $story = array())
{ 
    // / $x bedeutet: nicht verwendet, nur zur nuke-Modulkompatibilitaet
    global $theme_template; 
    // mxDebugFuncVars($story);
    // das Topic-Bild
    $topicimage = mxCreateImage($GLOBALS['tipath'] . $story['topicimage'], $story['topictext'], 0, "align='left' style='padding-right: 10px; padding-bottom: 5px;'");
    $notes = (empty($story['notes'])) ? "" : '<div style="font-style: italic;">' . $story['notes'] . '</div>';
    $authorinfo = (empty($story['informant']) || $story['informant'] == $GLOBALS['anonymous']) ? getThemeAdminname($story) : " " . $story['allmorelink']['informantlink'] . $story['informant'] . "</a>";
    $story['infoline'] = ($GLOBALS['storyhome_cols'] == 1) ? _NEWSSUBMITED . " " . $authorinfo . " " . $story['allmorelink']['datetime'] : $story['datetime'];
    $story['title'] = strip_tags($story['title']);
    $story['content'] = "<a href='modules.php?name=News&amp;new_topic=" . $story['topic'] . "'>" . $topicimage . "</a>\n" . $story['hometext'] . "<br>\n" . $story['bodytext'] . $notes; 
    // die oben definierten Variablen in dem passenden templateteil ersetzen
    echo theme_replace_vars($theme_template['themearticle'], $story);
    return;
} 

/**
 * hier geht es los :)
 */

/**
 * spezielle Themefunktionen und Konfigurationseinstellungen
 */
include_once(MX_THEME_DIR . '/functions.php');

/**
 * die themeEngine laden
 */
include_once('includes/mx_themes.php');

/**
 * und das war's auch schon :))
 */