[pLog-svn] r1984 - in plugins/trunk/submissions: . class class/action class/view js locale templates

mark at devel.plogworld.net mark at devel.plogworld.net
Wed May 11 17:00:16 GMT 2005


Author: mark
Date: 2005-05-11 17:00:15 +0000 (Wed, 11 May 2005)
New Revision: 1984

Added:
   plugins/trunk/submissions/class/view/
   plugins/trunk/submissions/class/view/adminsubmissionspluginsettingsview.class.php
   plugins/trunk/submissions/js/
   plugins/trunk/submissions/js/htmlarea-submissions.js
   plugins/trunk/submissions/locale/locale_zh_TW.php
Modified:
   plugins/trunk/submissions/class/action/addsubmissionaction.class.php
   plugins/trunk/submissions/class/action/adminsubmissionspluginsettingsaction.class.php
   plugins/trunk/submissions/class/action/adminsubmissionspluginupdatesettingsaction.class.php
   plugins/trunk/submissions/locale/locale_en_UK.php
   plugins/trunk/submissions/pluginsubmissions.class.php
   plugins/trunk/submissions/templates/accepted.template
   plugins/trunk/submissions/templates/pluginsettings.template
   plugins/trunk/submissions/templates/submitform.template
Log:
Submission ported complete!

1. UI already follow 1.0 UI guide line
2. Add support for htmlarea and plogeditor
3. Change the submitform to cache_disable, or we won't see any error messages.
4. add a hidden field of blogId, or the plugin won't work under custom url enabled.

Mark

Modified: plugins/trunk/submissions/class/action/addsubmissionaction.class.php
===================================================================
--- plugins/trunk/submissions/class/action/addsubmissionaction.class.php	2005-05-11 06:51:32 UTC (rev 1983)
+++ plugins/trunk/submissions/class/action/addsubmissionaction.class.php	2005-05-11 17:00:15 UTC (rev 1984)
@@ -53,7 +53,7 @@
             }
             
             if( $errors ) {
-                $this->_view = new PluginTemplatedView( $this->_blogInfo, "submissions", "submitform" );
+                $this->_view = new PluginTemplatedView( $this->_blogInfo, "submissions", "submitform", SMARTY_VIEW_CACHE_DISABLED );
                 $this->_view->setValue( "userName", $this->_userName );
                 $this->_view->setValue( "userEmailAddress", $this->_userEmailAddress );
                 $this->_view->setValue( "submissionTopic", $this->_topic );

Modified: plugins/trunk/submissions/class/action/adminsubmissionspluginsettingsaction.class.php
===================================================================
--- plugins/trunk/submissions/class/action/adminsubmissionspluginsettingsaction.class.php	2005-05-11 06:51:32 UTC (rev 1983)
+++ plugins/trunk/submissions/class/action/adminsubmissionspluginsettingsaction.class.php	2005-05-11 17:00:15 UTC (rev 1984)
@@ -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/submissions/class/view/adminsubmissionspluginsettingsview.class.php" );	
 
     class AdminSubmissionsPluginSettingsAction extends BlogOwnerAdminAction 
 	{
@@ -20,12 +20,11 @@
          */
         function perform()
         {
-			$this->_view = new AdminPluginTemplatedView( $this->_blogInfo, "submissions", "pluginsettings" );
-			$this->_view->setValue( "pluginEnabled", $this->_blogSettings->getValue( "plugin_submissions_enabled" ));
-            $this->setCommonData();
-
-            // better to return true if everything fine
-            return true;
+            $this->_view = new AdminSubmissionsPluginSettingsView( $this->_blogInfo );
+			
+			$this->setCommonData();
+			
+			return true;
         }
     }
 ?>

Modified: plugins/trunk/submissions/class/action/adminsubmissionspluginupdatesettingsaction.class.php
===================================================================
--- plugins/trunk/submissions/class/action/adminsubmissionspluginupdatesettingsaction.class.php	2005-05-11 06:51:32 UTC (rev 1983)
+++ plugins/trunk/submissions/class/action/adminsubmissionspluginupdatesettingsaction.class.php	2005-05-11 17:00:15 UTC (rev 1984)
@@ -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/submissions/class/view/adminsubmissionspluginsettingsview.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" );	
@@ -11,6 +10,7 @@
 	{
 	
 		var $_pluginEnabled;
+		var $_htmlareaEnabled;
 
     	/**
          * Constructor. If nothing else, it also has to call the constructor of the parent
@@ -23,13 +23,12 @@
 		
 		function validate()
 		{
-			$this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+            $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+            $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+            
+            $this->_htmlareaEnabled = $this->_request->getValue( "htmlareaEnabled" );
+            $this->_htmlareaEnabled = ($this->_htmlareaEnabled != "" );            
 			
-			if( $this->_pluginEnabled == "" )
-				$this->_pluginEnabled = false;
-			else
-				$this->_pluginEnabled = true;
-				
 			return true;
 		}
 		
@@ -107,17 +106,20 @@
          */
         function perform()
         {
+        	// update the plugin configurations to blog setting
 			$blogSettings = $this->_blogInfo->getSettings();
 			$blogSettings->setValue( "plugin_submissions_enabled", $this->_pluginEnabled );
+			$blogSettings->setValue( "plugin_submissions_htmlarea_enabled", $this->_htmlareaEnabled );
 			$this->_blogInfo->setSettings( $blogSettings );
-			$blogs = new Blogs();
 			
 			// update the settings in the db, and make sure that everything went fine
+			$blogs = new Blogs();
 			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;
+                $this->_view = new AdminSubmissionsPluginSettingsView( $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
@@ -126,14 +128,18 @@
 			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();
+			// if everything went ok...
+            $this->_blogInfo->setSettings( $blogSettings );
+            $this->_session->setValue( "blogInfo", $this->_blogInfo );
+            $this->saveSession();
+			
+			$this->_view = new AdminSubmissionsPluginSettingsView( $this->_blogInfo );
+			$this->_view->setSuccessMessage( $this->_locale->tr("submissions_settings_saved_ok"));			
+			$this->setCommonData();
 
-            // better to return true if everything fine
+			// clear the cache
+			CacheControl::resetBlogCache( $this->_blogInfo->getId());			
+            
             return true;
         }
     }

Added: plugins/trunk/submissions/class/view/adminsubmissionspluginsettingsview.class.php
===================================================================
--- plugins/trunk/submissions/class/view/adminsubmissionspluginsettingsview.class.php	2005-05-11 06:51:32 UTC (rev 1983)
+++ plugins/trunk/submissions/class/view/adminsubmissionspluginsettingsview.class.php	2005-05-11 17:00:15 UTC (rev 1984)
@@ -0,0 +1,30 @@
+<?php
+	
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+	/**
+	 * implements the main view of the submissions plugin
+	 */
+	class AdminSubmissionsPluginSettingsView extends AdminPluginTemplatedView
+	{
+
+		function AdminSubmissionsPluginSettingsView( $blogInfo )
+		{
+			$this->AdminPluginTemplatedView( $blogInfo, "submissions", "pluginsettings" );
+		}
+		
+		function render()
+		{
+			// load some configuration settings
+			$blogSettings = $this->_blogInfo->getSettings();
+			$pluginEnabled = $blogSettings->getValue( "plugin_submissions_enabled" );
+			$htmlareaEnabled = $blogSettings->getValue( "plugin_submissions_htmlarea_enabled" );
+			
+			// create a view and export the settings to the template
+			$this->setValue( "pluginEnabled", $pluginEnabled );
+			$this->setValue( "htmlareaEnabled", $htmlareaEnabled );
+			
+			parent::render();
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/submissions/js/htmlarea-submissions.js
===================================================================
--- plugins/trunk/submissions/js/htmlarea-submissions.js	2005-05-11 06:51:32 UTC (rev 1983)
+++ plugins/trunk/submissions/js/htmlarea-submissions.js	2005-05-11 17:00:15 UTC (rev 1984)
@@ -0,0 +1,28 @@
+var submissionTextEditor = null;
+
+// this function will get called at body.onload
+function initEditor() {
+
+    // ------------------------------------------------------
+    // Create submissionText Editor
+    // ------------------------------------------------------
+    submissionTextEditor = new HTMLArea("submissionText");
+
+    // add our new icon in a place better suited for this task...		
+    submissionTextEditor.config.toolbar = [
+    	[ "fontsize", "space","space",
+    	  "bold", "italic", "underline", "strikethrough", "separator",
+    	  "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
+    	  "orderedlist", "unorderedlist", "separator",
+    	  "createlink", "insertimage", "htmlmode" ]
+    ];    
+    
+    // Generate submissionTextEditor Editor
+    setTimeout(function() {submissionTextEditor.generate();}, 1000); 
+
+    return false;
+};
+
+// Initialize HTMLArea Editor
+HTMLArea.init();
+HTMLArea.onload = initEditor;
\ No newline at end of file

Modified: plugins/trunk/submissions/locale/locale_en_UK.php
===================================================================
--- plugins/trunk/submissions/locale/locale_en_UK.php	2005-05-11 06:51:32 UTC (rev 1983)
+++ plugins/trunk/submissions/locale/locale_en_UK.php	2005-05-11 17:00:15 UTC (rev 1984)
@@ -1,10 +1,27 @@
 <?php
+$messages["submissionsPluginSettings"] = "Submissions";
+$messages["submissions"] = "Visitor Submissions";
 
-$messages["your_name"] = "Your name (optional)";
-$messages["your_email_address"] = "Your email address (optional)";
-$messages["story_topic"] = "Your story topic";
-$messages["story_contents"] = "Your story contents";
+$messages["submissions_plugin_enabled"] = "Enable this plugin";
+$messages["submissions_plugin"] = "Submissions Plugin";
+
+$messages["submissions_htmlarea_enabled"] = "Enable build in HTMLArea editor";
+$messages["submissions_settings_saved_ok"] = "Submissions settings saved successfully!";
+$messages["error_submissions_not_enabled"] = "Please kindly enable Submissions plugin first.";
+$messages["error_submission_no_topic"] = "Topic Error! Topic should not be empty.";
+$messages["error_submission_no_text"] = "Content Error! Content should not be empty.";
+$messages["error_submission_no_category"] = "Category Error! You need to select at least one or more article cateogries.";
+$messages["submission_accepted_ok"] = "Your story submitted successfully!";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+$messages["label_htmlarea_enabled"] = "Enable Editor";
+
+$messages["your_name"] = "Your Name (Optional): ";
+$messages["your_email_address"] = "Your Email Address (Optional): ";
+$messages["story_topic"] = "Your Story Topic: ";
+$messages["story_contents"] = "Your Story Contents: ";
 $messages["submit_story"] = "Submit Story";
 $messages["post_status_external_submission"] = "Unmoderated";
-$messages["submissionsPluginSettings"] = "Submissions";
+
 ?>
\ No newline at end of file

Added: plugins/trunk/submissions/locale/locale_zh_TW.php
===================================================================
--- plugins/trunk/submissions/locale/locale_zh_TW.php	2005-05-11 06:51:32 UTC (rev 1983)
+++ plugins/trunk/submissions/locale/locale_zh_TW.php	2005-05-11 17:00:15 UTC (rev 1984)
@@ -0,0 +1,26 @@
+<?php
+$messages["submissionsPluginSettings"] = "訪客文章發表設定";
+$messages["submissions"] = "訪客文章發表";
+
+$messages["submissions_plugin_enabled"] = "啟動外掛程式";
+$messages["submissions_plugin"] = "訪客文章發表外掛程式";
+
+$messages["submissions_htmlarea_enabled"] = "啟動內建所見即所得文字編輯器";
+$messages["submissions_settings_saved_ok"] = "訪客文章發表設定儲存成功。";
+$messages["error_submissions_not_enabled"] = "請您先啟動訪客文章發表外掛程式。";
+$messages["error_submission_no_topic"] = "文章標題錯誤!文章標題不可為空白。";
+$messages["error_submission_no_text"] = "文章內容錯誤!文章內容不可為空白。";
+$messages["error_submission_no_category"] = "分類錯誤!至少選擇一個文章分類。";
+$messages["submission_accepted_ok"] = "文章發表成功。";
+
+$messages["label_configuration"] = "設定";
+$messages["label_enable"] = "啟動";
+$messages["label_htmlarea_enabled"] = "啟動編輯器";
+
+$messages["your_name"] = "姓名(非必填):";
+$messages["your_email_address"] = "電子郵件信箱(非必填):";
+$messages["story_topic"] = "文章標題:";
+$messages["story_contents"] = "文章內容:";
+$messages["submit_story"] = "送出文章";
+$messages["post_status_external_submission"] = "未審核";
+?>
\ No newline at end of file

Modified: plugins/trunk/submissions/pluginsubmissions.class.php
===================================================================
--- plugins/trunk/submissions/pluginsubmissions.class.php	2005-05-11 06:51:32 UTC (rev 1983)
+++ plugins/trunk/submissions/pluginsubmissions.class.php	2005-05-11 17:00:15 UTC (rev 1984)
@@ -15,9 +15,9 @@
 			$this->PluginBase();
 			
 			$this->id = "submissions";
-			$this->description = "Allows users to submit stories to the blog";
+			$this->description = "Allows visitor to submit stories to the blog.";
 			$this->author = "The pLog Team";
-			$this->locales = Array( "en_UK" );
+			$this->locales = Array();
 			
 			$this->init();
 		}
@@ -34,7 +34,36 @@
 			$this->registerAdminAction( "pluginSubmissionsUpdateSettings", "AdminSubmissionsPluginUpdateSettingsAction" );
 			
 			// add a couple of menu entries
-			$this->addMenuEntry( "/menu/controlCenter/manageSettings", "submissionsPluginSettings", "admin.php?op=submissionsPluginSettings", "", true, false );
-		}		
+			$this->addMenuEntry( "/menu/Manage/managePosts", "submissionsPluginSettings", "admin.php?op=submissionsPluginSettings", "", true, false );
+		}
+
+		function register()
+		{
+		    $blogSettings = $this->blogInfo->getSettings();
+		    $this->pluginEnabled = $blogSettings->getValue( "plugin_submissions_enabled" );
+		    $this->htmlareaEnabled = $blogSettings->getValue( "plugin_submissions_htmlarea_enabled" );
+	    }
+	    
+	    function isEnabled()
+	    {
+	        return $this->pluginEnabled;
+	    }
+
+	    function isHtmlareaEnabled()
+	    {
+	        return $this->htmlareaEnabled;
+	    }
+
+        function pluginTemplatePage()
+        {
+ 			$rg = new RawRequestGenerator($this->blogInfo);
+            
+        	$rg->addParameter( "op", "submissionForm" );
+            $rg->addParameter( "blogId", $this->blogInfo->getId());
+
+            $templatePage = $rg->getIndexUrl().$rg->getRequest();
+
+            return $templatePage;
+        }	    		
 	}  
 ?>
\ No newline at end of file

Modified: plugins/trunk/submissions/templates/accepted.template
===================================================================
--- plugins/trunk/submissions/templates/accepted.template	2005-05-11 06:51:32 UTC (rev 1983)
+++ plugins/trunk/submissions/templates/accepted.template	2005-05-11 17:00:15 UTC (rev 1984)
@@ -1,3 +1,4 @@
+{include file="$blogtemplate/header.template"}
 <p>
 {$locale->tr("submission_accepted_ok")}
 </p>
@@ -3,3 +4,4 @@
 <p>
  <a href="{$url->blogLink()}">{$locale->tr("back")}</a>
-</p>
\ No newline at end of file
+</p>
+{include file="$blogtemplate/footer.template"}
\ No newline at end of file

Modified: plugins/trunk/submissions/templates/pluginsettings.template
===================================================================
--- plugins/trunk/submissions/templates/pluginsettings.template	2005-05-11 06:51:32 UTC (rev 1983)
+++ plugins/trunk/submissions/templates/pluginsettings.template	2005-05-11 17:00:15 UTC (rev 1984)
@@ -1,16 +1,33 @@
 {include file="$admintemplatepath/header.template"}
-{include file="$admintemplatepath/navigation.template" showOpt=submissionsPluginSettings title=$locale->tr("submissionsPluginSettings")}
-<p>
-This plugin will allow you to allow visitors to send articles for publishing. It works by creating
-two additional custom fields that will be used to store the email address of the sender and the 
-name or nickname of the sender. Please do not remove these fields or the plugin will not work
-correctly.
-</p>
-<form name="pluginSubmissionsSettings" 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="pluginSubmissionsUpdateSettings" />
- <input type="submit" name="{$locale->tr("update")}" value="{$locale->tr("update")}" />
+{include file="$admintemplatepath/navigation.template" showOpt=submissionsPluginSettings title=$locale->tr("submissions_plugin")}
+<form name="pluginSubmissionsSettings"  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} value="1" />{$locale->tr("submissions_plugin_enabled")}
+   </div>
+  </div>
+
+  <div class="field">
+   <label for="htmlareaEnabled">{$locale->tr("label_htmlarea_enabled")}</label>
+   <span class="required"></span>
+   <div class="formHelp">
+    <input class="checkbox" type="checkbox" name="htmlareaEnabled" id="htmlareaEnabled" {if $htmlareaEnabled} checked="checked" {/if} value="1" />{$locale->tr("submissions_htmlarea_enabled")}
+   </div>
+  </div>  
+ 
+ </fieldset>
+ 
+ <div class="buttons">  
+  <input type="hidden" name="op" value="pluginSubmissionsUpdateSettings" />
+  <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

Modified: plugins/trunk/submissions/templates/submitform.template
===================================================================
--- plugins/trunk/submissions/templates/submitform.template	2005-05-11 06:51:32 UTC (rev 1983)
+++ plugins/trunk/submissions/templates/submitform.template	2005-05-11 17:00:15 UTC (rev 1984)
@@ -1,21 +1,36 @@
 {include file="$blogtemplate/header.template"}
+{if $submissions->isEnabled()}
+{if $submissions->isHtmlareaEnabled()}
+  <script type="text/javascript" src="js/htmlarea/htmlarea.js"/></script>
+  <script type="text/javascript" src="js/htmlarea/dialog.js"/></script>
+  <script type="text/javascript" src="plugins/submissions/js/htmlarea-submissions.js"/></script>
+{else}
+  <link rel="stylesheet" href="js/editor/plogeditor.css" type="text/css" />
+  <script type="text/javascript" src="js/editor/plogeditor.js"></script>
+{/if}
 {if $errors}
  <p style="color: red">
   {$errorMessage}
  </p>
 {/if}
 <form name="submission" method="post" action="{$url->getIndexUrl()}">
- {$locale->tr("your_name")}: <br/><input type="text" name="userName" value="{$userName}" /><br/>
- {$locale->tr("your_email_address")}: <br/><input type="text" name="userEmailAddress" value="{$userEmailAddress}" /><br/>
- {$locale->tr("story_topic")}: <br/><input type="text" name="submissionTopic" value="{$submissionTopic}" /><br/>
- {$locale->tr("story_contents")}: <br/><textarea rows="6" cols="70" name="submissionText">{$submissionText}</textarea><br/><br/>
- {$locale->tr("category")}: <br/>
+ {$locale->tr("your_name")}<br/><input type="text" name="userName" value="{$userName}" style="width:100%" /><br/>
+ {$locale->tr("your_email_address")}<br/><input type="text" name="userEmailAddress" value="{$userEmailAddress}" style="width:100%" /><br/>
+ {$locale->tr("story_topic")}<br/><input type="text" name="submissionTopic" value="{$submissionTopic}" style="width:100%" /><br/>
+ {$locale->tr("category")}<br/>
  <select name="submissionCategory[]" multiple="multiple">
  {foreach from=$articlecategories item=category}
   <option value="{$category->getId()}">{$category->getName()}</option>
  {/foreach}
  </select><br/>
+ {$locale->tr("story_contents")}<br/>
+ {if !$submissions->isHtmlareaEnabled()}<script type="text/javascript">var ed1 = new pLogEditor('submissionText','ed1');</script>{/if}
+ <textarea rows="15" id="submissionText" name="submissionText" style="width:100%">{$submissionText}</textarea><br/><br/>
  <input type="hidden" name="op" value="submitStory" />
+ <input type="hidden" name="blogId" value="{$blog->getId()}" />
  <input type="submit" name="{$locale->tr("submit_story")}" value="{$locale->tr("submit_story")}" />
 </form>
+ {else}
+  {$locale->tr("error_submissions_not_enabled")}
+ {/if}
 {include file="$blogtemplate/footer.template"}
\ No newline at end of file




More information about the pLog-svn mailing list