<?php
 
lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
    
    /*
     * Plugin that return all posts within a category
     */
class PluginGetCategory extends PluginBase
{
	
    function PluginGetCategory($source = ""){
        $this->PluginBase($source);

	    $this->id = "getcategory";
        $this->version = "20070914";
        $this->author = "Jon Daley";
        $this->desc = "This plugin adds the ability to get ".
            "posts given a category name";
    }

    function getArticles($categoryName, $numArticles){
        lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
        lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
        lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
        $categories = new ArticleCategories();
        $mangledName = Textfilter::urlize($categoryName);
        $category = $categories->getCategoryByName($mangledName,
                                                   $this->blogInfo->getId());
        if(!$category){
            print "couldn't find";
            return Array();
        }
        $articles = new Articles();
        $arts = $articles->getBlogArticles( $this->blogInfo->getId(),
                                            -1,
                                            $numArticles,
                                            $category->getId());
           
        return $arts;
    }
}
        
        
?>
