[pLog-svn] r3257 - in plog/trunk/class: data/validator template
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Tue Apr 18 14:11:25 GMT 2006
Author: jondaley
Date: 2006-04-18 14:11:25 +0000 (Tue, 18 Apr 2006)
New Revision: 3257
Added:
plog/trunk/class/data/validator/templatesetvalidator.class.php
Removed:
plog/trunk/class/data/validator/templatevalidator.class.php
Modified:
plog/trunk/class/template/templatesandbox.class.php
Log:
rename templatevalidator to templatesetvalidator
Copied: plog/trunk/class/data/validator/templatesetvalidator.class.php (from rev 3249, plog/trunk/class/data/validator/templatevalidator.class.php)
===================================================================
--- plog/trunk/class/data/validator/templatevalidator.class.php 2006-04-14 12:41:28 UTC (rev 3249)
+++ plog/trunk/class/data/validator/templatesetvalidator.class.php 2006-04-18 14:11:25 UTC (rev 3257)
@@ -0,0 +1,85 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH.'class/data/validator/validator.class.php' );
+ include_once( PLOG_CLASS_PATH.'class/file/file.class.php' );
+
+ define( 'ERROR_TEMPLATE_NOT_INSIDE_FOLDER', -1 );
+ define( 'ERROR_MISSING_BASE_FILES', -2 );
+
+ /**
+ * This is a more complex Validator (and a very specific one) that will validate whether
+ * the contents of a given folder are the same of a valid template set. In order to be valid
+ * a template folder must contain the following template files:
+ *
+ * - main.template
+ * - postandcomments.template
+ * - commentarticle.template
+ * - posttrackbacks.template
+ * - error.template
+ * - album.template
+ * - albums.template
+ * - resource.template
+ *
+ * The template files should be inside a folder with the same name as template set.
+ *
+ * If the template set is not valid, this class will set one of the following errors:
+ *
+ * - ERROR_TEMPLATE_NOT_INSIDE_FOLDER
+ * - ERROR_MISSING_BASE_FILES
+ *
+ * This Validator class is also a good example of the more complex things that can be achieved
+ * with Validator classes, not just simple data validation.
+ */
+ class TemplateSetValidator extends Validator
+ {
+
+ var $_templateName;
+ var $_folder;
+ var $_fullName;
+
+ // these are the basic files that should be present in every
+ // template set
+ var $_basicFiles = Array( 'main.template',
+ 'postandcomments.template',
+ 'commentarticle.template',
+ 'posttrackbacks.template',
+ 'error.template',
+ 'album.template',
+ 'albums.template',
+ 'resource.template'
+ );
+
+
+ function TemplateSetValidator( $templateName, $folder )
+ {
+ $this->Validator();
+
+ $this->_templateName = $templateName;
+ $this->_folder = $folder;
+
+ $this->_fullName = $this->_folder;
+ if( $this->_fullName[strlen($this->_fullName)-1] != '/' )
+ $this->_fullName[strlen($this->_fullName)] = '/';
+ $this->_fullName .= $templateName.'/';
+ }
+
+ /**
+ * Returns true if the template is a valid template set
+ */
+ function validate()
+ {
+ // first of all, check that the folder exists
+ if( !File::isDir( $this->_fullName ))
+ return ERROR_TEMPLATE_NOT_INSIDE_FOLDER;
+
+ // now check that all the basic files are available
+ foreach( $this->_basicFiles as $basicFile ) {
+ if( !File::isReadable( $this->_fullName.$basicFile )) {
+ return ERROR_MISSING_BASE_FILES;
+ }
+ }
+
+ return true;
+ }
+ }
+?>
Deleted: plog/trunk/class/data/validator/templatevalidator.class.php
===================================================================
--- plog/trunk/class/data/validator/templatevalidator.class.php 2006-04-18 13:49:20 UTC (rev 3256)
+++ plog/trunk/class/data/validator/templatevalidator.class.php 2006-04-18 14:11:25 UTC (rev 3257)
@@ -1,85 +0,0 @@
-<?php
-
- include_once( PLOG_CLASS_PATH.'class/data/validator/validator.class.php' );
- include_once( PLOG_CLASS_PATH.'class/file/file.class.php' );
-
- define( 'ERROR_TEMPLATE_NOT_INSIDE_FOLDER', -1 );
- define( 'ERROR_MISSING_BASE_FILES', -2 );
-
- /**
- * This is a more complex Validator (and a very specific one) that will validate whether
- * the contents of a given folder are the same of a valid template set. In order to be valid
- * a template folder must contain the following template files:
- *
- * - main.template
- * - postandcomments.template
- * - commentarticle.template
- * - posttrackbacks.template
- * - error.template
- * - album.template
- * - albums.template
- * - resource.template
- *
- * The template files should be inside a folder with the same name as template set.
- *
- * If the template set is not valid, this class will set one of the following errors:
- *
- * - ERROR_TEMPLATE_NOT_INSIDE_FOLDER
- * - ERROR_MISSING_BASE_FILES
- *
- * This Validator class is also a good example of the more complex things that can be achieved
- * with Validator classes, not just simple data validation.
- */
- class TemplateValidator extends Validator
- {
-
- var $_templateName;
- var $_folder;
- var $_fullName;
-
- // these are the basic files that should be present in every
- // template set
- var $_basicFiles = Array( 'main.template',
- 'postandcomments.template',
- 'commentarticle.template',
- 'posttrackbacks.template',
- 'error.template',
- 'album.template',
- 'albums.template',
- 'resource.template'
- );
-
-
- function TemplateValidator( $templateName, $folder )
- {
- $this->Validator();
-
- $this->_templateName = $templateName;
- $this->_folder = $folder;
-
- $this->_fullName = $this->_folder;
- if( $this->_fullName[strlen($this->_fullName)-1] != '/' )
- $this->_fullName[strlen($this->_fullName)] = '/';
- $this->_fullName .= $templateName.'/';
- }
-
- /**
- * Returns true if the template is a valid template set
- */
- function validate()
- {
- // first of all, check that the folder exists
- if( !File::isDir( $this->_fullName ))
- return ERROR_TEMPLATE_NOT_INSIDE_FOLDER;
-
- // now check that all the basic files are available
- foreach( $this->_basicFiles as $basicFile ) {
- if( !File::isReadable( $this->_fullName.$basicFile )) {
- return ERROR_MISSING_BASE_FILES;
- }
- }
-
- return true;
- }
- }
-?>
Modified: plog/trunk/class/template/templatesandbox.class.php
===================================================================
--- plog/trunk/class/template/templatesandbox.class.php 2006-04-18 13:49:20 UTC (rev 3256)
+++ plog/trunk/class/template/templatesandbox.class.php 2006-04-18 14:11:25 UTC (rev 3257)
@@ -17,7 +17,7 @@
* means that everything happens in a random temporary folder and that in case of
* error, everything is removed from disk.
*
- * @see TemplateValidator
+ * @see TemplateSetValidator
*/
class TemplateSandbox
{
@@ -92,7 +92,7 @@
return TEMPLATE_SANDBOX_ERROR_UNPACKING;
}
- // if the file was correctly unpacked, now we will need the TemplateValidator
+ // if the file was correctly unpacked, now we will need the TemplateSetValidator
// class to do some work for us
$fileNameParts = explode( '.', $file );
$fileNameNoExt = $fileNameParts[0];
@@ -127,8 +127,8 @@
if( $templateFolder[strlen($templateFolder)-1] != '/')
$templateFolder .= '/';
- include_once( PLOG_CLASS_PATH.'class/data/validator/templatevalidator.class.php' );
- $tv = new TemplateValidator($templateName, $templateFolder );
+ include_once( PLOG_CLASS_PATH.'class/data/validator/templatesetvalidator.class.php' );
+ $tv = new TemplateSetValidator($templateName, $templateFolder );
if( ($errorCode = $tv->validate()) < 0 ) {
return $errorCode;
}
More information about the pLog-svn
mailing list