<? 
/** 
* This plugin can be used to display archives in any timeframe specified through the plugin options 
*/ 
class NP_ArchiveExtras extends NucleusPlugin { 
function getEventList() { return array(); } 
function getName() { return 'ArchiveExtras'; } 
function getAuthor() { return 'Trent Adams'; } 
function getURL() { return 'http://www.onvertigo.com/'; } 
function getVersion() { return '3.0'; }
function install() { 
$this->createOption('FancyUrls','Fancy URLS: 0 is off and 1 is on','text','0');
$this->createOption('ShowDateCategory','Show Date & Category: 0 is off and 1 is on','text','1');
$this->createOption('SortOrder','Sorting Options: itime DESC (time order descending), itime ASC (time order ascending), ititle DESC (title order descending), ititle ASC (title order ascending)','text','itime DESC');}  
function getDescription() { 
return 'This plugin can be used to display a list of articles in the timeframe set in the use of the plugin parameters.  Usage is <%ArchiveExtras(1000,2003,06,01,2003,07,01)%> for up to a 1000 entries from June 1st, 2003 to June 30th, 2003.  Version 3.0 has the ability to show the date before the item link and the category after the link.  Also sort options and Fancy URL on or off in plugin options.'; 
} 
 
 
function doSkinVar($skinType) { 
   global $manager, $blog, $CONF; 
   $params = func_get_args(); 
   $b =& $blog;
 
   if ($params[1]){                        
                        $numberOfPosts = $params[1]; 
        } 
        else { $numberOfPosts = 25;}  
 
 
   if ($params[2]){                        
                        $startyear = $params[2]; 
        } 
        else { $startyear = "need start year,";}  
 
   if ($params[3]){                        
                        $startmonth = $params[3]; 
        } 
        else { $startmonth = "need start month,";}  
 
   if ($params[4]){                        
                        $startday = $params[4]; 
        } 
        else { $startday = "need start day,";}  
 
   if ($params[5]){                        
                        $finishyear = $params[5]; 
        } 
        else { $finishyear = "need finsh year,";} 
 
   if ($params[6]){                        
                        $finishmonth = $params[6]; 
        } 
        else { $finishmonth = "need finish month,";}  
 
   if ($params[7]){                        
                        $finishday = $params[7]; 
        } 
        else { $finishday = "need finish day,";} 
 
 
$timestart = mktime (0,0,0,$startmonth,$startday,$startyear);
$timefinish = mktime (0,0,0,$finishmonth,$finishday,$finishyear);
 
$FancyURLs = $this->getOption(FancyUrls);
$ShowDateCategory = $this->getOption(ShowDateCategory);   
        if ($blog)
            $b =& $blog;
        else
            $b =& $manager->getBlog($CONF['DefaultBlog']);
 $sortorder = $this->getOption(SortOrder);
 
        // select
 
        $query = "SELECT i.inumber as itemid, i.icat, i.ititle as title, UNIX_TIMESTAMP(i.itime) as timestamp, c.catid, c.cname as catname "
               . " FROM nucleus_item as i, nucleus_category as c, nucleus_blog as b "
               . " WHERE i.iblog= ".$b->blogid
               . " and i.iblog = b.bnumber " 
               . " and c.catid = i.icat "
               . " and i.idraft=0 " // exclude drafts
               . " and i.itime>= " . mysqldate($timestart)
               . " and i.itime< " . mysqldate($timefinish)
               . " ORDER by $sortorder LIMIT  0,".$numberOfPosts;
 
        $entries = sql_query($query);
        $count = 0;
        while ($row = mysql_fetch_assoc ($entries)){
            $itemlink = createItemLink($row['itemid'],'');
            $timestamp = date('M-d',$row['timestamp']);
            $catlink = createCategoryLink($row['catid'],'');
            if ( $FancyURLs ) {
 
			if ( $ShowDateCategory )
 
				if ( $row['title'] )
                			echo "$timestamp"." - "."<a href=\"".$itemlink."\">".$row['title']."</a>"." - "."["."<a href=\"".$catlink."\">".$row['catname']."</a>"."]";
                 		else echo "$timestamp"." - "."<a href=\"".$itemlink."\">"."Untitled"."</a>"." - "."["."<a href=\"".$catlink."\">".$row['catname']."</a>"."]";
 
				else
 
				if ( $row['title'] )
                			echo "<a href=\"".$itemlink."\">".$row['title']."</a>";
                 		else echo "<a href=\"".$itemlink."\">"."Untitled"."</a>";
 
		} else {
 
			if ( $ShowDateCategory )
 
                		if ( $row['title'] )
                			echo "$timestamp"." - "."<a href=\"".$b->getURL().$itemlink."\">".$row['title']."</a>"." - "."["."<a href=\"".$b->getURL()."/".$catlink."\">".$row['catname']."</a>"."]";
                		else echo "$timestamp"." - "."<a href=\"".$b->getURL()."/".$itemlink."\">"."Untitled"."</a>"." - "."["."<a href=\"".$b->getURL()."/".$catlink."\">".$row['catname']."</a>"."]";
 
				else
 
				if ( $row['title'] )
                			echo "<a href=\"".$b->getURL().$itemlink."\">".$row['title']."</a>";
                		else echo "<a href=\"".$b->getURL()."/".$itemlink."\">"."Untitled"."</a>";
 
}
 
            echo "<br />";
        }
 
 
} 
}
?>

:: Back to Archive Extras Plugin ::

archiveextrascode.txt · Last modified: 2007/10/28 14:57 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki