[pLog-svn] r1083 - in plugins/trunk/secret: . class class/action
class/view locale templates
mark at devel.plogworld.net
mark at devel.plogworld.net
Tue Feb 15 12:54:18 GMT 2005
Author: mark
Date: 2005-02-15 12:54:17 +0000 (Tue, 15 Feb 2005)
New Revision: 1083
Added:
plugins/trunk/secret/class/view/
plugins/trunk/secret/class/view/adminsecretpluginsettingsview.class.php
plugins/trunk/secret/locale/locale_zh_TW.php
Modified:
plugins/trunk/secret/class/action/adminsecretpluginsettingsaction.class.php
plugins/trunk/secret/class/action/adminsecretpluginupdatesettingsaction.class.php
plugins/trunk/secret/locale/locale_en_UK.php
plugins/trunk/secret/pluginsecret.class.php
plugins/trunk/secret/templates/pluginsettings.template
Log:
Port the secret post UI to 1.0 with 1.0 UI guide line, But still have no idea how to solve the lost $blogtemplate variable in pluginTemplate().
Modified: plugins/trunk/secret/class/action/adminsecretpluginsettingsaction.class.php
===================================================================
--- plugins/trunk/secret/class/action/adminsecretpluginsettingsaction.class.php 2005-02-15 05:11:10 UTC (rev 1082)
+++ plugins/trunk/secret/class/action/adminsecretpluginsettingsaction.class.php 2005-02-15 12:54:17 UTC (rev 1083)
@@ -1,7 +1,7 @@
<?php
include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/secret/class/view/adminsecretpluginsettingsview.class.php" );
class AdminSecretPluginSettingsAction extends BlogOwnerAdminAction
{
@@ -20,12 +20,11 @@
*/
function perform()
{
- $this->_view = new AdminPluginTemplatedView( $this->_blogInfo, "secret", "pluginsettings" );
- $this->_view->setValue( "pluginEnabled", $this->_blogSettings->getValue( "plugin_secret_enabled" ));
- $this->setCommonData();
-
- // better to return true if everything fine
- return true;
+ $this->_view = new AdminSecretPluginSettingsView( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ return true;
}
}
?>
Modified: plugins/trunk/secret/class/action/adminsecretpluginupdatesettingsaction.class.php
===================================================================
--- plugins/trunk/secret/class/action/adminsecretpluginupdatesettingsaction.class.php 2005-02-15 05:11:10 UTC (rev 1082)
+++ plugins/trunk/secret/class/action/adminsecretpluginupdatesettingsaction.class.php 2005-02-15 12:54:17 UTC (rev 1083)
@@ -1,8 +1,7 @@
<?php
include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/secret/class/view/adminsecretpluginsettingsview.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/customfields/customfield.class.php" );
@@ -23,13 +22,9 @@
function validate()
{
- $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
- if( $this->_pluginEnabled == "" )
- $this->_pluginEnabled = false;
- else
- $this->_pluginEnabled = true;
-
return true;
}
@@ -110,34 +105,40 @@
*/
function perform()
{
+ // update the plugin configurations to blog setting
$blogSettings = $this->_blogInfo->getSettings();
- $blogSettings->setValue( "plugin_secret_enabled", $this->_pluginEnabled );
- $this->_blogInfo->setSettings( $blogSettings );
+ $blogSettings->setValue( "plugin_secret_enabled", $this->_pluginEnabled );
+ $this->_blogInfo->setSettings( $blogSettings );
+
+ // save the blogs settings
$blogs = new Blogs();
+ if( !$blogs->updateBlog( $this->_blogInfo->getId(), $this->_blogInfo )) {
+ $this->_view = new AdminSecretPluginSettingsView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+ $this->setCommonData();
+
+ return false;
+ }
- // update the settings in the db, and make sure that everything went fine
- if( !$blogs->updateBlogSettings( $this->_blogInfo->getId(), $this->_blogInfo->getSettings())) {
- $this->_view = new AdminErrorView( $this->_blogInfo );
- $this->_view->setMessage( "There was an error saving the plugin configuration." );
- $this->setCommonData();
- return false;
- }
-
// check if the fields already exist and if not, create them
if( $this->_pluginEnabled )
$this->_createFields();
else
$this->_updateFields();
- $this->_session->setValue( "blogInfo", $this->_blogInfo );
- $this->saveSession();
-
- $this->_view = new AdminMessageView( $this->_blogInfo );
- $this->_view->setMessage( "Plugin settings saved successfully!" );
- $this->setCommonData();
-
- // better to return true if everything fine
- return true;
+ // if everything went ok...
+ $this->_blogInfo->setSettings( $blogSettings );
+ $this->_session->setValue( "blogInfo", $this->_blogInfo );
+ $this->saveSession();
+
+ $this->_view = new AdminSecretPluginSettingsView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("secret_settings_saved_ok"));
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ return true;
}
}
?>
Added: plugins/trunk/secret/class/view/adminsecretpluginsettingsview.class.php
===================================================================
--- plugins/trunk/secret/class/view/adminsecretpluginsettingsview.class.php 2005-02-15 05:11:10 UTC (rev 1082)
+++ plugins/trunk/secret/class/view/adminsecretpluginsettingsview.class.php 2005-02-15 12:54:17 UTC (rev 1083)
@@ -0,0 +1,28 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ /**
+ * implements the main view of the feed reader plugin
+ */
+ class AdminSecretPluginSettingsView extends AdminPluginTemplatedView
+ {
+
+ function AdminSecretPluginSettingsView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "secret", "pluginsettings" );
+ }
+
+ function render()
+ {
+ // load some configuration settings
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_secret_enabled" );
+
+ // create a view and export the settings to the template
+ $this->setValue( "pluginEnabled", $pluginEnabled );
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Modified: plugins/trunk/secret/locale/locale_en_UK.php
===================================================================
--- plugins/trunk/secret/locale/locale_en_UK.php 2005-02-15 05:11:10 UTC (rev 1082)
+++ plugins/trunk/secret/locale/locale_en_UK.php 2005-02-15 12:54:17 UTC (rev 1083)
@@ -1,3 +1,12 @@
<?php
-$messages["pluginSecretSettings"] = "Secret Posts";
+$messages["manageSecurityPlugins"] = "Security Management";
+$messages["pluginSecretSettings"] = "Secret Post";
+
+$messages["secret_plugin_enabled"] = "Enable this plugin";
+$messages["secret_plugin"] = "Secret Post Plugin";
+
+$messages["secret_settings_saved_ok"] = "Secret Post settings saved successfully!";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
?>
\ No newline at end of file
Added: plugins/trunk/secret/locale/locale_zh_TW.php
===================================================================
--- plugins/trunk/secret/locale/locale_zh_TW.php 2005-02-15 05:11:10 UTC (rev 1082)
+++ plugins/trunk/secret/locale/locale_zh_TW.php 2005-02-15 12:54:17 UTC (rev 1083)
@@ -0,0 +1,12 @@
+<?php
+$messages["manageSecurityPlugins"] = "ç¶²èªå®å
¨ç®¡ç";
+$messages["pluginSecretSettings"] = "ç§å¯æç« è¨å®";
+
+$messages["secret_plugin_enabled"] = "åå夿ç¨å¼";
+$messages["secret_plugin"] = "ç§å¯æç« 夿ç¨å¼";
+
+$messages["secret_settings_saved_ok"] = "ç§å¯æç« è¨å®å²åæåã";
+
+$messages["label_configuration"] = "è¨å®";
+$messages["label_enable"] = "åå";
+?>
\ No newline at end of file
Modified: plugins/trunk/secret/pluginsecret.class.php
===================================================================
--- plugins/trunk/secret/pluginsecret.class.php 2005-02-15 05:11:10 UTC (rev 1082)
+++ plugins/trunk/secret/pluginsecret.class.php 2005-02-15 12:54:17 UTC (rev 1083)
@@ -1,38 +1,44 @@
<?php
- include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
- include_once( PLOG_CLASS_PATH."plugins/secret/class/security/secretitemfilter.class.php" );
-
- /**
- * implements secret posts and categories
- */
- class PluginSecret extends PluginBase
- {
-
- function PluginSecret()
- {
- $this->PluginBase();
-
- $this->id = "secret";
- $this->description = "Implements secret posts and categories";
- $this->locales = Array( "en_UK" );
- $this->author = "The pLog Team";
-
- $this->init();
- }
-
- /**
- * registers all the filters and actions that we're going to use
- */
- function init()
- {
- // we only need to register a filter
- $this->registerFilter( "SecretItemFilter" );
-
- // register our action and menu entry
- $this->registerAdminAction( "pluginSecretSettings", "AdminSecretPluginSettingsAction" );
- $this->registerAdminAction( "pluginSecretUpdateSettings", "AdminSecretPluginUpdateSettingsAction" );
- $this->addMenuEntry( "/menu/controlCenter/manageSettings", "pluginSecretSettings", "admin.php?op=pluginSecretSettings", "", true, false );
- }
- }
+ 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."plugins/secret/class/security/secretitemfilter.class.php" );
+
+ /**
+ * implements secret posts and categories
+ */
+ class PluginSecret extends PluginBase
+ {
+
+ function PluginSecret()
+ {
+ $this->PluginBase();
+
+ $this->id = "secret";
+ $this->description = "This plugin offers the password protect to specific articles, unless user provide the right password or they can not see the articles.";
+ $this->locales = Array( "en_UK", "zh_TW" );
+ $this->author = "The pLog Team";
+
+ $this->init();
+ }
+
+ /**
+ * registers all the filters and actions that we're going to use
+ */
+ function init()
+ {
+ // we only need to register a filter
+ $this->registerFilter( "SecretItemFilter" );
+
+ // register our action and menu entry
+ $this->registerAdminAction( "pluginSecretSettings", "AdminSecretPluginSettingsAction" );
+ $this->registerAdminAction( "pluginSecretUpdateSettings", "AdminSecretPluginUpdateSettingsAction" );
+
+ // register our action and menu entry
+ $menu =& Menu::getMenu();
+ if( !$menu->entryExists( "/menu/controlCenter/manageSecurityPlugins" ))
+ $this->addMenuEntry( "/menu/controlCenter", "manageSecurityPlugins", "", "", true, false );
+ $this->addMenuEntry( "/menu/controlCenter/manageSecurityPlugins", "pluginSecretSettings", "admin.php?op=pluginSecretSettings", "", true, false );
+ }
+ }
?>
\ No newline at end of file
Modified: plugins/trunk/secret/templates/pluginsettings.template
===================================================================
--- plugins/trunk/secret/templates/pluginsettings.template 2005-02-15 05:11:10 UTC (rev 1082)
+++ plugins/trunk/secret/templates/pluginsettings.template 2005-02-15 12:54:17 UTC (rev 1083)
@@ -1,16 +1,24 @@
{include file="$admintemplatepath/header.template"}
-{include file="$admintemplatepath/navigation.template" showOpt=pluginSecretSettings title=$locale->tr("pluginSecretSettings")}
-<p>
- This plugin will allow to set certain posts to "secret", and a password will be required to
- view those. The plugin uses the "custom fields" feature to add two new custom fields to your blog,
- called "password_protected" and "password", so please do not remove those or else the plugin
- will not work properly!
-</p>
+{include file="$admintemplatepath/navigation.template" showOpt=pluginSecretSettings title=$locale->tr("secret_plugin")}
<form name="pluginSecretSettings" action="admin.php" method="post">
- <input type="checkbox" name="pluginEnabled" value="1" {if $pluginEnabled}checked="checked"{/if} />
- Enable this plugin.<br/><br/>
- <input type="hidden" name="op" value="pluginSecretUpdateSettings" />
- <input type="submit" name="{$locale->tr("update")}" value="{$locale->tr("update")}" />
+ <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>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("secret_plugin_enabled")}
+ </div>
+ </div>
+
+ </fieldset>
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="pluginSecretUpdateSettings" />
+ <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"}
\ No newline at end of file
More information about the pLog-svn
mailing list