[pLog-svn] r2929 - in plog/trunk: class/action/admin
class/cache/Cache_Lite class/controller class/plugin js/ui
templates/admin
mark at devel.lifetype.net
mark at devel.lifetype.net
Tue Feb 7 14:26:38 GMT 2006
Author: mark
Date: 2006-02-07 14:26:38 +0000 (Tue, 07 Feb 2006)
New Revision: 2929
Added:
plog/trunk/class/action/admin/adminchangetrackbacksstatusaction.class.php
plog/trunk/class/cache/Cache_Lite/Lite.old.php
Modified:
plog/trunk/class/action/admin/adminchangecommentsstatusaction.class.php
plog/trunk/class/controller/admincontrollermap.properties.php
plog/trunk/class/plugin/eventlist.properties.php
plog/trunk/js/ui/plogui.js
plog/trunk/templates/admin/edittrackbacks.template
Log:
Now, the massive change for trackbacks available.
To Do:
Comibine the changeTrackback/CommentsStatus.class.php and markTrackback/Comments together to reduce the number of actions.
Modified: plog/trunk/class/action/admin/adminchangecommentsstatusaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminchangecommentsstatusaction.class.php 2006-02-07 14:23:55 UTC (rev 2928)
+++ plog/trunk/class/action/admin/adminchangecommentsstatusaction.class.php 2006-02-07 14:26:38 UTC (rev 2929)
@@ -45,6 +45,8 @@
$this->_commentStatus = $this->_request->getValue( "commentStatus" );
$this->_changeComments();
+
+ return true;
}
/**
Added: plog/trunk/class/action/admin/adminchangetrackbacksstatusaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminchangetrackbacksstatusaction.class.php 2006-02-07 14:23:55 UTC (rev 2928)
+++ plog/trunk/class/action/admin/adminchangetrackbacksstatusaction.class.php 2006-02-07 14:26:38 UTC (rev 2929)
@@ -0,0 +1,133 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminarticletrackbackslistview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/trackbacks.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Allows to remove trackbacks from a certain article
+ */
+ class AdminChangeTrackbacksStatusAction extends AdminAction
+ {
+
+ var $_articleId;
+ var $_trackbackIds;
+ var $_trackbackStatus;
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminChangeTrackbacksStatusAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ $this->registerFieldValidator( "articleId", new IntegerValidator());
+ $this->registerFieldValidator( "trackbackIds", new ArrayValidator());
+ $this->registerFieldValidator( "trackbackStatus", new IntegerValidator());
+ $view = new AdminArticleTrackbacksListView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr("error_updating_trackbacks"));
+ $this->setValidationErrorView( $view );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ $this->_articleId = $this->_request->getValue( "articleId" );
+ $this->_trackbackIds = $this->_request->getValue( "trackbackIds" );
+ $this->_trackbackStatus = $this->_request->getValue( "trackbackStatus" );
+
+ $this->_changeTrackbacks();
+
+ return true;
+ }
+
+ /**
+ * change trackbacks status
+ * @private
+ */
+ function _changeTrackbacks()
+ {
+ $trackbacks = new Trackbacks();
+ $errorMessage = "";
+ $successMessage = "";
+ $totalOk = 0;
+
+ if( $articleId > 0 ) {
+ // if we can't even load the article, then forget it...
+ $articles = new Articles();
+ $article = $articles->getBlogArticle( $this->_articleId, $this->_blogInfo->getId());
+ if( !$article ) {
+ $this->_view = new AdminArticleTrackbacksListView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_post" ));
+ $this->setCommonData();
+
+ return false;
+ }
+ }
+ else {
+ // there was no article, so this probably was the view that shows all trackbacks...
+ $article = null;
+ }
+
+ // loop through the trackbacks and remove them
+ foreach( $this->_trackbackIds as $trackbackId ) {
+ // fetch the trackback
+ $trackback = $trackbacks->getTrackBack( $trackbackId );
+
+ if( !$trackback ) {
+ $errorMessage .= $this->_locale->pr("error_updating_trackback2", $trackbackId)."<br/>";
+ }
+ else {
+ // fire the pre-event
+ $this->notifyEvent( EVENT_PRE_TRACKBACK_UPDATE, Array( "trackback" => &$trackback ));
+
+ // check if the trackback really belongs to this blog...
+ $article = $trackback->getArticle();
+ if( $article->getBlogId() != $this->_blogInfo->getId()) {
+ // if not, then we shouldn't be allowed to remove anything!
+ $errorMessage .= $this->_locale->pr("error_updating_trackback", $trackback->getExcerpt())."<br/>";
+ }
+ else {
+ if( !$trackbacks->updateCommentStatus( $trackbackId, $this->_trackbackStatus ))
+ $errorMessage .= $this->_locale->pr("error_updating_trackback", $trackback->getExcerpt())."<br/>";
+ else {
+ $totalOk++;
+ if( $totalOk < 2 )
+ $successMessage .= $this->_locale->pr("trackback_updated_ok", $trackback->getExcerpt());
+ else
+ $successMessage = $this->_locale->pr("trackbacks_updated_ok", $totalOk );
+
+ // fire the post-event
+ $this->notifyEvent( EVENT_POST_TRACKBACK_UPDATE, Array( "trackback" => &$trackback ));
+ }
+ }
+ }
+ }
+
+ // if everything fine, then display the same view again with the feedback
+ if( $this->_articleId == 0 )
+ $this->_view = new AdminArticleTrackbacksListView( $this->_blogInfo, Array( "article" => null ));
+ else
+ $this->_view = new AdminArticleTrackbacksListView( $this->_blogInfo, Array( "article" => $article ));
+
+ if( $successMessage != "" ) {
+ $this->_view->setSuccessMessage( $successMessage );
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+ }
+ if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
+ $this->setCommonData();
+
+ // better to return true if everything fine
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/class/cache/Cache_Lite/Lite.old.php
===================================================================
--- plog/trunk/class/cache/Cache_Lite/Lite.old.php 2006-02-07 14:23:55 UTC (rev 2928)
+++ plog/trunk/class/cache/Cache_Lite/Lite.old.php 2006-02-07 14:26:38 UTC (rev 2929)
@@ -0,0 +1,740 @@
+<?php
+
+/**
+* Fast, light and safe Cache Class
+*
+* Cache_Lite is a fast, light and safe cache system. It's optimized
+* for file containers. It is fast and safe (because it uses file
+* locking and/or anti-corruption tests).
+*
+* There are some examples in the 'docs/examples' file
+* Technical choices are described in the 'docs/technical' file
+*
+* A tutorial is available in english at this url :
+* http://www.pearfr.org/index.php/en/article/cache_lite
+* (big thanks to Pierre-Alain Joye for the translation)
+*
+* The same tutorial is also available in french at this url :
+* http://www.pearfr.org/index.php/fr/article/cache_lite
+*
+* Memory Caching is from an original idea of
+* Mike BENOIT <ipso at snappymail.ca>
+*
+* @package Cache_Lite
+* @category Caching
+* @version $Id: Lite.php,v 1.23 2005/02/27 18:24:28 fab Exp $
+* @author Fabien MARTY <fab at php.net>
+*/
+
+require_once( PLOG_CLASS_PATH . 'class/object/object.class.php' );
+
+define('CACHE_LITE_ERROR_RETURN', 1);
+define('CACHE_LITE_ERROR_DIE', 8);
+
+class Cache_Lite
+{
+
+ // --- Private properties ---
+
+ /**
+ * Directory where to put the cache files
+ * (make sure to add a trailing slash)
+ *
+ * @var string $_cacheDir
+ */
+ var $_cacheDir = '/tmp/';
+
+ /**
+ * Enable / disable caching
+ *
+ * (can be very usefull for the debug of cached scripts)
+ *
+ * @var boolean $_caching
+ */
+ var $_caching = true;
+
+ /**
+ * Cache lifetime (in seconds)
+ *
+ * @var int $_lifeTime
+ */
+ var $_lifeTime = 604800;
+
+ /**
+ * Enable / disable fileLocking
+ *
+ * (can avoid cache corruption under bad circumstances)
+ *
+ * @var boolean $_fileLocking
+ */
+ var $_fileLocking = true;
+
+ /**
+ * Timestamp of the last valid cache
+ *
+ * @var int $_refreshTime
+ */
+ var $_refreshTime;
+
+ /**
+ * File name (with path)
+ *
+ * @var string $_file
+ */
+ var $_file;
+
+ /**
+ * File name (without path)
+ *
+ * @var string $_fileName
+ */
+ var $_fileName;
+
+ /**
+ * Enable / disable write control (the cache is read just after writing to detect corrupt entries)
+ *
+ * Enable write control will lightly slow the cache writing but not the cache reading
+ * Write control can detect some corrupt cache files but maybe it's not a perfect control
+ *
+ * @var boolean $_writeControl
+ */
+ var $_writeControl = true;
+
+ /**
+ * Enable / disable read control
+ *
+ * If enabled, a control key is embeded in cache file and this key is compared with the one
+ * calculated after the reading.
+ *
+ * @var boolean $_writeControl
+ */
+ var $_readControl = false;
+
+ /**
+ * Type of read control (only if read control is enabled)
+ *
+ * Available values are :
+ * 'md5' for a md5 hash control (best but slowest)
+ * 'crc32' for a crc32 hash control (lightly less safe but faster, better choice)
+ * 'strlen' for a length only test (fastest)
+ *
+ * @var boolean $_readControlType
+ */
+ var $_readControlType = 'crc32';
+
+ /**
+ * Current cache id
+ *
+ * @var string $_id
+ */
+ var $_id;
+
+ /**
+ * Current cache group
+ *
+ * @var string $_group
+ */
+ var $_group;
+
+ /**
+ * Enable / Disable "Memory Caching"
+ *
+ * NB : There is no lifetime for memory caching !
+ *
+ * @var boolean $_memoryCaching
+ */
+ var $_memoryCaching = false;
+
+ /**
+ * Enable / Disable "Only Memory Caching"
+ * (be carefull, memory caching is "beta quality")
+ *
+ * @var boolean $_onlyMemoryCaching
+ */
+ var $_onlyMemoryCaching = false;
+
+ /**
+ * Memory caching array
+ *
+ * @var array $_memoryCachingArray
+ */
+ var $_memoryCachingArray = array();
+
+ /**
+ * Memory caching counter
+ *
+ * @var int $memoryCachingCounter
+ */
+ var $_memoryCachingCounter = 0;
+
+ /**
+ * Memory caching limit
+ *
+ * @var int $memoryCachingLimit
+ */
+ var $_memoryCachingLimit = 1000;
+
+ /**
+ * File Name protection
+ *
+ * if set to true, you can use any cache id or group name
+ * if set to false, it can be faster but cache ids and group names
+ * will be used directly in cache file names so be carefull with
+ * special characters...
+ *
+ * @var boolean $fileNameProtection
+ */
+ var $_fileNameProtection = true;
+
+ /**
+ * Enable / disable automatic serialization
+ *
+ * it can be used to save directly datas which aren't strings
+ * (but it's slower)
+ *
+ * @var boolean $_serialize
+ */
+ var $_automaticSerialization = true;
+
+ /**
+ * Disable / Tune the automatic cleaning process
+ *
+ * The automatic cleaning process destroy too old (for the given life time)
+ * cache files when a new cache file is written.
+ * 0 => no automatic cache cleaning
+ * 1 => systematic cache cleaning
+ * x (integer) > 1 => automatic cleaning randomly 1 times on x cache write
+ *
+ * @var int $_automaticCleaning
+ */
+ var $_automaticCleaningFactor = 0;
+
+ /**
+ * Nested directory level
+ *
+ *
+ * @var int $_hashedDirectoryLevel
+ */
+ var $_hashedDirectoryLevel = 2;
+
+ // --- Public methods ---
+
+ /**
+ * Constructor
+ *
+ * $options is an assoc. Available options are :
+ * $options = array(
+ * 'cacheDir' => directory where to put the cache files (string),
+ * 'caching' => enable / disable caching (boolean),
+ * 'lifeTime' => cache lifetime in seconds (int),
+ * 'fileLocking' => enable / disable fileLocking (boolean),
+ * 'writeControl' => enable / disable write control (boolean),
+ * 'readControl' => enable / disable read control (boolean),
+ * 'readControlType' => type of read control 'crc32', 'md5', 'strlen' (string),
+ * 'pearErrorMode' => pear error mode (when raiseError is called) (cf PEAR doc) (int),
+ * 'memoryCaching' => enable / disable memory caching (boolean),
+ * 'onlyMemoryCaching' => enable / disable only memory caching (boolean),
+ * 'memoryCachingLimit' => max nbr of records to store into memory caching (int),
+ * 'fileNameProtection' => enable / disable automatic file name protection (boolean),
+ * 'automaticSerialization' => enable / disable automatic serialization (boolean)
+ * 'automaticCleaningFactor' => distable / tune automatic cleaning process (int)
+ * 'hashedDirectoryLevel' => level of the hashed directory system (int)
+ * );
+ *
+ * @param array $options options
+ * @access public
+ */
+ function Cache_Lite($options = array(NULL))
+ {
+ // original options
+ // $availableOptions = array('hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode');
+ // options really needed by pLog
+ $availableOptions = array('cacheDir');
+ foreach($options as $key => $value) {
+ if(in_array($key, $availableOptions)) {
+ $property = '_'.$key;
+ $this->$property = $value;
+ }
+ }
+ $this->_refreshTime = time() - $this->_lifeTime;
+
+ // activate memory caching if available memory is 24M or above
+ if( $this->byteValue(ini_get('memory_limit')) >= 25165824 )
+ $this->_memoryCaching = true;
+ }
+
+ /**
+ * Test if a cache is available and (if yes) return it
+ *
+ * @param string $id cache id
+ * @param string $group name of the cache group
+ * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
+ * @return string data of the cache (or false if no cache available)
+ * @access public
+ */
+ function get($id, $group = 'default', $doNotTestCacheValidity = false)
+ {
+ $this->_id = $id;
+ $this->_group = $group;
+ $data = false;
+ if ($this->_caching) {
+ $this->_setFileName($id, $group);
+ if ($this->_memoryCaching) {
+ if (isset($this->_memoryCachingArray[$this->_file])) {
+ if ($this->_automaticSerialization) {
+ return unserialize($this->_memoryCachingArray[$this->_file]);
+ } else {
+ return $this->_memoryCachingArray[$this->_file];
+ }
+ } else {
+ if ($this->_onlyMemoryCaching) {
+ return false;
+ }
+ }
+ }
+ if ($doNotTestCacheValidity) {
+ if (file_exists($this->_file)) {
+ $data = $this->_read();
+ }
+ } else {
+ if ((file_exists($this->_file)) && (@filemtime($this->_file) > $this->_refreshTime)) {
+ $data = $this->_read();
+ }
+ }
+ if (($data) and ($this->_memoryCaching)) {
+ $this->_memoryCacheAdd($this->_file, $data);
+ }
+ if (($this->_automaticSerialization) and (is_string($data))) {
+ $data = unserialize($data);
+ }
+ return $data;
+ }
+ return false;
+ }
+
+ /**
+ * Save some data in a cache file
+ *
+ * @param string $data data to put in cache (can be another type than strings if automaticSerialization is on)
+ * @param string $id cache id
+ * @param string $group name of the cache group
+ * @return boolean true if no problem
+ * @access public
+ */
+ function save($data, $id = NULL, $group = 'default')
+ {
+ if ($this->_caching) {
+ if ($this->_automaticSerialization) {
+ $data = serialize($data);
+ }
+ if (isset($id)) {
+ $this->_setFileName($id, $group);
+ }
+ if ($this->_memoryCaching) {
+ $this->_memoryCacheAdd($this->_file, $data);
+ if ($this->_onlyMemoryCaching) {
+ return true;
+ }
+ }
+ if ($this->_automaticCleaningFactor>0) {
+ $rand = rand(1, $this->_automaticCleaningFactor);
+ if ($rand==1) {
+ $this->clean(false, 'old');
+ }
+ }
+ if ($this->_writeControl) {
+ if (!$this->_writeAndControl($data)) {
+ @touch($this->_file, time() - 2*abs($this->_lifeTime));
+ return false;
+ } else {
+ return true;
+ }
+ } else {
+ return $this->_write($data);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Remove a cache file
+ *
+ * @param string $id cache id
+ * @param string $group name of the cache group
+ * @return boolean true if no problem
+ * @access public
+ */
+ function remove($id, $group = 'default')
+ {
+ $this->_setFileName($id, $group);
+ if ($this->_memoryCaching) {
+ if (isset($this->_memoryCachingArray[$this->_file])) {
+ unset($this->_memoryCachingArray[$this->_file]);
+ $this->_memoryCachingCounter = $this->_memoryCachingCounter - 1;
+ }
+ if ($this->_onlyMemoryCaching) {
+ return true;
+ }
+ }
+ return $this->_unlink($this->_file);
+ }
+
+ /**
+ * Clean the cache
+ *
+ * if no group is specified all cache files will be destroyed
+ * else only cache files of the specified group will be destroyed
+ *
+ * @param string $group name of the cache group
+ * @param string $mode flush cache mode : 'old', 'ingroup', 'notingroup'
+ * @return boolean true if no problem
+ * @access public
+ */
+ function clean($group = false, $mode = 'ingroup')
+ {
+ return $this->_cleanDir($this->_cacheDir, $group, $mode);
+ }
+
+ /**
+ * Set to debug mode
+ *
+ * When an error is found, the script will stop and the message will be displayed
+ * (in debug mode only).
+ *
+ * @access public
+ */
+ function setToDebug()
+ {
+ $this->_pearErrorMode = CACHE_LITE_ERROR_DIE;
+ }
+
+ /**
+ * Set a new life time
+ *
+ * @param int $newLifeTime new life time (in seconds)
+ * @access public
+ */
+ function setLifeTime($newLifeTime)
+ {
+ $this->_lifeTime = $newLifeTime;
+ $this->_refreshTime = time() - $newLifeTime;
+ }
+
+ /**
+ * Save the state of the caching memory array into a cache file cache
+ *
+ * @param string $id cache id
+ * @param string $group name of the cache group
+ * @access public
+ */
+ function saveMemoryCachingState($id, $group = 'default')
+ {
+ if ($this->_caching) {
+ $array = array(
+ 'counter' => $this->_memoryCachingCounter,
+ 'array' => $this->_memoryCachingState
+ );
+ $data = serialize($array);
+ $this->save($data, $id, $group);
+ }
+ }
+
+ /**
+ * Load the state of the caching memory array from a given cache file cache
+ *
+ * @param string $id cache id
+ * @param string $group name of the cache group
+ * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
+ * @access public
+ */
+ function getMemoryCachingState($id, $group = 'default', $doNotTestCacheValidity = false)
+ {
+ if ($this->_caching) {
+ if ($data = $this->get($id, $group, $doNotTestCacheValidity)) {
+ $array = unserialize($data);
+ $this->_memoryCachingCounter = $array['counter'];
+ $this->_memoryCachingArray = $array['array'];
+ }
+ }
+ }
+
+ /**
+ * Return the cache last modification time
+ *
+ * BE CAREFUL : THIS METHOD IS FOR HACKING ONLY !
+ *
+ * @return int last modification time
+ */
+ function lastModified() {
+ return filemtime($this->_file);
+ }
+
+ // --- Private methods ---
+
+ /**
+ * Remove a file
+ *
+ * @param string $file complete file path and name
+ * @return boolean true if no problem
+ * @access private
+ */
+ function _unlink($file)
+ {
+ if (file_exists($file) && !@unlink($file)) {
+ $this->log->log('Unable to remove cache !', LOGGER_PRIO_ERROR );
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Recursive function for cleaning cache file in the given directory
+ *
+ * @param string $dir directory complete path (with a trailing slash)
+ * @param string $group name of the cache group
+ * @param string $mode flush cache mode : 'old', 'ingroup', 'notingroup'
+ * @return boolean true if no problem
+ * @access private
+ */
+ function _cleanDir($dir, $group = false, $mode = 'ingroup')
+ {
+ if ($this->_fileNameProtection) {
+ $motif = ($group) ? 'cache_'.md5($group).'_' : 'cache_';
+ } else {
+ $motif = ($group) ? 'cache_'.$group.'_' : 'cache_';
+ }
+ if ($this->_memoryCaching) {
+ while (list($key, $value) = each($this->_memoryCachingArray)) {
+ if (strpos($key, $motif, 0)) {
+ unset($this->_memoryCachingArray[$key]);
+ $this->_memoryCachingCounter = $this->_memoryCachingCounter - 1;
+ }
+ }
+ if ($this->_onlyMemoryCaching) {
+ return true;
+ }
+ }
+ if (!($dh = opendir($dir))) {
+ $this->log->log('Unable to open cache directory!', LOGGER_PRIO_ERROR );
+ return false;
+ }
+ $result = true;
+ while ($file = readdir($dh)) {
+ if (($file != '.') && ($file != '..')) {
+ if (substr($file, 0, 6)=='cache_') {
+ $file2 = $dir . $file;
+ if (is_file($file2)) {
+ switch ($mode) {
+ case 'old':
+ // files older than lifeTime get deleted from cache
+ if ((mktime() - filemtime($file2)) > $this->_lifeTime) {
+ $result = ($result and ($this->_unlink($file2)));
+ }
+ break;
+ case 'notingroup':
+ if (!strpos($file2, $motif, 0)) {
+ $result = ($result and ($this->_unlink($file2)));
+ }
+ break;
+ case 'ingroup':
+ default:
+ if (strpos($file2, $motif, 0)) {
+ $result = ($result and ($this->_unlink($file2)));
+ }
+ break;
+ }
+ }
+ if ((is_dir($file2)) and ($this->_hashedDirectoryLevel>0)) {
+ $result = ($result and ($this->_cleanDir($file2 . '/', $group, $mode)));
+ }
+ }
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Add some date in the memory caching array
+ *
+ * @param string $id cache id
+ * @param string $data data to cache
+ * @access private
+ */
+ function _memoryCacheAdd($id, $data)
+ {
+ $this->_memoryCachingArray[$this->_file] = $data;
+ if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) {
+ list($key, $value) = each($this->_memoryCachingArray);
+ unset($this->_memoryCachingArray[$key]);
+ } else {
+ $this->_memoryCachingCounter = $this->_memoryCachingCounter + 1;
+ }
+ }
+
+ /**
+ * Make a file name (with path)
+ *
+ * @param string $id cache id
+ * @param string $group name of the group
+ * @access private
+ */
+ function _setFileName($id, $group)
+ {
+
+ if ($this->_fileNameProtection) {
+ $suffix = 'cache_'.md5($group).'_'.md5($id);
+ } else {
+ $suffix = 'cache_'.$group.'_'.$id;
+ }
+ $root = $this->_cacheDir;
+ if ($this->_hashedDirectoryLevel>0) {
+ $hash = md5($suffix);
+ for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
+ $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
+ }
+ }
+ $this->_fileName = $suffix;
+ $this->_file = $root.$suffix;
+ }
+
+ /**
+ * Read the cache file and return the content
+ *
+ * @return string content of the cache file
+ * @access private
+ */
+ function _read()
+ {
+ $fp = @fopen($this->_file, "rb");
+ if ($this->_fileLocking) @flock($fp, LOCK_SH);
+ if ($fp) {
+ clearstatcache(); // because the filesize can be cached by PHP itself...
+ $length = @filesize($this->_file);
+ $mqr = get_magic_quotes_runtime();
+ set_magic_quotes_runtime(0);
+ if ($this->_readControl) {
+ $hashControl = @fread($fp, 32);
+ $length = $length - 32;
+ }
+ $data = @fread($fp, $length);
+ set_magic_quotes_runtime($mqr);
+ if ($this->_fileLocking) @flock($fp, LOCK_UN);
+ @fclose($fp);
+ if ($this->_readControl) {
+ $hashData = $this->_hash($data, $this->_readControlType);
+ if ($hashData == false) {
+ return false;
+ }
+ if ($hashData != $hashControl) {
+ @touch($this->_file, time() - 2*abs($this->_lifeTime));
+ return false;
+ }
+ }
+ return $data;
+ }
+ $this->log->log( 'Unable to read cache !', LOGGER_PRIO_ERROR );
+ return false;
+ }
+
+ /**
+ * Write the given data in the cache file
+ *
+ * @param string $data data to put in cache
+ * @return boolean true if ok
+ * @access private
+ */
+ function _write($data)
+ {
+ $this->_createCacheDir();
+ $fp = @fopen($this->_file, 'w');
+ if ($fp) {
+ if ($this->_fileLocking) @flock($fp, LOCK_EX);
+ if ($this->_readControl) {
+ $hashData = $this->_hash($data, $this->_readControlType);
+ if ($hasData)
+ @fwrite($fp, $hasData, 32);
+ else
+ return false;
+ }
+ $len = strlen($data);
+ @fwrite($fp, $data, $len);
+ if ($this->_fileLocking) @flock($fp, LOCK_UN);
+ @fclose($fp);
+ return true;
+ }
+ $this->log->log('Unable to write cache file : '.$this->_file, LOGGER_PRIO_ERROR );
+ return false;
+ }
+
+ function _createCacheDir()
+ {
+ if (($this->_hashedDirectoryLevel>0)) {
+ $hash = md5($this->_fileName);
+ $root = $this->_cacheDir;
+ for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
+ $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
+ if (!is_dir($root)) {
+ @mkdir($root, 0700);
+ }
+ }
+ }
+ }
+
+ /**
+ * Write the given data in the cache file and control it just after to avoir corrupted cache entries
+ *
+ * @param string $data data to put in cache
+ * @return boolean true if the test is ok
+ * @access private
+ */
+ function _writeAndControl($data)
+ {
+ $this->_write($data);
+ $dataRead = $this->_read($data);
+ return ($dataRead==$data);
+ }
+
+ /**
+ * Make a control key with the string containing datas
+ *
+ * @param string $data data
+ * @param string $controlType type of control 'md5', 'crc32' or 'strlen'
+ * @return string control key
+ * @access private
+ */
+ function _hash($data, $controlType)
+ {
+ switch ($controlType) {
+ case 'md5':
+ return md5($data);
+ case 'crc32':
+ return sprintf('% 32d', crc32($data));
+ case 'strlen':
+ return sprintf('% 32d', strlen($data));
+ default:
+ $this->log->log('Unknown cache controlType! Caching will be disabled
+ (available values are only \'md5\', \'crc32\', \'strlen\')',
+ LOGGER_PRIO_ERROR );
+ return false;
+ }
+ }
+
+ function byteValue($val) {
+ $val = trim($val);
+ $last = strtolower($val{strlen($val)-1});
+ switch($last) {
+ case 'g':
+ $val *= 1024;
+ case 'm':
+ $val *= 1024;
+ case 'k':
+ $val *= 1024;
+ }
+
+ return $val;
+ }
+
+}
+
+?>
Modified: plog/trunk/class/controller/admincontrollermap.properties.php
===================================================================
--- plog/trunk/class/controller/admincontrollermap.properties.php 2006-02-07 14:23:55 UTC (rev 2928)
+++ plog/trunk/class/controller/admincontrollermap.properties.php 2006-02-07 14:26:38 UTC (rev 2929)
@@ -241,6 +241,8 @@
// remove a trackback
$actions["deleteTrackback"] = "AdminDeleteTrackbackAction";
$actions["deleteTrackbacks"] = "AdminDeleteTrackbackAction";
+ // massive change trackbacks status
+ $actions["changeTrackbacksStatus"] = "AdminChangeTrackbacksStatusAction";
// delete referrers
$actions["deleteReferrer"] = "AdminDeleteReferrerAction";
$actions["deleteReferrers"] = "AdminDeleteReferrerAction";
Modified: plog/trunk/class/plugin/eventlist.properties.php
===================================================================
--- plog/trunk/class/plugin/eventlist.properties.php 2006-02-07 14:23:55 UTC (rev 2928)
+++ plog/trunk/class/plugin/eventlist.properties.php 2006-02-07 14:26:38 UTC (rev 2929)
@@ -12,166 +12,169 @@
* to discover them
*/
+ $eventValue = 0;
+
// single post and bunch of posts loaded
- define( "EVENT_POST_LOADED", 1 );
- define( "EVENT_POSTS_LOADED", 2 );
+ define( "EVENT_POST_LOADED", ++$eventValue );
+ define( "EVENT_POSTS_LOADED", ++$eventValue );
// single comment and bunch of comments loaded
- define( "EVENT_COMMENT_LOADED", 3 );
- define( "EVENT_COMMENTS_LOADED", 4 );
+ define( "EVENT_COMMENT_LOADED", ++$eventValue );
+ define( "EVENT_COMMENTS_LOADED", ++$eventValue );
// post previewed, in the admin interface
- define( "EVENT_POST_PREVIEW", 5 );
+ define( "EVENT_POST_PREVIEW", ++$eventValue );
// before and after a post is added, updated and deleted
- define( "EVENT_PRE_POST_ADD", 6 );
- define( "EVENT_POST_POST_ADD", 7 );
- define( "EVENT_PRE_POST_UPDATE", 8 );
- define( "EVENT_POST_POST_UPDATE", 9 );
- define( "EVENT_PRE_POST_DELETE", 10 );
- define( "EVENT_POST_POST_DELETE", 11 );
+ define( "EVENT_PRE_POST_ADD", ++$eventValue );
+ define( "EVENT_POST_POST_ADD", ++$eventValue );
+ define( "EVENT_PRE_POST_UPDATE", ++$eventValue );
+ define( "EVENT_POST_POST_UPDATE", ++$eventValue );
+ define( "EVENT_PRE_POST_DELETE", ++$eventValue );
+ define( "EVENT_POST_POST_DELETE", ++$eventValue );
// before and after a new category is added, updated and deleted
- define( "EVENT_PRE_CATEGORY_ADD", 12 );
- define( "EVENT_POST_CATEGORY_ADD", 13 );
- define( "EVENT_PRE_CATEGORY_UPDATE", 14 );
- define( "EVENT_POST_CATEGORY_UPDATE", 15 );
- define( "EVENT_PRE_CATEGORY_DELETE", 16 );
- define( "EVENT_POST_CATEGORY_DELETE", 17 );
+ define( "EVENT_PRE_CATEGORY_ADD", ++$eventValue );
+ define( "EVENT_POST_CATEGORY_ADD", ++$eventValue );
+ define( "EVENT_PRE_CATEGORY_UPDATE", ++$eventValue );
+ define( "EVENT_POST_CATEGORY_UPDATE", ++$eventValue );
+ define( "EVENT_PRE_CATEGORY_DELETE", ++$eventValue );
+ define( "EVENT_POST_CATEGORY_DELETE", ++$eventValue );
// before and after a comment is added, updated and deleted
- define( "EVENT_PRE_COMMENT_ADD", 18 );
- define( "EVENT_POST_COMMENT_ADD", 19 );
- define( "EVENT_PRE_COMMENT_UPDATE", 20 );
- define( "EVENT_POST_COMMENT_UPDATE", 21 );
- define( "EVENT_PRE_COMMENT_DELETE", 22 );
- define( "EVENT_POST_COMMENT_DELETE", 23 );
+ define( "EVENT_PRE_COMMENT_ADD", ++$eventValue );
+ define( "EVENT_POST_COMMENT_ADD", ++$eventValue );
+ define( "EVENT_PRE_COMMENT_UPDATE", ++$eventValue );
+ define( "EVENT_POST_COMMENT_UPDATE", ++$eventValue );
+ define( "EVENT_PRE_COMMENT_DELETE", ++$eventValue );
+ define( "EVENT_POST_COMMENT_DELETE", ++$eventValue );
// before and after a comment is marked as spam and no-spam
- define( "EVENT_PRE_MARK_SPAM_COMMENT", 24 );
- define( "EVENT_POST_MARK_SPAM_COMMENT", 25 );
- define( "EVENT_PRE_MARK_NO_SPAM_COMMENT", 26 );
- define( "EVENT_POST_MARK_NO_SPAM_COMMENT", 27 );
+ define( "EVENT_PRE_MARK_SPAM_COMMENT", ++$eventValue );
+ define( "EVENT_POST_MARK_SPAM_COMMENT", ++$eventValue );
+ define( "EVENT_PRE_MARK_NO_SPAM_COMMENT", ++$eventValue );
+ define( "EVENT_POST_MARK_NO_SPAM_COMMENT", ++$eventValue );
// before and after a trackback is received
- define( "EVENT_PRE_TRACKBACK_ADD", 28 );
- define( "EVENT_POST_TRACKBACK_ADD", 29 );
+ define( "EVENT_PRE_TRACKBACK_ADD", ++$eventValue );
+ define( "EVENT_POST_TRACKBACK_ADD", ++$eventValue );
+ define( "EVENT_PRE_TRACKBACK_DELETE", ++$eventValue );
+ define( "EVENT_POST_TRACKBACK_DELETE", ++$eventValue );
+ define( "EVENT_PRE_TRACKBACK_UPDATE", ++$eventValue );
+ define( "EVENT_POST_TRACKBACK_UPDATE", ++$eventValue );
// load the post trackbacks
- define( "EVENT_TRACKBACKS_LOADED", 30 );
+ define( "EVENT_TRACKBACKS_LOADED", ++$eventValue );
// successful and unsuccessful login
- define( "EVENT_LOGIN_SUCCESS", 31 );
- define( "EVENT_LOGIN_FAILURE", 32 );
+ define( "EVENT_LOGIN_SUCCESS", ++$eventValue );
+ define( "EVENT_LOGIN_FAILURE", ++$eventValue );
// logout event
- define( "EVENT_PRE_LOGOUT", 33 );
- define( "EVENT_POST_LOGOUT", 34 );
+ define( "EVENT_PRE_LOGOUT", ++$eventValue );
+ define( "EVENT_POST_LOGOUT", ++$eventValue );
// before and after a user is registered, deleted and updated
- define( "EVENT_PRE_USER_ADD", 35 );
- define( "EVENT_POST_USER_ADD", 36 );
- define( "EVENT_PRE_USER_DELETE", 37 );
- define( "EVENT_POST_USER_DELETE", 38 );
- define( "EVENT_PRE_USER_UPDATE", 39 );
- define( "EVENT_POST_USER_UPDATE", 40 );
+ define( "EVENT_PRE_USER_ADD", ++$eventValue );
+ define( "EVENT_POST_USER_ADD", ++$eventValue );
+ define( "EVENT_PRE_USER_DELETE", ++$eventValue );
+ define( "EVENT_POST_USER_DELETE", ++$eventValue );
+ define( "EVENT_PRE_USER_UPDATE", ++$eventValue );
+ define( "EVENT_POST_USER_UPDATE", ++$eventValue );
// before and after a new blog is registered
- define( "EVENT_PRE_BLOG_ADD", 41 );
- define( "EVENT_POST_BLOG_ADD", 42 );
- define( "EVENT_PRE_BLOG_DELETE", 43 );
- define( "EVENT_POST_BLOG_DELETE", 44 );
- define( "EVENT_PRE_BLOG_UPDATE", 45 );
- define( "EVENT_POST_BLOG_UPDATE", 46 );
+ define( "EVENT_PRE_BLOG_ADD", ++$eventValue );
+ define( "EVENT_POST_BLOG_ADD", ++$eventValue );
+ define( "EVENT_PRE_BLOG_DELETE", ++$eventValue );
+ define( "EVENT_POST_BLOG_DELETE", ++$eventValue );
+ define( "EVENT_PRE_BLOG_UPDATE", ++$eventValue );
+ define( "EVENT_POST_BLOG_UPDATE", ++$eventValue );
// before and after a custom field is added, updated and deleted
- define( "EVENT_PRE_CUSTOM_FIELD_ADD", 47 );
- define( "EVENT_POST_CUSTOM_FIELD_ADD", 48 );
- define( "EVENT_PRE_CUSTOM_FIELD_UPDATE", 49 );
- define( "EVENT_POST_CUSTOM_FIELD_UPDATE", 50 );
- define( "EVENT_PRE_CUSTOM_FIELD_DELETE", 51 );
- define( "EVENT_POST_CUSTOM_FIELD_DELETE", 52 );
+ define( "EVENT_PRE_CUSTOM_FIELD_ADD", ++$eventValue );
+ define( "EVENT_POST_CUSTOM_FIELD_ADD", ++$eventValue );
+ define( "EVENT_PRE_CUSTOM_FIELD_UPDATE", ++$eventValue );
+ define( "EVENT_POST_CUSTOM_FIELD_UPDATE", ++$eventValue );
+ define( "EVENT_PRE_CUSTOM_FIELD_DELETE", ++$eventValue );
+ define( "EVENT_POST_CUSTOM_FIELD_DELETE", ++$eventValue );
// before and after the settings of the blog are updated
- define( "EVENT_PRE_BLOG_SETTINGS_UPDATE", 53 );
- define( "EVENT_POST_BLOG_SETTINGS_UPDATE", 54 );
+ define( "EVENT_PRE_BLOG_SETTINGS_UPDATE", ++$eventValue );
+ define( "EVENT_POST_BLOG_SETTINGS_UPDATE", ++$eventValue );
// before and after a resource is added, updated and deleted
- define( "EVENT_PRE_RESOURCE_ADD", 55 );
- define( "EVENT_POST_RESOURCE_ADD", 56 );
- define( "EVENT_PRE_RESOURCE_UPDATE", 57 );
- define( "EVENT_POST_RESOURCE_UPDATE", 58 );
- define( "EVENT_PRE_RESOURCE_DELETE", 59 );
- define( "EVENT_POST_RESOURCE_DELETE", 60 );
+ define( "EVENT_PRE_RESOURCE_ADD", ++$eventValue );
+ define( "EVENT_POST_RESOURCE_ADD", ++$eventValue );
+ define( "EVENT_PRE_RESOURCE_UPDATE", ++$eventValue );
+ define( "EVENT_POST_RESOURCE_UPDATE", ++$eventValue );
+ define( "EVENT_PRE_RESOURCE_DELETE", ++$eventValue );
+ define( "EVENT_POST_RESOURCE_DELETE", ++$eventValue );
// before and after a resource album is added, updated and deleted
- define( "EVENT_PRE_ALBUM_ADD", 61 );
- define( "EVENT_POST_ALBUM_ADD", 62 );
- define( "EVENT_PRE_ALBUM_UPDATE", 63 );
- define( "EVENT_POST_ALBUM_UPDATE", 64 );
- define( "EVENT_PRE_ALBUM_DELETE", 65 );
- define( "EVENT_POST_ALBUM_DELETE", 66 );
+ define( "EVENT_PRE_ALBUM_ADD", ++$eventValue );
+ define( "EVENT_POST_ALBUM_ADD", ++$eventValue );
+ define( "EVENT_PRE_ALBUM_UPDATE", ++$eventValue );
+ define( "EVENT_POST_ALBUM_UPDATE", ++$eventValue );
+ define( "EVENT_PRE_ALBUM_DELETE", ++$eventValue );
+ define( "EVENT_POST_ALBUM_DELETE", ++$eventValue );
// resources loaded
- define( "EVENT_RESOURCE_LOADED", 67 );
- define( "EVENT_RESOURCES_LOADED", 68 );
+ define( "EVENT_RESOURCE_LOADED", ++$eventValue );
+ define( "EVENT_RESOURCES_LOADED", ++$eventValue );
// some others that I forgot..
- define( "EVENT_CUSTOM_FIELD_LOADED", 69 );
- define( "EVENT_CUSTOM_FIELDS_LOADED", 70 );
- define( "EVENT_CATEGORY_LOADED", 71 );
- define( "EVENT_CATEGORIES_LOADED", 72 );
- define( "EVENT_USER_REGISTER", 73 );
- define( "EVENT_BLOG_REGISTER", 74 );
- define( "EVENT_USERS_LOADED", 75 );
- define( "EVENT_USER_LOADED", 76 );
- define( "EVENT_BLOG_LOADED", 77 );
- define( "EVENT_BLOGS_LOADED", 78 );
+ define( "EVENT_CUSTOM_FIELD_LOADED", ++$eventValue );
+ define( "EVENT_CUSTOM_FIELDS_LOADED", ++$eventValue );
+ define( "EVENT_CATEGORY_LOADED", ++$eventValue );
+ define( "EVENT_CATEGORIES_LOADED", ++$eventValue );
+ define( "EVENT_USER_REGISTER", ++$eventValue );
+ define( "EVENT_BLOG_REGISTER", ++$eventValue );
+ define( "EVENT_USERS_LOADED", ++$eventValue );
+ define( "EVENT_USER_LOADED", ++$eventValue );
+ define( "EVENT_BLOG_LOADED", ++$eventValue );
+ define( "EVENT_BLOGS_LOADED", ++$eventValue );
// template and locale events
- define( "EVENT_PRE_TEMPLATE_ADD", 79 );
- define( "EVENT_POST_TEMPLATE_ADD", 80);
- define( "EVENT_PRE_TEMPLATE_DELETE", 81 );
- define( "EVENT_POST_TEMPLATE_DELETE", 82 );
- define( "EVENT_PRE_LOCALE_ADD", 83 );
- define( "EVENT_POST_LOCALE_ADD", 84 );
- define( "EVENT_PRE_LOCALE_DELETE", 85 );
- define( "EVENT_POST_LOCALE_DELETE", 86 );
+ define( "EVENT_PRE_TEMPLATE_ADD", ++$eventValue );
+ define( "EVENT_POST_TEMPLATE_ADD", ++$eventValue);
+ define( "EVENT_PRE_TEMPLATE_DELETE", ++$eventValue );
+ define( "EVENT_POST_TEMPLATE_DELETE", ++$eventValue );
+ define( "EVENT_PRE_LOCALE_ADD", ++$eventValue );
+ define( "EVENT_POST_LOCALE_ADD", ++$eventValue );
+ define( "EVENT_PRE_LOCALE_DELETE", ++$eventValue );
+ define( "EVENT_POST_LOCALE_DELETE", ++$eventValue );
// albums
- define( "EVENT_ALBUM_LOADED", 87 );
- define( "EVENT_ALBUMS_LOADED", 88 );
+ define( "EVENT_ALBUM_LOADED", ++$eventValue );
+ define( "EVENT_ALBUMS_LOADED", ++$eventValue );
// links
- define( "EVENT_PRE_LINK_ADD", 89 );
- define( "EVENT_POST_LINK_ADD", 90 );
- define( "EVENT_PRE_LINK_UPDATE", 91 );
- define( "EVENT_POST_LINK_UPDATE", 92 );
- define( "EVENT_PRE_LINK_DELETE", 93 );
- define( "EVENT_POST_LINK_DELETE", 94 );
- define( "EVENT_LINK_LOADED", 95 );
- define ("EVENT_LINKS_LOADED", 96 );
+ define( "EVENT_PRE_LINK_ADD", ++$eventValue );
+ define( "EVENT_POST_LINK_ADD", ++$eventValue );
+ define( "EVENT_PRE_LINK_UPDATE", ++$eventValue );
+ define( "EVENT_POST_LINK_UPDATE", ++$eventValue );
+ define( "EVENT_PRE_LINK_DELETE", ++$eventValue );
+ define( "EVENT_POST_LINK_DELETE", ++$eventValue );
+ define( "EVENT_LINK_LOADED", ++$eventValue );
+ define ("EVENT_LINKS_LOADED", ++$eventValue );
// link categories
- define( "EVENT_PRE_LINK_CATEGORY_ADD", 97 );
- define( "EVENT_POST_LINK_CATEGORY_ADD", 98 );
- define( "EVENT_PRE_LINK_CATEGORY_UPDATE", 99 );
- define( "EVENT_POST_LINK_CATEGORY_UPDATE", 100 );
- define( "EVENT_PRE_LINK_CATEGORY_DELETE", 101 );
- define( "EVENT_POST_LINK_CATEGORY_DELETE", 102 );
- define( "EVENT_LINK_CATEGORY_LOADED", 103 );
- define( "EVENT_LINK_CATEGORIES_LOADED", 104 );
+ define( "EVENT_PRE_LINK_CATEGORY_ADD", ++$eventValue );
+ define( "EVENT_POST_LINK_CATEGORY_ADD", ++$eventValue );
+ define( "EVENT_PRE_LINK_CATEGORY_UPDATE", ++$eventValue );
+ define( "EVENT_POST_LINK_CATEGORY_UPDATE", ++$eventValue );
+ define( "EVENT_PRE_LINK_CATEGORY_DELETE", ++$eventValue );
+ define( "EVENT_POST_LINK_CATEGORY_DELETE", ++$eventValue );
+ define( "EVENT_LINK_CATEGORY_LOADED", ++$eventValue );
+ define( "EVENT_LINK_CATEGORIES_LOADED", ++$eventValue );
// event thrown when plog is going to render some text that could be written
// in something else other than xhtml markup (wiki) or to implement text filters
// such as textile and stuff like that... by popular request, again :-)
- define( "EVENT_TEXT_FILTER", 105 );
- // when removing trackbacks
- define( "EVENT_PRE_TRACKBACK_DELETE", 106 );
- define( "EVENT_POST_TRACKBACK_DELETE", 107 );
+ define( "EVENT_TEXT_FILTER", ++$eventValue );
// for referrers
- define( "EVENT_PRE_REFERRER_DELETE", 108 );
- define( "EVENT_POST_REFERRER_DELETE", 109 );
- define( "EVENT_PRE_REFERRER_ADD", 110 );
- define( "EVENT_POST_REFERRER_ADD", 111 );
+ define( "EVENT_PRE_REFERRER_DELETE", ++$eventValue );
+ define( "EVENT_POST_REFERRER_DELETE", ++$eventValue );
+ define( "EVENT_PRE_REFERRER_ADD", ++$eventValue );
+ define( "EVENT_POST_REFERRER_ADD", ++$eventValue );
// before and after a trackback is marked as spam and no-spam
- define( "EVENT_PRE_MARK_SPAM_TRACKBACK", 24 );
- define( "EVENT_POST_MARK_SPAM_TRACKBACK", 25 );
- define( "EVENT_PRE_MARK_NO_SPAM_TRACKBACK", 26 );
- define( "EVENT_POST_MARK_NO_SPAM_TRACKBACK", 27 );
+ define( "EVENT_PRE_MARK_SPAM_TRACKBACK", EVENT_PRE_MARK_SPAM_COMMENT );
+ define( "EVENT_POST_MARK_SPAM_TRACKBACK", EVENT_POST_MARK_SPAM_COMMENT );
+ define( "EVENT_PRE_MARK_NO_SPAM_TRACKBACK", EVENT_PRE_MARK_NO_SPAM_COMMENT );
+ define( "EVENT_POST_MARK_NO_SPAM_TRACKBACK", EVENT_POST_MARK_NO_SPAM_COMMENT );
// events related to new blog categories
- define( "EVENT_PRE_ADD_BLOG_CATEGORY", 112 );
- define( "EVENT_POST_ADD_BLOG_CATEGORY", 113 );
- define( "EVENT_PRE_UPDATE_BLOG_CATEGORY", 114 );
- define( "EVENT_POST_UPDATE_BLOG_CATEGORY", 115 );
- define( "EVENT_PRE_DELETE_BLOG_CATEGORY", 116 );
- define( "EVENT_POST_DELETE_BLOG_CATEGORY", 117 );
- define( "EVENT_BLOG_CATEGORIES_LOADED", 118 );
+ define( "EVENT_PRE_ADD_BLOG_CATEGORY", ++$eventValue );
+ define( "EVENT_POST_ADD_BLOG_CATEGORY", ++$eventValue );
+ define( "EVENT_PRE_UPDATE_BLOG_CATEGORY", ++$eventValue );
+ define( "EVENT_POST_UPDATE_BLOG_CATEGORY", ++$eventValue );
+ define( "EVENT_PRE_DELETE_BLOG_CATEGORY", ++$eventValue );
+ define( "EVENT_POST_DELETE_BLOG_CATEGORY", ++$eventValue );
+ define( "EVENT_BLOG_CATEGORIES_LOADED", ++$eventValue );
// global article categories
- define( "EVENT_PRE_ADD_GLOBAL_CATEGORY", 119 );
- define( "EVENT_POST_ADD_GLOBAL_CATEGORY", 120 );
- define( "EVENT_PRE_UPDATE_GLOBAL_CATEGORY", 121 );
- define( "EVENT_POST_UPDATE_GLOBAL_CATEGORY", 122 );
- define( "EVENT_PRE_DELETE_GLOBAL_CATEGORY", 123 );
- define( "EVENT_POST_DELETE_GLOBAL_CATEGORY", 124 );
- define( "EVENT_GLOBAL_CATEGORIES_LOADED", 125 );
+ define( "EVENT_PRE_ADD_GLOBAL_CATEGORY", ++$eventValue );
+ define( "EVENT_POST_ADD_GLOBAL_CATEGORY", ++$eventValue );
+ define( "EVENT_PRE_UPDATE_GLOBAL_CATEGORY", ++$eventValue );
+ define( "EVENT_POST_UPDATE_GLOBAL_CATEGORY", ++$eventValue );
+ define( "EVENT_PRE_DELETE_GLOBAL_CATEGORY", ++$eventValue );
+ define( "EVENT_POST_DELETE_GLOBAL_CATEGORY", ++$eventValue );
+ define( "EVENT_GLOBAL_CATEGORIES_LOADED", ++$eventValue );
// post-processing of templates
- define( "EVENT_PROCESS_BLOG_TEMPLATE_OUTPUT", 126 );
+ define( "EVENT_PROCESS_BLOG_TEMPLATE_OUTPUT", ++$eventValue );
?>
\ No newline at end of file
Modified: plog/trunk/js/ui/plogui.js
===================================================================
--- plog/trunk/js/ui/plogui.js 2006-02-07 14:23:55 UTC (rev 2928)
+++ plog/trunk/js/ui/plogui.js 2006-02-07 14:26:38 UTC (rev 2929)
@@ -195,6 +195,25 @@
}
}
+function submitTrackbacksList(op)
+{
+ if ( op == 'changeTrackbacksStatus' )
+ {
+ if ( document.getElementById("postTrackbacksList").trackbackStatus.value == -1 )
+ window.alert(errorTrackbackStatusMsg);
+ else
+ {
+ document.getElementById("postTrackbacksList").op.value = op;
+ document.getElementById("postTrackbacksList").submit();
+ }
+ }
+ else
+ {
+ document.getElementById("postTrackbacksList").op.value = op;
+ document.getElementById("postTrackbacksList").submit();
+ }
+}
+
function switchMassiveOption()
{
if ( $('massiveChangeOption').style.display == 'none' )
Modified: plog/trunk/templates/admin/edittrackbacks.template
===================================================================
--- plog/trunk/templates/admin/edittrackbacks.template 2006-02-07 14:23:55 UTC (rev 2928)
+++ plog/trunk/templates/admin/edittrackbacks.template 2006-02-07 14:26:38 UTC (rev 2929)
@@ -1,11 +1,17 @@
{include file="$admintemplatepath/header.template"}
{include file="$admintemplatepath/navigation.template" showOpt=editTrackbacks title=$locale->tr("editTrackbacks")}
+ <script type="text/javascript" src="js/ui/plogui.js"></script>
+ <script type="text/javascript">
+ var errorTrackbackStatusMsg = '{$locale->tr("error_trackback_status")}';
+ var showMassiveChangeOption = '{$locale->tr("show_massive_change_option")}';
+ var hideMassiveChangeOption = '{$locale->tr("hide_massive_change_option")}';
+ </script>
<div id="list_nav_bar">
<div id="list_nav_select">
<form id="showBy" action="admin.php" method="post">
<fieldset>
- <legend>{$locale->tr("show_by")}</legend>
+ <legend>{$locale->tr("show_by")} {if $post}( {$post->getTopic()} ){/if}</legend>
<div class="list_nav_option">
<label for="showStatus">{$locale->tr("status")}</label>
@@ -36,14 +42,17 @@
<br style="clear:both;" />
</div>
- <form id="postTrackbacks" action="admin.php" method="post">
+ <form id="postTrackbacksList" action="admin.php" method="post">
+ <div class="optionIcon">
+ <a id="optionIconLink" href="#" title="{$locale->tr("show_massive_change_option")}" onclick="switchMassiveOption()">{$locale->tr("show_massive_change_option")}</a>
+ </div>
<div id="list">
{include file="$admintemplatepath/successmessage.template"}
{include file="$admintemplatepath/errormessage.template"}
<table class="info">
<thead>
<tr>
- <th style="width:10px;"><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="toggleAllChecks('postCommentsList');" /></th>
+ <th style="width:10px;"><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="toggleAllChecks('postTrackbacksList');" /></th>
<th style="width:85px;">{$locale->tr("topic")}</th>
<th style="width:360px;">{$locale->tr("text")}</th>
<th style="width:70px;">{$locale->tr("author")}</th>
@@ -57,7 +66,7 @@
{foreach from=$comments item=trackback}
<tr class="{cycle values="odd,even"}">
<td>
- <input class="checkbox" type="checkbox" name="trackbackIds[{$trackback->getId()}]" id="checks_1" value="{$trackback->getId()}" />
+ <input class="checkbox" type="checkbox" name="trackbackIds[{$trackback->getId()}]" id="trackbackIds[{$trackback->getId()}]" value="{$trackback->getId()}" />
</td>
<td class="col_highlighted">
{$trackback->getTopic()}
@@ -101,9 +110,23 @@
</div>
<div id="list_action_bar">
{include file="$admintemplatepath/adminpager.template" style=list}
- <input type="submit" name="delete" value="{$locale->tr("delete")}" class="submit" />
<input type="hidden" name="articleId" value="{if $post}{$post->getId()}{else}0{/if}" />
- <input type="hidden" name="op" value="deleteTrackbacks" />
+ <input type="button" name="delete" value="{$locale->tr("delete")}" class="submit" onClick="javascript:submitTrackbacksList('deleteTrackbacks');" />
+ <input type="hidden" name="op" value="" />
+ <div id="massiveChangeOption" style="display: none">
+ <fieldset>
+ <legend>{$locale->tr("messave_change_option")}</legend>
+ <label for="trackbackStatus">{$locale->tr("status")}</label>
+ <select name="trackbackStatus" id="trackbackStatus">
+ <option value="-1">-{$locale->tr("select")}-</option>
+ {foreach from=$commentstatusWithoutAll key=name item=status}
+ <option value="{$status}">{$locale->tr($name)}</option>
+ {/foreach}
+ </select>
+ <input type="button" name="changeTrackbacksStatus" value="{$locale->tr("change_status")}" class="submit" onClick="javascript:submitTrackbacksList('changeTrackbacksStatus');" />
+ </fieldset>
+ </div>
+ </div>
</div>
</form>
{include file="$admintemplatepath/footernavigation.template"}
More information about the pLog-svn
mailing list