[pLog-svn] r7139 - in plugins/branches/lifetype-1.2: . series series/class series/class/action series/class/view series/locale series/templates
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Tue Oct 4 10:19:58 EDT 2011
Author: jondaley
Date: 2011-10-04 10:19:58 -0400 (Tue, 04 Oct 2011)
New Revision: 7139
Added:
plugins/branches/lifetype-1.2/series/
plugins/branches/lifetype-1.2/series/class/
plugins/branches/lifetype-1.2/series/class/action/
plugins/branches/lifetype-1.2/series/class/action/adminseriespluginsettingsaction.class.php
plugins/branches/lifetype-1.2/series/class/action/adminseriespluginupdatesettingsaction.class.php
plugins/branches/lifetype-1.2/series/class/view/
plugins/branches/lifetype-1.2/series/class/view/adminseriespluginsettingsview.class.php
plugins/branches/lifetype-1.2/series/locale/
plugins/branches/lifetype-1.2/series/locale/locale_en_UK.php
plugins/branches/lifetype-1.2/series/pluginseries.class.php
plugins/branches/lifetype-1.2/series/readme.txt
plugins/branches/lifetype-1.2/series/templates/
plugins/branches/lifetype-1.2/series/templates/pluginsettings.template
Log:
new plugin: 'Series', useful for creating sub-titles when one runs a 'series' of posts for a month or whatever
Added: plugins/branches/lifetype-1.2/series/class/action/adminseriespluginsettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/series/class/action/adminseriespluginsettingsaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/series/class/action/adminseriespluginsettingsaction.class.php 2011-10-04 14:19:58 UTC (rev 7139)
@@ -0,0 +1,32 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/series/class/view/adminseriespluginsettingsview.class.php" );
+
+ class AdminSeriesPluginSettingsAction extends AdminAction
+ {
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminSeriesPluginSettingsAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ $this->requirePermission( "manage_plugins" );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ $this->_view = new AdminSeriesPluginSettingsView( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/series/class/action/adminseriespluginupdatesettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/series/class/action/adminseriespluginupdatesettingsaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/series/class/action/adminseriespluginupdatesettingsaction.class.php 2011-10-04 14:19:58 UTC (rev 7139)
@@ -0,0 +1,94 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/series/class/view/adminseriespluginsettingsview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfield.class.php" );
+
+ class AdminSeriesPluginUpdateSettingsAction extends AdminAction
+ {
+
+ var $_pluginEnabled;
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminSeriesPluginUpdateSettingsAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ $this->requirePermission( "manage_plugins" );
+ }
+
+ function validate(){
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+ return true;
+ }
+
+ /**
+ * Updates the custom fields
+ */
+ function _updateFields(){
+ $customFields = new CustomFields();
+ $blogFields = $customFields->getBlogCustomFields( $this->_blogInfo->getId());
+
+ // if the checkbox fields doesn't exist and this plugin is enabled,
+ // create the field
+ if(!array_key_exists("seriesTitle", $blogFields) && $this->_pluginEnabled){
+ $customField = new CustomField("seriesTitle",
+ $this->_locale->tr("plugin_series_title" ),
+ CUSTOM_FIELD_TEXTBOX,
+ $this->_blogInfo->getId(),
+ false,
+ true );
+ $customFields->addCustomField($customField);
+ }
+ else{
+ $protectedField = $blogFields["seriesTitle"];
+ $protectedField->setHidden(!$this->_pluginEnabled);
+ $customFields->updateCustomField($protectedField);
+ }
+
+ return true;
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform(){
+ // update the plugin configurations to blog setting
+ $blogSettings = $this->_blogInfo->getSettings();
+ $blogSettings->setValue( "plugin_series_enabled", $this->_pluginEnabled );
+ $this->_blogInfo->setSettings( $blogSettings );
+
+ // update the settings in the db, and make sure that everything went fine
+ $blogs = new Blogs();
+ if( !$blogs->updateBlog( $this->_blogInfo )) {
+ $this->_view = new AdminSeriesPluginSettingsView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ // check if the fields already exist and if not, create them
+ $this->_updateFields();
+
+ // if everything went ok...
+ $this->_blogInfo->setSettings( $blogSettings );
+ $this->_session->setValue( "blogInfo", $this->_blogInfo );
+ $this->saveSession();
+
+ $this->_view = new AdminSeriesPluginSettingsView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("series_settings_saved_ok"));
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ return true;
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/series/class/view/adminseriespluginsettingsview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/series/class/view/adminseriespluginsettingsview.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/series/class/view/adminseriespluginsettingsview.class.php 2011-10-04 14:19:58 UTC (rev 7139)
@@ -0,0 +1,28 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ /**
+ * implements the main view of the series plugin
+ */
+ class AdminSeriesPluginSettingsView extends AdminPluginTemplatedView
+ {
+
+ function AdminSeriesPluginSettingsView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "series", "pluginsettings" );
+ }
+
+ function render()
+ {
+ // load some configuration settings
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_series_enabled" );
+
+ // create a view and export the settings to the template
+ $this->setValue( "pluginEnabled", $pluginEnabled );
+
+ parent::render();
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/series/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/series/locale/locale_en_UK.php (rev 0)
+++ plugins/branches/lifetype-1.2/series/locale/locale_en_UK.php 2011-10-04 14:19:58 UTC (rev 7139)
@@ -0,0 +1,9 @@
+<?php
+$messages["seriesPluginSettings"] = "Blog Series";
+
+$messages["series_plugin_enabled"] = "Enable this plugin";
+$messages["series_plugin"] = "Series Plugin";
+
+$messages["plugin_series_title"] = "Title for this blog series";
+
+$messages["series_settings_saved_ok"] = "Series settings saved successfully!";
Added: plugins/branches/lifetype-1.2/series/pluginseries.class.php
===================================================================
--- plugins/branches/lifetype-1.2/series/pluginseries.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/series/pluginseries.class.php 2011-10-04 14:19:58 UTC (rev 7139)
@@ -0,0 +1,52 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+
+ /**
+ * allows users to group blog posts into 'series', with a separate headline, rather than
+ * having to use the title field or creating a new category for a temporary series
+ */
+ class PluginSeries extends PluginBase
+ {
+ function PluginSeries($source = ""){
+ $this->PluginBase($source);
+
+ $this->id = "series";
+ $this->desc = "Allows groups of blog posts to be grouped into a series, with a separate headline";
+ $this->author = "Jon Daley";
+ $this->version = "20111004";
+
+ if( $source == "admin" )
+ $this->initAdmin();
+
+ }
+
+ /**
+ * registers all the filters and actions that we're going to
+ * use on the admin side
+ */
+ function initAdmin(){
+ $this->registerAdminAction( "seriesPluginSettings", "AdminSeriesPluginSettingsAction" );
+ $this->registerAdminAction( "pluginSeriesUpdateSettings", "AdminSeriesPluginUpdateSettingsAction" );
+
+ $this->addMenuEntry( "/menu/Manage/managePosts", "seriesPluginSettings", "admin.php?op=seriesPluginSettings", "", true, false );
+ }
+
+
+ function register(){
+ $blogSettings = $this->blogInfo->getSettings();
+ $this->pluginEnabled = $blogSettings->getValue( "plugin_series_enabled" );
+ }
+
+ function isEnabled(){
+ return $this->pluginEnabled;
+ }
+
+ function getPluginConfigurationKeys(){
+
+ return (Array(
+ Array("name" => "plugin_series_enabled",
+ "type" => "boolean"),
+ ));
+ }
+ }
Added: plugins/branches/lifetype-1.2/series/readme.txt
===================================================================
--- plugins/branches/lifetype-1.2/series/readme.txt (rev 0)
+++ plugins/branches/lifetype-1.2/series/readme.txt 2011-10-04 14:19:58 UTC (rev 7139)
@@ -0,0 +1,17 @@
+Plugin: Series
+Author: Jon Daley
+Release Date: 2011/10/03
+Version: 1.0
+
+This plugin offers the ability to group posts into a series. For
+example, you might run a series of blog posts for a month and then
+never used that series again, so you don't want to create a separate
+category for just that month.
+
+Install:
+1. Copy the files to the plugins directory.
+2. Install the plugin by going to the Plugin Center in the Administration section.
+3. Configure and enable the plugin under the Post Management section.
+4. Use something like the following example in your template to display the series title:
+ {if $post->getField("seriesTitle")}Series: {$post->getField("seriesTitle")}{/if}
+
Added: plugins/branches/lifetype-1.2/series/templates/pluginsettings.template
===================================================================
--- plugins/branches/lifetype-1.2/series/templates/pluginsettings.template (rev 0)
+++ plugins/branches/lifetype-1.2/series/templates/pluginsettings.template 2011-10-04 14:19:58 UTC (rev 7139)
@@ -0,0 +1,28 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=seriesPluginSettings title=$locale->tr("series_plugin")}
+<form name="pluginSeriesSettings" action="admin.php" method="post">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_configuration")}</legend>
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <div class="field">
+ <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+ <span class="required"></span>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if}
+ {user_cannot_override
+ key=plugin_series_enabled}disabled="disabled"
+ {/user_cannot_override}
+ value="1" />{$locale->tr("series_plugin_enabled")}
+ </div>
+ </div>
+ </fieldset>
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="pluginSeriesUpdateSettings" />
+ <input type="reset" name="{$locale->tr("reset")}" />
+ <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}" />
+ </div>
+</form>
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
More information about the pLog-svn
mailing list