<?php
/*
Plugin - PlogHaiku
Copyright (C) 2005 Darren Greer

This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

*/

    include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
    include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
    include_once(PLOG_CLASS_PATH."plugins/ploghaiku/class/dao/ploghaikudao.class.php");
    include_once(PLOG_CLASS_PATH."class/config/config.class.php");

    /**
     * Implementation of a very simple haiku plugin
     */
    class PluginPlogHaiku extends PluginBase {

	var $_pluginEnabled = 1;

        function PluginPlogHaiku()
        {
            $this->PluginBase();

            $this->id = "ploghaiku";
            $this->author = "Darren Greer";
            $this->locale = Array();
            $this->desc = "
            This plugin will generate a random Haiku<br/>
        <br/>
        Usage (Place these somewhere in your favorite template:<br/>
            &nbsp;&nbsp;To Display The Haiku:
            &nbsp;&nbsp;{\$PlogHaiku->getHaiku()}<br/>
            &nbsp;&nbsp;To Display The Possible Permutations:
            &nbsp;&nbsp;{\$PlogHaiku->getHaikuPermutations()}<br/>
            &nbsp;&nbsp;To Display Haiku Status:
            &nbsp;&nbsp;{\$PlogHaiku->getHaikuStats()}<br/>
        ";

	    $this->init();
        }

	function init()
	{
	    /* Add Haiku Template Page */
	    $this->registerAdminAction("manageHaikuView", "ManageHaikuViewAction");

	    /* Add the Haiku */
	    $this->registerAdminAction("initializeHaiku", "InitializeHaikuAction");
	    $this->registerAdminAction("addHaiku", "AddHaikuAction");
	    $this->registerAdminAction("deleteHaiku", "DeleteHaikuAction");

	    $menu =& Menu::getMenu();

            if(!$menu->entryExists( "/menu/Manage/PlogHaiku"))
	    	/* setup the admin interface information */
	    	$this->addMenuEntry("/menu/Manage","PlogHaiku","","",true,false);
        
            $this->addMenuEntry("/menu/Manage/PlogHaiku", "InitializeHaiku", "?op=initializeHaiku", "");
            $this->addMenuEntry("/menu/Manage/PlogHaiku", "ManageHaiku", "?op=manageHaikuView", "");

	}

	function register()
	{
	    $blogSettings = $this->blogInfo->getSettings();
	}

	function isEnabled()
	{
	    return $this->_pluginEnabled;
	}

        function getHaiku()
        {
	    $haikuDao = new PlogHaikuDao();
	    $haiku = $haikuDao->getHaiku($this->blogInfo->getId());
	    if (!$haiku) /*If not haiku exists*/
		return false;

	    return $haiku; /*no errors*/
        }

        function getHaikuStats()
        {
	    $haikuDao = new PlogHaikuDao();
	    $haikuStats = $haikuDao->getHaikuStats($this->blogInfo->getId());
	    if (!$haikuStats) /*If not haiku stats exists*/
		return false;

	    return $haikuStats; /*no errors*/
        }

        function getHaikuPermutations()
        {
	    $haikuDao = new PlogHaikuDao();
	    $haikuPermutations = $haikuDao->getHaikuPermutations($this->blogInfo->getId());
	    if (!$haikuPermutations) /*If not haiku permutations exists*/
		return false;

	    return $haikuPermutations; /*no errors*/
        }

    }

?>
