[pLog-svn] r868 - in plugins/trunk/hostblock: class/action class/view templates

mark at devel.plogworld.net mark at devel.plogworld.net
Fri Jan 28 06:35:25 GMT 2005


Author: mark
Date: 2005-01-28 06:35:24 +0000 (Fri, 28 Jan 2005)
New Revision: 868

Added:
   plugins/trunk/hostblock/class/view/admineditblockedhostview.class.php
Modified:
   plugins/trunk/hostblock/class/action/admineditblockedhostaction.class.php
   plugins/trunk/hostblock/templates/addblockedhost.template
   plugins/trunk/hostblock/templates/blockedhosts.template
   plugins/trunk/hostblock/templates/editblockedhost.template
Log:


Modified: plugins/trunk/hostblock/class/action/admineditblockedhostaction.class.php
===================================================================
--- plugins/trunk/hostblock/class/action/admineditblockedhostaction.class.php	2005-01-27 23:09:51 UTC (rev 867)
+++ plugins/trunk/hostblock/class/action/admineditblockedhostaction.class.php	2005-01-28 06:35:24 UTC (rev 868)
@@ -1,10 +1,10 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
-    include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
-    include_once( PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
-    include_once( PLOG_CLASS_PATH."plugins/hostblock/class/dao/blockedhosts.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+    include_once( PLOG_CLASS_PATH."plugins/hostblock/class/dao/blockedhosts.class.php" );
+    include_once( PLOG_CLASS_PATH."plugins/hostblock/class/view/admineditblockedhostview.class.php" );
+    include_once( PLOG_CLASS_PATH."plugins/hostblock/class/view/adminblockedhostsview.class.php" );      
 
     /**
      * Changes the settings of a blocked host
@@ -21,22 +21,12 @@
         function AdminEditBlockedHostAction( $actionInfo, $request )
         {
         	$this->SiteAdminAction( $actionInfo, $request );
-        }
 
-        function validate()
-        {
-        	$this->_hostId = $this->_request->getValue( "hostId" );
-
-            $val = new IntegerValidator();
-            if( !$val->validate( $this->_hostId )) {
-            	$this->_view = new AdminErrorView( $this->_blogInfo );
-                $this->_view->setMessage( $this->_locale->tr( "error_incorrect_blocked_host_id" ));
-                $this->setCommonData();
-
-                return false;
-            }
-
-            return true;
+			// data validation stuff
+			$this->registerFieldValidator( "hostId", new IntegerValidator());
+			$view = new AdminBlockedHostsView( $this->_blogInfo );
+			$view->setErrorMessage( $this->_locale->tr("error_incorrect_blocked_host_id") );
+			$this->setValidationErrorView( $view );             	
         }
 
         /**
@@ -44,29 +34,24 @@
          */
         function perform()
         {
+        	// fetch the data
+        	$this->_hostId = $this->_request->getValue( "hostId" );
+
         	$blockedHosts = new BlockedHosts();
             $blockedHost = $blockedHosts->getBlockedHost( $this->_hostId );
 
             // check if the info about the blocked host is correct
             if( !$blockedHost ) {
-            	$this->_view = new AdminErrorView( $this->_blogInfo );
-                $this->_view->setMessage( $this->_locale->tr( "error_fetching_blocked_host" ));
+            	$this->_view = new AdminBlockedHostsView( $this->_blogInfo );
+                $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_blocked_host"));
                 $this->setCommonData();
 
-                return false;
+            	return false;                
             }
 
             // if so, continue
-            $this->_view = new AdminPluginTemplatedView( $this->_blogInfo, "hostblock", "editblockedhost" );
-            $this->_view->setValue( "blockedhost", $blockedHost );
+            $this->_view = new AdminEditBlockedHostView( $this->_blogInfo, $this->_hostId );
 
-            // to make things easier in the template, let's do the following:
-            $ipParts = explode( ".", $blockedHost->getHost());
-            $this->_view->setValue( "ip1", $ipParts[0] );
-            $this->_view->setValue( "ip2", $ipParts[1] );
-            $this->_view->setValue( "ip3", $ipParts[2] );
-            $this->_view->setValue( "ip4", $ipParts[3] );
-
             $this->setCommonData();
 
             // better to return true if everything fine

Added: plugins/trunk/hostblock/class/view/admineditblockedhostview.class.php
===================================================================
--- plugins/trunk/hostblock/class/view/admineditblockedhostview.class.php	2005-01-27 23:09:51 UTC (rev 867)
+++ plugins/trunk/hostblock/class/view/admineditblockedhostview.class.php	2005-01-28 06:35:24 UTC (rev 868)
@@ -0,0 +1,36 @@
+<?php
+	
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+    include_once( PLOG_CLASS_PATH."plugins/hostblock/class/dao/blockedhosts.class.php" );
+
+	/**
+	 * implements the main view of the feed reader plugin
+	 */
+	class AdminEditBlockedHostView extends AdminPluginTemplatedView
+	{
+        var $_hostId;
+		
+		function AdminEditBlockedHostView( $blogInfo, $hostId )
+		{
+			$this->AdminPluginTemplatedView( $blogInfo, "hostblock", "editblockedhost" );
+			
+			$this->_hostId = $hostId;
+		}
+		
+		function render()
+		{
+        	$blockedHosts = new BlockedHosts();
+            $blockedHost = $blockedHosts->getBlockedHost( $this->_hostId );
+
+            $this->setValue( "blockedhost", $blockedHost );
+            // to make things easier in the template, let's do the following:
+            $ipParts = explode( ".", $blockedHost->getHost());
+            $this->setValue( "ip1", $ipParts[0] );
+            $this->setValue( "ip2", $ipParts[1] );
+            $this->setValue( "ip3", $ipParts[2] );
+            $this->setValue( "ip4", $ipParts[3] );
+            
+            parent::render();
+		}
+	}
+?>
\ No newline at end of file

Modified: plugins/trunk/hostblock/templates/addblockedhost.template
===================================================================
--- plugins/trunk/hostblock/templates/addblockedhost.template	2005-01-27 23:09:51 UTC (rev 867)
+++ plugins/trunk/hostblock/templates/addblockedhost.template	2005-01-28 06:35:24 UTC (rev 868)
@@ -3,7 +3,7 @@
 {include file="common.template"}
 <form name="newBlockedHost" action="admin.php" method="post" onSubmit="return checkIpAddress(this);">
  <fieldset class="inputField">
- <legend>{$locale->tr("addFilteredContent")}</legend>
+ <legend>{$locale->tr("addBlockedHost")}</legend>
   {include file="$admintemplatepath/successmessage.template"}
   {include file="$admintemplatepath/errormessage.template"} 
   <div class="field">

Modified: plugins/trunk/hostblock/templates/blockedhosts.template
===================================================================
--- plugins/trunk/hostblock/templates/blockedhosts.template	2005-01-27 23:09:51 UTC (rev 867)
+++ plugins/trunk/hostblock/templates/blockedhosts.template	2005-01-28 06:35:24 UTC (rev 868)
@@ -23,7 +23,7 @@
      <td>
       {if $blockedhost->getType() == 1}{$locale->tr("access_blocked")}{/if}
       {if $blockedhost->getType() == 2}{$locale->tr("posting_blocked")}{/if}
-      {if $blockedhost->isGlobal()} (<b>{$locale->tr("global")}</b>){/if}
+      {if $blockedhost->isGlobal()} <b>[{$locale->tr("global")}]</b>{/if}
      </td>
      <td>
       <div class="list_action_button">

Modified: plugins/trunk/hostblock/templates/editblockedhost.template
===================================================================
--- plugins/trunk/hostblock/templates/editblockedhost.template	2005-01-27 23:09:51 UTC (rev 867)
+++ plugins/trunk/hostblock/templates/editblockedhost.template	2005-01-28 06:35:24 UTC (rev 868)
@@ -1,45 +1,53 @@
 {include file="$admintemplatepath/header.template"}
 {include file="$admintemplatepath/navigation.template" showOpt=blockedHosts title=$locale->tr("blockedHosts")}
 {include file="common.template"}
-<form name="newBlockedHost" action="admin.php" method="post" onSubmit="return checkIpAddress(this);">
- <table width="100%">
-  <tr>
-   <td class="alignright" width="15%">{$locale->tr("ip_address")}: </td>
-   <td>
-    <input type="text" size="3" maxlength="3" name="ip1" value="{$ip1}" />.
-    <input type="text" size="3" maxlength="3" name="ip2" value="{$ip2}" />.
-    <input type="text" size="3" maxlength="3" name="ip3" value="{$ip3}" />.
-    <input type="text" size="3" maxlength="3" name="ip4" value="{$ip4}" />
-    / <select name="mask">
+<form name="editBlockedHost" action="admin.php" method="post" onSubmit="return checkIpAddress(this);">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("editBlockedHost")}</legend>
+  {include file="$admintemplatepath/successmessage.template"}
+  {include file="$admintemplatepath/errormessage.template"} 
+  <div class="field">
+   <label for="blockedHost">{$locale->tr("ip_address")}</label>
+   <span class="required">*</span>
+   <div class="formHelp">{$locale->tr("host_to_block_help")}</div>
+    <input style="width:40px;" type="text" size="3" maxlength="3" name="ip1" id="ip1" value="{$ip1}" />.
+    <input style="width:40px;" type="text" size="3" maxlength="3" name="ip2" id="ip2" value="{$ip2}" />.
+    <input style="width:40px;" type="text" size="3" maxlength="3" name="ip3" id="ip3" value="{$ip3}" />.
+    <input style="width:40px;" type="text" size="3" maxlength="3" name="ip4" id="ip4" value="{$ip4}" />
+    / <select name="mask" id="mask">
      <option value="8" {if $blockedhost->getMask() == 8} selected="selected"{/if}>8 {$locale->tr("bits")}</option>
      <option value="16" {if $blockedhost->getMask() == 16} selected="selected"{/if}>16 {$locale->tr("bits")}</option>
      <option value="24" {if $blockedhost->getMask() == 24} selected="selected"{/if}>24 {$locale->tr("bits")}</option>
      <option value="32" {if $blockedhost->getMask() == 32} selected="selected"{/if}>32 {$locale->tr("bits")}</option>
     </select>
-   </td>
-  </tr>
-  <tr>
-   <td class="alignright">{$locale->tr("block_type")}:</td>
-   <td>
-    <select name="blockType">
-     <option value="1" {if $blockedhost->getReason() == 1} selected="selected" {/if}>{$locale->tr("access_blocked")}</option>
-     <option value="2" {if $blockedhost->getReason() == 2} selected="selected" {/if}>{$locale->tr("posting_blocked")}</option>
-    </select>
-   </td>
-  </tr>
-  <tr>
-   <td class="alignright">{$locale->tr("reason")}: </td>
-   <td><input type="text" style="width:100%" name="reason" value="{$blockedhost->getReason()}"/></td>
-  </tr>
-  <tr>
-   <td>&nbsp;</td>
-   <td>
-    <input type="hidden" name="op" value="updateBlockedHost" />
-    <input type="hidden" name="hostId" value="{$blockedhost->getId()}" />
-    <input type="submit" name="Add" value="{$locale->tr("update")}"/>
-   </td>
-  </tr>
- </table>
+  </div>
+
+  <div class="field">
+   <label for="blockType">{$locale->tr("block_type")}</label>
+   <span class="required"></span>
+   <div class="formHelp">{$locale->tr("block_type_help")}</div>
+     <select name="blockType" id="blockType">
+     <option value="1" {if $blockedhost->getType() == 1} selected="selected" {/if}>{$locale->tr("access_blocked")}</option>
+     <option value="2" {if $blockedhost->getType() == 2} selected="selected" {/if}>{$locale->tr("posting_blocked")}</option>
+    </select> 
+  </div>
+
+  <div class="field">
+   <label for="reason">{$locale->tr("reason")}</label>
+   <span class="required"></span>
+   <div class="formHelp">{$locale->tr("reason_help")}</div>
+   <input type="text" name="reason" id="reason" value="{$blockedhost->getReason()}"/>
+  </div>
+
+ </fieldset>
+
+ <div class="buttons">
+  <input type="hidden" name="op" value="updateBlockedHost" />
+  <input type="hidden" name="hostId" value="{$blockedhost->getId()}" />
+  <input type="reset" name="reset" value="{$locale->tr("reset")}" />	
+  <input type="submit" name="Add" 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