[pLog-svn] r7130 - in plugins/branches/lifetype-1.2/templateeditor/class: . action misc
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Thu Sep 1 10:01:55 EDT 2011
Author: jondaley
Date: 2011-09-01 10:01:55 -0400 (Thu, 01 Sep 2011)
New Revision: 7130
Added:
plugins/branches/lifetype-1.2/templateeditor/class/misc/
plugins/branches/lifetype-1.2/templateeditor/class/misc/plugintemplatehelpers.class.php
Modified:
plugins/branches/lifetype-1.2/templateeditor/class/action/pluginblogcopytemplatefileaction.class.php
plugins/branches/lifetype-1.2/templateeditor/class/action/pluginblogcopytemplatesetaction.class.php
plugins/branches/lifetype-1.2/templateeditor/class/action/pluginbloguploadtemplatefileaction.class.php
plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsitecopytemplatefileaction.class.php
plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsitecopytemplatesetaction.class.php
plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsiteuploadtemplatefileaction.class.php
Log:
move duplicate code to templatehelpers class. use templatesetnamevalidator, in order to avoid the '..' case
Modified: plugins/branches/lifetype-1.2/templateeditor/class/action/pluginblogcopytemplatefileaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/templateeditor/class/action/pluginblogcopytemplatefileaction.class.php 2011-09-01 13:42:13 UTC (rev 7129)
+++ plugins/branches/lifetype-1.2/templateeditor/class/action/pluginblogcopytemplatefileaction.class.php 2011-09-01 14:01:55 UTC (rev 7130)
@@ -1,6 +1,7 @@
<?php
lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/misc/plugintemplatehelpers.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogtemplateslistview.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogtemplatesubfolderlistview.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/file/myfile.class.php" );
@@ -21,15 +22,19 @@
$this->AdminAction( $actionInfo, $request );
$this->requirePermission( "edit_blog_templates" );
+ // TODO: validate data!
}
function validate()
{
+ if(!parent::validate())
+ return false;
+
$this->_templateId = $this->_request->getValue( "templateId" );
$this->_subFolderId = $this->_request->getValue( "subFolderId" );
$this->_fileId = $this->_request->getValue( "fileId" );
$this->_newFileId = $this->_request->getValue( "newFileId" );
- if( !$this->isValidTemplateFileName( $this->_newFileId ) ) {
+ if( !PluginTemplateHelpers::isValidTemplateFileName( $this->_newFileId ) ) {
if ( empty($this->_subFolderId) ) {
$this->_view = new PluginBlogTemplatesListView( $this->_blogInfo, $this->_templateId );
} else {
@@ -40,7 +45,7 @@
return false;
}
- if( !$this->isValidExtension( $this->_newFileId ) ) {
+ if( !PluginTemplateHelpers::isValidExtension( $this->_newFileId ) ) {
if ( empty($this->_subFolderId) ) {
$this->_view = new PluginBlogTemplatesListView( $this->_blogInfo, $this->_templateId );
} else {
@@ -109,30 +114,6 @@
return true;
}
- function isValidTemplateFileName( $name )
- {
- $pattern = '/^[a-zA-Z0-9\._-]+$/';
- if (preg_match($pattern, $name) ) {
- return true;
- } else {
- return false;
- }
- }
-
- function isValidExtension( $name )
- {
- $config =& Config::getConfig();
- $allowedExtension = $config->getValue( "plugin_templateeditor_allowedextension" );
- $extensionList = explode(",", $allowedExtension);
- $fileExtension = array_pop(explode('.', $name));
- foreach ($extensionList as $extension) {
- if ( $fileExtension == trim($extension) ) {
- return true;
- }
- }
- return false;
- }
-
function getTemplateFiles( $folder ) {
$config =& Config::getConfig();
$allowedExtension = $config->getValue( "plugin_templateeditor_allowedextension" );
Modified: plugins/branches/lifetype-1.2/templateeditor/class/action/pluginblogcopytemplatesetaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/templateeditor/class/action/pluginblogcopytemplatesetaction.class.php 2011-09-01 13:42:13 UTC (rev 7129)
+++ plugins/branches/lifetype-1.2/templateeditor/class/action/pluginblogcopytemplatesetaction.class.php 2011-09-01 14:01:55 UTC (rev 7130)
@@ -4,7 +4,7 @@
lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogtemplatesetslistview.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/file/myfile.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/validator/templatenamevalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/templatesetnamevalidator.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/validator/integerrangevalidator.class.php" );
/**
@@ -18,8 +18,8 @@
$this->requirePermission( "edit_blog_templates" );
- $this->registerFieldValidator( "templateId", new TemplateNameValidator());
- $this->registerFieldValidator( "newTemplateId", new TemplateNameValidator());
+ $this->registerFieldValidator( "templateId", new TemplateSetNameValidator());
+ $this->registerFieldValidator( "newTemplateId", new TemplateSetNameValidator());
$this->registerFieldValidator( "type", new IntegerRangeValidator(1, 2));
$view = new PluginBlogTemplateSetsListView( $this->_blogInfo );
@@ -108,14 +108,5 @@
return true;
}
- function isValidTemplateSetName( $name )
- {
- $pattern = '/^[a-zA-Z0-9_-]*$/';
- if (preg_match($pattern, $name) ) {
- return true;
- } else {
- return false;
- }
- }
}
?>
Modified: plugins/branches/lifetype-1.2/templateeditor/class/action/pluginbloguploadtemplatefileaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/templateeditor/class/action/pluginbloguploadtemplatefileaction.class.php 2011-09-01 13:42:13 UTC (rev 7129)
+++ plugins/branches/lifetype-1.2/templateeditor/class/action/pluginbloguploadtemplatefileaction.class.php 2011-09-01 14:01:55 UTC (rev 7130)
@@ -2,6 +2,7 @@
lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/misc/plugintemplatehelpers.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogtemplateslistview.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginblogtemplatesubfolderlistview.class.php" );
@@ -41,7 +42,7 @@
return false;
}
- if( !$this->isValidExtension( $this->_files['resourceFile']['name'] ) ) {
+ if( !PluginTemplateHelpers::isValidExtension( $this->_files['resourceFile']['name'] ) ) {
if ( empty($this->_subFolderId) ) {
$this->_view = new PluginBlogTemplatesListView( $this->_blogInfo, $this->_templateId );
} else {
@@ -108,20 +109,5 @@
return true;
}
-
- function isValidExtension( $name )
- {
- $config =& Config::getConfig();
- $allowedExtension = $config->getValue( "plugin_templateeditor_allowedextension" );
- $allowedExtension = $allowedExtension . ",jpg,gif,png,bmp";
- $extensionList = explode(",", $allowedExtension);
- $fileExtension = array_pop(explode('.', $name));
- foreach ($extensionList as $extension) {
- if ( $fileExtension == trim($extension) ) {
- return true;
- }
- }
- return false;
- }
}
?>
\ No newline at end of file
Modified: plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsitecopytemplatefileaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsitecopytemplatefileaction.class.php 2011-09-01 13:42:13 UTC (rev 7129)
+++ plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsitecopytemplatefileaction.class.php 2011-09-01 14:01:55 UTC (rev 7130)
@@ -1,6 +1,7 @@
<?php
lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/misc/plugintemplatehelpers.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginsitetemplateslistview.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginsitetemplatesubfolderlistview.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/file/myfile.class.php" );
@@ -21,15 +22,20 @@
$this->AdminAction( $actionInfo, $request );
$this->requireAdminPermission( "edit_global_templates" );
+
+ // TODO: validate data!
}
function validate()
{
+ if(!parent::validate())
+ return false;
+
$this->_templateId = $this->_request->getValue( "templateId" );
$this->_subFolderId = $this->_request->getValue( "subFolderId" );
$this->_fileId = $this->_request->getValue( "fileId" );
$this->_newFileId = $this->_request->getValue( "newFileId" );
- if( !$this->isValidTemplateFileName( $this->_newFileId ) ) {
+ if( !PluginTemplateHelpers::isValidTemplateFileName( $this->_newFileId ) ) {
if ( empty($this->_subFolderId) ) {
$this->_view = new PluginSiteTemplatesListView( $this->_blogInfo, $this->_templateId );
} else {
@@ -40,7 +46,7 @@
return false;
}
- if( !$this->isValidExtension( $this->_newFileId ) ) {
+ if( !PluginTemplateHelpers::isValidExtension( $this->_newFileId ) ) {
if ( empty($this->_subFolderId) ) {
$view = new PluginSiteTemplatesListView( $this->_blogInfo, $this->_templateId );
} else {
@@ -109,33 +115,9 @@
return true;
}
- function isValidTemplateFileName( $name )
- {
- $pattern = '/^[a-zA-Z0-9\._-]+$/';
- if (preg_match($pattern, $name) ) {
- return true;
- } else {
- return false;
- }
- }
-
- function isValidExtension( $name )
- {
+ function getTemplateFiles( $folder ) {
$config =& Config::getConfig();
$allowedExtension = $config->getValue( "plugin_templateeditor_allowedextension" );
- $extensionList = explode(",", $allowedExtension);
- $fileExtension = array_pop(explode('.', $name));
- foreach ($extensionList as $extension) {
- if ( $fileExtension == trim($extension) ) {
- return true;
- }
- }
- return false;
- }
-
- function getTemplateFiles( $folder ) {
- $config =& Config::getConfig();
- $allowedExtension = $config->getValue( "plugin_templateeditor_allowedextension" );
if ( $allowedExtension == "" ) $allowedExtension = "css,inc,template,txt";
$extensionList = explode(",", $allowedExtension);
$templateFiles = Array();
Modified: plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsitecopytemplatesetaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsitecopytemplatesetaction.class.php 2011-09-01 13:42:13 UTC (rev 7129)
+++ plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsitecopytemplatesetaction.class.php 2011-09-01 14:01:55 UTC (rev 7130)
@@ -4,7 +4,7 @@
lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginsitetemplatesetslistview.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/file/myfile.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/validator/templatenamevalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/templatesetnamevalidator.class.php" );
/**
* Removes global templates from disk.
@@ -18,8 +18,8 @@
$this->requireAdminPermission( "edit_global_templates" );
- $this->registerFieldValidator( "templateId", new TemplateNameValidator());
- $this->registerFieldValidator( "newTemplateId", new TemplateNameValidator());
+ $this->registerFieldValidator( "templateId", new TemplateSetNameValidator());
+ $this->registerFieldValidator( "newTemplateId", new TemplateSetNameValidator());
$view = new PluginSiteTemplateSetsListView( $this->_blogInfo );
// Note, error message will be wrong if the type value is incorrect
@@ -74,18 +74,5 @@
return true;
}
- function isValidTemplateSetName( $name )
- {
- $pattern = '/^[a-zA-Z0-9_-]*$/';
- if (preg_match($pattern, $name) ) {
- if ( $name != "admin" && $name != "rss" && $name != "summary" && $name != "wizard" ) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
}
?>
Modified: plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsiteuploadtemplatefileaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsiteuploadtemplatefileaction.class.php 2011-09-01 13:42:13 UTC (rev 7129)
+++ plugins/branches/lifetype-1.2/templateeditor/class/action/pluginsiteuploadtemplatefileaction.class.php 2011-09-01 14:01:55 UTC (rev 7130)
@@ -2,6 +2,7 @@
lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/misc/plugintemplatehelpers.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginsitetemplateslistview.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/templateeditor/class/view/pluginsitetemplatesubfolderlistview.class.php" );
@@ -41,7 +42,7 @@
return false;
}
- if( !$this->isValidExtension( $this->_files['resourceFile']['name'] ) ) {
+ if( !PluginTemplateHelpers::$this->isValidExtension( $this->_files['resourceFile']['name'] ) ) {
if ( empty($this->_subFolderId) ) {
$this->_view = new PluginSiteTemplatesListView( $this->_blogInfo, $this->_templateId );
} else {
@@ -110,19 +111,5 @@
return true;
}
- function isValidExtension( $name )
- {
- $config =& Config::getConfig();
- $allowedExtension = $config->getValue( "plugin_templateeditor_allowedextension" );
- $allowedExtension = $allowedExtension . ",jpg,gif,png,bmp";
- $extensionList = explode(",", $allowedExtension);
- $fileExtension = array_pop(explode('.', $name));
- foreach ($extensionList as $extension) {
- if ( $fileExtension == trim($extension) ) {
- return true;
- }
- }
- return false;
- }
}
?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/templateeditor/class/misc/plugintemplatehelpers.class.php
===================================================================
--- plugins/branches/lifetype-1.2/templateeditor/class/misc/plugintemplatehelpers.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/templateeditor/class/misc/plugintemplatehelpers.class.php 2011-09-01 14:01:55 UTC (rev 7130)
@@ -0,0 +1,38 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+
+ /**
+ * Static class with various helper functions
+ */
+ class PluginTemplatetHelper
+ {
+ var $_templateId;
+
+ static function isValidExtension( $name )
+ {
+ $config =& Config::getConfig();
+ $allowedExtension = $config->getValue( "plugin_templateeditor_allowedextension" );
+ $allowedExtension = $allowedExtension . ",jpg,gif,png,bmp";
+ $extensionList = explode(",", $allowedExtension);
+ $fileExtension = array_pop(explode('.', $name));
+ foreach ($extensionList as $extension) {
+ if ( $fileExtension == trim($extension) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ static function isValidTemplateFileName( $name )
+ {
+ $pattern = '/^[a-zA-Z0-9\._-]+$/';
+ if (preg_match($pattern, $name) ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ }
\ No newline at end of file
More information about the pLog-svn
mailing list