<?php

/**
  * BLOG:CMS: PHP/MySQL Personal Content Management System (CMS)
  * http://blogcms.com/
  * ----------------------------------------------------------------
  *
  * Copyright (C) 2003-2005 Radek HULÁN
  * http://hulan.cz/contact/
  *
  * Based on: 
  * ----------------------------------------------------------------
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 
  * Copyright (C) 2002-2003 The Nucleus Group
  *
  * ----------------------------------------------------------------
  * 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.
**/

    include('../../../cfg.php');
    global $manager, $blog, $CONF, $DIR_PLUGINS, $itemid;
	if (!is_dir($DIR_PLUGINS)) die;

	$itemid = intval(getVar('itemid'));
	$res = sql_query('SELECT iblog FROM '.sql_table('item').' WHERE inumber=' . intval($itemid));
	$obj = sql_fetch_object($res);
	$blogid = $obj->iblog;
    $b =& $manager->getBlog($blogid);

	global $Blogname;  
    $Blogname = $b->getName();

    // Get the original plugin again ...
    $plugin =& $manager->getPlugin('NP_Print');

	$extra1 = $plugin->getOption(fontSelector1);
	$extra2 = $plugin->getOption(fontSelector2);
	$extra3 = $plugin->getOption(fontSelector3);
	$extra4 = $plugin->getOption(fontSelector4);
	$extra5 = $plugin->getOption(option2);
	$extra6 = $plugin->getOption(option3);
	$template = $plugin->getOption(option4);
	$extra7 = $plugin->getOption(option5);
	$extra8 = $plugin->getOption(option6);

    dohtmlHead();

    // Here we decide what we do
    $extraQuery = ' and inumber=' . intval($itemid);
    if ($template == "") {$template  = "default";}
    echo "<div class='printitem'>";
    $b->readLogAmount($template, 1, $extraQuery, 0, 1, 0);
    echo "</div>";

    dohtmlEnd();
    
function showError($message, $what) {
    echo "Chyba: <span style='color:red'>\n".$what.$message."</span><br />\n";
}

function dohtmlHead() {
    global $Blogname, $itemid, $CONF, $extra1, $extra2, $extra3, $extra4, $extra5, $extra6, $extra7;
    echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n";
    echo "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='cs' lang='cs'>\n";
    echo "<head>\n";
    echo "<meta http-equiv='Content-Type' content='text/html; charset="._CHARSET."' />\n";
    echo "<title>".$Blogname."</title> \n";
    echo "<base href=\"".$CONF['IndexURL']."\">";
    echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"".$CONF['AdminURL']."plugins/print/print.css\"> \n";
    echo "<link rel=\"stylesheet\" type=\"text/css\" media=\"print\" href=\"".$CONF['AdminURL']."plugins/print/printx.css\"> \n";
    
	if ($extra1 == 'yes') { 
	echo "<script language=\"JavaScript\" src=\"".$CONF['AdminURL']."plugins/print/easydynfont.js\"></script>";
	}

    echo "</head> \n";
    echo "<body";
	if ($extra1 == 'yes') { echo " onload=\"init()\""; } 
	echo "> \n";

	$itemurl = fancyLink($itemid);
	if ($extra7 != '') { include($extra7); }

	echo "<div id=\"menu\">";
	echo "<table width=\"100%\" cellpading=\"0\" cellspacing=\"3\" border=\"0\"><tr>";
	echo "<td align=\"center\">";
	echo "<br /><a href=\"javascript:print()\">".$extra5."</a>";
	echo "<br />".$extra6."<br />";
   
	if ($extra1 == 'yes') { 
	echo "</td></tr><tr><td align=\"center\">";
	echo "<script language=\"JavaScript\">drawform();</script> \n";
	echo "<input type=\"button\" onclick=\"addSize(-10)\" value=\"".$extra3."\" />";
	echo "<input type=\"button\" onclick=\"addSize(10)\" value=\"".$extra4."\" />";
	echo "</form>";
	}

	echo "</td></tr></table></div> \n";

  return 1;
}

function dohtmlEnd() {
	global $extra8, $itemid;
	$itemurl = fancyLink($itemid);
	if ($extra8 != '') { include($extra8); }
	echo "\n</body>\n</html>";
    return 1;
}

?>