[pLog-svn] r1251 - in plugins/trunk/templateeditor: . class/action
class/view locale templates
mark at devel.plogworld.net
mark at devel.plogworld.net
Mon Feb 28 19:08:19 GMT 2005
Author: mark
Date: 2005-02-28 19:08:19 +0000 (Mon, 28 Feb 2005)
New Revision: 1251
Added:
plugins/trunk/templateeditor/class/action/plugintemplateeditorconfigaction.class.php
plugins/trunk/templateeditor/class/action/plugintemplateeditorupdateconfigaction.class.php
plugins/trunk/templateeditor/class/view/plugintemplateeditorconfigview.class.php
plugins/trunk/templateeditor/templates/pluginsettings.template
Modified:
plugins/trunk/templateeditor/locale/locale_en_UK.php
plugins/trunk/templateeditor/locale/locale_zh_TW.php
plugins/trunk/templateeditor/plugintemplateeditor.class.php
Log:
Add a pluginsettings to template editor. The plugin options are global, So I use $config instead of $blogSettings to save the options.
Site owner can enable or diable blog user's template editor.
Added: plugins/trunk/templateeditor/class/action/plugintemplateeditorconfigaction.class.php
===================================================================
--- plugins/trunk/templateeditor/class/action/plugintemplateeditorconfigaction.class.php 2005-02-28 18:14:10 UTC (rev 1250)
+++ plugins/trunk/templateeditor/class/action/plugintemplateeditorconfigaction.class.php 2005-02-28 19:08:19 UTC (rev 1251)
@@ -0,0 +1,26 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/templateeditor/class/view/plugintemplateeditorconfigview.class.php" );
+
+ /**
+ * shows a form with the current configuration
+ */
+ class PluginTemplateEditorConfigAction extends SiteAdminAction
+ {
+
+ function PluginTemplateEditorConfigAction( $actionInfo, $request )
+ {
+ $this->SiteAdminAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ $this->_view = new PluginTemplateEditorConfigView( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/templateeditor/class/action/plugintemplateeditorupdateconfigaction.class.php
===================================================================
--- plugins/trunk/templateeditor/class/action/plugintemplateeditorupdateconfigaction.class.php 2005-02-28 18:14:10 UTC (rev 1250)
+++ plugins/trunk/templateeditor/class/action/plugintemplateeditorupdateconfigaction.class.php 2005-02-28 19:08:19 UTC (rev 1251)
@@ -0,0 +1,64 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/templateeditor/class/view/plugintemplateeditorconfigview.class.php" );
+
+ /**
+ * updates the plugin configuration
+ */
+ class PluginTemplateEditorUpdateConfigAction extends AdminAction
+ {
+ var $_pluginEnabled;
+ var $_maxBackupFiles;
+
+ function PluginTemplateEditorUpdateConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function validate()
+ {
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+ $this->_maxBackupFiles = $this->_request->getValue( "maxBackupFiles" );
+ if( $this->_maxBackupFiles <= 0 || !ctype_digit($this->_maxBackupFiles) ) {
+ $this->_view = new PluginTemplateEditorConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("templateeditor_error_maxbackupfiles"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ return true;
+ }
+
+ function perform()
+ {
+ // // update the plugin configurations to blog setting
+ $config =& Config::getConfig();
+ $config->setValue( "plugin_templateeditor_enabled", $this->_pluginEnabled );
+ $config->setValue( "plugin_templateeditor_maxbackupfiles", $this->_maxBackupFiles );
+
+ if( !$config->save() ) {
+ $this->_view = new PluginTemplateEditorConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ // if everything went ok...
+ $this->_session->setValue( "blogInfo", $this->_blogInfo );
+ $this->saveSession();
+
+ $this->_view = new PluginTemplateEditorConfigView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("templateeditor_settings_saved_ok"));
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/templateeditor/class/view/plugintemplateeditorconfigview.class.php
===================================================================
--- plugins/trunk/templateeditor/class/view/plugintemplateeditorconfigview.class.php 2005-02-28 18:14:10 UTC (rev 1250)
+++ plugins/trunk/templateeditor/class/view/plugintemplateeditorconfigview.class.php 2005-02-28 19:08:19 UTC (rev 1251)
@@ -0,0 +1,31 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ /**
+ * implements the main view of the feed reader plugin
+ */
+ class PluginTemplateEditorConfigView extends AdminPluginTemplatedView
+ {
+
+ function PluginTemplateEditorConfigView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "templateeditor", "pluginsettings" );
+ }
+
+ function render()
+ {
+ // load some configuration settings
+ $config =& Config::getConfig();
+ $pluginEnabled = $config->getValue( "plugin_templateeditor_enabled" );
+ $maxBackupFiles = $config->getValue( "plugin_templateeditor_maxbackupfiles" );
+ if ($maxBackupFiles == "") $maxBackupFiles = 5;
+
+ // create a view and export the settings to the template
+ $this->setValue( "pluginEnabled", $pluginEnabled );
+ $this->setValue( "maxBackupFiles", $maxBackupFiles );
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Modified: plugins/trunk/templateeditor/locale/locale_en_UK.php
===================================================================
--- plugins/trunk/templateeditor/locale/locale_en_UK.php 2005-02-28 18:14:10 UTC (rev 1250)
+++ plugins/trunk/templateeditor/locale/locale_en_UK.php 2005-02-28 19:08:19 UTC (rev 1251)
@@ -1,23 +1,30 @@
<?php
$messages["SiteTemplateEditor"] = "Site Template Editor";
$messages["BlogTemplateEditor"] = "Blog Template Editor";
+$messages["TemplateEditorConfig"] = "Template Editor Settings";
$messages["templateeditor_backupfile"] = "Please select the date that you want to recover, template editor will load it to editor automatically. Each template file can has 5 backup files in total.";
$messages["templateeditor_choose_backupfile"] = "Select backup file to recover";
$messages["templateeditor_currentfile"] = "Current File";
$messages["templateeditor_filecontent"] = "Modify your template file.";
$messages["templateeditor_recover_from"] = "Recover From";
+$messages["templateeditor_plugin_enabled"] = "Allow blog user to use template editor";
+$messages["templateeditor_maxbackupfiles"] = "Max backup files of each template file";
$messages["error_no_files_selected"] = "No files were selected to delete.";
$messages["error_removing_template_file"] = "There was an error deleting template file %s.";
$messages["error_updating_template_file"] = "There was an error updating template file.";
$messages["error_backup_template_file"] = "There was an error backing up template file.";
+$messages["templateeditor_error_maxbackupfiles"] = "Maximum Backup Files Should > 0!";
-
$messages["template_file_removed_ok"] = "Template file %s deleted successfully.";
$messages["template_files_removed_ok"] = "%s templates files deleted successfully";
$messages["templateeditor_file_saved_ok"] = "Template file saved successfully.";
+$messages["templateeditor_settings_saved_ok"] = "Templete Editor settings saved successfully!";
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+$messages["label_maxbackupfiles"] = "Backup Files";
$messages["label_edit"] = "Edit";
$messages["label_backupfile"] = "Backup Recover";
?>
\ No newline at end of file
Modified: plugins/trunk/templateeditor/locale/locale_zh_TW.php
===================================================================
--- plugins/trunk/templateeditor/locale/locale_zh_TW.php 2005-02-28 18:14:10 UTC (rev 1250)
+++ plugins/trunk/templateeditor/locale/locale_zh_TW.php 2005-02-28 19:08:19 UTC (rev 1251)
@@ -1,22 +1,30 @@
<?php
$messages["SiteTemplateEditor"] = "全域模版編輯器";
$messages["BlogTemplateEditor"] = "網誌模版編輯器";
+$messages["TemplateEditorConfig"] = "模版編輯器設定";
$messages["templateeditor_backupfile"] = "請選擇您要回復的備份日期,模版編輯器會自動將備份檔載入編輯器中。pLog 系統預設為儲存 5 個備份檔。";
$messages["templateeditor_choose_backupfile"] = "請選擇要回復的備份檔";
$messages["templateeditor_currentfile"] = "載入最新模版檔";
$messages["templateeditor_filecontent"] = "修改模版檔案內容。";
-$messages["templateeditor_recover_from"] = "回覆自";
+$messages["templateeditor_recover_from"] = "回復自";
+$messages["templateeditor_plugin_enabled"] = "允許網誌使用者使用模版編輯器";
+$messages["templateeditor_maxbackupfiles"] = "備份檔案的儲存限制";
$messages["error_no_files_selected"] = "您沒有選擇任何模版檔案。";
$messages["error_removing_template_file"] = "在刪除模版檔案 %s 時發生錯誤。";
$messages["error_updating_template_file"] = "在更新模版檔案時發生錯誤。";
$messages["error_backup_template_file"] = "在備份模版檔案時發生錯誤。";
+$messages["templateeditor_error_maxbackupfiles"] = "模版備份檔案儲存限制個數必須要 > 0!";
$messages["template_file_removed_ok"] = "模版檔案「%s」已順利刪除。";
$messages["template_files_removed_ok"] = "已順利刪除「%s」個模版檔案。";
$messages["templateeditor_file_saved_ok"] = "模版檔案儲存成功。";
+$messages["templateeditor_settings_saved_ok"] = "模版編輯器設定儲存成功。";
+$messages["label_configuration"] = "設定";
+$messages["label_enable"] = "啟動";
+$messages["label_maxbackupfiles"] = "模版備份限制";
$messages["label_edit"] = "編輯";
$messages["label_backupfile"] = "備份回覆";
?>
\ No newline at end of file
Modified: plugins/trunk/templateeditor/plugintemplateeditor.class.php
===================================================================
--- plugins/trunk/templateeditor/plugintemplateeditor.class.php 2005-02-28 18:14:10 UTC (rev 1250)
+++ plugins/trunk/templateeditor/plugintemplateeditor.class.php 2005-02-28 19:08:19 UTC (rev 1251)
@@ -14,6 +14,9 @@
$this->author = "Mark Wu";
$this->desc = "The plugin offer online template editor function for pLog";
+ $config =& Config::getConfig();
+ $this->pluginEnabled = $config->getValue( "plugin_templateeditor_enabled" );
+
$this->locales = Array( "en_UK" , "zh_TW" );
$this->init();
@@ -37,10 +40,17 @@
$this->registerAdminAction( "blogDeleteTemplateFile", "PluginBlogDeleteTemplateFilesAction" );
$this->registerAdminAction( "blogDeleteTemplateFiles", "PluginBlogDeleteTemplateFilesAction" );
$this->registerAdminAction( "blogEditTemplateFile", "PluginBlogEditTemplateFileAction" );
- $this->registerAdminAction( "blogUpdateTemplateFile", "PluginBlogUpdateTemplateFileAction" );
+ $this->registerAdminAction( "blogUpdateTemplateFile", "PluginBlogUpdateTemplateFileAction" );
+
+ $this->registerAdminAction( "templateEditorConfig", "PluginTemplateEditorConfigAction" );
+ $this->registerAdminAction( "updateTemplateEditorConfig", "PluginTemplateEditorUpdateConfigAction" );
- $this->addMenuEntry( "/menu/adminSettings/Templates", "SiteTemplateEditor", "admin.php?op=siteTemplateSetsList", "SiteTemplateEditor", false, true );
- $this->addMenuEntry( "/menu/controlCenter/manageBlogTemplates", "BlogTemplateEditor", "admin.php?op=blogTemplateSetsList", "BlogTemplateEditor", false, true );
+ $this->addMenuEntry( "/menu/adminSettings/Templates", "SiteTemplateEditor", "admin.php?op=siteTemplateSetsList", "" );
+ $this->addMenuEntry( "/menu/adminSettings/Templates", "TemplateEditorConfig", "admin.php?op=templateEditorConfig", "" );
+
+ if ($this->pluginEnabled) {
+ $this->addMenuEntry( "/menu/controlCenter/manageBlogTemplates", "BlogTemplateEditor", "admin.php?op=blogTemplateSetsList", "" );
+ }
}
}
?>
\ No newline at end of file
Added: plugins/trunk/templateeditor/templates/pluginsettings.template
===================================================================
--- plugins/trunk/templateeditor/templates/pluginsettings.template 2005-02-28 18:14:10 UTC (rev 1250)
+++ plugins/trunk/templateeditor/templates/pluginsettings.template 2005-02-28 19:08:19 UTC (rev 1251)
@@ -0,0 +1,32 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=TemplateEditorConfig title=$locale->tr("TemplateEditorConfig")}
+<form name="templateEditorConfig" 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} value="1" />{$locale->tr("templateeditor_plugin_enabled")}
+ </div>
+ </div>
+
+ <div class="field">
+ <label for="maxBackupFiles">{$locale->tr("label_maxbackupfiles")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("templateeditor_maxbackupfiles")}</div>
+ <input class="text" type="text" name="maxBackupFiles" id="maxBackupFiles" value="{$maxBackupFiles}" width="10" />
+ </div>
+
+ </fieldset>
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="updateTemplateEditorConfig" />
+ <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