[pLog-svn] r4901 - in plog/trunk/class: action action/admin cache cache/Cache_Lite config controller dao dao/userdata data data/pager database file locale logger misc net net/http net/http/session object plugin security summary/action summary/view template/menu template/smarty template/smarty/internals template/smarty/plugins test/tests test/tests/dao test/tests/locale test/tests/logger test/tests/misc view view/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Thu Mar 1 08:45:38 EST 2007
Author: oscar
Date: 2007-03-01 08:45:38 -0500 (Thu, 01 Mar 2007)
New Revision: 4901
Added:
plog/trunk/class/locale/bloglocale.class.php
plog/trunk/class/test/tests/dao/trackbackclient_test.class.php
plog/trunk/class/test/tests/locale/
plog/trunk/class/test/tests/locale/locale_test.class.php
plog/trunk/class/test/tests/logger/
plog/trunk/class/test/tests/logger/loggerutil_test.class.php
plog/trunk/class/test/tests/misc/
plog/trunk/class/test/tests/misc/glob_test.class.php
Removed:
plog/trunk/class/logger/LogUtilTest.php
plog/trunk/class/test/tests/locale/locale_test.class.php
plog/trunk/class/test/tests/logger/loggerutil_test.class.php
plog/trunk/class/test/tests/misc/glob_test.class.php
Modified:
plog/trunk/class/action/action.class.php
plog/trunk/class/action/actioninfo.class.php
plog/trunk/class/action/admin/adminaddlocationajaxaction.class.php
plog/trunk/class/action/admin/adminupdatelocationajaxaction.class.php
plog/trunk/class/action/admin/adminupdateusersettingsaction.class.php
plog/trunk/class/action/blogaction.class.php
plog/trunk/class/action/rssaction.class.php
plog/trunk/class/cache/Cache_Lite/Lite.php
plog/trunk/class/cache/cache.class.php
plog/trunk/class/cache/cachemanager.class.php
plog/trunk/class/cache/memcache.class.php
plog/trunk/class/config/configdbstorage.class.php
plog/trunk/class/config/configfilestorage.class.php
plog/trunk/class/controller/controller.class.php
plog/trunk/class/controller/resourceclassloader.class.php
plog/trunk/class/dao/bloginfo.class.php
plog/trunk/class/dao/commentscommon.class.php
plog/trunk/class/dao/daocacheconstants.properties.php
plog/trunk/class/dao/model.class.php
plog/trunk/class/dao/trackbackclient.class.php
plog/trunk/class/dao/userdata/baseuserdataprovider.class.php
plog/trunk/class/dao/userdata/joomlauserdataprovider.class.php
plog/trunk/class/dao/userdata/lifetypeuserdataprovider.class.php
plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php
plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php
plog/trunk/class/dao/userdata/vbb3userdataprovider.class.php
plog/trunk/class/dao/userdata/wbbuserdataprovider.class.php
plog/trunk/class/dao/users.class.php
plog/trunk/class/data/pager/pager.class.php
plog/trunk/class/data/plogcalendar.class.php
plog/trunk/class/database/dbobject.class.php
plog/trunk/class/file/file.class.php
plog/trunk/class/locale/locale.class.php
plog/trunk/class/locale/locales.class.php
plog/trunk/class/misc/glob.class.php
plog/trunk/class/misc/osdetect.class.php
plog/trunk/class/net/baserequestgenerator.class.php
plog/trunk/class/net/customrequestgenerator.class.php
plog/trunk/class/net/http/httpcache.class.php
plog/trunk/class/net/http/session/sessioninfo.class.php
plog/trunk/class/net/linkparser.class.php
plog/trunk/class/net/modrewriterequestgenerator.class.php
plog/trunk/class/net/prettyrequestgenerator.class.php
plog/trunk/class/net/rawrequestgenerator.class.php
plog/trunk/class/net/request.class.php
plog/trunk/class/net/requestgenerator.class.php
plog/trunk/class/object/object.class.php
plog/trunk/class/plugin/eventlist.properties.php
plog/trunk/class/plugin/pluginbase.class.php
plog/trunk/class/plugin/pluginmanager.class.php
plog/trunk/class/security/pipeline.class.php
plog/trunk/class/security/pipelineresult.class.php
plog/trunk/class/summary/action/activeaccountaction.class.php
plog/trunk/class/summary/view/summaryuserlistview.class.php
plog/trunk/class/template/menu/menurenderer.class.php
plog/trunk/class/template/smarty/Config_File.class.php
plog/trunk/class/template/smarty/Smarty.class.php
plog/trunk/class/template/smarty/Smarty_Compiler.class.php
plog/trunk/class/template/smarty/debug.tpl
plog/trunk/class/template/smarty/internals/core.write_file.php
plog/trunk/class/template/smarty/plugins/function.html_select_date.php
plog/trunk/class/template/smarty/plugins/function.html_table.php
plog/trunk/class/template/smarty/plugins/function.mailto.php
plog/trunk/class/template/smarty/plugins/function.pager.php
plog/trunk/class/template/smarty/plugins/modifier.capitalize.php
plog/trunk/class/template/smarty/plugins/modifier.date_format.php
plog/trunk/class/template/smarty/plugins/modifier.debug_print_var.php
plog/trunk/class/template/smarty/plugins/outputfilter.trimwhitespace.php
plog/trunk/class/view/admin/adminsiteuserslistview.class.php
plog/trunk/class/view/admin/admintemplatedview.class.php
plog/trunk/class/view/blogview.class.php
plog/trunk/class/view/defaultview.class.php
plog/trunk/class/view/errorview.class.php
Log:
I wonder how on Earth I managed to forget to check in the class/ folder after the merge from 1.2...
Modified: plog/trunk/class/action/action.class.php
===================================================================
--- plog/trunk/class/action/action.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/action/action.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -272,42 +272,7 @@
return true;
}
- /**
- * after executing the current action we will not show the results but
- * transfer the execution flow to another action. In other words, the Controller
- * will detect that the processing is being passed to another Action class and
- * instead of calling Action::getView() right after Action::perform() it will
- * call the perform() method of the next action in the flow. It is only possible
- * to specify one action to forward to at a time, but this feature can be used
- * as many times as needed.
- *
- * @param actionKey The key of the action to which we're forwarding the process flow. This
- * is <b>not</b> the class name of the action but the <b>key</b> name to which the
- * action class has been assigned.
- * @return Always true
- */
- function setForwardAction( $nextActionKey )
- {
- Controller::setForwardAction( $nextActionKey, $this );
-
- return true;
- }
-
/**
- * sets a parameter in the session... or in other words, make it available
- * for the next coming action.
- *
- * @param param
- * @param value
- * @return Always true
- * @private
- */
- function setForwardActionParameter( $param, $value )
- {
- return true;
- }
-
- /**
* This method can be used to trigger validation errors even if they did not really happen, or
* to disable errors if they happened.
*
Modified: plog/trunk/class/action/actioninfo.class.php
===================================================================
--- plog/trunk/class/action/actioninfo.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/action/actioninfo.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,7 +1,5 @@
<?php
-
-
/**
* \ingroup Action
*
@@ -11,6 +9,9 @@
*/
class ActionInfo
{
+
+ var $_actionParamName;
+ var $_actionParamValue;
/**
* Constructor.
@@ -28,9 +29,7 @@
* action.
*/
function ActionInfo( $actionParamName, $actionParamValue )
- {
-
-
+ {
$this->_actionParamName = $actionParamName;
$this->_actionParamValue = $actionParamValue;
}
Modified: plog/trunk/class/action/admin/adminaddlocationajaxaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddlocationajaxaction.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/action/admin/adminaddlocationajaxaction.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,40 +1,29 @@
<?php
- lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/action/admin/ajax/adminajaxaction.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
- lt_include( PLOG_CLASS_PATH."class/view/admin/adminxmlview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/locations.class.php" );
/**
* \ingroup Action
* @private
*/
- class AdminAddLocationAjaxAction extends AdminAction
+ class AdminAddLocationAjaxAction extends AdminAjaxAction
{
function AdminAddLocationAjaxAction( $actionInfo, $request )
{
$this->AdminAction( $actionInfo, $request );
- $this->registerFieldValidator( "id", new IntegerValidator());
$this->registerFieldValidator( "lat", new StringValidator());
$this->registerFieldValidator( "long", new StringValidator());
$this->registerFieldValidator( "desc", new StringValidator());
- $this->setValidationErrorView( $this->_getErrorView());
+ $this->setValidationErrorView( $this->getErrorView( $this->_locale->tr("error_adding_location" )));
}
- function _getErrorView()
+ function perform()
{
- $view = new AdminXmlView( $this->_blogInfo, "response" );
- $view->setValue( "method", "addLocationAjax" );
- $view->setValue( "success", "0" );
- $view->setValue( "message", $this->_locale->tr("error_adding_location" ));
-
- return( $view );
- }
-
- function validate()
- {
// load data from the request
$lat = $this->_request->getValue( "lat" );
$long = $this->_request->getValue( "long" );
@@ -52,18 +41,18 @@
$locations = new Locations();
$res = $locations->addLocation( $loc );
if( !$res ) {
- $this->_view = $this->_getErrorView();
+ $this->_view = $this->getErrorView( $this->_locale->tr("error_adding_location" ));
$this->setCommonData();
return( false );
}
// everything went fine, we can send the confirmation
- $this->_view = new AdminXmlView( $this->_blogInfo, "response" );
+ $this->_view = new AdminAjaxView( $this->_blogInfo, "response" );
$this->_view->setValue( "method", "addLocationAjax" );
$this->_view->setValue( "success", "1" );
$this->_view->setValue( "message", $this->_locale->tr("location_added_ok" ));
- $this->_view->setValue( "result", $loc->toXml());
+ $this->_view->setValue( "result", $loc );
return true;
}
Modified: plog/trunk/class/action/admin/adminupdatelocationajaxaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdatelocationajaxaction.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/action/admin/adminupdatelocationajaxaction.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,42 +1,32 @@
<?php
- lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/action/admin/ajax/adminajaxaction.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
- lt_include( PLOG_CLASS_PATH."class/view/admin/adminxmlview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/locations.class.php" );
/**
* \ingroup Action
* @private
*/
- class AdminUpdateLocationAjaxAction extends AdminAction
+ class AdminUpdateLocationAjaxAction extends AdminAjaxAction
{
function AdminUpdateLocationAjaxAction( $actionInfo, $request )
{
- $this->AdminAction( $actionInfo, $request );
+ $this->AdminAjaxAction( $actionInfo, $request );
- $this->registerFieldValidator( "id", new IntegerValidator());
+ $this->registerFieldValidator( "locId", new IntegerValidator());
$this->registerFieldValidator( "lat", new StringValidator());
$this->registerFieldValidator( "long", new StringValidator());
$this->registerFieldValidator( "desc", new StringValidator());
- $this->setValidationErrorView( $this->_getErrorView());
+ $this->setValidationErrorView( $this->getErrorView($this->_locale->tr("error_updating_location" )));
}
- function _getErrorView()
+ function perform()
{
- $view = new AdminXmlView( $this->_blogInfo, "response" );
- $view->setValue( "method", "updateLocationAjax" );
- $view->setValue( "success", "0" );
- $view->setValue( "message", $this->_locale->tr("error_updating_location" ));
-
- return( $view );
- }
-
- function validate()
- {
// load data from the request
- $id = $this->_request->getValue( "locId" );
+ $id = $this->_request->getValue( "locId" );
$lat = $this->_request->getValue( "lat" );
$long = $this->_request->getValue( "long" );
$desc = $this->_request->getValue( "desc" );
@@ -45,14 +35,14 @@
$locations = new Locations();
$loc = $locations->getLocation( $id );
if( !$loc ) {
- $this->_view = $this->_getErrorView();
+ $this->_view = $this->getErrorView( $this->_locale->tr("error_updating_location" ));
$this->setCommonData();
return( false );
}
// check if the location belongs to the blog
if( $loc->getBlogId() != $this->_blogInfo->getId()) {
- $this->_view = $this->_getErrorView();
+ $this->_view = $this->getErrorView( $this->_locale->tr("error_updating_location" ));
$this->setCommonData();
return( false );
}
@@ -63,17 +53,15 @@
$loc->setLongitude( $long );
$res = $locations->updateLocation( $loc );
- $this->_view = new AdminXmlView( $this->_blogInfo, "response" );
- $this->_view->setValue( "method", "updateLocationAjax" );
+ $this->_view = new AdminAjaxView( $this->_blogInfo, "updateLocationAjax" );
if( $res ) {
- $this->_view->setValue( "success", "1" );
- $this->_view->setValue( "message", $this->_locale->tr("location_updated_ok" ));
- $this->_view->setValue( "result", $loc->toXml());
+ $this->_view->setSuccess( true );
+ $this->_view->setMessage( $this->_locale->tr("location_updated_ok" ));
+ $this->_view->setResult( $loc );
}
- else
- {
- $this->_view->setValue( "success", "0" );
- $this->_view->setValue( "message", $this->_locale->tr("error_updating_location" ));
+ else {
+ $this->_view->setSuccess( false );
+ $this->_view->setMessage( $this->_locale->tr("error_updating_location" ));
}
return true;
Modified: plog/trunk/class/action/admin/adminupdateusersettingsaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateusersettingsaction.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/action/admin/adminupdateusersettingsaction.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -49,18 +49,20 @@
$this->_userPassword = trim($this->_request->getValue( "userSettingsPassword" ));
$this->_userConfirmPassword = trim($this->_request->getValue( "confirmPassword" ));
- $valid = parent::validate();
+ $valid = parent::validate();
// check that the password is correct and confirm it
if( $this->_userPassword != "" ) {
$passwordVal = new PasswordValidator();
if( !$passwordVal->validate( $this->_userPassword )) {
$this->_form->setFieldValidationStatus( "userSettingsPassword", false );
+ $this->_view = $this->_validationErrorView;
$this->setCommonData( true );
return false;
}
if( $this->_userPassword != $this->_userConfirmPassword ) {
$this->_form->setFieldValidationStatus( "confirmPassword", false );
+ $this->_view = $this->_validationErrorView;
$this->setCommonData( true );
return false;
}
Modified: plog/trunk/class/action/blogaction.class.php
===================================================================
--- plog/trunk/class/action/blogaction.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/action/blogaction.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -74,7 +74,7 @@
$this->_pm->setUserInfo( $this->_userInfo );
// locale
- $this->_locale = $this->_blogInfo->getLocale();
+ $this->_locale = $this->_blogInfo->getBlogLocale();
//
// security stuff
Modified: plog/trunk/class/action/rssaction.class.php
===================================================================
--- plog/trunk/class/action/rssaction.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/action/rssaction.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -22,9 +22,14 @@
function RssAction( $blogInfo, $request )
{
$this->BlogAction( $blogInfo, $request );
-
+
$this->registerFieldValidator( "categoryId", new IntegerValidator(), true );
- $this->registerFieldValidator( "profile", new StringValidator(), true );
+
+ // create a StringValidator and add an extra rule to make sure that the input string contains only
+ // alphanumeric characters
+ $profileValidator = new StringValidator();
+ $profileValidator->addRule( new RegexpRule( "^([a-zA-Z0-9]*)$" ));
+ $this->registerFieldValidator( "profile", $profileValidator, true );
// generate a dummy view with nothing in it to signal an error
$view = new RssView( $this->_blogInfo, RSS_VIEW_DEFAULT_PROFILE );
@@ -51,8 +56,8 @@
// fetch the articles for the given blog
$blogSettings = $this->_blogInfo->getSettings();
- $localeCode = $blogSettings->getValue( "locale" );
+
// fetch the default profile as chosen by the administrator
$defaultProfile = $this->_config->getValue( "default_rss_profile" );
if( $defaultProfile == "" || $defaultProfile == null )
@@ -63,6 +68,11 @@
// use the default profile as configured
$profile = $this->_request->getValue( "profile" );
if( $profile == "" ) $profile = $defaultProfile;
+
+ // sanitize the profile variable
+ $profile = str_replace( ".", "", $profile );
+ $profile = str_replace( "/", "", $profile );
+ $profile = str_replace( "%", "", $profile );
// fetch the category, or set it to '0' otherwise, which will mean
// fetch all the most recent posts from any category
@@ -87,11 +97,7 @@
$articles = new Articles();
- // create an instance of a locale object
- $locale = Locales::getLocale( $localeCode );
-
// fetch the posts, though we are going to fetch the same amount in both branches
-
$hardLimit = SiteConfig::getHardRecentPostsMax();
$amount = $blogSettings->getValue( "recent_posts_max", 15 );
if( $amount > $hardLimit ) $amount = $hardLimit;
@@ -130,7 +136,7 @@
array_push( $articles, $article );
}
- $this->_view->setValue( "locale", $locale );
+ $this->_view->setValue( "locale", $this->_locale );
$this->_view->setValue( "posts", $articles );
$this->setCommonData();
Modified: plog/trunk/class/cache/Cache_Lite/Lite.php
===================================================================
--- plog/trunk/class/cache/Cache_Lite/Lite.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/cache/Cache_Lite/Lite.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,7 +1,5 @@
<?php
-lt_include( PLOG_CLASS_PATH."class/object/loggable.class.php" );
-
/**
* \ingroup Cache
*
@@ -30,7 +28,7 @@
define('CACHE_LITE_ERROR_RETURN', 1);
define('CACHE_LITE_ERROR_DIE', 8);
-class Cache_Lite extends Loggable
+class Cache_Lite
{
// --- Private properties ---
@@ -283,7 +281,6 @@
*/
function Cache_Lite($options = array(NULL))
{
- $this->Loggable();
foreach($options as $key => $value) {
$this->setOption($key, $value);
}
@@ -538,7 +535,9 @@
*/
function raiseError($msg, $code)
{
- $this->log->error($msg, LOGGER_PRIO_ERROR);
+ lt_include( PLOG_CLASS_PATH."class/object/loggable.class.php" );
+ $log =& LoggerManager::getLogger();
+ $log->error($msg, LOGGER_PRIO_ERROR);
}
/**
Modified: plog/trunk/class/cache/cache.class.php
===================================================================
--- plog/trunk/class/cache/cache.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/cache/cache.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -28,9 +28,6 @@
class Cache
{
var $cache;
-
- var $_disabledCacheCategories = array();
-
var $lifeTime;
/**
@@ -43,7 +40,6 @@
require_once( PLOG_CLASS_PATH . "class/cache/Cache_Lite/Lite.php" );
$this->cache = new Cache_Lite( $cacheProperties );
-
$this->lifeTime = $cacheProperties['lifeTime'];
}
@@ -70,11 +66,8 @@
*/
function setData( $id, $group, $data )
{
- if( $this->_cacheCategoryEnabled($group) ) {
- $this->cache->setLifeTime( $this->lifeTime );
- return $this->cache->save( $data, $id, "$group" );
- } else
- return true;
+ $this->cache->setLifeTime( $this->lifeTime );
+ return $this->cache->save( $data, $id, "$group" );
}
/**
@@ -91,24 +84,19 @@
*/
function setMultipleData( $id, $group, $data )
{
- if( $this->_cacheCategoryEnabled($group) ) {
-
- $currentData = $this->getData( $id, $group );
- if( !$currentData ) $currentData = Array();
+ $currentData = $this->getData( $id, $group );
+ if( !$currentData ) $currentData = Array();
- /**
- * :TODO:
- * It's clear that we're only going to cache DbObjects using this method
- * but what happens if we don't? Should we force developers to provide a method
- * to uniquely identify their own objects? We definitely need a unique id here so that
- * the array doesn't grow forever...
- */
- $currentData[$data->getId()] = $data;
+ /**
+ * :TODO:
+ * It's clear that we're only going to cache DbObjects using this method
+ * but what happens if we don't? Should we force developers to provide a method
+ * to uniquely identify their own objects? We definitely need a unique id here so that
+ * the array doesn't grow forever...
+ */
+ $currentData[$data->getId()] = $data;
- return $this->cache->save( $currentData, $id, "$group" );
- } else
- return true;
-
+ return $this->cache->save( $currentData, $id, "$group" );
}
/**
@@ -123,25 +111,18 @@
global $__cache_hits;
global $__cache_queries;
global $__cache_misses;
-
- if( $this->_cacheCategoryEnabled($group) ) {
+ $__cache_queries++;
- $__cache_queries++;
+ $data = $this->cache->get( $id, $group );
- $data = $this->cache->get( $id, $group );
-
- if ($data) {
- $__cache_hits++;
- }
- else {
- $__cache_misses++;
- }
-
- return $data;
- } else {
- return false;
+ if ($data) {
+ $__cache_hits++;
}
+ else {
+ $__cache_misses++;
+ }
+ return $data;
}
/**
@@ -153,10 +134,7 @@
*/
function removeData( $id, $group )
{
- if( $this->_cacheCategoryEnabled($group) ) {
- return $this->cache->remove( $id, $group );
- } else
- return true;
+ return $this->cache->remove( $id, $group );
}
/**
@@ -167,10 +145,7 @@
*/
function clearCacheByGroup( $group )
{
- if( $this->_cacheCategoryEnabled($group) ) {
- return $this->cache->clean( $group );
- } else
- return true;
+ return $this->cache->clean( $group );
}
/**
@@ -194,34 +169,6 @@
{
$this->cache->cacheDir = $temp_folder;
}
-
- /**
- * Disables caching for one whole category
- *
- * @param category The category for which we're disabling caching
- * @return Always true
- */
- function disableCacheForCategory( $category )
- {
- $this->_disabledCacheCategories = array_merge( $this->_disabledCacheCategories,
- array($category) );
- return true;
- }
-
- /**
- * Returns true if the given caching category is enabled
- *
- * @param category The cache category we'd like to check
- * @return True if it is enabled or false otherwise
- * @private
- */
- function _cacheCategoryEnabled( $category )
- {
- if( in_array($category, $this->_disabledCacheCategories) ) {
- return false;
- } else
- return true;
- }
/**
* Returns the total count of cache hits, miss and total queries over the lifetime of the
Modified: plog/trunk/class/cache/cachemanager.class.php
===================================================================
--- plog/trunk/class/cache/cachemanager.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/cache/cachemanager.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -11,8 +11,6 @@
*/
class CacheManager
{
- var $cache;
-
/**
* Returns an instance of the cache.
*
@@ -42,7 +40,7 @@
);
// build a new cache object
- $cache =& new MemCache( $cacheParameter);
+ $cache = new MemCache( $cacheParameter);
}
else {
require_once( PLOG_CLASS_PATH . "class/cache/cache.class.php" );
@@ -57,7 +55,7 @@
);
// build a new cache object
- $cache =& new Cache( $cacheParameter);
+ $cache = new Cache( $cacheParameter);
}
}
return $cache;
Modified: plog/trunk/class/cache/memcache.class.php
===================================================================
--- plog/trunk/class/cache/memcache.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/cache/memcache.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,7 +1,5 @@
<?php
- lt_include( PLOG_CLASS_PATH . "class/object/loggable.class.php" );
-
$__memcache_hits = 0;
$__memcache_misses = 0;
$__memcache_queries = 0;
@@ -11,7 +9,7 @@
*
* Support for caching via memcached
*/
- class MemCache extends Loggable
+ class MemCache
{
var $cache;
var $lifeTime;
@@ -21,7 +19,6 @@
function MemCache( $cacheProperties )
{
require_once( PLOG_CLASS_PATH . "class/cache/Memcached_Client/memcached-client.php" );
- $this->Loggable();
$this->cache = new memcached( $cacheProperties );
$this->lifeTime = $cacheProperties['life_time'];
@@ -34,12 +31,8 @@
function setData( $id, $group, $data )
{
- if( $this->_cacheCategoryEnabled($group) ) {
- $this->log->debug("Caching $id ($group):" . $data , LOGGER_PRIO_INFO );
- $key = $this->getKey( $id, $group );
- return $this->cache->set( $key, $data, $this->lifeTime );
- } else
- return true;
+ $key = $this->getKey( $id, $group );
+ return $this->cache->set( $key, $data, $this->lifeTime );
}
/**
@@ -49,25 +42,19 @@
*/
function setMultipleData( $id, $group, $data )
{
- if( $this->_cacheCategoryEnabled($group) ) {
- $this->log->debug("Multiple Caching $id ($group):" . $data , LOGGER_PRIO_INFO );
+ $currentData = $this->getData( $id, $group );
+ if( !$currentData ) $currentData = Array();
- $currentData = $this->getData( $id, $group );
- if( !$currentData ) $currentData = Array();
-
- /**
- * :TODO:
- * It's clear that we're only going to cache DbObjects using this method
- * but what happens if we don't? Should we force developers to provide a method
- * to uniquely identify their own objects? We definitely need a unique id here so that
- * the array doesn't grow forever...
- */
- $currentData[$data->getId()] = $data;
-
- return $this->setData( $id, "$group", $currentData );
- } else
- return true;
-
+ /**
+ * :TODO:
+ * It's clear that we're only going to cache DbObjects using this method
+ * but what happens if we don't? Should we force developers to provide a method
+ * to uniquely identify their own objects? We definitely need a unique id here so that
+ * the array doesn't grow forever...
+ */
+ $currentData[$data->getId()] = $data;
+
+ return $this->setData( $id, "$group", $currentData );
}
function getData( $id, $group )
@@ -76,67 +63,37 @@
global $__memcache_queries;
global $__memcache_misses;
- if( $this->_cacheCategoryEnabled($group) ) {
-
- $__memcache_queries++;
+ $__memcache_queries++;
- $key = $this->getKey( $id, $group );
- $data = $this->cache->get( $key );
+ $key = $this->getKey( $id, $group );
+ $data = $this->cache->get( $key );
- if ($data) {
- $this->log->debug("Cache hit for $id ($group): $data", LOGGER_PRIO_INFO );
- $__memcache_hits++;
- }
- else {
- $this->log->debug("Cache miss for $id ($group)", LOGGER_PRIO_WARN );
- $__memcache_misses++;
- }
-
- return $data;
- } else {
- return false;
+ if ($data) {
+ $__memcache_hits++;
}
+ else {
+ $__memcache_misses++;
+ }
+ return $data;
}
function removeData( $id, $group )
{
- if( $this->_cacheCategoryEnabled($group) ) {
- $this->log->debug("Removing from cache $id ($group)", LOGGER_PRIO_WARN );
- $key = $this->getKey( $id, $group );
- return $this->cache->delete( $key, $group );
- } else
- return true;
+ $key = $this->getKey( $id, $group );
+ return $this->cache->delete( $key, $group );
}
function clearCacheByGroup( $group )
{
- $this->log->debug( "Removing cache group does not implement in Memcached Client yet." );
return true;
}
function clearCache()
{
- $this->log->debug("Cleaning the cache", LOGGER_PRIO_WARN );
return $this->cache->flush_all();
}
- function disableCacheForCategory( $category )
- {
- $this->_disabledCacheCategories = array_merge( $this->_disabledCacheCategories,
- array($category) );
- return true;
- }
-
- function _cacheCategoryEnabled( $category )
- {
- if( in_array($category, $this->_disabledCacheCategories) ) {
- $this->log->debug("Caching category $group disabled", LOGGER_PRIO_INFO );
- return false;
- } else
- return true;
- }
-
/**
* returns the total count of cache hits, miss and total queries over the lifetime of the
* script so far.
Modified: plog/trunk/class/config/configdbstorage.class.php
===================================================================
--- plog/trunk/class/config/configdbstorage.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/config/configdbstorage.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -50,9 +50,15 @@
function ConfigDbStorage()
{
$this->_cache =& CacheManager::getCache();
+
+ // load data from the databas, but only if it was already not in the cache
+ if( (!$this->_data = $this->_cache->getData( CACHE_CONFIGDBSTORAGE, CACHE_GLOBAL ))) {
+ $this->_loadAllValuesFromDatabase();
+ }
}
- function _loadAllValuesFromDatabase() {
+ function _loadAllValuesFromDatabase()
+ {
// initialize the database
$this->_initializeDatabase();
@@ -67,7 +73,8 @@
* Initialize the Database to allow db access
*
*/
- function _initializeDatabase() {
+ function _initializeDatabase()
+ {
if ($this->_db == null) {
// source the neccessary class files
lt_include( PLOG_CLASS_PATH."class/database/db.class.php" );
@@ -127,18 +134,6 @@
*/
function getValue( $key, $defaultValue = null )
{
- if (!is_object( $this->_cache )) {
- $this->_cache =& CacheManager::getCache();
- }
- if($this->_data == array()) {
- $data = $this->_data = $this->_cache->getData( CACHE_CONFIGDBSTORAGE, CACHE_GLOBAL );
- if ($data) {
- $this->_data = $data;
- } else {
- $this->_loadAllValuesFromDatabase();
- }
- }
-
if( array_key_exists($key, $this->_data) ) {
if ($this->_data[$key] == "" || $this->_data[$key] == null) {
return $defaultValue;
@@ -364,4 +359,4 @@
return $result;
}
}
-?>
+?>
\ No newline at end of file
Modified: plog/trunk/class/config/configfilestorage.class.php
===================================================================
--- plog/trunk/class/config/configfilestorage.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/config/configfilestorage.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -138,7 +138,6 @@
*/
function _getDataString( $data )
{
- //print("data = $data<br/>");
if( $this->_getType( $data ) == TYPE_INTEGER ) {
$dataString = $data;
}
@@ -168,8 +167,6 @@
$dataString[strlen($dataString)-1] = ")";
else
$dataString .= ")";
-
- // print("dataString = ".$dataString."<br/>");
}
elseif( $this->_getType( $data ) == TYPE_OBJECT ) {
$dataString = serialize( $data );
@@ -296,7 +293,6 @@
function save()
{
foreach( $this->_props->getAsArray() as $key => $value ) {
- //print("saving: $key - ".htmlspecialchars($value)."<br/>");
$this->saveValue( $key, $value );
}
Modified: plog/trunk/class/controller/controller.class.php
===================================================================
--- plog/trunk/class/controller/controller.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/controller/controller.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -132,6 +132,16 @@
* @private
*/
var $_cannotPerformAction;
+
+ /**
+ * @private
+ */
+ var $_forwardAction;
+
+ /**
+ * @private
+ */
+ var $_loader;
/**
* $ActionsMap is an associative array of the form:
Modified: plog/trunk/class/controller/resourceclassloader.class.php
===================================================================
--- plog/trunk/class/controller/resourceclassloader.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/controller/resourceclassloader.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,5 +1,7 @@
<?php
+ define("DEFAULT_CLASSFILE_SUFFIX", ".class.php");
+
/**
* \ingroup Controller
*
@@ -29,10 +31,8 @@
* @param classFileSuffix default suffix that each class file will have. It defaults to
* ".class.php"
*/
- function ResourceClassLoader( $path = "./", $classFileSuffix = '.class.php' )
+ function ResourceClassLoader( $path = "./", $classFileSuffix = DEFAULT_CLASSFILE_SUFFIX )
{
-
-
$this->_paths = Array( $path );
$this->_classFileSuffix = $classFileSuffix;
}
@@ -101,11 +101,14 @@
*/
function load( $actionClassName )
{
+ lt_include(PLOG_CLASS_PATH . "class/file/file.class.php");
+
//foreach( $this->_paths as $path ) {
$i = 0;
$loaded = false;
- while( ($i < count( $this->_paths )) && !$loaded ) {
+ $numPaths = count( $this->_paths );
+ while( ($i < $numPaths ) && !$loaded ) {
// get the current folder
$path = $this->_paths[$i];
// build up the file name
Modified: plog/trunk/class/dao/bloginfo.class.php
===================================================================
--- plog/trunk/class/dao/bloginfo.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/bloginfo.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -34,6 +34,7 @@
// the Locale object
var $_locale;
+ var $_blogLocale;
// the status
var $_status;
@@ -491,6 +492,17 @@
return $this->_locale;
}
+ function &getBlogLocale()
+ {
+ if( $this->_blogLocale === null ) {
+ lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
+ $this->_blogLocale =& Locales::getBlogLocale( $this->getSetting( "locale" ), "en_UK" );
+ }
+
+ return $this->_blogLocale;
+ }
+
+
/**
* sets the new locale for the blog
*
Modified: plog/trunk/class/dao/commentscommon.class.php
===================================================================
--- plog/trunk/class/dao/commentscommon.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/commentscommon.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -107,69 +107,36 @@
$page = -1,
$itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
- if( $order == COMMENT_ORDER_NEWEST_FIRST ){
- $order = Array( "date" => "DESC" );
- $cache_item = CACHE_ARTICLE_COMMENTS_BYARTICLE_NEWEST_TO_OLDEST;
- }
- else{
- $order = Array( "date" => "ASC" );
- $cache_item = CACHE_ARTICLE_COMMENTS_BYARTICLE_OLDEST_TO_NEWEST;
- }
-
- $comments = $this->getMany( "article_id",
- $artid,
- $cache_item,
- Array(),
- $order,
- "",
- $page,
- $itemsPerPage );
+ $query = "SELECT * FROM ".$this->getPrefix()."articles_comments ".
+ "WHERE article_id = '".Db::qstr( $artid )."'";
+
+ if( $status != COMMENT_STATUS_ALL )
+ $query .= "AND status = '".Db::qstr( $status )."'";
+
+ if( $type != COMMENT_TYPE_ANY )
+ $query .= " AND type = '".Db::qstr( $type )."'";
+
+ if( $order == COMMENT_ORDER_NEWEST_FIRST )
+ $query .= " ORDER BY date DESC";
+ else
+ $query .=" ORDER BY date ASC";
+
+ $result = $this->Execute( $query, $page, $itemsPerPage );
+
+ if( !$result )
+ return( Array());
- $result = Array();
+ $results = Array();
- if( $comments ) {
- // load the post to get the blog in order to get the time difference
- $articles = new Articles();
- $article = $articles->getArticle( $artid );
- $blog = $article->getBlogInfo();
- $blogSettings = $blog->getSettings();
- $timeDiff = $blogSettings->getValue( "time_offset" );
- lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
- foreach( $comments as $comment ) {
- if( $this->check( $comment, $type, $status )) {
- $result[] = $comment;
- }
- }
+ while( $row = $result->FetchRow()) {
+ $results[] = $this->mapRow( $row );
}
- else
- $result = Array();
- return( $result );
+ return( $results );
}
/**
- * @param comment
- * @param type
- * @param status
- * @private
- */
- function check( $comment, $type, $status )
- {
- if( $type != COMMENT_TYPE_ANY ) {
- if( $comment->getType() != $type ) {
- return false;
- }
- }
-
- if( $status != COMMENT_STATUS_ALL )
- if( $comment->getStatus() != $status )
- return false;
-
- return( true );
- }
-
- /**
* Returns the total number of comments for a post
*
* @param artId the post id
Modified: plog/trunk/class/dao/daocacheconstants.properties.php
===================================================================
--- plog/trunk/class/dao/daocacheconstants.properties.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/daocacheconstants.properties.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -106,6 +106,7 @@
* locales
*/
define( "CACHE_LOCALES", "locales" );
+ define( "CACHE_BLOG_LOCALES", "bloglocales" );
/**
* permissions
Modified: plog/trunk/class/dao/model.class.php
===================================================================
--- plog/trunk/class/dao/model.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/model.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -42,8 +42,6 @@
*
*/
- lt_include( PLOG_CLASS_PATH."class/object/loggable.class.php" );
-
/**
* default database prefix, if none other specified
*/
@@ -88,7 +86,7 @@
* worry about that. Later on, the Model classes will be used by
* the corresponding action object.
*/
- class Model extends Loggable
+ class Model
{
var $_db;
@@ -104,8 +102,6 @@
*/
function Model( $cacheEnabled = DATA_CACHE_ENABLED )
{
- $this->Loggable();
-
// allow a cache for all dao objects
lt_include( PLOG_CLASS_PATH . "class/cache/cachemanager.class.php" );
$this->_cache =& CacheManager::getCache( $cacheEnabled );
Modified: plog/trunk/class/dao/trackbackclient.class.php
===================================================================
--- plog/trunk/class/dao/trackbackclient.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/trackbackclient.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -47,8 +47,6 @@
$regexp ="/<rdf:RDF.*?<\/rdf:RDF>/s";
$links = preg_match_all( $regexp, $page, $out, PREG_SET_ORDER );
- //print_r($out);
-
$links = Array();
foreach( $out as $result ) {
// we have to get now from within the rdf code the following identifiers:
@@ -59,35 +57,21 @@
$dcIdentifier = $dc_ident[1];
// get the trackback:ping
- if(preg_match( "/trackback:ping=\"([^\"]+)\"/", $result[0], $tb_ping))
+ if(preg_match( "/trackback:ping=\"([^\"]+)\"/", $result[0], $tb_ping)) {
$tbPing = $tb_ping[1];
- else {
- // as a fallback plan, try to get the "about"
- if(preg_match( "/about=\"([^\"]+)\"/", $result[0], $tb_ping))
- $tbPing = $tb_ping[1];
- }
- //print("dc:identifier--> ".$dcIdentifier."<br/>");
- //print("trackback:ping-->".$tbPing."<br/>");
- //print("page:".$pageUrl."<br/>");
-
- // oddly enough, we could not find anything despite the presence
- // of the rdf:RDF tag...
- if( $tbPing=="")
- return;
-
- // if we provided the url of the page, we have a mechanism to make sure
- // that we are fetching the right trackback ping
- if( $pageUrl != "" ) {
- if( $dcIdentifier == $pageUrl || $dcIdentifier == htmlentities($pageUrl)) {
- //print("identifer matches page!!");
- array_push( $links, $tbPing );
- }
- }
- else {
- //print("adding tb link to array nevertheless");
- array_push( $links, $tbPing );
- }
+ // if we provided the url of the page, we have a mechanism to make sure
+ // that we are fetching the right trackback ping
+ if( $pageUrl != "" ) {
+ if( $dcIdentifier == $pageUrl || $dcIdentifier == htmlentities($pageUrl) || urldecode($dcIdentifier) == $pageUrl ) {
+ //print("identifer matches page!!");
+ array_push( $links, $tbPing );
+ }
+ }
+ else {
+ array_push( $links, $tbPing );
+ }
+ }
}
return $links;
Modified: plog/trunk/class/dao/userdata/baseuserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/baseuserdataprovider.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/userdata/baseuserdataprovider.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -166,12 +166,13 @@
* Returns an array with all the users available in the database
*
* @param status
- * @param includeExtraInfo
+ * @param searchTerms
+ * @param orderBy
* @param page
* @param itemsPerPage
* @return An array containing all the users.
*/
- function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+ function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $orderBy = "", $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
}
Modified: plog/trunk/class/dao/userdata/joomlauserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/joomlauserdataprovider.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/userdata/joomlauserdataprovider.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -288,7 +288,7 @@
* @param itemsPerPage
* @return An array containing all the users.
*/
- function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+ function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $orderBy = "", $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
$query = "SELECT * FROM ".$this->_joomladbprefix."users ORDER BY id ASC";
Modified: plog/trunk/class/dao/userdata/lifetypeuserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/lifetypeuserdataprovider.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/userdata/lifetypeuserdataprovider.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -94,14 +94,15 @@
* Returns an array with all the users available in the database
*
* @param status
- * @param includeExtraInfo
* @param searchTerms
+ * @param orderBy
* @param page
* @param itemsPerPage
* @return An array containing all the users.
*/
function getAllUsers( $status = USER_STATUS_ALL,
- $searchTerms = "",
+ $searchTerms = "",
+ $orderBy = "",
$page = DEFAULT_PAGING_ENABLED,
$itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
@@ -117,15 +118,19 @@
}
if( $where != "" )
$where = "WHERE $where";
+
+ if( $orderBy == "" )
+ $orderBy = "id ASC";
- $query = "SELECT * FROM ".$this->getPrefix()."users $where ORDER BY id ASC";
+ $query = "SELECT * FROM ".$this->getPrefix()."users $where ORDER BY $orderBy";
+
$result = $this->Execute( $query, $page, $itemsPerPage );
$users = Array();
if( !$result )
return $users;
-
+
while ($row = $result->FetchRow()) {
$user = $this->mapRow( $row );
$users[] = $user;
Modified: plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -226,7 +226,7 @@
* @param itemsPerPage
* @return An array containing all the users.
*/
- function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+ function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $orderBy = "", $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
$query = "SELECT * FROM ".$this->_phpbbprefix."users WHERE user_id >= 0 ORDER BY user_id ASC";
Modified: plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -207,7 +207,8 @@
* @return An array containing all the users.
*/
function getAllUsers( $status = USER_STATUS_ALL,
- $searchTerms = "",
+ $searchTerms = "",
+ $orderBy = "",
$page = DEFAULT_PAGING_ENABLED,
$itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
Modified: plog/trunk/class/dao/userdata/vbb3userdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/vbb3userdataprovider.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/userdata/vbb3userdataprovider.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -310,7 +310,7 @@
* @param itemsPerPage
* @return An array containing all the users.
*/
- function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+ function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $orderBy = "", $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
$where = "";
switch ($status)
Modified: plog/trunk/class/dao/userdata/wbbuserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/wbbuserdataprovider.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/userdata/wbbuserdataprovider.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -230,7 +230,7 @@
* @param itemsPerPage
* @return An array containing all the users.
*/
- function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $page = DEFAULT_PAGING_ENABLED, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+ function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $orderBy = "", $page = DEFAULT_PAGING_ENABLED, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
$query = "SELECT * FROM ".$this->_wbbprefix."users WHERE userid >= 0 ORDER BY userid ASC";
Modified: plog/trunk/class/dao/users.class.php
===================================================================
--- plog/trunk/class/dao/users.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/dao/users.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -112,14 +112,15 @@
* Returns an array with all the users available in the database
*
* @param status
- * @param includeExtraInfo
+ * @param searchTerms
+ * @param orderBy
* @param page
* @param itemsPerPage
* @return An array containing all the users.
*/
- function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+ function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $orderBy = "", $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
- return( $this->_provider->getAllUsers( $status, $searchTerms, $page, $itemsPerPage ));
+ return( $this->_provider->getAllUsers( $status, $searchTerms, $orderBy, $page, $itemsPerPage ));
}
/**
Modified: plog/trunk/class/data/pager/pager.class.php
===================================================================
--- plog/trunk/class/data/pager/pager.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/data/pager/pager.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -58,7 +58,6 @@
var $_endPage;
var $_pageLinks;
-
/**
* Constructor of the pager
*
@@ -247,8 +246,19 @@
{
$i = 1;
$pages = Array();
+
+ // check wether we need to perform a replacement or not...
+ // if not, we'll just append the page number at the end of the string
+ $replace = strpos( $this->_baseUrl, "{page}" );
+
while( $i <= $this->_totalPages ) {
- $pages[$i] = $this->_baseUrl.$i;
+ if( $replace ) {
+ $pages[$i] = str_replace( "{page}", $i, $this->_baseUrl );
+ }
+ else {
+ $pages[$i] = $this->_baseUrl.$i;
+ }
+
$i++;
}
Modified: plog/trunk/class/data/plogcalendar.class.php
===================================================================
--- plog/trunk/class/data/plogcalendar.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/data/plogcalendar.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -33,19 +33,15 @@
* @param localeCode A code specifying the locale we want to use. If empty, the default
* one specified in the configuration file will be used.
*/
- function PlogCalendar( $dayPosts = null, $blogInfo = null, $localeCode = null )
+ function PlogCalendar( $dayPosts = null, $blogInfo = null, $locale = null )
{
$this->Calendar();
- if( $localeCode == null ) {
+ if( $locale == null ) {
$config = Config::getConfig();
//$locale = new Locale( $config->getValue( "default_locale" ));
$locale = Locales::getLocale( $config->getValue( "default_locale" ));
}
- else {
- //$locale = new Locale( $localeCode );
- $locale = Locales::getLocale( $localeCode );
- }
$this->_dayPosts = $dayPosts;
$this->_blogInfo = $blogInfo;
Modified: plog/trunk/class/database/dbobject.class.php
===================================================================
--- plog/trunk/class/database/dbobject.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/database/dbobject.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -65,20 +65,6 @@
{
return( $this->_fields );
}
-
- /**
- * Provides an XML version of this object
- */
- function toXml( $useEnvelope = false )
- {
- if( $useEnvelope ) {
- $xml = "<?xml version=\"1.0\"?><dbobject></dbobject>";
- }
- else
- $xml = "";
-
- return( $xml );
- }
/**
* No null values are serialized to the session. If there any values in your data class
Modified: plog/trunk/class/file/file.class.php
===================================================================
--- plog/trunk/class/file/file.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/file/file.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -82,7 +82,7 @@
$contents = file( $this->_fileName );
- for( $i = 0; $i < count( $contents ); $i++ )
+ for( $i = 0, $elements = count( $contents ); $i < $elements; $i++ )
$contents[$i] = trim( $contents[$i] );
return $contents;
Copied: plog/trunk/class/locale/bloglocale.class.php (from rev 4899, plog/branches/lifetype-1.2/class/locale/bloglocale.class.php)
===================================================================
--- plog/trunk/class/locale/bloglocale.class.php (rev 0)
+++ plog/trunk/class/locale/bloglocale.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -0,0 +1,64 @@
+<?php
+
+ /**
+ * \ingroup Locale
+ *
+ * @see Locale
+ * @see Locales
+ */
+
+ lt_include( PLOG_CLASS_PATH."class/locale/locale.class.php" );
+
+ class BlogLocale extends Locale
+ {
+
+ var $_defaultFolder;
+ var $_code; // our ISO locale code, eg. es_ES, en_UK, etc
+ var $_cache;
+ var $_messages;
+ var $_charset;
+ var $_description;
+ var $_dateFormat;
+ var $_firstDayOfWeek;
+ var $_dataLoaded;
+
+ /**
+ * Constructor.
+ *
+ * @param $code Code follows the Java naming scheme: language_COUNTRY, so
+ * for example if we want to have the texts translated in the English spoken
+ * in the UK, we'd have to use en_UK as the code. The two digits country
+ * code and language code are ISO standards and can be found in
+ * http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html (country codes) and
+ * http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_639.html (language codes)
+ */
+ function BlogLocale( $code )
+ {
+ $this->Locale( $code );
+ }
+
+ /**
+ * @private
+ */
+ function _loadLocaleFile()
+ {
+ $this->_defaultFolder = $this->getLocaleFolder();
+
+ $fileName = $this->_defaultFolder."/locale_".$this->_code.".php";
+
+ if( File::isReadable( $fileName ))
+ include( $fileName );
+
+ // The following is just to handle the case where there isn't
+ // a valid local file.
+ if ( !isset($messages) || !is_array( $messages ) ) {
+ $messages = array();
+ }
+ $this->_messages = $messages;
+
+ $this->_dataLoaded = true;
+
+ unset($messages);
+ }
+ }
+?>
\ No newline at end of file
Modified: plog/trunk/class/locale/locale.class.php
===================================================================
--- plog/trunk/class/locale/locale.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/locale/locale.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -86,6 +86,7 @@
var $_description;
var $_dateFormat;
var $_firstDayOfWeek;
+ var $_dataLoaded;
/**
* Constructor.
@@ -98,9 +99,7 @@
* http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_639.html (language codes)
*/
function Locale( $code )
- {
-
-
+ {
$this->_code = $code;
$this->_loadLocaleInfo();
@@ -108,27 +107,35 @@
if( $this->_charset == "" )
$this->_charset = DEFAULT_ENCODING;
+ $this->_dataLoaded = false;
}
/**
* @private
*/
function _loadLocaleFile()
- {
+ {
$this->_defaultFolder = $this->getLocaleFolder();
+ // load the blog locale
$fileName = $this->_defaultFolder."/locale_".$this->_code.".php";
-
if( File::isReadable( $fileName ))
include( $fileName );
-
- // The following is just to handle the case where there isn't
- // a valid local file.
- if ( !isset($messages) || !is_array( $messages ) )
- {
+ if ( !isset($messages) || !is_array( $messages ) ) {
$messages = array();
}
$this->_messages = $messages;
+
+ // load the admin locale
+ $fileName = $this->_defaultFolder."/admin/locale_".$this->_code.".php";
+ if( File::isReadable( $fileName ))
+ include( $fileName );
+ if ( !isset($messages) || !is_array( $messages ) ) {
+ $messages = array();
+ }
+ $this->_messages = array_merge( $this->_messages, $messages );
+
+ $this->_dataLoaded = true;
unset($messages);
}
@@ -223,31 +230,6 @@
$this->_loadLocaleFile();
}
- /**
- * Translates a string
- *
- * @param id Identifier of the message we would like to translate
- */
- function getString( $id )
- {
- // load the file if it hadn't been loaded yet
- if( !is_array($this->_messages) ) {
- $this->_loadLocaleFile();
- }
-
- if( is_array($this->_messages) && array_key_exists($id, $this->_messages) &&
- $this->_messages[ $id ] != "" ) {
- $string = $this->_messages[ $id ];
- } else {
- $string = $id;
- }
-
- /*if( $this->getDirection() == "rtl" )
- $string = "<span dir=\"rtl\">$string</span>";*/
-
- return $string;
- }
-
/**
* returns all the strings
*
@@ -263,12 +245,21 @@
}
/**
- * Alias for getString
- * @see getString
+ * Translates a string
+ *
+ * @param id Identifier of the message we would like to translate
*/
function tr( $id )
{
- return $this->getString( $id );
+ // load the file if it hasn't been loaded yet
+ if( !$this->_dataLoaded ) {
+ $this->_loadLocaleFile();
+ }
+
+ isset( $this->_messages[$id] ) ? $string = $this->_messages[$id] : $string = $id;
+ if( $string == "" ) $string = $id;
+
+ return $string;
}
/**
@@ -490,31 +481,14 @@
{
// load the file if it hadn't been loaded yet
if( !is_array($this->_messages))
- $this->_loadLocaleFile();
+ $this->_loadLocaleFile();
- // timestamp only returns the values in english, so we should translate
- // them before using
- $monthId = (int)$timeStamp->getMonth();
- $monthStr = $this->_messages["months"][$monthId-1];
- if( !empty( $this->_messages["monthsshort"] ) )
- $shortMonthStr = $this->_messages["monthsshort"][$monthId-1];
- else
- $shortMonthStr = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($monthStr), 0, 3 )) : substr($monthStr, 0, 3);
-
- //print("monthstr: $monthStr");
- // and the same for the weekdays
- $weekdayId = $timeStamp->getWeekdayId();
- $weekday = $this->_messages["days"][$weekdayId];
- if( !empty( $this->_messages["weekdaysshort"] ) )
- $shortWeekday = $this->_messages["weekdaysshort"][$weekdayId];
- else
- $shortWeekday = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($weekday), 0, 3 )) : substr($weekday, 0, 3);
-
- lt_include( PLOG_CLASS_PATH."class/data/Date.class.php" );
+ // if the user did not specify a format, let's use the default one
+ if( $format == null )
+ $format = $this->_dateFormat;
+
// Get the unix time stamp
$time = $timeStamp->getTimestamp(DATE_FORMAT_UNIXTIME);
-
- // Get the time zone offset for the server, on the specified date
$timeZoneSec = date("Z", $time);
if ( $blog ) {
//
@@ -523,62 +497,123 @@
$timeDiff = 0;
$blogSettings = $blog->getSettings();
$timeDiff = $blogSettings->getValue( 'time_offset' );
-
+
// The following line relies on the fact that the result will
// be an int.
$timeZoneSec += ( $timeDiff * 3600 );
- }
- // Now convert the time zone seconds to hours and minutes
- $timeZoneHours = intval( abs($timeZoneSec) / 3600 );
- $timeZoneMins = intval(( abs($timeZoneSec) % 3600 ) / 60 );
- $timeZoneDirection = ($timeZoneSec < 0 ) ? "-" : "+";
-
+ }
+
+ $text = $format;
+
+ if( strpos( $text, "%a" ) !== FALSE ) {
+ $weekdayId = $timeStamp->getWeekdayId();
+ $weekday = $this->_messages["days"][$weekdayId];
+ if( !empty( $this->_messages["weekdaysshort"] ) )
+ $shortWeekday = $this->_messages["weekdaysshort"][$weekdayId];
+ else
+ $shortWeekday = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($weekday), 0, 3 )) : substr($weekday, 0, 3);
+ $text = str_replace( "%a", $shortWeekday, $text );
+ }
+ if( strpos( $text, "%A" ) !== FALSE ) {
+ $weekdayId = $timeStamp->getWeekdayId();
+ $text = str_replace( "%A", $this->_messages["days"][$weekdayId], $text );
+ }
+ if( strpos( $text, "%b" ) !== FALSE ) {
+ $monthId = (int)$timeStamp->getMonth();
+ $monthStr = $this->_messages["months"][$monthId-1];
+ if( !empty( $this->_messages["monthsshort"] ) )
+ $shortMonthStr = $this->_messages["monthsshort"][$monthId-1];
+ else
+ $shortMonthStr = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($monthStr), 0, 3 )) : substr($monthStr, 0, 3);
+
+ $text = str_replace( "%b", $shortMonthStr, $text );
+ }
+ if( strpos( $text, "%B" ) !== FALSE ) {
+ $monthId = (int)$timeStamp->getMonth();
+ $text = str_replace( "%B", $this->_messages["months"][$monthId-1], $text );
+ }
+ if( strpos( $text, "%d" ) !== FALSE ) {
+ $text = str_replace( "%d", ($timeStamp->getDay() < 10) ? "0".$timeStamp->getDay() : $timeStamp->getDay(), $text );
+ }
+ if( strpos( $text, "%e" ) !== FALSE ) {
+ $text = str_replace( "%e", intval($timeStamp->getDay()), $text );
+ }
+ if( strpos( $text, "%j" ) !== FALSE ) {
+ $text = str_replace( "%j", $timeStamp->getDay(), $text );
+ }
+ if( strpos( $text, "%H" ) !== FALSE ) {
+ $text = str_replace( "%H", $timeStamp->getHour(), $text );
+ }
+ if( strpos( $text, "%I" ) !== FALSE ) {
+ $text = str_replace( "%I", ($timeStamp->getHour() != 0) ? ($timeStamp->getHour() > 12) ? $timeStamp->getHour()-12 : $timeStamp->getHour()+0 : 12, $text );
+ }
+ if( strpos( $text, "%p" ) !== FALSE ) {
+ $text = str_replace( "%p", $timeStamp->getHour() >= 12 ? "pm" : "am", $text );
+ }
+ if( strpos( $text, "%P" ) !== FALSE ) {
+ $text = str_replace( "%P", $timeStamp->getHour() >= 12 ? "PM" : "AM", $text );
+ }
+ if( strpos( $text, "%M" ) !== FALSE ) {
+ $text = str_replace( "%M", $timeStamp->getMinutes(), $text );
+ }
+ if( strpos( $text, "%m" ) !== FALSE ) {
+ $text = str_replace( "%m", $timeStamp->getMonth(), $text );
+ }
+ if( strpos( $text, "%S" ) !== FALSE ) {
+ $text = str_replace( "%S", $timeStamp->getSeconds(), $text );
+ }
+ if( strpos( $text, "%y" ) !== FALSE ) {
+ $text = str_replace( "%y", substr($timeStamp->getYear(), 2, 4 ), $text );
+ }
+ if( strpos( $text, "%Y" ) !== FALSE ) {
+ $text = str_replace( "%Y", $timeStamp->getYear(), $text );
+ }
+ if( strpos( $text, "%O" ) !== FALSE ) {
+ // Now convert the time zone seconds to hours and minutes
+ $timeZoneHours = intval( abs($timeZoneSec) / 3600 );
+ $timeZoneMins = intval(( abs($timeZoneSec) % 3600 ) / 60 );
+ $timeZoneDirection = ($timeZoneSec < 0 ) ? "-" : "+";
+
+ $text = str_replace( "%O", sprintf( "%s%02d%02d", $timeZoneDirection, $timeZoneHours, $timeZoneMins ), $text );
+ }
+ if( strpos( $text, "%%" ) !== FALSE ) {
+ $text = str_replace( "%%", "%", $text );
+ }
+ if( strpos( $text, "%T" ) !== FALSE ) {
+ $monthId = (int)$timeStamp->getMonth();
+ $monthStr = $this->_messages["months"][$monthId-1];
+
+ $text = str_replace( "%T", $this->getDayOrdinal( $timeStamp )." ".$this->tr("of")." ".$monthStr, $text );
+ }
+ if( strpos( $text, "%D" ) !== FALSE ) {
+ $text = str_replace( "%D", $this->getDayOrdinal( $timeStamp ), $text );
+ }
- // if the user did not specify a format, let's use the default one
- if( $format == null )
- $format = $this->_dateFormat;
-
- // now we can continue normally
- $values["%a"] = $shortWeekday;
- $values["%A"] = $weekday;
- $values["%b"] = $shortMonthStr;
- $values["%B"] = $monthStr;
- $values["%d"] = ($timeStamp->getDay() < 10) ? "0".$timeStamp->getDay() : $timeStamp->getDay();
- $values["%e"] = intval($timeStamp->getDay());
- $values["%j"] = $timeStamp->getDay();
- $values["%H"] = $timeStamp->getHour();
- $values["%I"] = ($timeStamp->getHour() != 0) ? ($timeStamp->getHour() > 12) ? $timeStamp->getHour()-12 : $timeStamp->getHour()+0 : 12;
- $values["%p"] = $timeStamp->getHour() >= 12 ? "pm" : "am";
- $values["%P"] = $timeStamp->getHour() >= 12 ? "PM" : "AM";
- $values["%M"] = $timeStamp->getMinutes();
- $values["%m"] = $timeStamp->getMonth();
- $values["%S"] = $timeStamp->getSeconds();
- $values["%y"] = substr($timeStamp->getYear(), 2, 4 );
- $values["%Y"] = $timeStamp->getYear();
- $values["%O"] = sprintf( "%s%02d%02d", $timeZoneDirection, $timeZoneHours, $timeZoneMins );
- $values["%%"] = "%";
- $values["%T"] = $this->getDayOrdinal( $timeStamp )." ".$this->tr("of")." ".$monthStr;
- $values["%D"] = $this->getDayOrdinal( $timeStamp );
- /* Start Hack By FiFtHeLeMeNt For Persian Language */
if ( $this->_code == 'fa_IR' )
- {
+ {
lt_include( PLOG_CLASS_PATH."class/data/jalalicalendar.class.php" );
- list( $jyear, $jmonth, $jday ) = JalaliCalendar::gregorian_to_jalali($timeStamp->getYear(), $timeStamp->getMonth(), $timeStamp->getDay());
- $values["%q"] = JalaliCalendar::Convertnumber2farsi($jyear);
- $values["%w"]= JalaliCalendar::Convertnumber2farsi($jmonth);
- $values["%o"] = JalaliCalendar::Convertnumber2farsi($jday);
- $values["%R"] = JalaliCalendar::monthname($jmonth);
- $values["%T"] = JalaliCalendar::Convertnumber2farsi($timeStamp->getHour());
- $values["%U"] = JalaliCalendar::Convertnumber2farsi($timeStamp->getMinutes());
- }
- /* End Hack By FiFtHeLeMeNt For Persian Language */
+ list( $jyear, $jmonth, $jday ) = JalaliCalendar::gregorian_to_jalali(gmdate( "Y", $time ), gmdate( "m", $time ), gmdate( "d", $time ));
+
+ if( strpos( $text, "%q" ) !== FALSE ) {
+ $text = str_replace( "%q", JalaliCalendar::Convertnumber2farsi($jyear), $text );
+ }
+ if( strpos( $text, "%w" ) !== FALSE ) {
+ $text = str_replace( "%w", JalaliCalendar::Convertnumber2farsi($jmonth), $text );
+ }
+ if( strpos( $text, "%o" ) !== FALSE ) {
+ $text = str_replace( "%o", JalaliCalendar::Convertnumber2farsi($jday), $text );
+ }
+ if( strpos( $text, "%R" ) !== FALSE ) {
+ $text = str_replace( "%R", JalaliCalendar::monthname($jmonth), $text );
+ }
+ if( strpos( $text, "%T" ) !== FALSE ) {
+ $text = str_replace( "%T", JalaliCalendar::Convertnumber2farsi($timeStamp->getHour()), $text );
+ }
+ if( strpos( $text, "%U" ) !== FALSE ) {
+ $text = str_replace( "%U", JalaliCalendar::Convertnumber2farsi($timeStamp->getMinutes()), $text );
+ }
+ }
- $text = $format;
- foreach( array_keys($values) as $key ) {
- if( ereg($key, $text) )
- $text = str_replace( $key, $values[$key], $text );
- }
-
return $text;
}
@@ -613,10 +648,19 @@
*/
function formatDateGMT( $timeStamp, $format = null, $blog = null )
{
- // load the file if it hadn't been loaded yet
- if( !is_array($this->_messages))
- $this->_loadLocaleFile();
-
+
+
+ // load the file if it hadn't been loaded yet
+ if( !is_array($this->_messages))
+ $this->_loadLocaleFile();
+
+ // if the user did not specify a format, let's use the default one
+ if( $format == null )
+ $format = $this->_dateFormat;
+
+ // Get the unix time stamp
+ $time = $timeStamp->getTimestamp(DATE_FORMAT_UNIXTIME);
+ $timeZoneSec = date("Z", $time);
if ( $blog ) {
//
// The blog was specified. Use it to get the time offset
@@ -630,81 +674,116 @@
$timeStamp->addSeconds( $timeDiff * 3600 );
else
$timeStamp->subtractSeconds( $timeDiff * (-3600));
-
- }
- lt_include( PLOG_CLASS_PATH."class/data/Date.class.php" );
- // Get the unix time stamp
- $time = $timeStamp->getTimestamp(DATE_FORMAT_UNIXTIME);
+ }
+
+ $text = $format;
+
+ if( strpos( $text, "%a" ) !== FALSE ) {
+ $weekdayId = gmdate( "w", $time );
+ $weekday = $this->_messages["days"][$weekdayId];
+ if( !empty( $this->_messages["weekdaysshort"] ) )
+ $shortWeekday = $this->_messages["weekdaysshort"][$weekdayId];
+ else
+ $shortWeekday = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($weekday), 0, 3 )) : substr($weekday, 0, 3);
+
+ $text = str_replace( "%a", $shortWeekday, $text );
+ }
+ if( strpos( $text, "%A" ) !== FALSE ) {
+ $weekdayId = gmdate( "w", $time );
+ $text = str_replace( "%A", $this->_messages["days"][$weekdayId], $text );
+ }
+ if( strpos( $text, "%b" ) !== FALSE ) {
+ $monthId = gmdate( "n", $time );
+ $monthStr = $this->_messages["months"][$monthId-1];
+ if( !empty( $this->_messages["monthsshort"] ) )
+ $shortMonthStr = $this->_messages["monthsshort"][$monthId-1];
+ else
+ $shortMonthStr = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($monthStr), 0, 3 )) : substr($monthStr, 0, 3);
- // This does not take into account the time offset that the user
- // specified, since we are converting the time to GMT. Since the
- // offset is just used to handle time zone differences, it is not
- // necessary, as the time GMT is still the same.
-
- // timestamp only returns the values in english, so we should translate
- // them before using
- $monthId = gmdate( "n", $time );
- $monthStr = $this->_messages["months"][$monthId-1];
- if( !empty( $this->_messages["monthsshort"] ) )
- $shortMonthStr = $this->_messages["monthsshort"][$monthId-1];
- else
- $shortMonthStr = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($monthStr), 0, 3 )) : substr($monthStr, 0, 3);
-
- //print("monthstr: $monthStr");
- // and the same for the weekdays
- $weekdayId = gmdate( "w", $time );
- $weekday = $this->_messages["days"][$weekdayId];
- if( !empty( $this->_messages["weekdaysshort"] ) )
- $shortWeekday = $this->_messages["weekdaysshort"][$weekdayId];
- else
- $shortWeekday = function_exists('html_entity_decode') ? htmlentities(substr(html_entity_decode($weekday), 0, 3 )) : substr($weekday, 0, 3);
-
- // if the user did not specify a format, let's use the default one
- if( $format == null )
- $format = $this->_dateFormat;
-
- // now we can continue normally
- $values["%a"] = $shortWeekday;
- $values["%A"] = $weekday;
- $values["%b"] = $shortMonthStr;
- $values["%B"] = $monthStr;
- $values["%d"] = gmdate( "d", $time );
- $values["%e"] = intval(gmdate( "d", $time ));
- $values["%j"] = gmdate( "j", $time );
- $values["%H"] = gmdate( "H", $time );
- $values["%I"] = gmdate( "g", $time );
- $values["%p"] = gmdate( "a", $time );
- $values["%P"] = gmdate( "A", $time );
- $values["%M"] = gmdate( "i", $time );
- $values["%m"] = gmdate( "m", $time );
- $values["%S"] = gmdate( "s", $time );
- $values["%y"] = gmdate( "y", $time );
- $values["%Y"] = gmdate( "Y", $time );
- $values["%O"] = "+0000";
- $values["%%"] = "%";
- $values["%T"] = $this->getDateOrdinal( gmdate( "d", $time ) )." ".$this->tr("of")." ".$monthStr;
- $values["%D"] = $this->getDateOrdinal( gmdate( "d", $time ) );
- /* Start Hack By FiFtHeLeMeNt For Persian Language */
+ $text = str_replace( "%b", $shortMonthStr, $text );
+ }
+ if( strpos( $text, "%B" ) !== FALSE ) {
+ $monthId = gmdate( "n", $time );
+ $text = str_replace( "%B", $this->_messages["months"][$monthId-1], $text );
+ }
+ if( strpos( $text, "%d" ) !== FALSE ) {
+ $text = str_replace( "%d", gmdate( "d", $time ), $text );
+ }
+ if( strpos( $text, "%e" ) !== FALSE ) {
+ $text = str_replace( "%e", intval(gmdate( "d", $time )), $text );
+ }
+ if( strpos( $text, "%j" ) !== FALSE ) {
+ $text = str_replace( "%j", gmdate( "j", $time ), $text );
+ }
+ if( strpos( $text, "%H" ) !== FALSE ) {
+ $text = str_replace( "%H", gmdate( "H", $time ), $text );
+ }
+ if( strpos( $text, "%I" ) !== FALSE ) {
+ $text = str_replace( "%I", gmdate( "g", $time ), $text );
+ }
+ if( strpos( $text, "%p" ) !== FALSE ) {
+ $text = str_replace( "%p", gmdate( "a", $time ), $text );
+ }
+ if( strpos( $text, "%P" ) !== FALSE ) {
+ $text = str_replace( "%P", gmdate( "A", $time ), $text );
+ }
+ if( strpos( $text, "%M" ) !== FALSE ) {
+ $text = str_replace( "%M", gmdate( "i", $time ), $text );
+ }
+ if( strpos( $text, "%m") !== FALSE ) {
+ $text = str_replace( "%m", gmdate( "m", $time ), $text );
+ }
+ if( strpos( $text, "%S" ) !== FALSE ) {
+ $text = str_replace( "%S", gmdate( "s", $time ), $text );
+ }
+ if( strpos( $text, "%y" ) !== FALSE ) {
+ $text = str_replace( "%y", gmdate( "y", $time ), $text );
+ }
+ if( strpos( $text, "%Y" ) !== FALSE ) {
+ $text = str_replace( "%Y", gmdate( "Y", $time ), $text );
+ }
+ if( strpos( $text, "%O" ) !== FALSE ) {
+ $text = str_replace( "%O", "+0000", $text );
+ }
+ if( strpos( $text, "%%" ) !== FALSE ) {
+ $text = str_replace( "%%", "%", $text );
+ }
+ if( strpos( $text, "%T" ) !== FALSE ) {
+ $monthId = (int)$timeStamp->getMonth();
+ $monthStr = $this->_messages["months"][$monthId-1];
+
+ $text = str_replace( "%T", $this->getDateOrdinal( gmdate( "d", $time ))." ".$this->tr("of")." ".$monthStr, $text );
+ }
+ if( strpos( $text, "%D" ) !== FALSE ) {
+ $text = str_replace( "%D", $this->getDateOrdinal( gmdate( "d", $time )), $text );
+ }
+
if ( $this->_code == 'fa_IR' )
- {
+ {
lt_include( PLOG_CLASS_PATH."class/data/jalalicalendar.class.php" );
list( $jyear, $jmonth, $jday ) = JalaliCalendar::gregorian_to_jalali(gmdate( "Y", $time ), gmdate( "m", $time ), gmdate( "d", $time ));
- $values["%q"] = JalaliCalendar::Convertnumber2farsi($jyear);
- $values["%w"]= JalaliCalendar::Convertnumber2farsi($jmonth);
- $values["%o"] = JalaliCalendar::Convertnumber2farsi($jday);
- $values["%R"] = JalaliCalendar::monthname($jmonth);
- $values["%T"] = JalaliCalendar::Convertnumber2farsi(gmdate( "H", $time ));
- $values["%U"] = JalaliCalendar::Convertnumber2farsi(gmdate( "i", $time ));
- }
- /* End Hack By FiFtHeLeMeNt For Persian Language */
+
+ if( strpos( $text, "%q" ) !== FALSE ) {
+ $text = str_replace( "%q", JalaliCalendar::Convertnumber2farsi($jyear), $text );
+ }
+ if( strpos( $text, "%w" ) !== FALSE ) {
+ $text = str_replace( "%w", JalaliCalendar::Convertnumber2farsi($jmonth), $text );
+ }
+ if( strpos( $text, "%o" ) !== FALSE ) {
+ $text = str_replace( "%o", JalaliCalendar::Convertnumber2farsi($jday), $text );
+ }
+ if( strpos( $text, "%R" ) !== FALSE ) {
+ $text = str_replace( "%R", JalaliCalendar::monthname($jmonth), $text );
+ }
+ if( strpos( $text, "%T" ) !== FALSE ) {
+ $text = str_replace( "%T", JalaliCalendar::Convertnumber2farsi(gmdate( "H", $time )), $text );
+ }
+ if( strpos( $text, "%U" ) !== FALSE ) {
+ $text = str_replace( "%U", JalaliCalendar::Convertnumber2farsi(gmdate( "i", $time )), $text );
+ }
+ }
- $text = $format;
- foreach( array_keys($values) as $key ) {
- if( ereg($key, $text) )
- $text = str_replace( $key, $values[$key], $text );
- }
-
- return $text;
+ return $text;
}
/**
@@ -739,4 +818,4 @@
}
}
}
-?>
+?>
\ No newline at end of file
Modified: plog/trunk/class/locale/locales.class.php
===================================================================
--- plog/trunk/class/locale/locales.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/locale/locales.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -49,6 +49,87 @@
* @return Returns a Locale object corresponding to the requested locale.
* @see Locale
*/
+ function &getBlogLocale( $localeCode = null )
+ {
+ include_once( PLOG_CLASS_PATH."class/locale/bloglocale.class.php" );
+
+ // array to keep track of the locales that we have already loaded, so that
+ // we don't have to fetch them from disk
+ static $loadedLocales;
+
+ // if there is no locale parameter, we use the default one
+ if( $localeCode == null ) {
+ $config =& Config::getConfig();
+ $localeCode = $config->getValue( "default_locale" );
+ }
+
+ // check if we have already loaded that locale or else, load it from
+ // disk and keep it for later, just in case anybody asks again
+ if( isset($loadedLocales[$localeCode]) ) {
+ $locale = $loadedLocales[$localeCode];
+ }
+ else {
+ require_once( PLOG_CLASS_PATH . "class/cache/cachemanager.class.php" );
+ $cache =& CacheManager::getCache();
+ $locale = $cache->getData( $localeCode, CACHE_BLOG_LOCALES );
+ if ( !$locale ) {
+ $locale = new BlogLocale( $localeCode );
+ $cache->setData( $localeCode, CACHE_BLOG_LOCALES, $locale );
+ }
+
+ Locales::_loadPluginLocales( $locale );
+ }
+
+ $loadedLocales[$localeCode] = $locale;
+
+ return $locale;
+ }
+
+ function _loadPluginLocales( &$locale )
+ {
+ $localeCode = $locale->getLocaleCode();
+
+ $pm =& PluginManager::getPluginManager();
+ foreach( $pm->_pluginList as $pluginId ) {
+ if( $pm->pluginHasLocale( $pluginId, $localeCode )) {
+ // if the plugin provides the locale that we need, continue
+ $pluginLocale = Locales::getPluginLocale( $pluginId, $localeCode );
+ }
+ else {
+ // if not, try to load en_UK by default
+ if( $pm->pluginHasLocale( $pluginId, "en_UK" )) {
+ $pluginLocale = Locales::getPluginLocale( $pluginId, "en_UK" );
+ }
+ // if not en_UK locale available, forget about it...
+ }
+
+ // merge the plugin locale with the big locale
+ if ( isset( $pluginLocale ) ) {
+ $locale->mergeLocale( $pluginLocale );
+ }
+ }
+
+ return( true );
+ }
+
+ /**
+ * @static
+ * Static method that offers some kind of locale factory. Since the Locale object
+ * better not use a Singleton (otherwise we couldn't use more than one locale file
+ * at a time) this function has been included here to provide a system similar to
+ * a singleton: we keep an static array inside the function, that contains all the
+ * locale files that have been loaded so far. Whenever somebody requests a locale
+ * to be fetched from disk, we will first check that we have not loaded it before. If
+ * we have, then we only have to return the same object we were keeping.
+ * If the locale wasn't there, we will then load it from disk and store/cache the
+ * resulting object for future use.
+ * It is recommended to use this method over creating new Locale objects every time
+ * we need one.
+ *
+ * @param localeCode The code (eg. en_UK, es_ES) of the locale we want to get.
+ * @return Returns a Locale object corresponding to the requested locale.
+ * @see Locale
+ */
function &getLocale( $localeCode = null )
{
// array to keep track of the locales that we have already loaded, so that
@@ -65,7 +146,8 @@
// disk and keep it for later, just in case anybody asks again
if( isset($loadedLocales[$localeCode]) ) {
$locale = $loadedLocales[$localeCode];
- } else {
+ }
+ else {
require_once( PLOG_CLASS_PATH . "class/cache/cachemanager.class.php" );
$cache =& CacheManager::getCache();
$locale = $cache->getData( $localeCode, CACHE_LOCALES );
@@ -73,25 +155,8 @@
$locale = new Locale( $localeCode );
$cache->setData( $localeCode, CACHE_LOCALES, $locale );
}
- $pm =& PluginManager::getPluginManager();
- foreach( $pm->_pluginList as $pluginId ) {
- if( $pm->pluginHasLocale( $pluginId, $localeCode )) {
- // if the plugin provides the locale that we need, continue
- $pluginLocale = Locales::getPluginLocale( $pluginId, $localeCode );
- }
- else {
- // if not, try to load en_UK by default
- if( $pm->pluginHasLocale( $pluginId, "en_UK" )) {
- $pluginLocale = Locales::getPluginLocale( $pluginId, "en_UK" );
- }
- // if not en_UK locale available, forget about it...
- }
-
- // merge the plugin locale with the big locale
- if ( isset( $pluginLocale ) ) {
- $locale->mergeLocale( $pluginLocale );
- }
- }
+
+ Locales::_loadPluginLocales( $locale );
}
$loadedLocales[$localeCode] = $locale;
Deleted: plog/trunk/class/logger/LogUtilTest.php
===================================================================
--- plog/trunk/class/logger/LogUtilTest.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/logger/LogUtilTest.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,39 +0,0 @@
-<?php
-
-require_once "LogUtil.php";
-require_once "PHPUnit2/Framework/TestCase.php";
-
-class LogUtilTest extends PHPUnit2_Framework_TestCase {
-
- protected function setUp() {
- }
-
- public function testFormat() {
- // test integer
- $var = 1;
- $this->assertEquals("2", LogUtil::format($var));
-
- // test string
- $var = "test";
- $this->assertEquals("test",LogUtil::format($var));
-
- // test simple array
- $var = array("a"=>1,"b"=>2);
- $this->assertEquals("array(2) {
- [\"a\"]=>
- int(1)
- [\"b\"]=>
- int(2)
-}
-",LogUtil::format($var));
-
- // test boolean
- $var = true;
- $this->assertEquals("TRUE",LogUtil::format($var));
-
- // test object
- // but how to? object->toString()?
- }
-}
-?>
-
Modified: plog/trunk/class/misc/glob.class.php
===================================================================
--- plog/trunk/class/misc/glob.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/misc/glob.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -126,12 +126,12 @@
*
* Based on a user-contributed code for the fnmatch php function here:
* http://www.php.net/manual/en/function.fnmatch.php
+ *
+ * @static
*/
function myFnmatch( $pattern, $file )
{
-
-
- for($i=0; $i<strlen($pattern); $i++) {
+ for($i=0,$len = strlen($pattern); $i<$len; $i++) {
if($pattern[$i] == "*") {
for($c=$i; $c<max(strlen($pattern), strlen($file)); $c++) {
if(Glob::myFnmatch(substr($pattern, $i+1), substr($file, $c))) {
@@ -142,7 +142,7 @@
}
if($pattern[$i] == "[") {
$letter_set = array();
- for($c=$i+1; $c<strlen($pattern); $c++) {
+ for($c=$i+1, $len2 = strlen($pattern); $c<$len2; $c++) {
if($pattern[$c] != "]") {
array_push($letter_set, $pattern[$c]);
}
Modified: plog/trunk/class/misc/osdetect.class.php
===================================================================
--- plog/trunk/class/misc/osdetect.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/misc/osdetect.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -20,7 +20,7 @@
*/
function getOsString()
{
- return php_uname();
+ return PHP_OS;
}
/**
Modified: plog/trunk/class/net/baserequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/baserequestgenerator.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/net/baserequestgenerator.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -8,10 +8,6 @@
*
* @see Net_HTTP
*/
-
-
-
- lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
define( "DEFAULT_SCRIPT_NAME", "index.php" );
@@ -43,6 +39,8 @@
var $_xhtmlEnabled;
var $_subdomainsEnabled;
var $_includeBlogId;
+ var $_subdomainsBaseUrl;
+ var $_scriptName;
/**
* Constructor. It initializes certain things such as the base url, checks whether subdomains are
@@ -404,7 +402,7 @@
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">';
$trackbackLink = $this->getTrackbackUrl()."?id=".$post->getId();
- $postLink = str_replace('-', '%2D', $this->postLink($post));
+ $postLink = $this->postLink($post);
$topic = str_replace('-', '\-', $post->getTopic());
$rdfBody = "<rdf:Description
rdf:about=\"".$postLink."\"
@@ -419,7 +417,7 @@
/**
* generates an archive link given a date. Must be implemented by child classes to generate a valid URL.
*
- * @param date A Timestamp object
+ * @param date A String in the format yyyymm
* @return A valid archive link
*/
function getArchiveLink( $date )
@@ -492,7 +490,7 @@
function resourcePreviewLink( $resource )
{
$blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
- $resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/previews/".urlencode($resource->getPreviewFileName());
+ $resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/previews/".rawurlencode($resource->getPreviewFileName());
return $resourceLink;
}
@@ -504,7 +502,7 @@
function resourceMediumSizePreviewLink( $resource )
{
$blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
- $resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/previews-med/".urlencode($resource->getMediumSizePreviewFileName());
+ $resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/previews-med/".rawurlencode($resource->getMediumSizePreviewFileName());
return $resourceLink;
}
@@ -516,7 +514,7 @@
function resourceDownloadLink( $resource )
{
$blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
- $resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/".urlencode($resource->getFileName());
+ $resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/".rawurlencode($resource->getFileName());
return $resourceLink;
}
@@ -705,4 +703,4 @@
return( $this->getIndexUrl(false)."?op=locationDisplay&locId=".$loc->getId());
}
}
-?>
\ No newline at end of file
+?>
Modified: plog/trunk/class/net/customrequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/customrequestgenerator.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/net/customrequestgenerator.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -82,7 +82,7 @@
/**
* generates an archive link given a date.
*
- * @param date A Timestamp object
+ * @param date A String in the format yyyymm
* @return A valid archive link
*/
function getArchiveLink( $date )
@@ -489,12 +489,11 @@
*
* @return A page suffix
*/
- function getPageSuffix( $page = "" )
+ function getPageSuffix()
{
$pageFormat = $this->_config->getValue( "page_suffix_format" );
- $pageFormat = str_replace( "{page}", $page, $pageFormat );
return( $pageFormat );
}
}
-?>
\ No newline at end of file
+?>
Modified: plog/trunk/class/net/http/httpcache.class.php
===================================================================
--- plog/trunk/class/net/http/httpcache.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/net/http/httpcache.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,7 +1,5 @@
<?php
-lt_include( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
-
//In RSS/ATOM feedMode, contains the date of the clients last update.
$clientCacheDate=0; //Global public variable because PHP4 does not allow conditional arguments by reference
$_sessionMode=false; //Global private variable
Modified: plog/trunk/class/net/http/session/sessioninfo.class.php
===================================================================
--- plog/trunk/class/net/http/session/sessioninfo.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/net/http/session/sessioninfo.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,7 +1,6 @@
<?php
lt_include( PLOG_CLASS_PATH."class/config/properties.class.php" );
- lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
/**
* \ingroup Net_HTTP
Modified: plog/trunk/class/net/linkparser.class.php
===================================================================
--- plog/trunk/class/net/linkparser.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/net/linkparser.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -73,7 +73,7 @@
preg_match_all("#\{(.+?)\}#", $this->_linkFormat, $tokens);
$result = array();
- for($i = 0; $i < count($tokens[1]); $i++) {
+ for($i = 0, $elements = count($tokens[1]); $i < $elements; $i++) {
$name = $tokens[1][$i];
if(isset($values[$i+1])){
$result["$name"] = $values[$i+1];
Modified: plog/trunk/class/net/modrewriterequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/modrewriterequestgenerator.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/net/modrewriterequestgenerator.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -238,7 +238,7 @@
/**
* generates an archive link given a date.
*
- * @param date A Timestamp object
+ * @param date A String in the format yyyymm
* @return A valid archive link
*/
function getArchiveLink( $date )
@@ -322,90 +322,6 @@
}
/**
- * Returns the link to a resource
- *
- * @param album Generates the correct link to fetch a resource
- */
- function resourceLink( $resource )
- {
- $blogId = $this->_blogInfo->getId();
- $ownerId = $resource->getOwnerId();
-
- if ( $blogId != $ownerId ) {
- $blogId = $ownerId;
- $blogs =& new Blogs();
- $blogInfo = $blogs->getBlogInfo($blogId);
- $blogShortName = $blogInfo->getBlog();
- } else {
- $blogShortName = $this->_blogInfo->getBlog();
- }
-
- $resourceLink = $this->getBaseUrl().'/'.$blogId.'_'.StringUtils::text2url( $blogShortName ).'/resources/'.rawurlencode($resource->getFileName()).'.html';
-
- return $resourceLink;
- }
-
- /**
- * Returns the link to a resource preview
- *
- * @param album Generates the correct link to fetch a resource preview
- */
- function resourcePreviewLink( $resource )
- {
- $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
-
- $this->addParameter( "blogId", $blogId);
- $this->addParameter( "resource", rawurlencode($resource->getFileName()));
- $this->addParameter( "mode", "preview" );
-
- $resourceLink = $this->getResourceServerUrl().$this->getRequest();
-
- return $resourceLink;
- }
-
- /**
- * Returns the link to a resource preview
- *
- * @param album Generates the correct link to fetch a resource preview
- */
- function resourceMediumSizePreviewLink( $resource )
- {
- $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
-
- $this->addParameter( "blogId", $blogId);
- $this->addParameter( "resource", rawurlencode($resource->getFileName()));
- $this->addParameter( "mode", "medium" );
-
- $resourceLink = $this->getResourceServerUrl().$this->getRequest();
-
- return $resourceLink;
- }
-
- /**
- * Returns the link to a resource
- *
- * @param resource Generates the correct link to fetch a resource
- */
- function resourceDownloadLink( $resource )
- {
- $blogId = $this->_blogInfo->getId();
- $ownerId = $resource->getOwnerId();
-
- if ( $blogId != $ownerId ) {
- $blogId = $ownerId;
- $blogs =& new Blogs();
- $blogInfo = $blogs->getBlogInfo($blogId);
- $blogShortName = $blogInfo->getBlog();
- } else {
- $blogShortName = $this->_blogInfo->getBlog();
- }
-
- $resourceLink = $this->getBaseUrl().'/'.$blogId.'_'.StringUtils::text2url( $blogShortName ).'/get/'.rawurlencode($resource->getFileName());
-
- return $resourceLink;
- }
-
- /**
* Returns a string representing the request
*
* @return A String object representing the request
@@ -457,9 +373,7 @@
$url = $this->blogLink();
}
- $pageFormat = ".page.";
-
- return( $url.$pageFormat );
+ return( $url.$this->getPageSuffix());
}
/**
@@ -467,10 +381,9 @@
*
* @return A page suffix
*/
- function getPageSuffix( $page = "" )
+ function getPageSuffix()
{
- $pageFormat = ".page.".$page;
-
+ $pageFormat = ".page.";
return( $pageFormat );
}
}
Modified: plog/trunk/class/net/prettyrequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/prettyrequestgenerator.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/net/prettyrequestgenerator.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -45,7 +45,7 @@
/**
* generates an archive link given a date.
*
- * @param date A Timestamp object
+ * @param date A String in the format yyyymm
* @return A valid archive link
*/
function getArchiveLink( $date )
@@ -348,7 +348,7 @@
$url = $this->blogLink( null, true );
}
- return( $url."/page/" );
+ return( $url.$this->getPageSuffix());
}
/**
@@ -356,11 +356,10 @@
*
* @return A page suffix
*/
- function getPageSuffix( $page = "" )
+ function getPageSuffix()
{
- $pageFormat = "/page/".$page;
-
+ $pageFormat = "/page/";
return( $pageFormat );
}
}
-?>
\ No newline at end of file
+?>
Modified: plog/trunk/class/net/rawrequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/rawrequestgenerator.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/net/rawrequestgenerator.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -274,7 +274,7 @@
/**
* generates an archive link given a date.
*
- * @param date A Timestamp object
+ * @param date A String in the format yyyymm
* @return A valid archive link
*/
function getArchiveLink( $date )
@@ -440,7 +440,7 @@
if( $params )
$url .= $params;
- $url .= "page=";
+ $url .= $this->getPageSuffix();
return( $url );
}
@@ -450,14 +450,14 @@
*
* @return A page suffix
*/
- function getPageSuffix( $page = "" )
+ function getPageSuffix()
{
if( $this->isXHTML())
$amp = "&";
else
$amp = "&";
- $pageFormat = $amp."page=".$page;
+ $pageFormat = $amp."page=";
return( $pageFormat );
}
Modified: plog/trunk/class/net/request.class.php
===================================================================
--- plog/trunk/class/net/request.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/net/request.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -2,7 +2,6 @@
lt_include( PLOG_CLASS_PATH."class/config/properties.class.php" );
- lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
if ( !defined("CHECK_CONFIG_REQUEST_MODE") )
define( "CHECK_CONFIG_REQUEST_MODE", 0 );
@@ -25,6 +24,7 @@
{
var $_paramsRaw;
+ var $_stripSlashes;
/**
* Initializes the request object
Modified: plog/trunk/class/net/requestgenerator.class.php
===================================================================
--- plog/trunk/class/net/requestgenerator.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/net/requestgenerator.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -59,7 +59,8 @@
* RequestGenerator proxy class.
*/
class RequestGenerator
- {
+ {
+ var $_mode;
function getRequestGenerator( $blogInfo = null, $mode = CHECK_CONFIG_REQUEST_MODE )
{
Modified: plog/trunk/class/object/object.class.php
===================================================================
--- plog/trunk/class/object/object.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/object/object.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -4,7 +4,6 @@
lt_include( PLOG_CLASS_PATH."class/object/exception.class.php" );
lt_include( PLOG_CLASS_PATH."class/logger/loggermanager.class.php" );
- lt_include( PLOG_CLASS_PATH."debug.php" );
/**
* \ingroup Core
@@ -84,9 +83,7 @@
*/
function getParentClass()
{
- $parent_class_name = get_parent_class( $this );
-
- return $parent_class_name;
+ return( get_parent_class( $this ));
}
/**
@@ -120,4 +117,4 @@
return is_a( $this, $object->className());
}
}
-?>
+?>
\ No newline at end of file
Modified: plog/trunk/class/plugin/eventlist.properties.php
===================================================================
--- plog/trunk/class/plugin/eventlist.properties.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/plugin/eventlist.properties.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -185,4 +185,5 @@
define( "EVENT_POST_UPDATE_PERMISSION", ++$eventValue );
define( "EVENT_PRE_DELETE_PERMISSION", ++$eventValue );
define( "EVENT_POST_DELETE_PERMISSION", ++$eventValue );
+ define( "EVENT_PROCESS_BLOG_ADMIN_TEMPLATE_OUTPUT", ++$eventValue );
?>
\ No newline at end of file
Modified: plog/trunk/class/plugin/pluginbase.class.php
===================================================================
--- plog/trunk/class/plugin/pluginbase.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/plugin/pluginbase.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -77,13 +77,28 @@
* plugin manager when the plugin loads
*/
var $pluginFolder;
+
+ /**
+ * This attribute will store the original value of the $source parameter,
+ * which was passed to the plugin in the constructor. The $source identifies
+ * the code that initialized the plugin, and it should mainly be used to identify
+ * whether the plugin is being called from admin.php ("admin") or index.php ("index")
+ */
+ var $source;
+
/**
* Constructor. Feel free to do here whatever you need to.
+ *
+ * @param source Only defined to be 'blog' or 'admin'. This parameter should be used to determine
+ * whether it is index.php registering this plugin ("index") or admin.php doing it ("admin") so that
+ * we can perform different things. This means that the plugin can be initialized in two different ways
+ * depending on whether we're being called via index.php or via admin.php so things like menu entries
+ * or admin actions do not need to be registered unless it's admin.php calling, and so on.
*/
- function PluginBase()
+ function PluginBase( $source = "" )
{
-
+ $this->source = $source;
}
/**
@@ -399,5 +414,15 @@
return( $this->version );
}
+
+ /**
+ * Returns the value of the source parameter
+ *
+ * @param return Source
+ */
+ function getSource()
+ {
+ return( $this->source );
+ }
}
?>
Modified: plog/trunk/class/plugin/pluginmanager.class.php
===================================================================
--- plog/trunk/class/plugin/pluginmanager.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/plugin/pluginmanager.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -41,6 +41,7 @@
var $_blogInfo;
var $_userInfo;
var $_pluginInstances;
+ var $_source;
/**
* global variable to save the list of plugins registered so far
@@ -60,9 +61,7 @@
* @param filePattern
*/
function PluginManager( $pluginDir = PLUGIN_MANAGER_DEFAULT_PLUGIN_FOLDER, $filePattern = PLUGIN_MANAGER_DEFAULT_PLUGIN_FILE_PATTERN )
- {
-
-
+ {
$config =& Config::getConfig();
// initialize the arrays used to keep track of plugins and events
@@ -165,11 +164,13 @@
/**
* Loads all the plugins from disk
*
- * @private
+ * @param source
*/
- function loadPlugins()
+ function loadPlugins( $source = "" )
{
$classLoader =& ResourceClassLoader::getLoader();
+
+ $this->_source = $source;
foreach( $this->_pluginList as $plugin ) {
$pluginFile = "./plugins/$plugin";
@@ -202,7 +203,7 @@
$pluginFileName = "plugin".$pluginId.".class.php";
$pluginFullPath = PLOG_CLASS_PATH."$pluginFile/$pluginFileName";
// and try to include it
- if( File::isReadable( $pluginFile."/".$pluginFileName )) {
+ if( File::isReadable( $pluginFullPath )) {
$pluginList[] = $pluginId;
}
}
@@ -243,7 +244,7 @@
if( File::isReadable( $pluginFile."/".$pluginFileName )) {
$className = "Plugin".$plugin;
lt_include( $pluginFullPath );
- $classInstance = new $className();
+ $classInstance = new $className( $this->_source );
$classInstance->setPluginFolder( PLOG_CLASS_PATH.$pluginFile."/" );
$name = $classInstance->getId();
Modified: plog/trunk/class/security/pipeline.class.php
===================================================================
--- plog/trunk/class/security/pipeline.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/security/pipeline.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -69,12 +69,7 @@
$this->_httpRequest = $httpRequest;
$this->_blogInfo = $blogInfo;
- //global $_pLogPipelineRegisteredFilters;
- //$_pLogPipelineRegisteredFilters = Array();
-
- $this->_registerDefaultFilters();
-
- $this->_result;
+ $this->_registerDefaultFilters();;
}
/**
Modified: plog/trunk/class/security/pipelineresult.class.php
===================================================================
--- plog/trunk/class/security/pipelineresult.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/security/pipelineresult.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -15,6 +15,11 @@
*/
class PipelineResult
{
+
+ var $_valid;
+ var $_errorCode;
+ var $_errorMessage;
+ var $_view;
/**
* Constructor of this type of object
Modified: plog/trunk/class/summary/action/activeaccountaction.class.php
===================================================================
--- plog/trunk/class/summary/action/activeaccountaction.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/summary/action/activeaccountaction.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -5,7 +5,6 @@
lt_include(PLOG_CLASS_PATH.'class/dao/users.class.php');
lt_include(PLOG_CLASS_PATH.'class/dao/blogs.class.php');
lt_include(PLOG_CLASS_PATH.'class/summary/view/summarymessageview.class.php');
-lt_include(PLOG_CLASS_PATH.'class/logger/LogUtil.php');
class ActiveAccountAction extends SummaryAction
{
@@ -52,6 +51,14 @@
break;
}
}
+
+ if( $blog->getStatus() != BLOG_STATUS_UNCONFIRMED ) {
+ // we should only activate blogs whose status is 'unconfirmed'
+ $this->_view = new SummaryView( "summaryerror");
+ $this->_view->setErrorMessage( $this->_locale->tr("error_invalid_activation_code"));
+ return false;
+ }
+
$blogs = new Blogs();
$blog->setStatus(BLOG_STATUS_ACTIVE);
$blogs->updateBlog($blog);
Modified: plog/trunk/class/summary/view/summaryuserlistview.class.php
===================================================================
--- plog/trunk/class/summary/view/summaryuserlistview.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/summary/view/summaryuserlistview.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -37,7 +37,7 @@
// get the data itself
$users = new Users();
- $siteUsers = $users->getAllUsers( USER_STATUS_ACTIVE, "", $this->_page, $this->_numUsersPerPage );
+ $siteUsers = $users->getAllUsers( USER_STATUS_ACTIVE, "", "id desc", $this->_page, $this->_numUsersPerPage );
if( !$siteUsers ) {
// if there was an error, show the error view
Modified: plog/trunk/class/template/menu/menurenderer.class.php
===================================================================
--- plog/trunk/class/template/menu/menurenderer.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/menu/menurenderer.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -172,9 +172,9 @@
* @private
* Used by render() to really render the tree
*/
- function _render( $node, $depth = 0, $activeOpt = "" )
+ function _render( $node, $depth = 0, $activeOpt = "", $menuTop = true )
{
- $result = "<ul class=\"menuTop\">";
+ $result = ($menuTop === true) ? "<ul class=\"menuTop\">" : "<li><ul class=\"menuTop\">";
$depth--;
foreach( $node->children as $child ) {
if( $child->name != "" ) {
@@ -188,12 +188,13 @@
else
$result .= "<li class=\"$cssClass\">".$this->_locale->tr($child->name)."</li>";
- if( $depth > 0 )
- $result .= $this->_render( $child, $depth, $activeOpt );
+ if( $depth > 0 ) {
+ $result .= $this->_render( $child, $depth, $activeOpt, false );
+ }
}
}
}
- $result .= "</ul>";
+ $result .= ($menuTop === true) ? "</ul>" : "</ul></li>";
return $result;
}
Modified: plog/trunk/class/template/smarty/Config_File.class.php
===================================================================
--- plog/trunk/class/template/smarty/Config_File.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/Config_File.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -18,14 +18,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://smarty.php.net/
- * @version 2.6.14
+ * @version 2.6.16
* @copyright Copyright: 2001-2005 New Digital Group, Inc.
* @author Andrei Zmievski <andrei at php.net>
* @access public
* @package Smarty
*/
-/* $Id: Config_File.class.php,v 1.84 2006/01/18 19:02:52 mohrt Exp $ */
+/* $Id: Config_File.class.php,v 1.86 2006/11/30 17:01:28 mohrt Exp $ */
/**
* Config file reading class
Modified: plog/trunk/class/template/smarty/Smarty.class.php
===================================================================
--- plog/trunk/class/template/smarty/Smarty.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/Smarty.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -27,10 +27,10 @@
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei at php.net>
* @package Smarty
- * @version 2.6.14
+ * @version 2.6.16
*/
-/* $Id: Smarty.class.php,v 1.524 2006/01/18 19:02:52 mohrt Exp $ */
+/* $Id: Smarty.class.php,v 1.526 2006/11/30 17:01:28 mohrt Exp $ */
/**
* DIR_SEP isn't used anymore, but third party apps might
@@ -464,7 +464,7 @@
*
* @var string
*/
- var $_version = '2.6.14';
+ var $_version = '2.6.16';
/**
* current template inclusion depth
Modified: plog/trunk/class/template/smarty/Smarty_Compiler.class.php
===================================================================
--- plog/trunk/class/template/smarty/Smarty_Compiler.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/Smarty_Compiler.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -21,12 +21,12 @@
* @link http://smarty.php.net/
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei at php.net>
- * @version 2.6.14
+ * @version 2.6.16
* @copyright 2001-2005 New Digital Group, Inc.
* @package Smarty
*/
-/* $Id: Smarty_Compiler.class.php,v 1.381 2006/05/25 14:46:18 boots Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.386 2006/11/30 17:01:28 mohrt Exp $ */
/**
* Template compiling class
@@ -927,8 +927,12 @@
$name = $this->_dequote($attrs['name']);
if (empty($name)) {
- $this->_syntax_error("missing insert name", E_USER_ERROR, __FILE__, __LINE__);
+ return $this->_syntax_error("missing insert name", E_USER_ERROR, __FILE__, __LINE__);
}
+
+ if (!preg_match('~^\w+$~', $name)) {
+ return $this->_syntax_error("'insert: 'name' must be an insert function name", E_USER_ERROR, __FILE__, __LINE__);
+ }
if (!empty($attrs['script'])) {
$delayed_loading = true;
@@ -1160,7 +1164,7 @@
}
$item = $this->_dequote($attrs['item']);
if (!preg_match('~^\w+$~', $item)) {
- return $this->_syntax_error("'foreach: item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
+ return $this->_syntax_error("'foreach: 'item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
}
if (isset($attrs['key'])) {
@@ -1671,11 +1675,11 @@
// if contains unescaped $, expand it
if(preg_match_all('~(?:\`(?<!\\\\)\$' . $this->_dvar_guts_regexp . '(?:' . $this->_obj_ext_regexp . ')*\`)|(?:(?<!\\\\)\$\w+(\[[a-zA-Z0-9]+\])*)~', $var_expr, $_match)) {
$_match = $_match[0];
- rsort($_match);
- reset($_match);
+ $_replace = array();
foreach($_match as $_var) {
- $var_expr = str_replace ($_var, '".(' . $this->_parse_var(str_replace('`','',$_var)) . ')."', $var_expr);
+ $_replace[$_var] = '".(' . $this->_parse_var(str_replace('`','',$_var)) . ')."';
}
+ $var_expr = strtr($var_expr, $_replace);
$_return = preg_replace('~\.""|(?<!\\\\)""\.~', '', $var_expr);
} else {
$_return = $var_expr;
Modified: plog/trunk/class/template/smarty/debug.tpl
===================================================================
--- plog/trunk/class/template/smarty/debug.tpl 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/debug.tpl 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,64 +1,157 @@
{* Smarty *}
+{* debug.tpl, last updated version 2.1.0 *}
+{assign_debug_info}
+{capture assign=debug_output}
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title>Smarty Debug Console</title>
+{literal}
+<style type="text/css">
+/* <![CDATA[ */
+body, h1, h2, td, th, p {
+ font-family: sans-serif;
+ font-weight: normal;
+ font-size: 0.9em;
+ margin: 1px;
+ padding: 0;
+}
-{* debug.tpl, last updated version 2.0.1 *}
+h1 {
+ margin: 0;
+ text-align: left;
+ padding: 2px;
+ background-color: #f0c040;
+ color: black;
+ font-weight: bold;
+ font-size: 1.2em;
+ }
-{assign_debug_info}
+h2 {
+ background-color: #9B410E;
+ color: white;
+ text-align: left;
+ font-weight: bold;
+ padding: 2px;
+ border-top: 1px solid black;
+}
+body {
+ background: black;
+}
+
+p, table, div {
+ background: #f0ead8;
+}
+
+p {
+ margin: 0;
+ font-style: italic;
+ text-align: center;
+}
+
+table {
+ width: 100%;
+}
+
+th, td {
+ font-family: monospace;
+ vertical-align: top;
+ text-align: left;
+ width: 50%;
+}
+
+td {
+ color: green;
+}
+
+.odd {
+ background-color: #eeeeee;
+}
+
+.even {
+ background-color: #fafafa;
+}
+
+.exectime {
+ font-size: 0.8em;
+ font-style: italic;
+}
+
+#table_assigned_vars th {
+ color: blue;
+}
+
+#table_config_vars th {
+ color: maroon;
+}
+/* ]]> */
+</style>
+{/literal}
+</head>
+<body>
+
+<h1>Smarty Debug Console</h1>
+
+<h2>included templates & config files (load time in seconds)</h2>
+
+<div>
+{section name=templates loop=$_debug_tpls}
+ {section name=indent loop=$_debug_tpls[templates].depth} {/section}
+ <font color={if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}>
+ {$_debug_tpls[templates].filename|escape:html}</font>
+ {if isset($_debug_tpls[templates].exec_time)}
+ <span class="exectime">
+ ({$_debug_tpls[templates].exec_time|string_format:"%.5f"})
+ {if %templates.index% eq 0}(total){/if}
+ </span>
+ {/if}
+ <br />
+{sectionelse}
+ <p>no templates included</p>
+{/section}
+</div>
+
+<h2>assigned template variables</h2>
+
+<table id="table_assigned_vars">
+ {section name=vars loop=$_debug_keys}
+ <tr class="{cycle values="odd,even"}">
+ <th>{ldelim}${$_debug_keys[vars]|escape:'html'}{rdelim}</th>
+ <td>{$_debug_vals[vars]|@debug_print_var}</td></tr>
+ {sectionelse}
+ <tr><td><p>no template variables assigned</p></td></tr>
+ {/section}
+</table>
+
+<h2>assigned config file variables (outer template scope)</h2>
+
+<table id="table_config_vars">
+ {section name=config_vars loop=$_debug_config_keys}
+ <tr class="{cycle values="odd,even"}">
+ <th>{ldelim}#{$_debug_config_keys[config_vars]|escape:'html'}#{rdelim}</th>
+ <td>{$_debug_config_vals[config_vars]|@debug_print_var}</td></tr>
+ {sectionelse}
+ <tr><td><p>no config vars assigned</p></td></tr>
+ {/section}
+</table>
+</body>
+</html>
+{/capture}
{if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"}
- <table border=0 width=100%>
- <tr bgcolor=#cccccc><th colspan=2>Smarty Debug Console</th></tr>
- <tr bgcolor=#cccccc><td colspan=2><b>included templates & config files (load time in seconds):</b></td></tr>
- {section name=templates loop=$_debug_tpls}
- <tr bgcolor={if %templates.index% is even}#eeeeee{else}#fafafa{/if}><td colspan=2><tt>{section name=indent loop=$_debug_tpls[templates].depth} {/section}<font color={if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}>{$_debug_tpls[templates].filename|escape:html}</font>{if isset($_debug_tpls[templates].exec_time)} <font size=-1><i>({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}</i></font>{/if}</tt></td></tr>
- {sectionelse}
- <tr bgcolor=#eeeeee><td colspan=2><tt><i>no templates included</i></tt></td></tr>
- {/section}
- <tr bgcolor=#cccccc><td colspan=2><b>assigned template variables:</b></td></tr>
- {section name=vars loop=$_debug_keys}
- <tr bgcolor={if %vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=blue>{ldelim}${$_debug_keys[vars]}{rdelim}</font></tt></td><td nowrap><tt><font color=green>{$_debug_vals[vars]|@debug_print_var}</font></tt></td></tr>
- {sectionelse}
- <tr bgcolor=#eeeeee><td colspan=2><tt><i>no template variables assigned</i></tt></td></tr>
- {/section}
- <tr bgcolor=#cccccc><td colspan=2><b>assigned config file variables (outer template scope):</b></td></tr>
- {section name=config_vars loop=$_debug_config_keys}
- <tr bgcolor={if %config_vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=maroon>{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}</font></tt></td><td><tt><font color=green>{$_debug_config_vals[config_vars]|@debug_print_var}</font></tt></td></tr>
- {sectionelse}
- <tr bgcolor=#eeeeee><td colspan=2><tt><i>no config vars assigned</i></tt></td></tr>
- {/section}
- </table>
-</BODY></HTML>
+ {$debug_output}
{else}
-<SCRIPT language=javascript>
- if( self.name == '' ) {ldelim}
- var title = 'Console';
- {rdelim}
- else {ldelim}
- var title = 'Console_' + self.name;
- {rdelim}
- _smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
- _smarty_console.document.write("<HTML><HEAD><TITLE>Smarty Debug Console_"+self.name+"</TITLE></HEAD><BODY bgcolor=#ffffff>");
- _smarty_console.document.write("<table border=0 width=100%>");
- _smarty_console.document.write("<tr bgcolor=#cccccc><th colspan=2>Smarty Debug Console</th></tr>");
- _smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>included templates & config files (load time in seconds):</b></td></tr>");
- {section name=templates loop=$_debug_tpls}
- _smarty_console.document.write("<tr bgcolor={if %templates.index% is even}#eeeeee{else}#fafafa{/if}><td colspan=2><tt>{section name=indent loop=$_debug_tpls[templates].depth} {/section}<font color={if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}>{$_debug_tpls[templates].filename|escape:html|escape:javascript}</font>{if isset($_debug_tpls[templates].exec_time)} <font size=-1><i>({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}</i></font>{/if}</tt></td></tr>");
- {sectionelse}
- _smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no templates included</i></tt></td></tr>");
- {/section}
- _smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>assigned template variables:</b></td></tr>");
- {section name=vars loop=$_debug_keys}
- _smarty_console.document.write("<tr bgcolor={if %vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=blue>{ldelim}${$_debug_keys[vars]}{rdelim}</font></tt></td><td nowrap><tt><font color=green>{$_debug_vals[vars]|@debug_print_var|escape:javascript}</font></tt></td></tr>");
- {sectionelse}
- _smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no template variables assigned</i></tt></td></tr>");
- {/section}
- _smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>assigned config file variables (outer template scope):</b></td></tr>");
- {section name=config_vars loop=$_debug_config_keys}
- _smarty_console.document.write("<tr bgcolor={if %config_vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=maroon>{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}</font></tt></td><td><tt><font color=green>{$_debug_config_vals[config_vars]|@debug_print_var|escape:javascript}</font></tt></td></tr>");
- {sectionelse}
- _smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no config vars assigned</i></tt></td></tr>");
- {/section}
- _smarty_console.document.write("</table>");
- _smarty_console.document.write("</BODY></HTML>");
- _smarty_console.document.close();
-</SCRIPT>
-{/if}
+<script type="text/javascript">
+// <![CDATA[
+ if ( self.name == '' ) {ldelim}
+ var title = 'Console';
+ {rdelim}
+ else {ldelim}
+ var title = 'Console_' + self.name;
+ {rdelim}
+ _smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
+ _smarty_console.document.write('{$debug_output|escape:'javascript'}');
+ _smarty_console.document.close();
+// ]]>
+</script>
+{/if}
\ No newline at end of file
Modified: plog/trunk/class/template/smarty/internals/core.write_file.php
===================================================================
--- plog/trunk/class/template/smarty/internals/core.write_file.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/internals/core.write_file.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -23,8 +23,7 @@
smarty_core_create_dir_structure($_params, $smarty);
}
- // write to tmp file, then rename it to avoid
- // file locking race condition
+ // write to tmp file, then rename it to avoid file locking race condition
$_tmp_file = tempnam($_dirname, 'wrt');
if (!($fd = @fopen($_tmp_file, 'wb'))) {
@@ -38,12 +37,13 @@
fwrite($fd, $params['contents']);
fclose($fd);
- // Delete the file if it allready exists (this is needed on Win,
- // because it cannot overwrite files with rename()
- if (file_exists($params['filename'])) {
+ if (PHP_OS == 'Windows' || !@rename($_tmp_file, $params['filename'])) {
+ // On platforms and filesystems that cannot overwrite with rename()
+ // delete the file before renaming it -- because windows always suffers
+ // this, it is short-circuited to avoid the initial rename() attempt
@unlink($params['filename']);
+ @rename($_tmp_file, $params['filename']);
}
- @rename($_tmp_file, $params['filename']);
@chmod($params['filename'], $smarty->_file_perms);
return true;
@@ -51,4 +51,4 @@
/* vim: set expandtab: */
-?>
+?>
\ No newline at end of file
Modified: plog/trunk/class/template/smarty/plugins/function.html_select_date.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/function.html_select_date.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/plugins/function.html_select_date.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -24,9 +24,11 @@
* day values (Marcus Bointon)
* - 1.3.2 support negative timestamps, force year
* dropdown to include given date unless explicitly set (Monte)
+ * - 1.3.4 fix behaviour of 0000-00-00 00:00:00 dates to match that
+ * of 0000-00-00 dates (cybot, boots)
* @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual)
- * @version 1.3.2
+ * @version 1.3.4
* @author Andrei Zmievski
* @author Monte Ohrt <monte at ohrt dot com>
* @param array
@@ -131,19 +133,21 @@
}
}
- if(preg_match('!^-\d+$!',$time)) {
+ if (preg_match('!^-\d+$!', $time)) {
// negative timestamp, use date()
- $time = date('Y-m-d',$time);
+ $time = date('Y-m-d', $time);
}
// If $time is not in format yyyy-mm-dd
- if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) {
+ if (preg_match('/^(\d{0,4}-\d{0,2}-\d{0,2})/', $time, $found)) {
+ $time = $found[1];
+ } else {
// use smarty_make_timestamp to get an unix timestamp and
// strftime to make yyyy-mm-dd
$time = strftime('%Y-%m-%d', smarty_make_timestamp($time));
}
// Now split this in pieces, which later can be used to set the select
$time = explode("-", $time);
-
+
// make syntax "+N" or "-N" work with start_year and end_year
if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
if ($match[1] == '+') {
@@ -159,7 +163,7 @@
$start_year = strftime('%Y') - $match[2];
}
}
- if (strlen($time[0]) > 0) {
+ if (strlen($time[0]) > 0) {
if ($start_year > $time[0] && !isset($params['start_year'])) {
// force start year to include given date if not explicitly set
$start_year = $time[0];
Modified: plog/trunk/class/template/smarty/plugins/function.html_table.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/function.html_table.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/plugins/function.html_table.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -15,12 +15,15 @@
* Purpose: make an html table from an array of data<br>
* Input:<br>
* - loop = array to loop through
- * - cols = number of columns
+ * - cols = number of columns, comma separated list of column names
+ * or array of column names
* - rows = number of rows
* - table_attr = table attributes
+ * - th_attr = table heading attributes (arrays are cycled)
* - tr_attr = table row attributes (arrays are cycled)
* - td_attr = table cell attributes (arrays are cycled)
* - trailpad = value to pad trailing cells with
+ * - caption = text for caption element
* - vdir = vertical direction (default: "down", means top-to-bottom)
* - hdir = horizontal direction (default: "right", means left-to-right)
* - inner = inner loop (default "cols": print $loop line by line,
@@ -31,10 +34,12 @@
* <pre>
* {table loop=$data}
* {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
- * {table loop=$data cols=4 tr_attr=$colors}
+ * {table loop=$data cols="first,second,third" tr_attr=$colors}
* </pre>
* @author Monte Ohrt <monte at ohrt dot com>
- * @version 1.0
+ * @author credit to Messju Mohr <messju at lammfellpuschen dot de>
+ * @author credit to boots <boots dot smarty at yahoo dot com>
+ * @version 1.1
* @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table}
* (Smarty online manual)
* @param array
@@ -45,13 +50,15 @@
{
$table_attr = 'border="1"';
$tr_attr = '';
+ $th_attr = '';
$td_attr = '';
- $cols = 3;
+ $cols = $cols_count = 3;
$rows = 3;
$trailpad = ' ';
$vdir = 'down';
$hdir = 'right';
$inner = 'cols';
+ $caption = '';
if (!isset($params['loop'])) {
$smarty->trigger_error("html_table: missing 'loop' parameter");
@@ -65,6 +72,19 @@
break;
case 'cols':
+ if (is_array($_value) && !empty($_value)) {
+ $cols = $_value;
+ $cols_count = count($_value);
+ } elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) {
+ $cols = explode(',', $_value);
+ $cols_count = count($cols);
+ } elseif (!empty($_value)) {
+ $cols_count = (int)$_value;
+ } else {
+ $cols_count = $cols;
+ }
+ break;
+
case 'rows':
$$_key = (int)$_value;
break;
@@ -74,11 +94,13 @@
case 'hdir':
case 'vdir':
case 'inner':
+ case 'caption':
$$_key = (string)$_value;
break;
case 'tr_attr':
case 'td_attr':
+ case 'th_attr':
$$_key = $_value;
break;
}
@@ -87,25 +109,42 @@
$loop_count = count($loop);
if (empty($params['rows'])) {
/* no rows specified */
- $rows = ceil($loop_count/$cols);
+ $rows = ceil($loop_count/$cols_count);
} elseif (empty($params['cols'])) {
if (!empty($params['rows'])) {
/* no cols specified, but rows */
- $cols = ceil($loop_count/$rows);
+ $cols_count = ceil($loop_count/$rows);
}
}
$output = "<table $table_attr>\n";
+ if (!empty($caption)) {
+ $output .= '<caption>' . $caption . "</caption>\n";
+ }
+
+ if (is_array($cols)) {
+ $cols = ($hdir == 'right') ? $cols : array_reverse($cols);
+ $output .= "<thead><tr>\n";
+
+ for ($r=0; $r<$cols_count; $r++) {
+ $output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>';
+ $output .= $cols[$r];
+ $output .= "</th>\n";
+ }
+ $output .= "</tr></thead>\n";
+ }
+
+ $output .= "<tbody>\n";
for ($r=0; $r<$rows; $r++) {
$output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n";
- $rx = ($vdir == 'down') ? $r*$cols : ($rows-1-$r)*$cols;
+ $rx = ($vdir == 'down') ? $r*$cols_count : ($rows-1-$r)*$cols_count;
- for ($c=0; $c<$cols; $c++) {
- $x = ($hdir == 'right') ? $rx+$c : $rx+$cols-1-$c;
+ for ($c=0; $c<$cols_count; $c++) {
+ $x = ($hdir == 'right') ? $rx+$c : $rx+$cols_count-1-$c;
if ($inner!='cols') {
/* shuffle x to loop over rows*/
- $x = floor($x/$cols) + ($x%$cols)*$rows;
+ $x = floor($x/$cols_count) + ($x%$cols_count)*$rows;
}
if ($x<$loop_count) {
@@ -116,6 +155,7 @@
}
$output .= "</tr>\n";
}
+ $output .= "</tbody>\n";
$output .= "</table>\n";
return $output;
Modified: plog/trunk/class/template/smarty/plugins/function.mailto.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/function.mailto.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/plugins/function.mailto.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -62,6 +62,8 @@
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
// so, don't encode it.
+ $search = array('%40', '%2C');
+ $replace = array('@', ',');
$mail_parms = array();
foreach ($params as $var=>$value) {
switch ($var) {
@@ -69,7 +71,7 @@
case 'bcc':
case 'followupto':
if (!empty($value))
- $mail_parms[] = $var.'='.str_replace('%40','@',rawurlencode($value));
+ $mail_parms[] = $var.'='.str_replace($search,$replace,rawurlencode($value));
break;
case 'subject':
Modified: plog/trunk/class/template/smarty/plugins/function.pager.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/function.pager.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/plugins/function.pager.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -12,6 +12,9 @@
* @param previous Text to be used to the link to the previous page in the sequence. If not present, it defaults to
* whatever the current locale has defined for 'prev_post'
* @param disablediv Whether not to enclose the pager data in a <div class="pager">...</pager> or not. Defaults to 'false'
+ * @param anchor Specify the name of an HTML anchor that will be appended to each one of the links in pages, so that
+ * we can get the browser to jump to the right section of the page (in case the paged content doesn't start at the
+ * top of the page)
*/
function smarty_function_pager($params, &$smarty)
{
@@ -73,6 +76,9 @@
isset( $params["middle"] ) ? $middle = $params["middle"] : $middle = 5;
// Number of pages shown in the end
isset( $params["end"] ) ? $end = $params["end"] : $end = 3;
+ // whether we need to append an anchor reference to all links (in case the paged
+ // doesn't start immediately at the top of the page)
+ isset( $params["anchor"]) ? $anchor = $params["anchor"] : $anchor = "";
$base_url = $pager->getBaseUrl();
@@ -84,6 +90,8 @@
$page_string = '';
+ $pageLinks = $pager->getPageLinks();
+
if( $style == "links" ) {
if ( $total_pages == 1 )
return '';
@@ -93,7 +101,7 @@
$init_page_max = ( $total_pages > $beginning ) ? $beginning : $total_pages;
for($i = 1; $i < $init_page_max + 1; $i++) {
- $page_string .= ( $i == $on_page ) ? " <span class=\"pagerCurrent\">$i</span>" : " <a class=\"pagerLink\" href=\"{$base_url}{$i}\">$i</a>";
+ $page_string .= ( $i == $on_page ) ? " <span class=\"pagerCurrent\">$i</span>" : " <a class=\"pagerLink\" href=\"".$pageLinks[$i].$anchor."\">$i</a>";
if ( $i < $init_page_max ) {
$page_string .= $separator;
}
@@ -107,7 +115,7 @@
for($i = $init_page_min - $middle; $i < $init_page_max + ($middle + 1); $i++) {
- $page_string .= ( $i == $on_page ) ? " <span class=\"pagerCurrent\">$i</span>" : " <a class=\"pagerLink\" href=\"{$base_url}{$i}\">$i</a>";
+ $page_string .= ( $i == $on_page ) ? " <span class=\"pagerCurrent\">$i</span>" : " <a class=\"pagerLink\" href=\"".$pageLinks[$i].$anchor."\">$i</a>";
if ( $i < $init_page_max + 1 ) {
$page_string .= $separator;
}
@@ -120,7 +128,7 @@
}
for($i = $total_pages - ($end - 1); $i < $total_pages + 1; $i++) {
- $page_string .= ( $i == $on_page ) ? " <span class=\"pagerCurrent\">$i</span>" : " <a class=\"pagerLink\" href=\"{$base_url}{$i}\">$i</a>";
+ $page_string .= ( $i == $on_page ) ? " <span class=\"pagerCurrent\">$i</span>" : " <a class=\"pagerLink\" href=\"".$pageLinks[$i].$anchor."\">$i</a>";
if( $i < $total_pages ) {
$page_string .= $separator;
}
@@ -128,7 +136,7 @@
}
else {
for($i = 1; $i < $total_pages + 1; $i++) {
- $page_string .= ( $i == $on_page ) ? " <span class=\"pagerCurrent\">$i</span>" : " <a class=\"pagerLink\" href=\"{$base_url}{$i}\">$i</a>";
+ $page_string .= ( $i == $on_page ) ? " <span class=\"pagerCurrent\">$i</span>" : " <a class=\"pagerLink\" href=\"".$pageLinks[$i].$anchor."\">$i</a>";
if ( $i < $total_pages ) {
$page_string .= $separator;
}
@@ -137,11 +145,11 @@
if ( $add_prevnext_text ) {
if ( $on_page > 1 ) {
- $page_string = ' <a class="pagerLinkPrevPage" href="'.$base_url.( $on_page - 1 ).'">'.$prevText.'</a> '.$page_string;
+ $page_string = ' <a class="pagerLinkPrevPage" href="'.$pageLinks[$on_page - 1 ].$anchor.'">'.$prevText.'</a> '.$page_string;
}
if ( $on_page < $total_pages ) {
- $page_string .= ' <a class="pagerLinkNextPage" href="'.$base_url.( $on_page + 1 ).'">'.$nextText.'</a>';
+ $page_string .= ' <a class="pagerLinkNextPage" href="'.$pageLinks[$on_page + 1].$anchor.'">'.$nextText.'</a>';
}
}
}
@@ -159,7 +167,7 @@
<span class=\"pager\">";
if( !$pager->isFirstPage() && !$pager->isEmpty()) {
$page_string .= "<span class=\"list_action_button\">
- <a href=\"".$pager->getPrevPageLink()."\"><img src=\"imgs/admin/icon_left-16.png\" alt=\"$prevText\" /></a>
+ <a href=\"".$pager->getPrevPageLink().$anchor."\"><img src=\"imgs/admin/icon_left-16.png\" alt=\"$prevText\" /></a>
</span>";
}
$page_string .= "<select name=\"plogPager\" id=\"plogPager\" onChange=\"onPagerListChange(this)\"";
@@ -168,7 +176,7 @@
}
$page_string .= ">";
foreach( $pager->getPageLinks() as $pageId => $pageLink ) {
- $page_string .= "<option value=\"$pageLink\"";
+ $page_string .= "<option value=\"{$pageLink}{$anchor}\"";
if( $pageId == $pager->getCurrentPage())
$page_string .= "selected=\"selected\"";
$page_string .= ">$pageId</option>";
@@ -178,19 +186,19 @@
if( !$pager->isLastPage() && !$pager->isEmpty()) {
$page_string .= "<span class=\"list_action_button\">";
- $page_string .= "<a href=\"".$pager->getNextPageLink()."\"><img src=\"imgs/admin/icon_right-16.png\" alt=\"$nextText\" /></a>";
+ $page_string .= "<a href=\"".$pager->getNextPageLink().$anchor."\"><img src=\"imgs/admin/icon_right-16.png\" alt=\"$nextText\" /></a>";
$page_string .= "</span>";
}
$page_string .= "</span>";
}
elseif( $style == "prevonly" ) {
if (!$pager->isFirstPage() && !$pager->isEmpty()) {
- $page_string .= "<a class=\"pagerLinkPrevPage\" href=\"".$pager->getPrevPageLink()."\">$prevText</a> ";
+ $page_string .= "<a class=\"pagerLinkPrevPage\" href=\"".$pager->getPrevPageLink().$anchor."\">$prevText</a> ";
}
}
elseif( $style == "nextonly" ) {
if (!$pager->isLastPage() && !$pager->isEmpty()) {
- $page_string .= "<a class=\"pagerLinkNextPage\" href=\"".$pager->getNextPageLink()."\">$nextText</a> ";
+ $page_string .= "<a class=\"pagerLinkNextPage\" href=\"".$pager->getNextPageLink().$anchor."\">$nextText</a> ";
}
}
else {
Modified: plog/trunk/class/template/smarty/plugins/modifier.capitalize.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/modifier.capitalize.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/plugins/modifier.capitalize.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -20,8 +20,13 @@
*/
function smarty_modifier_capitalize($string, $uc_digits = false)
{
- smarty_modifier_capitalize_ucfirst(null, $uc_digits);
- return preg_replace_callback('!\b\w+\b!', 'smarty_modifier_capitalize_ucfirst', $string);
+ //smarty_modifier_capitalize_ucfirst(null, $uc_digits);
+ //return preg_replace_callback('!\'?\b\w(\w|\')*\b!', 'smarty_modifier_capitalize_ucfirst', $string);
+
+ // Fix for Mantis issue http://bugs.lifetype.net/view.php?id=1183
+ // Characters such as 'ç' are used as words separators instead of being considered as characters
+ // so a word such as 'retroenllaços' becomes 'RetroenllaçOs'
+ return( ucwords( $string ));
}
function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null)
@@ -33,11 +38,10 @@
return;
}
- if(!preg_match('!\d!',$string[0]) || $_uc_digits)
+ if(substr($string[0],0,1) != "'" && !preg_match("!\d!",$string[0]) || $_uc_digits)
return ucfirst($string[0]);
else
return $string[0];
}
-
?>
Modified: plog/trunk/class/template/smarty/plugins/modifier.date_format.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/modifier.date_format.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/plugins/modifier.date_format.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -31,9 +31,11 @@
function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null)
{
if (substr(PHP_OS,0,3) == 'WIN') {
- $_win_from = array ('%e', '%T', '%D');
- $_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y');
- $format = str_replace($_win_from, $_win_to, $format);
+ $hours = strftime('%I', $string);
+ $short_hours = ( $hours < 10 ) ? substr( $hours, -1) : $hours;
+ $_win_from = array ('%e', '%T', '%D', '%l');
+ $_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y', $short_hours);
+ $format = str_replace($_win_from, $_win_to, $format);
}
if($string != '') {
return strftime($format, smarty_make_timestamp($string));
Modified: plog/trunk/class/template/smarty/plugins/modifier.debug_print_var.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/modifier.debug_print_var.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/plugins/modifier.debug_print_var.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -22,33 +22,66 @@
*/
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
{
- $_replace = array("\n"=>'<i>\n</i>', "\r"=>'<i>\r</i>', "\t"=>'<i>\t</i>');
- if (is_array($var)) {
- $results = "<b>Array (".count($var).")</b>";
- foreach ($var as $curr_key => $curr_val) {
- $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length);
- $results .= "<br>".str_repeat(' ', $depth*2)."<b>".strtr($curr_key, $_replace)."</b> => $return";
- }
- } else if (is_object($var)) {
- $object_vars = get_object_vars($var);
- $results = "<b>".get_class($var)." Object (".count($object_vars).")</b>";
- foreach ($object_vars as $curr_key => $curr_val) {
- $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length);
- $results .= "<br>".str_repeat(' ', $depth*2)."<b>$curr_key</b> => $return";
- }
- } else if (is_resource($var)) {
- $results = '<i>'.(string)$var.'</i>';
- } else if (empty($var) && $var != "0") {
- $results = '<i>empty</i>';
- } else {
- if (strlen($var) > $length ) {
- $results = substr($var, 0, $length-3).'...';
- } else {
- $results = $var;
- }
- $results = htmlspecialchars($results);
- $results = strtr($results, $_replace);
+ $_replace = array(
+ "\n" => '<i>\n</i>',
+ "\r" => '<i>\r</i>',
+ "\t" => '<i>\t</i>'
+ );
+
+ switch (gettype($var)) {
+ case 'array' :
+ $results = '<b>Array (' . count($var) . ')</b>';
+ foreach ($var as $curr_key => $curr_val) {
+ $results .= '<br>' . str_repeat(' ', $depth * 2)
+ . '<b>' . strtr($curr_key, $_replace) . '</b> => '
+ . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
+ $depth--;
+ }
+ break;
+ case 'object' :
+ $object_vars = get_object_vars($var);
+ $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
+ foreach ($object_vars as $curr_key => $curr_val) {
+ $results .= '<br>' . str_repeat(' ', $depth * 2)
+ . '<b> ->' . strtr($curr_key, $_replace) . '</b> = '
+ . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
+ $depth--;
+ }
+ break;
+ case 'boolean' :
+ case 'NULL' :
+ case 'resource' :
+ if (true === $var) {
+ $results = 'true';
+ } elseif (false === $var) {
+ $results = 'false';
+ } elseif (null === $var) {
+ $results = 'null';
+ } else {
+ $results = htmlspecialchars((string) $var);
+ }
+ $results = '<i>' . $results . '</i>';
+ break;
+ case 'integer' :
+ case 'float' :
+ $results = htmlspecialchars((string) $var);
+ break;
+ case 'string' :
+ $results = strtr($var, $_replace);
+ if (strlen($var) > $length ) {
+ $results = substr($var, 0, $length - 3) . '...';
+ }
+ $results = htmlspecialchars('"' . $results . '"');
+ break;
+ case 'unknown type' :
+ default :
+ $results = strtr((string) $var, $_replace);
+ if (strlen($results) > $length ) {
+ $results = substr($results, 0, $length - 3) . '...';
+ }
+ $results = htmlspecialchars($results);
}
+
return $results;
}
Modified: plog/trunk/class/template/smarty/plugins/outputfilter.trimwhitespace.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/outputfilter.trimwhitespace.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/template/smarty/plugins/outputfilter.trimwhitespace.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -49,14 +49,14 @@
// preceeded by a php close tag.
$source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source));
- // replace script blocks
- smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source);
+ // replace textarea blocks
+ smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source);
// replace pre blocks
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source);
- // replace textarea blocks
- smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source);
+ // replace script blocks
+ smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source);
return $source;
}
Copied: plog/trunk/class/test/tests/dao/trackbackclient_test.class.php (from rev 4899, plog/branches/lifetype-1.2/class/test/tests/dao/trackbackclient_test.class.php)
===================================================================
--- plog/trunk/class/test/tests/dao/trackbackclient_test.class.php (rev 0)
+++ plog/trunk/class/test/tests/dao/trackbackclient_test.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -0,0 +1,140 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/trackbackclient.class.php" );
+
+ /**
+ * \ingroup Test
+ *
+ * Test cases for the TrackbackClient class
+ */
+ class TrackbackClient_Test extends LifeTypeTestCase
+ {
+ function setUp()
+ {
+ // definition of our test pages
+
+ $this->page = '
+<html><body>
+!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+<Work rdf:about="">
+ <license rdf:resource="http://creativecommons.org/licenses/by-nc-sa/2.5/" />
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
+</Work>
+<License rdf:about="http://creativecommons.org/licenses/by-nc-sa/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+ <permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/>
+ <requires rdf:resource="http://web.resource.org/cc/Attribution"/><prohibits rdf:resource="http://web.resource.org/cc/CommercialUse"/>
+ <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/><requires rdf:resource="http://web.resource.org/cc/ShareAlike"/></License>
+</rdf:RDF> -->
+<p>blah blah blah</p>
+<!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
+ <rdf:Description rdf:about="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased" dc:identifier="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"
+ dc:title="Critical security issue: Lifetype 1.1.6 and Lifetype 1.2\-beta2 released"
+ trackback:ping="http://www.lifetype.net/trackback.php?id=193"/></rdf:RDF> -->
+</body></html>
+';
+
+ // this one has three different trackback links
+ $this->page2 = '
+<html><body>
+!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+<Work rdf:about="">
+ <license rdf:resource="http://creativecommons.org/licenses/by-nc-sa/2.5/" />
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
+</Work>
+<License rdf:about="http://creativecommons.org/licenses/by-nc-sa/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+ <permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/>
+ <requires rdf:resource="http://web.resource.org/cc/Attribution"/><prohibits rdf:resource="http://web.resource.org/cc/CommercialUse"/>
+ <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/><requires rdf:resource="http://web.resource.org/cc/ShareAlike"/></License>
+</rdf:RDF> -->
+<p>blah blah blah</p>
+<!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
+ <rdf:Description rdf:about="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased" dc:identifier="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"
+ dc:title="Critical security issue: Lifetype 1.1.6 and Lifetype 1.2\-beta2 released"
+ trackback:ping="http://www.lifetype.net/trackback.php?id=194"/></rdf:RDF> -->
+ <!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
+ <rdf:Description rdf:about="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased" dc:identifier="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"
+ dc:title="Critical security issue: Lifetype 1.1.6 and Lifetype 1.2\-beta2 released"
+ trackback:ping="http://www.lifetype.net/trackback.php?id=193"/></rdf:RDF> -->
+ <!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
+ <rdf:Description rdf:about="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased" dc:identifier="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"
+ dc:title="Critical security issue: Lifetype 1.1.6 and Lifetype 1.2\-beta2 released"
+ trackback:ping="http://www.lifetype.net/trackback.php?id=195"/></rdf:RDF> -->
+</body></html>
+';
+
+ // this one has no valid trackback tags
+ $this->page3 = '
+<html><body>
+!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+<Work rdf:about="">
+ <license rdf:resource="http://creativecommons.org/licenses/by-nc-sa/2.5/" />
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
+</Work>
+<License rdf:about="http://creativecommons.org/licenses/by-nc-sa/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+ <permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/>
+ <requires rdf:resource="http://web.resource.org/cc/Attribution"/><prohibits rdf:resource="http://web.resource.org/cc/CommercialUse"/>
+ <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/><requires rdf:resource="http://web.resource.org/cc/ShareAlike"/></License>
+</rdf:RDF> -->
+<p>blah blah blah</p>
+</body></html>
+';
+
+ }
+
+ function testGetTrackbackLinks()
+ {
+ // get the trackback links from the given page
+ $links = TrackbackClient::getTrackbackLinks( $this->page );
+
+ // there should only be one link
+ $this->assertEquals( 1, count( $links ), "There was more than one trackback link detected in the test page!" );
+
+ // and that it is equal to the value that we're expecting
+ $this->assertEquals( "http://www.lifetype.net/trackback.php?id=193", $links[0], "The returned trackback link was not the expected one!" );
+ }
+
+ function testGetMultipleTrackbackLinks()
+ {
+ // get the trackback links from the given page
+ $links = TrackbackClient::getTrackbackLinks( $this->page2 );
+
+ // there should only be one link
+ $this->assertEquals( 3, count( $links ), "There was not 3 trackback links detected in the test page!" );
+
+ // and that it is equal to the value that we're expecting
+ $this->assertEquals( "http://www.lifetype.net/trackback.php?id=194", $links[0], "The returned trackback link was not the expected one!" );
+ $this->assertEquals( "http://www.lifetype.net/trackback.php?id=193", $links[1], "The returned trackback link was not the expected one!" );
+ $this->assertEquals( "http://www.lifetype.net/trackback.php?id=195", $links[2], "The returned trackback link was not the expected one!" );
+ }
+
+ function testNoTrackbackLinks()
+ {
+ // get the trackback links from the given page
+ $links = TrackbackClient::getTrackbackLinks( $this->page3 );
+
+ // there should only be one link
+ $this->assertEquals( 0, count( $links ), "There shouldn't be any trackback links detected in this page!" );
+ }
+
+ function testTrackbackLinksWithDashes()
+ {
+ // get the trackback links from the given page
+ $links = TrackbackClient::getTrackbackLinks( $this->page, "http://www.lifetype.net/blog/lifetype-development-journal/2007/02/14/critical-security-issue-lifetype-1.1.6-and-lifetype-1.2-beta2-released" );
+
+ // there should only be one link
+ $this->assertEquals( 1, count( $links ), "There was more than one trackback link detected in the test page!" );
+
+ // and that it is equal to the value that we're expecting
+ $this->assertEquals( "http://www.lifetype.net/trackback.php?id=193", $links[0], "The returned trackback link was not the expected one!" );
+ }
+ }
+?>
\ No newline at end of file
Copied: plog/trunk/class/test/tests/locale (from rev 4899, plog/branches/lifetype-1.2/class/test/tests/locale)
Deleted: plog/trunk/class/test/tests/locale/locale_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/locale/locale_test.class.php 2007-03-01 10:09:20 UTC (rev 4899)
+++ plog/trunk/class/test/tests/locale/locale_test.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,112 +0,0 @@
-<?php
-
- lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
- lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
- lt_include( PLOG_CLASS_PATH."class/locale/locale.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
-
- /**
- * \ingroup Test
- *
- * Test cases for the Locale class.
- */
- class Locale_Test extends LifeTypeTestCase
- {
- var $l;
-
- function setUp()
- {
- // let's use the English locale as the base one
- $this->l = new Locale( "en_UK" );
- }
-
- /**
- * test all the modifiers from the Locale::formatDate() method:
- *
- * <li>%a abbreviated weekday</li>
- * <li>%A complete weekday</li>
- * <li>%b abbreviated month</li>
- * <li>%B long month</li>
- * <li>%d day of the month, 2 digits with leading zero</li>
- * <li>%j day of the month, numeric (without leading zero)</li>
- * <li>%H hours, in 24-h format</li>
- * <li>%I hours, in 12-h format (without leading zero)</li>
- * <li>%p returns 'am' or 'pm'</li>
- * <li>%P returns 'AM' or 'PM'</li>
- * <li>%M minutes</li>
- * <li>%m month number, from 00 to 12</li>
- * <li>%S seconds</li>
- * <li>%y 2-digit year representation</li>
- * <li>%Y 4-digit year representation</li>
- * <li>%O Difference to Greenwich time (GMT) in hours</li>
- * <li>%% the '%' character
- * </ul>
- * (these have been added by myself and are therefore incompatible with php)<ul>
- * <li>%T "_day_ of _month_", where the day is in ordinal form and 'month' is the name of the month</li>
- * <li>%D cardinal representation of the day</li>
- */
- function testFormatDate()
- {
- $d = new Timestamp( "20070205230000" );
-
- $this->assertEquals( "Mon", $this->l->formatDate( $d, "%a" ));
- $this->assertEquals( "Monday", $this->l->formatDate( $d, "%A" ));
- $this->assertEquals( "Feb", $this->l->formatDate( $d, "%b" ));
- $this->assertEquals( "February", $this->l->formatDate( $d, "%B" ));
- $this->assertEquals( "05", $this->l->formatDate( $d, "%d" ));
- $this->assertEquals( "5", $this->l->formatDate( $d, "%j" ));
- $this->assertEquals( "23", $this->l->formatDate( $d, "%H" ));
- $this->assertEquals( "11", $this->l->formatDate( $d, "%I" ));
- $this->assertEquals( "pm", $this->l->formatDate( $d, "%p" ));
- $this->assertEquals( "PM", $this->l->formatDate( $d, "%P" ));
- $this->assertEquals( "00", $this->l->formatDate( $d, "%M" ));
- $this->assertEquals( "02", $this->l->formatDate( $d, "%m" ));
- $this->assertEquals( "00", $this->l->formatDate( $d, "%S" ));
- $this->assertEquals( "07", $this->l->formatDate( $d, "%y" ));
- $this->assertEquals( "2007", $this->l->formatDate( $d, "%Y" ));
- $this->assertEquals( "%", $this->l->formatDate( $d, "%%" ));
- $this->assertEquals( "5th of February", $this->l->formatDate( $d, "%T" ));
- $this->assertEquals( "5th", $this->l->formatDate( $d, "%D" ));
-
- // a longer format test
- $this->assertEquals( "Feb ", $this->l->formatDate( $d, "%b " ));
- $this->assertEquals( "Feb 5", $this->l->formatDate( $d, "%b %j" ));
- $this->assertEquals( "05/02/2007", $this->l->formatDate( $d, "%d/%m/%Y" ));
- $this->assertEquals( "05 February, 2007 23:00", $this->l->formatDate( $d, "%d %B, %Y %H:%M" ));
- }
-
- /**
- * Tests that the Locale::testFormatDateGMT() method also behaves
- * as expected
- */
- function testFormatDateGMT()
- {
- $d = new Timestamp( "20070205230000" );
-
- $this->assertEquals( "Mon", $this->l->formatDateGMT( $d, "%a" ));
- $this->assertEquals( "Monday", $this->l->formatDateGMT( $d, "%A" ));
- $this->assertEquals( "Feb", $this->l->formatDateGMT( $d, "%b" ));
- $this->assertEquals( "February", $this->l->formatDateGMT( $d, "%B" ));
- $this->assertEquals( "05", $this->l->formatDateGMT( $d, "%d" ));
- $this->assertEquals( "5", $this->l->formatDateGMT( $d, "%j" ));
- $this->assertEquals( "21", $this->l->formatDateGMT( $d, "%H" ));
- $this->assertEquals( "9", $this->l->formatDateGMT( $d, "%I" ));
- $this->assertEquals( "pm", $this->l->formatDateGMT( $d, "%p" ));
- $this->assertEquals( "PM", $this->l->formatDateGMT( $d, "%P" ));
- $this->assertEquals( "00", $this->l->formatDateGMT( $d, "%M" ));
- $this->assertEquals( "02", $this->l->formatDateGMT( $d, "%m" ));
- $this->assertEquals( "00", $this->l->formatDateGMT( $d, "%S" ));
- $this->assertEquals( "07", $this->l->formatDateGMT( $d, "%y" ));
- $this->assertEquals( "2007", $this->l->formatDateGMT( $d, "%Y" ));
- $this->assertEquals( "%", $this->l->formatDateGMT( $d, "%%" ));
- $this->assertEquals( "5th of February", $this->l->formatDateGMT( $d, "%T" ));
- $this->assertEquals( "5th", $this->l->formatDateGMT( $d, "%D" ));
-
- // a longer format test
- $this->assertEquals( "Feb ", $this->l->formatDateGMT( $d, "%b " ));
- $this->assertEquals( "Feb 5", $this->l->formatDateGMT( $d, "%b %j" ));
- $this->assertEquals( "05/02/2007", $this->l->formatDateGMT( $d, "%d/%m/%Y" ));
- $this->assertEquals( "05 February, 2007 21:00", $this->l->formatDateGMT( $d, "%d %B, %Y %H:%M" ));
- }
- }
-?>
\ No newline at end of file
Copied: plog/trunk/class/test/tests/locale/locale_test.class.php (from rev 4899, plog/branches/lifetype-1.2/class/test/tests/locale/locale_test.class.php)
===================================================================
--- plog/trunk/class/test/tests/locale/locale_test.class.php (rev 0)
+++ plog/trunk/class/test/tests/locale/locale_test.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -0,0 +1,112 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/locale/locale.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
+ /**
+ * \ingroup Test
+ *
+ * Test cases for the Locale class.
+ */
+ class Locale_Test extends LifeTypeTestCase
+ {
+ var $l;
+
+ function setUp()
+ {
+ // let's use the English locale as the base one
+ $this->l = new Locale( "en_UK" );
+ }
+
+ /**
+ * test all the modifiers from the Locale::formatDate() method:
+ *
+ * <li>%a abbreviated weekday</li>
+ * <li>%A complete weekday</li>
+ * <li>%b abbreviated month</li>
+ * <li>%B long month</li>
+ * <li>%d day of the month, 2 digits with leading zero</li>
+ * <li>%j day of the month, numeric (without leading zero)</li>
+ * <li>%H hours, in 24-h format</li>
+ * <li>%I hours, in 12-h format (without leading zero)</li>
+ * <li>%p returns 'am' or 'pm'</li>
+ * <li>%P returns 'AM' or 'PM'</li>
+ * <li>%M minutes</li>
+ * <li>%m month number, from 00 to 12</li>
+ * <li>%S seconds</li>
+ * <li>%y 2-digit year representation</li>
+ * <li>%Y 4-digit year representation</li>
+ * <li>%O Difference to Greenwich time (GMT) in hours</li>
+ * <li>%% the '%' character
+ * </ul>
+ * (these have been added by myself and are therefore incompatible with php)<ul>
+ * <li>%T "_day_ of _month_", where the day is in ordinal form and 'month' is the name of the month</li>
+ * <li>%D cardinal representation of the day</li>
+ */
+ function testFormatDate()
+ {
+ $d = new Timestamp( "20070205230000" );
+
+ $this->assertEquals( "Mon", $this->l->formatDate( $d, "%a" ));
+ $this->assertEquals( "Monday", $this->l->formatDate( $d, "%A" ));
+ $this->assertEquals( "Feb", $this->l->formatDate( $d, "%b" ));
+ $this->assertEquals( "February", $this->l->formatDate( $d, "%B" ));
+ $this->assertEquals( "05", $this->l->formatDate( $d, "%d" ));
+ $this->assertEquals( "5", $this->l->formatDate( $d, "%j" ));
+ $this->assertEquals( "23", $this->l->formatDate( $d, "%H" ));
+ $this->assertEquals( "11", $this->l->formatDate( $d, "%I" ));
+ $this->assertEquals( "pm", $this->l->formatDate( $d, "%p" ));
+ $this->assertEquals( "PM", $this->l->formatDate( $d, "%P" ));
+ $this->assertEquals( "00", $this->l->formatDate( $d, "%M" ));
+ $this->assertEquals( "02", $this->l->formatDate( $d, "%m" ));
+ $this->assertEquals( "00", $this->l->formatDate( $d, "%S" ));
+ $this->assertEquals( "07", $this->l->formatDate( $d, "%y" ));
+ $this->assertEquals( "2007", $this->l->formatDate( $d, "%Y" ));
+ $this->assertEquals( "%", $this->l->formatDate( $d, "%%" ));
+ $this->assertEquals( "5th of February", $this->l->formatDate( $d, "%T" ));
+ $this->assertEquals( "5th", $this->l->formatDate( $d, "%D" ));
+
+ // a longer format test
+ $this->assertEquals( "Feb ", $this->l->formatDate( $d, "%b " ));
+ $this->assertEquals( "Feb 5", $this->l->formatDate( $d, "%b %j" ));
+ $this->assertEquals( "05/02/2007", $this->l->formatDate( $d, "%d/%m/%Y" ));
+ $this->assertEquals( "05 February, 2007 23:00", $this->l->formatDate( $d, "%d %B, %Y %H:%M" ));
+ }
+
+ /**
+ * Tests that the Locale::testFormatDateGMT() method also behaves
+ * as expected
+ */
+ function testFormatDateGMT()
+ {
+ $d = new Timestamp( "20070205230000" );
+
+ $this->assertEquals( "Mon", $this->l->formatDateGMT( $d, "%a" ));
+ $this->assertEquals( "Monday", $this->l->formatDateGMT( $d, "%A" ));
+ $this->assertEquals( "Feb", $this->l->formatDateGMT( $d, "%b" ));
+ $this->assertEquals( "February", $this->l->formatDateGMT( $d, "%B" ));
+ $this->assertEquals( "05", $this->l->formatDateGMT( $d, "%d" ));
+ $this->assertEquals( "5", $this->l->formatDateGMT( $d, "%j" ));
+ $this->assertEquals( "21", $this->l->formatDateGMT( $d, "%H" ));
+ $this->assertEquals( "9", $this->l->formatDateGMT( $d, "%I" ));
+ $this->assertEquals( "pm", $this->l->formatDateGMT( $d, "%p" ));
+ $this->assertEquals( "PM", $this->l->formatDateGMT( $d, "%P" ));
+ $this->assertEquals( "00", $this->l->formatDateGMT( $d, "%M" ));
+ $this->assertEquals( "02", $this->l->formatDateGMT( $d, "%m" ));
+ $this->assertEquals( "00", $this->l->formatDateGMT( $d, "%S" ));
+ $this->assertEquals( "07", $this->l->formatDateGMT( $d, "%y" ));
+ $this->assertEquals( "2007", $this->l->formatDateGMT( $d, "%Y" ));
+ $this->assertEquals( "%", $this->l->formatDateGMT( $d, "%%" ));
+ $this->assertEquals( "5th of February", $this->l->formatDateGMT( $d, "%T" ));
+ $this->assertEquals( "5th", $this->l->formatDateGMT( $d, "%D" ));
+
+ // a longer format test
+ $this->assertEquals( "Feb ", $this->l->formatDateGMT( $d, "%b " ));
+ $this->assertEquals( "Feb 5", $this->l->formatDateGMT( $d, "%b %j" ));
+ $this->assertEquals( "05/02/2007", $this->l->formatDateGMT( $d, "%d/%m/%Y" ));
+ $this->assertEquals( "05 February, 2007 21:00", $this->l->formatDateGMT( $d, "%d %B, %Y %H:%M" ));
+ }
+ }
+?>
\ No newline at end of file
Copied: plog/trunk/class/test/tests/logger (from rev 4899, plog/branches/lifetype-1.2/class/test/tests/logger)
Deleted: plog/trunk/class/test/tests/logger/loggerutil_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/logger/loggerutil_test.class.php 2007-03-01 10:09:20 UTC (rev 4899)
+++ plog/trunk/class/test/tests/logger/loggerutil_test.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,24 +0,0 @@
-<?php
-
- lt_include( PLOG_CLASS_PATH."class/logger/LogUtil.php" );
- lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
-
- class LoggerUtil_Test extends LifeTypeTestCase
- {
- function testFormat()
- {
- // test integer
- $var = 1;
- $this->assertEquals("1", LogUtil::format($var));
-
- // test string
- $var = "test";
- $this->assertEquals("test",LogUtil::format($var));
-
- // test boolean
- $var = true;
- $this->assertEquals("TRUE",LogUtil::format($var));
- }
- }
-?>
-
Copied: plog/trunk/class/test/tests/logger/loggerutil_test.class.php (from rev 4899, plog/branches/lifetype-1.2/class/test/tests/logger/loggerutil_test.class.php)
===================================================================
--- plog/trunk/class/test/tests/logger/loggerutil_test.class.php (rev 0)
+++ plog/trunk/class/test/tests/logger/loggerutil_test.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -0,0 +1,24 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/logger/LogUtil.php" );
+ lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
+
+ class LoggerUtil_Test extends LifeTypeTestCase
+ {
+ function testFormat()
+ {
+ // test integer
+ $var = 1;
+ $this->assertEquals("1", LogUtil::format($var));
+
+ // test string
+ $var = "test";
+ $this->assertEquals("test",LogUtil::format($var));
+
+ // test boolean
+ $var = true;
+ $this->assertEquals("TRUE",LogUtil::format($var));
+ }
+ }
+?>
+
Copied: plog/trunk/class/test/tests/misc (from rev 4899, plog/branches/lifetype-1.2/class/test/tests/misc)
Deleted: plog/trunk/class/test/tests/misc/glob_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/misc/glob_test.class.php 2007-03-01 10:09:20 UTC (rev 4899)
+++ plog/trunk/class/test/tests/misc/glob_test.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -1,22 +0,0 @@
-<?php
-
- lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
- lt_include( PLOG_CLASS_PATH."class/misc/glob.class.php" );
-
- /**
- * \ingroup Test
- *
- * Test cases for the Glob class.
- */
- class Glob_Test extends LifeTypeTestCase
- {
- function testmyFnMatch()
- {
- // incorrect match
- $this->assertFalse( Glob::myFnMatch( "*.index.template.*", "index.template.php" ));
-
- // valid match
- $this->assertTrue( Glob::myFnMatch( "*index.template.*", "index.template.php" ));
- }
- }
-?>
\ No newline at end of file
Copied: plog/trunk/class/test/tests/misc/glob_test.class.php (from rev 4899, plog/branches/lifetype-1.2/class/test/tests/misc/glob_test.class.php)
===================================================================
--- plog/trunk/class/test/tests/misc/glob_test.class.php (rev 0)
+++ plog/trunk/class/test/tests/misc/glob_test.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -0,0 +1,22 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/misc/glob.class.php" );
+
+ /**
+ * \ingroup Test
+ *
+ * Test cases for the Glob class.
+ */
+ class Glob_Test extends LifeTypeTestCase
+ {
+ function testmyFnMatch()
+ {
+ // incorrect match
+ $this->assertFalse( Glob::myFnMatch( "*.index.template.*", "index.template.php" ));
+
+ // valid match
+ $this->assertTrue( Glob::myFnMatch( "*index.template.*", "index.template.php" ));
+ }
+ }
+?>
\ No newline at end of file
Modified: plog/trunk/class/view/admin/adminsiteuserslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminsiteuserslistview.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/view/admin/adminsiteuserslistview.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -67,7 +67,7 @@
// get the users of the blog
$users = new Users();
- $siteUsers = $users->getAllUsers( $this->_status, $this->_searchTerms, $this->_page, DEFAULT_ITEMS_PER_PAGE );
+ $siteUsers = $users->getAllUsers( $this->_status, $this->_searchTerms, "", $this->_page, DEFAULT_ITEMS_PER_PAGE );
$numUsers = $users->getNumUsers( $this->_status, $this->_searchTerms );
// in case of problems, empty array...
Modified: plog/trunk/class/view/admin/admintemplatedview.class.php
===================================================================
--- plog/trunk/class/view/admin/admintemplatedview.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/view/admin/admintemplatedview.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -39,8 +39,11 @@
// assign all the values
$template->assign( $this->_params->getAsArray());
- // and send the results
- print $template->fetch();
+ // and send the results after asking plugins if they need to process anything
+ $output = $template->fetch();
+ $this->notifyEvent( EVENT_PROCESS_BLOG_ADMIN_TEMPLATE_OUTPUT, Array( 'content' => &$output, 'template' => $this->_templateName ));
+
+ print( $output );
}
}
?>
Modified: plog/trunk/class/view/blogview.class.php
===================================================================
--- plog/trunk/class/view/blogview.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/view/blogview.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -20,6 +20,7 @@
var $_pm;
var $_pageTitle;
+ var $_locale;
/**
* @see SmartyView
@@ -33,8 +34,8 @@
$this->_pm->setBlogInfo( $this->_blogInfo );
// set the character set in the request based on the blog locale
- $locale = $this->_blogInfo->getLocale();
- $this->setCharset( $locale->getCharset());
+ $this->_locale = $this->_blogInfo->getBlogLocale();
+ $this->setCharset( $this->_locale->getCharset());
// set the initial page title
$this->_pageTitle = $blogInfo->getBlog();
@@ -52,9 +53,8 @@
lt_include( PLOG_CLASS_PATH.'class/data/plogcalendar.class.php' );
$monthPosts = $this->getValue( 'monthposts' );
- $locale = $this->_blogInfo->getLocale();
- $calendar = new PlogCalendar( $monthPosts, $this->_blogInfo, $locale->getLocaleCode());
+ $calendar = new PlogCalendar( $monthPosts, $this->_blogInfo, $this->_locale );
$this->setValue( 'calendar', $calendar->getMonthView( $month, $year ));
}
@@ -90,11 +90,10 @@
return false;
$links = Array();
- $locale = $this->_blogInfo->getLocale();
$urls = $this->_blogInfo->getBlogRequestGenerator();
// format of dates used in the archive, but it defaults to '%B %Y' if none specified
- $archiveDateFormat = $locale->tr( 'archive_date_format' );
+ $archiveDateFormat = $this->_locale->tr( 'archive_date_format' );
// need to check whether we got the same thing back, since that's the way Locale::tr() works instead of
// returning an empty string
if( $archiveDateFormat == "archive_date_format" ) $archiveDateFormat = ARCHIVE_DEFAULT_DATE_FORMAT;
@@ -106,7 +105,7 @@
$t->setYear( $yearName );
$t->setMonth( $monthName );
$archiveUrl = $urls->getArchiveLink( $t->getYear().$t->getMonth());
- $linkName = $locale->formatDate( $t, $archiveDateFormat );
+ $linkName = $this->_locale->formatDate( $t, $archiveDateFormat );
$link = new ArchiveLink( $linkName, '', $archiveUrl, $this->_blogInfo->getId(), 0, $month, 0);
$links[] = $link;
}
@@ -278,7 +277,7 @@
// these things can go in since they do not mean much overhead when generating the view...
//
- $this->setValue( 'locale', $this->_blogInfo->getLocale());
+ $this->setValue( 'locale', $this->_locale );
$this->setValue( 'blog', $this->_blogInfo );
$this->setValue( 'blogsettings', $this->_blogInfo->getSettings());
$this->setValue( 'misctemplatepath', TemplateSetStorage::getMiscTemplateFolder());
Modified: plog/trunk/class/view/defaultview.class.php
===================================================================
--- plog/trunk/class/view/defaultview.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/view/defaultview.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -33,7 +33,6 @@
function _addShowMoreLink()
{
$posts = $this->_params->getValue( 'posts' );
- $locale = $this->_blogInfo->getLocale();
//lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
//$textFilter = new TextFilter();
@@ -42,7 +41,7 @@
foreach( $posts as $post ) {
if( $post->hasExtendedText()) {
$result = $post->getIntroText();
- $showMoreText = $locale->tr( 'read_more' );
+ $showMoreText = $this->_locale->tr( 'read_more' );
$showMoreLink = " <a class=\"showMoreLink\" href=\"".$rg->postPermalink($post)."\">".$showMoreText."</a>";
$post->setText( $result. $showMoreLink );
}
@@ -63,8 +62,7 @@
{
$title = $this->_blogInfo->getBlog();
if(($date = $this->getValue( "date" ))) {
- $locale = $this->_blogInfo->getLocale();
- $title .= " | ".$locale->formatDate( $date, "%B %Y" );
+ $title .= " | ".$this->_locale->formatDate( $date, "%B %Y" );
}
elseif(( $category = $this->getValue( "category" ))) {
$title .= " | ".$category->getName();
Modified: plog/trunk/class/view/errorview.class.php
===================================================================
--- plog/trunk/class/view/errorview.class.php 2007-03-01 11:04:33 UTC (rev 4900)
+++ plog/trunk/class/view/errorview.class.php 2007-03-01 13:45:38 UTC (rev 4901)
@@ -41,8 +41,7 @@
*/
function getPageTitle()
{
- $locale = $this->_blogInfo->getLocale();
- return( $this->_blogInfo->getBlog()." | ".$locale->tr("error"));
+ return( $this->_blogInfo->getBlog()." | ".$this->_locale->tr("error"));
}
/**
More information about the pLog-svn
mailing list