[pLog-svn] r4256 - in
plugins/branches/lifetype-1.1/unported/recommended: . locale
templates
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Wed Nov 8 03:16:15 GMT 2006
Author: jondaley
Date: 2006-11-08 03:15:13 +0000 (Wed, 08 Nov 2006)
New Revision: 4256
Added:
plugins/branches/lifetype-1.1/unported/recommended/readme.txt
Modified:
plugins/branches/lifetype-1.1/unported/recommended/locale/locale_en_UK.php
plugins/branches/lifetype-1.1/unported/recommended/pluginrecommended.class.php
plugins/branches/lifetype-1.1/unported/recommended/templates/recommended.template
Log:
updated for 1.1
Modified: plugins/branches/lifetype-1.1/unported/recommended/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.1/unported/recommended/locale/locale_en_UK.php 2006-11-06 20:53:09 UTC (rev 4255)
+++ plugins/branches/lifetype-1.1/unported/recommended/locale/locale_en_UK.php 2006-11-08 03:15:13 UTC (rev 4256)
@@ -4,6 +4,8 @@
$messages["recommended"] = "Recommended Posts";
$messages["recommended_posts"] = "Recommended Post IDs";
+$messages["recommended_posts_help"] = "Enter a space-delimited list of post IDs that you want to display on the Recommended list";
+
$messages["recommended_plugin_enabled"] = "Enable this plugin";
$messages["recommended_plugin"] = "Recommended Posts Plugin";
Modified: plugins/branches/lifetype-1.1/unported/recommended/pluginrecommended.class.php
===================================================================
--- plugins/branches/lifetype-1.1/unported/recommended/pluginrecommended.class.php 2006-11-06 20:53:09 UTC (rev 4255)
+++ plugins/branches/lifetype-1.1/unported/recommended/pluginrecommended.class.php 2006-11-08 03:15:13 UTC (rev 4256)
@@ -1,94 +1,91 @@
<?php
- 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."class/dao/articles.class.php" );
+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."class/dao/articles.class.php" );
/**
* Plugin that offers features to returns the top read posts object of current blog
*/
- class PluginRecommended extends PluginBase
- {
+class PluginRecommended extends PluginBase
+{
- var $prefix;
- var $pluginEnabled;
- var $recommendedPosts;
+ var $prefix;
+ var $pluginEnabled;
+ var $recommendedPosts;
- function PluginRecommended()
- {
- $this->PluginBase();
-
- $this->id = "recommended";
- $this->author = "Jon Daley";
- $this->desc = "This plugin offers a list of recommended articles, selected by the blog owner";
+ function PluginRecommended(){
+ $this->PluginBase();
+
+ $this->id = "recommended";
+ $this->author = "Jon Daley";
+ $this->desc = "This plugin offers a list of recommended articles, selected by the blog owner";
+ $this->prefix = Db::getPrefix();
+
+ $this->locales = Array( "en_UK" );
+ $this->recommendedPosts = Array();
+
+ $this->init();
+ }
- $this->prefix = Db::getPrefix();
-
- $this->locales = Array( "en_UK" );
- $this->recommendedPosts = Array();
-
- $this->init();
- }
-
- function init()
- {
- $this->registerAdminAction( "recommended", "PluginRecommendedConfigAction" );
- $this->registerAdminAction( "updateRecommendedConfig",
- "PluginRecommendedUpdateConfigAction" );
-
- $menu =& Menu::getMenu();
- if( !$menu->entryExists( "/menu/controlCenter/manageTopPlugins" ))
- $this->addMenuEntry( "/menu/controlCenter", "manageTopPlugins", "", "", true, false );
- $this->addMenuEntry( "/menu/controlCenter/manageTopPlugins", "Recommended", "?op=recommended", "" );
- }
-
- function register(){
- $blogSettings = $this->blogInfo->getSettings();
- $this->pluginEnabled = $blogSettings->getValue( "plugin_recommended_enabled" );
- $this->recommendedPosts = $blogSettings->getValue( "plugin_recommended_posts" );
- }
+ function init(){
+ include_once( PLOG_CLASS_PATH."class/template/menu/menu.class.php" );
+ $this->registerAdminAction( "recommended", "PluginRecommendedConfigAction" );
+ $this->registerAdminAction( "updateRecommendedConfig",
+ "PluginRecommendedUpdateConfigAction" );
+
+ $menu =& Menu::getMenu();
+ if( !$menu->entryExists( "/menu/controlCenter/manageTopPlugins" ))
+ $this->addMenuEntry( "/menu/controlCenter", "manageTopPlugins", "", "", true, false);
+ $this->addMenuEntry( "/menu/controlCenter/manageTopPlugins", "Recommended", "?op=recommended", "" );
+ }
+
+ function register(){
+ $blogSettings = $this->blogInfo->getSettings();
+ $this->pluginEnabled = $blogSettings->getValue( "plugin_recommended_enabled" );
+ $this->recommendedPosts = $blogSettings->getValue( "plugin_recommended_posts" );
+ }
- function isEnabled()
- {
- return $this->pluginEnabled;
- }
+ function isEnabled(){
+ return $this->pluginEnabled;
+ }
/**
* Returns the posts object of current blog
*/
- function getPosts()
- {
- if(!$this->recommendedPosts)
- return Array();
-
- $articles = new Articles();
- $blogId = $this->blogInfo->getId();
- $query = "SELECT * FROM ".$this->prefix."articles";
- $query .= " WHERE blog_id = ".$blogId." AND status = 1";
- $count = 0;
- foreach($this->recommendedPosts as $id){
- $count++;
- if($count == 1){
- $query .= " AND id = " . $id;
- }
- else{
- $query .= " OR id = " . $id;
- }
+ function getPosts(){
+ if(!$this->recommendedPosts)
+ return Array();
+
+ $articles = new Articles();
+ $blogId = $this->blogInfo->getId();
+ $query = "SELECT * FROM ".$this->prefix."articles";
+ $query .= " WHERE blog_id = ".$blogId." AND status = 1";
+ $count = 0;
+ foreach($this->recommendedPosts as $id){
+ $count++;
+ if($count == 1){
+ $query .= " AND id = " . $id;
}
- $query .= " ORDER BY num_reads DESC";
-
- $result = $articles->_db->Execute( $query );
-
- if( !$result )
- return false;
-
- $recommended = Array();
- while( $row = $result->FetchRow()) {
- $article = $articles->_fillArticleInformation( $row );
- array_push( $recommended, $article);
- }
-
- return $recommended;
+ else{
+ $query .= " OR id = " . $id;
+ }
}
+ $query .= " ORDER BY num_reads DESC";
+
+ $db =& Db::getDb();
+ $result = $db->Execute( $query );
+
+ if( !$result )
+ return false;
+
+ $recommended = Array();
+ while( $row = $result->FetchRow()) {
+ $article = $articles->mapRow( $row );
+ array_push( $recommended, $article);
+ }
+
+ return $recommended;
}
+}
?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.1/unported/recommended/readme.txt
===================================================================
--- plugins/branches/lifetype-1.1/unported/recommended/readme.txt 2006-11-06 20:53:09 UTC (rev 4255)
+++ plugins/branches/lifetype-1.1/unported/recommended/readme.txt 2006-11-08 03:15:13 UTC (rev 4256)
@@ -0,0 +1,38 @@
+Plugin: Recommended
+Author: Jon Daley
+Release Date: 2006/11/07
+Version: 1.1
+
+This plugin prints the "recommended" posts, as assigned by the blog owner.
+
+You can use:
+1. $recommended->isEnabled() to check the plugin is enabled or not.
+2. $recommended->getPosts() to get the posts set in the control center.
+
+
+Example:
+Add the following code to panel.template
+
+{if $recommended && $recommended->isEnabled()}
+ <div class="sidetitle">{$locale->tr("Recommended")}</div>
+ <div class="side">
+ <div class="sideitem">
+ <ul>
+ {assign var=posts value=$recommended->getPosts()}
+ {foreach from=$posts item=rec_post}
+ <li>
+ <a title="{$rec_post->getText()|truncate:150:"..."|strip_tags|escape}"
+ href="{$url->postLink($rec_post)}">
+ {$rec_post->getTopic()|truncate:32:"..."|strip_tags|escape:"htmlall"}</a>
+ [{$rec_post->getNumReads()}]
+ </li>
+ {/foreach}
+ </ul>
+ </div>
+ </div>
+{/if}
+
+
+TODO:
+ Don't require the post ids in the control center administration, but
+ maybe a drop down list of posts?
Modified: plugins/branches/lifetype-1.1/unported/recommended/templates/recommended.template
===================================================================
--- plugins/branches/lifetype-1.1/unported/recommended/templates/recommended.template 2006-11-06 20:53:09 UTC (rev 4255)
+++ plugins/branches/lifetype-1.1/unported/recommended/templates/recommended.template 2006-11-08 03:15:13 UTC (rev 4256)
@@ -16,7 +16,7 @@
<div class="field">
<label for="recommended">{$locale->tr("label_recommended")}</label>
<span class="required">*</span>
- <div class="formHelp">{$locale->tr("recommended_posts")}</div>
+ <div class="formHelp">{$locale->tr("recommended_posts_help")}</div>
<input class="text" type="text" name="recommendedPosts" id="recommendedPosts"
value="{$recommendedPosts}" width="10" />
</div>
@@ -30,4 +30,4 @@
</div>
</form>
{include file="$admintemplatepath/footernavigation.template"}
-{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
+{include file="$admintemplatepath/footer.template"}
More information about the pLog-svn
mailing list