<?php

// -- plugin manager stuff
include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );

// for the public side action
include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );

// for the admin side action
include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
include_once( PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );

// plugin self inclusions
include_once( PLOG_CLASS_PATH."plugins/currentlyaddictedto/class/dao/cat_item.class.php" );
foreach (glob(PLOG_CLASS_PATH . "/plugins/currentlyaddictedto/class/dao/cat_*.php") as $filename) {
    include_once($filename);
}
    
class PluginCurrentlyaddictedto extends PluginBase  {
    var $s;

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

        $this->desc    = "Currentlyaddictedto plugin: tell me more about you";
        $this->author  = "Palantir (radar@netpalantir.it)";
        $this->id      = "Currentlyaddictedto";
        $this->locales = Array();

        $this->registerAdminAction("Currentlyaddictedto", "PluginCurrentlyaddictedtoAction" );
        $this->registerAdminAction("CurrentlyaddictedtoSelect", "PluginCurrentlyaddictedtoSelectAction" );
        //$this->registerAdminAction("modifyCATItem", "PluginCurrentlyaddictedtoAction" );
        //$this->registerAdminAction( "deleteCATItem", "PluginCurrentlyaddictedtoUpdateConfigAction" );
        //$this->registerAdminAction( "deleteShouts", "PluginCurrentlyaddictedtoDeleteShoutsAction" );
        //$this->registerAdminAction( "setupCurrentlyaddictedto", "PluginCurrentlyaddictedtoSetupAction" );
        
        $this->addMenuEntry( "/menu/controlCenter/manageSettings", "CAT", "?op=CurrentlyaddictedtoSelect", "" );
    }

    function getItems() {
        foreach (glob(PLOG_CLASS_PATH . "/plugins/currentlyaddictedto/class/dao/cat_*.php") as $filename) {
            if(ereg('cat\_([a-zA-Z]+)\.class\.php', basename($filename), $regs)) {
                $className = $regs[1];
                if($className != 'item') {
                    $className = $regs[1];
                    $if = new CAT_ItemsFetcher($this->blogInfo->getId(),
                                               $this->blogSettings);
                    $items[$className] = $if->getItems('CAT_' . ucfirst($className), true);
                }
            }
        }
        return $items;
    }

    function getItemsByCategory($className) {
        $if = new CAT_ItemsFetcher($this->blogInfo->getId(), $this->blogSettings);
        $items = $if->getItems('CAT_' . ucfirst($className), true);
        return $items;
    }

    function getBanner($className) {
        eval ('$tmp = new ' . 'CAT_' . ucfirst($className) . "();");
        return $tmp->getBanner();
    }

    function getEmptyMessage($className) {
        eval ('$tmp = new ' . 'CAT_' . ucfirst($className) . "();");
        return $tmp->getEmptyMessage();
    }

    function process( $eventType, $params )
    {			
        // return the content as it came, as the caller class probably expected us to do
        // something with it...
        return $params;
    }
}