[pLog-svn] r5930 - in plugins/branches/lifetype-1.2: . getcategory navmenu sortedlinks
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Fri Sep 14 15:55:40 EDT 2007
Author: jondaley
Date: 2007-09-14 15:55:40 -0400 (Fri, 14 Sep 2007)
New Revision: 5930
Added:
plugins/branches/lifetype-1.2/getcategory/
plugins/branches/lifetype-1.2/getcategory/README.txt
plugins/branches/lifetype-1.2/getcategory/plugingetcategory.class.php
plugins/branches/lifetype-1.2/navmenu/
plugins/branches/lifetype-1.2/navmenu/README.txt
plugins/branches/lifetype-1.2/navmenu/pluginnavmenu.class.php
plugins/branches/lifetype-1.2/sortedlinks/
plugins/branches/lifetype-1.2/sortedlinks/README.txt
plugins/branches/lifetype-1.2/sortedlinks/pluginsortedlinks.class.php
Log:
various CMS-type plugins. Perhaps others will find them useful as well
Added: plugins/branches/lifetype-1.2/getcategory/README.txt
===================================================================
--- plugins/branches/lifetype-1.2/getcategory/README.txt (rev 0)
+++ plugins/branches/lifetype-1.2/getcategory/README.txt 2007-09-14 19:55:40 UTC (rev 5930)
@@ -0,0 +1,26 @@
+Get Category plugin for LifeType.
+Author: Jon Daley
+URL: http://limedaley.com/
+
+This plugin will retrieve any number of articles given a category
+name, perhaps useful for sticky posts, etc.
+
+Example template code:
+
+{if $getcategory}
+ <div id="Press">
+ <h2><a href="/category/press-releases">Press Releases</a></h2>
+ {assign var="pressarticles"
+ value=$getcategory->getArticles("Press Releases", 3)}
+ {foreach from=$pressarticles item=pa}
+ <p>
+ {assign var="postTitle" value=$pa->getTopic()}
+ {assign var="permLink" value=$url->postPermalink($pa)}
+ {if $postTitle != "Press and Analyst Contacts"}
+ <a href="{$permLink}">{$postTitle}</a><br/>
+ {$pa->getText()|strip_tags|truncate:300:" ...":false}
+ {/if}
+ </p>
+ {/foreach}
+ </div>
+{/if}
Added: plugins/branches/lifetype-1.2/getcategory/plugingetcategory.class.php
===================================================================
--- plugins/branches/lifetype-1.2/getcategory/plugingetcategory.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/getcategory/plugingetcategory.class.php 2007-09-14 19:55:40 UTC (rev 5930)
@@ -0,0 +1,44 @@
+<?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;
+ }
+}
+
+
+?>
Added: plugins/branches/lifetype-1.2/navmenu/README.txt
===================================================================
--- plugins/branches/lifetype-1.2/navmenu/README.txt (rev 0)
+++ plugins/branches/lifetype-1.2/navmenu/README.txt 2007-09-14 19:55:40 UTC (rev 5930)
@@ -0,0 +1,31 @@
+SortedLinks plugin for LifeType.
+Author: Jon Daley
+URL: http://limedaley.com/
+
+This plugin lets you put a bunch of links in a category
+and then print them out sorted and with html in between each link.
+
+Only one function:
+printHtml(CategoryName, SortSeparator, HTML)
+
+CategoryName is the category name of the links you want to print
+SortSeparator is the hacky way to order the links the way you want.
+HTML is the stuff you want printed in between each link.
+
+
+Example template code:
+<div id="Bottommenu">
+ {if $sortedlinks}
+ {$sortedlinks->printHtml("Footer", "_", " | ")}
+ {/if}
+</div>
+
+
+My links are named:
+1_Home
+3_Pizza
+2_George
+
+
+If you used the above template code, it would print out:
+<a href="/link/to/home">Home</a> | <a href="/link/to/george">George</a> | <a href="/link/to/pizza">Pizza</a>
Added: plugins/branches/lifetype-1.2/navmenu/pluginnavmenu.class.php
===================================================================
--- plugins/branches/lifetype-1.2/navmenu/pluginnavmenu.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/navmenu/pluginnavmenu.class.php 2007-09-14 19:55:40 UTC (rev 5930)
@@ -0,0 +1,120 @@
+<?php
+
+lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+
+
+
+ /*
+ * Plugin that offers features to return links within a
+ * given link category with extra html in between each link
+ */
+class PluginNavMenu extends PluginBase
+{
+ // TODO: grab the posts dynamically - maybe use a custom field to
+ // determine whether the post should be shown on the menu?
+ var $menu = Array("Home" =>
+ Array("LINK" => "/",
+ ),
+
+ "Company" =>
+ Array("LINK" => "/category/company",
+ "Management Team" => "/category/company/management",
+ "Investors" => "/category/company/investors",
+ "Directors" => "/category/company/directors",
+ "Advisory Board" => "/category/company/advisory",
+ "News" => "/category/press-releases",
+ "Careers" => "/category/company/careers",
+ ),
+
+ "Products" =>
+ Array("LINK" => "/category/products",
+ "Key Benefits" => "/category/products/benefits",
+ "Featured Capabilities" => "/category/products/capabilities",
+ ),
+
+ "Partners" =>
+ Array("LINK" => "/category/partners"),
+
+ "Support" =>
+ Array("LINK" => "/category/support",
+ "Support Site Login" => "http://designadvance.com/frame.html",
+ "Software Downloads" => "https://system.netsuite.com/app/center/center.nl?c=453099&sc=7&category=140&ctype=KB",
+ ),
+
+ );
+
+
+ function PluginNavMenu($source = ""){
+ $this->PluginBase($source);
+
+ $this->id = "navmenu";
+ $this->version = "20070904";
+ $this->author = "Jon Daley";
+ $this->desc = "This plugin adds the ability to print out a semi-dynamic menu";
+ }
+
+ function printHtml(){
+ $id=1;
+ $count=0;
+
+ $menu_height = $this->_getMenuHeight($this->menu);
+
+ print "<table><tr><td width='30%'>\n";
+ print "<table>";
+ foreach($this->menu as $key => $value){
+ if(is_array($value)){
+ $count++;
+ print "<tr><td>";
+ print "<a onMouseover='showit(".
+ ((count($value) > 1) ? $id : -1).
+ ")' href='";
+ print $this->_removeSpaces($value["LINK"]);
+ print "'>$key</a>\n";
+ if(count($value) > 1)
+ $this->printJavascript($value, $id, $menu_height);
+ print "</td></tr>\n";
+ }
+ $id++;
+ }
+ for($i=$count; $i < $menu_height; $i++)
+ print "<tr><td> </td></tr>";
+ print "</table></td><td width='70%' id='describe' onMouseover='clear_delayhide()' onMouseout='resetit(event)'>".
+ "</td></tr></table>";
+ }
+
+ function printJavascript($arr, $id, $menu_height){
+ print "<script type='text/javascript'>\n";
+ print "submenu[".$id."] = '".
+ "<table>";
+ $count = 0;
+ foreach($arr as $str => $link){
+ if($str != "LINK"){
+ $count++;
+ print "<tr><td><a href=\"$link\">";
+ print $this->_removeSpaces($str);
+ print "</a></td></tr>";
+ }
+ }
+ for($i=$count; $i < $menu_height; $i++)
+ print "<tr><td> </td></tr>";
+ print "</table>';</script>\n";
+ }
+
+ function _removeSpaces($str){
+ $str = str_replace(" ", " ", $str);
+ return $str;
+ }
+
+ function _getMenuHeight($menu){
+ $height = count($menu) - 1;
+ foreach($this->menu as $key => $value){
+ if(is_array($value)){
+ $item_height = count($value);
+ if($item_height > $height)
+ $height = $item_height - 1;
+ }
+ }
+ return $height;
+ }
+}
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/sortedlinks/README.txt
===================================================================
--- plugins/branches/lifetype-1.2/sortedlinks/README.txt (rev 0)
+++ plugins/branches/lifetype-1.2/sortedlinks/README.txt 2007-09-14 19:55:40 UTC (rev 5930)
@@ -0,0 +1,31 @@
+SortedLinks plugin for LifeType.
+Author: Jon Daley
+URL: http://limedaley.com/
+
+This plugin lets you put a bunch of links in a category
+and then print them out sorted and with html in between each link.
+
+Only one function:
+printHtml(CategoryName, SortSeparator, HTML)
+
+CategoryName is the category name of the links you want to print
+SortSeparator is the hacky way to order the links the way you want.
+HTML is the stuff you want printed in between each link.
+
+
+Example template code:
+<div id="Bottommenu">
+ {if $sortedlinks}
+ {$sortedlinks->printHtml("Footer", "_", " | ")}
+ {/if}
+</div>
+
+
+My links are named:
+1_Home
+3_Pizza
+2_George
+
+
+If you used the above template code, it would print out:
+<a href="/link/to/home">Home</a> | <a href="/link/to/george">George</a> | <a href="/link/to/pizza">Pizza</a>
Added: plugins/branches/lifetype-1.2/sortedlinks/pluginsortedlinks.class.php
===================================================================
--- plugins/branches/lifetype-1.2/sortedlinks/pluginsortedlinks.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/sortedlinks/pluginsortedlinks.class.php 2007-09-14 19:55:40 UTC (rev 5930)
@@ -0,0 +1,58 @@
+<?php
+
+lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+
+ /*
+ * Plugin that offers features to return links within a
+ * given link category with extra html in between each link
+ */
+class PluginSortedLinks extends PluginBase
+{
+ function PluginSortedLinks($source = ""){
+ $this->PluginBase($source);
+
+ $this->id = "sortedlinks";
+ $this->version = "20070903";
+ $this->author = "Jon Daley";
+ $this->desc = "This plugin adds the ability to retrieve
+ links from within a category, sorted, and then displayed";
+ }
+
+ function printHtml($categoryName, $sortSeparator, $html){
+ lt_include( PLOG_CLASS_PATH."class/dao/mylinkscategories.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/mylinks.class.php" );
+ $lc = new MyLinksCategories();
+
+ // get the category id for the given category name
+ $categories = $lc->getMyLinksCategories($this->blogInfo->getId(),
+ MYLINKS_CATEGORIES_ALPHABETICAL_ORDER,
+ $categoryName, 1, 1);
+ unset($lc);
+ if(!count($categories)){
+ return "Error - no category found";
+ }
+
+ $myLinks = new MyLinks();
+ $links = $myLinks->getLinks($this->blogInfo->getId(), $categories[0]->getId());
+
+ $sortedLinkNames = Array();
+ $sortedLink = Array();
+ foreach($links as $link){
+ list($key, $value) = explode($sortSeparator, $link->getName(), 2);
+ $sortedLinkNames[$key] = $value;
+ $sortedLinks[$key] = $link->getUrl();
+ }
+ ksort($sortedLinkNames);
+
+ $printed = 0;
+ foreach($sortedLinkNames as $key => $name){
+ if($printed == 0)
+ $printed = 1;
+ else
+ print $html;
+
+ print "<a href='".$sortedLinks[$key]."'>$name</a>";
+ }
+ }
+}
+?>
More information about the pLog-svn
mailing list