aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/include/functions_upgrade.php50
-rw-r--r--admin/template/goto/permalinks.tpl56
-rw-r--r--include/category_default.inc.php7
-rw-r--r--include/common.inc.php28
-rw-r--r--include/config_default.inc.php1
-rw-r--r--include/functions.inc.php78
-rw-r--r--include/functions_plugins.inc.php103
-rw-r--r--plugins/event_tracer/main.inc.php27
-rw-r--r--template/yoga/menubar.tpl2
9 files changed, 151 insertions, 201 deletions
diff --git a/admin/include/functions_upgrade.php b/admin/include/functions_upgrade.php
index d7c1a4e96..3181946eb 100644
--- a/admin/include/functions_upgrade.php
+++ b/admin/include/functions_upgrade.php
@@ -185,4 +185,52 @@ WHERE '.$conf['user_fields']['username'].'="'.$username.'"
define('PHPWG_IN_UPGRADE', true);
}
}
-?>
+
+/**
+ * which upgrades are available ?
+ *
+ * @return array
+ */
+function get_available_upgrade_ids()
+{
+ $upgrades_path = PHPWG_ROOT_PATH.'install/db';
+
+ $available_upgrade_ids = array();
+
+ if ($contents = opendir($upgrades_path))
+ {
+ while (($node = readdir($contents)) !== false)
+ {
+ if (is_file($upgrades_path.'/'.$node)
+ and preg_match('/^(.*?)-database\.php$/', $node, $match))
+ {
+ array_push($available_upgrade_ids, $match[1]);
+ }
+ }
+ }
+ natcasesort($available_upgrade_ids);
+
+ return $available_upgrade_ids;
+}
+
+
+/**
+ * returns true if there are available upgrade files
+ */
+function check_upgrade_feed()
+{
+ // retrieve already applied upgrades
+ $query = '
+SELECT id
+ FROM '.UPGRADE_TABLE.'
+;';
+ $applied = array_from_query($query, 'id');
+
+ // retrieve existing upgrades
+ $existing = get_available_upgrade_ids();
+
+ // which upgrades need to be applied?
+ return (count(array_diff($existing, $applied)) > 0);
+}
+
+?> \ No newline at end of file
diff --git a/admin/template/goto/permalinks.tpl b/admin/template/goto/permalinks.tpl
index 375853a40..3e04cc3d0 100644
--- a/admin/template/goto/permalinks.tpl
+++ b/admin/template/goto/permalinks.tpl
@@ -28,40 +28,40 @@
<h3>{'Permalinks'|@translate}</h3>
<table class="table2">
- <tr class="throw">
- <td style="width:20%;">Id {$SORT_ID}</td>
- <td style="width:20%;">{'Category'|@translate} {$SORT_NAME}</td>
- <td style="width:20%;">{'Permalink'|@translate} {$SORT_PERMALINK}</td>
- </tr>
+ <tr class="throw">
+ <td>Id {$SORT_ID}</td>
+ <td>{'Category'|@translate} {$SORT_NAME}</td>
+ <td>{'Permalink'|@translate} {$SORT_PERMALINK}</td>
+ </tr>
{foreach from=$permalinks item=permalink name="permalink_loop"}
- <tr class="{if $smarty.foreach.permalink_loop.index is odd}row1{else}row2{/if}" style="line-height: 2.2em;">
- <td style="text-align:center;">{$permalink.id}</td>
- <td>{$permalink.name}</td>
- <td>{$permalink.permalink}</td>
- </tr>
+ <tr class="{if $smarty.foreach.permalink_loop.index is odd}row1{else}row2{/if}" style="line-height:1.5em;">
+ <td style="text-align:center;">{$permalink.id}</td>
+ <td>{$permalink.name}</td>
+ <td>{$permalink.permalink}</td>
+ </tr>
{/foreach}
</table>
<h3>{'Permalink history'|@translate} <a name="old_permalinks"></a></h3>
<table class="table2">
- <tr class="throw">
- <td style="width:40px;">Id {$SORT_OLD_CAT_ID}</td>
- <td style="width:25%;">{'Category'|@translate}</td>
- <td style="width:25%;">{'Permalink'|@translate} {$SORT_OLD_PERMALINK}</td>
- <td style="width:15%;">Deleted on {$SORT_OLD_DATE_DELETED}</td>
- <td style="width:15%;">Last hit {$SORT_OLD_LAST_HIT}</td>
- <td style="width:20px;">Hit {$SORT_OLD_HIT}</td>
- <td style="width:5px;"></td>
- </tr>
+ <tr class="throw">
+ <td>Id {$SORT_OLD_CAT_ID}</td>
+ <td>{'Category'|@translate}</td>
+ <td>{'Permalink'|@translate} {$SORT_OLD_PERMALINK}</td>
+ <td>Deleted on {$SORT_OLD_DATE_DELETED}</td>
+ <td>Last hit {$SORT_OLD_LAST_HIT}</td>
+ <td style="width:20px;">Hit {$SORT_OLD_HIT}</td>
+ <td style="width:5px;"></td>
+ </tr>
{foreach from=$deleted_permalinks item=permalink}
- <tr style="line-height: 2.2em;">
- <td style="text-align:center;">{$permalink.cat_id}</td>
- <td>{$permalink.name}</td>
- <td>{$permalink.permalink}</td>
- <td>{$permalink.date_deleted}</td>
- <td>{$permalink.last_hit}</td>
- <td>{$permalink.hit}</td>
- <td><a href="{$permalink.U_DELETE}" {$TAG_INPUT_ENABLED}><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/delete.png" alt="[{'delete'|@translate}]" class="button"></a></td>
- </tr>
+ <tr style="line-height:1.5em;">
+ <td style="text-align:center;">{$permalink.cat_id}</td>
+ <td>{$permalink.name}</td>
+ <td>{$permalink.permalink}</td>
+ <td>{$permalink.date_deleted}</td>
+ <td>{$permalink.last_hit}</td>
+ <td>{$permalink.hit}</td>
+ <td><a href="{$permalink.U_DELETE}" {$TAG_INPUT_ENABLED}><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/delete.png" alt="[{'delete'|@translate}]" class="button"></a></td>
+ </tr>
{/foreach}
</table>
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index 025adcc40..98e6250f1 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -134,8 +134,7 @@ foreach ($pictures as $row)
}
if ($conf['show_thumbnail_caption'])
- {
- // name of the picture
+ {// name of the picture
if (isset($row['name']) and $row['name'] != '')
{
$name = $row['name'];
@@ -166,9 +165,7 @@ foreach ($pictures as $row)
if ( isset($nb_comments_of) )
{
- $row['nb_comments'] = isset($nb_comments_of[$row['id']])
- ? (int)$nb_comments_of[$row['id']] : 0;
- $tpl_var['NB_COMMENTS'] = $row['nb_comments'];
+ $tpl_var['NB_COMMENTS'] = (int)@$nb_comments_of[$row['id']];
}
$tpl_thumbnails_var[] = $tpl_var;
diff --git a/include/common.inc.php b/include/common.inc.php
index db50f31f2..76054153a 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -115,18 +115,11 @@ if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') )
pwg_query('SET NAMES "'.DB_CHARSET.'"');
}
}
-else
+elseif ( strtolower(PWG_CHARSET)!='iso-8859-1' )
{
- if ( strtolower(PWG_CHARSET)!='iso-8859-1' )
- {
- fatal_error('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info());
- }
+ fatal_error('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info());
}
-//
-// Setup gallery wide options, if this fails then we output a CRITICAL_ERROR
-// since basic gallery information is not available
-//
load_conf_from_db();
load_plugins();
@@ -187,19 +180,8 @@ if ($conf['gallery_locked'])
if ($conf['check_upgrade_feed'])
{
-
- // retrieve already applied upgrades
- $query = '
-SELECT id
- FROM '.UPGRADE_TABLE.'
-;';
- $applied = array_from_query($query, 'id');
-
- // retrieve existing upgrades
- $existing = get_available_upgrade_ids();
-
- // which upgrades need to be applied?
- if (count(array_diff($existing, $applied)) > 0)
+ include_once(PHPWG_ROOT_PATH.'admin/include/functions_upgrade.php');
+ if (check_upgrade_feed())
{
$header_msgs[] = 'Some database upgrades are missing, '
.'<a href="'.get_absolute_root_url(false).'upgrade_feed.php">upgrade now</a>';
@@ -242,4 +224,4 @@ add_event_handler('render_comment_content', 'parse_comment_content');
add_event_handler('render_comment_author', 'strip_tags');
add_event_handler('blockmanager_register_blocks', 'register_default_menubar_blocks', EVENT_HANDLER_PRIORITY_NEUTRAL-1);
trigger_action('init');
-?>
+?> \ No newline at end of file
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index c0f889808..81fe7ef0f 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -688,7 +688,6 @@ $conf['filter_pages'] = array
'install' => array('cancel' => true),
'password' => array('cancel' => true),
'register' => array('cancel' => true),
- 'upgrade_feed' => array('cancel' => true),
);
// +-----------------------------------------------------------------------+
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 1902acdac..1675dbce8 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -133,12 +133,11 @@ function replace_space( $string )
$remaining = $string;
// $start represents the position of the next '<' character
// $end represents the position of the next '>' character
- $start = 0;
- $end = 0;
- $start = strpos ( $remaining, '<' ); // -> 0
+ ; // -> 0
$end = strpos ( $remaining, '>' ); // -> 16
// as long as a '<' and his friend '>' are found, we loop
- while ( is_numeric( $start ) and is_numeric( $end ) )
+ while ( ($start=strpos( $remaining, '<' )) !==false
+ and ($end=strpos( $remaining, '>' )) !== false )
{
// $treatment is the part of the string to treat
// In the first loop of our example, this variable is empty, but in the
@@ -153,8 +152,6 @@ function replace_space( $string )
// the remaining string is deplaced to the part after the '>' of this
// loop
$remaining = substr ( $remaining, $end + 1, strlen( $remaining ) );
- $start = strpos ( $remaining, '<' );
- $end = strpos ( $remaining, '>' );
}
$treatment = str_replace( ' ', '&nbsp;', $remaining );
$treatment = str_replace( '-', '&minus;', $treatment );
@@ -242,11 +239,8 @@ function mkgetdir($dir, $flags=MKGETDIR_DEFAULT)
}
if ( !is_writable($dir) )
{
- if ( !is_writable($dir) )
- {
- !($flags&MKGETDIR_DIE_ON_ERROR) or fatal_error( "$dir ".l10n('no_write_access'));
- return false;
- }
+ !($flags&MKGETDIR_DIE_ON_ERROR) or fatal_error( "$dir ".l10n('no_write_access'));
+ return false;
}
return true;
}
@@ -464,7 +458,7 @@ function get_languages($target_charset = null)
while ($file = readdir($dir))
{
$path = PHPWG_ROOT_PATH.'language/'.$file;
- if (is_dir($path) and !is_link($path) and file_exists($path.'/iso.txt'))
+ if (!is_link($path) and file_exists($path.'/iso.txt'))
{
list($language_name) = @file($path.'/iso.txt');
@@ -526,15 +520,9 @@ function pwg_log($image_id = null, $image_type = null)
}
$tags_string = null;
- if (isset($page['section']) and $page['section'] == 'tags')
+ if ('tags'==@$page['section'])
{
- $tag_ids = array();
- foreach ($page['tags'] as $tag)
- {
- array_push($tag_ids, $tag['id']);
- }
-
- $tags_string = implode(',', $tag_ids);
+ $tags_string = implode(',', $page['tag_ids']);
}
$query = '
@@ -911,7 +899,7 @@ function get_thumbnail_title($element_info)
if (!empty($element_info['filesize']))
{
- $thumbnail_title .= ' : '.l10n_dec('%d Kb', '%d Kb', $element_info['filesize']);
+ $thumbnail_title .= ' : '.sprintf(l10n('%d Kb'), $element_info['filesize']);
}
return $thumbnail_title;
@@ -1139,33 +1127,6 @@ SELECT '.$conf['user_fields']['email'].'
}
/**
- * which upgrades are available ?
- *
- * @return array
- */
-function get_available_upgrade_ids()
-{
- $upgrades_path = PHPWG_ROOT_PATH.'install/db';
-
- $available_upgrade_ids = array();
-
- if ($contents = opendir($upgrades_path))
- {
- while (($node = readdir($contents)) !== false)
- {
- if (is_file($upgrades_path.'/'.$node)
- and preg_match('/^(.*?)-database\.php$/', $node, $match))
- {
- array_push($available_upgrade_ids, $match[1]);
- }
- }
- }
- natcasesort($available_upgrade_ids);
-
- return $available_upgrade_ids;
-}
-
-/**
* Add configuration parameters from database to global $conf array
*
* @return void
@@ -1274,29 +1235,18 @@ function script_basename()
foreach (array('SCRIPT_NAME', 'SCRIPT_FILENAME', 'PHP_SELF') as $value)
{
- $continue = !empty($_SERVER[$value]);
- if ($continue)
+ if (!empty($_SERVER[$value]))
{
$filename = strtolower($_SERVER[$value]);
-
- if ($conf['php_extension_in_urls'])
- {
- $continue = get_extension($filename) === 'php';
- }
-
- if ($continue)
- {
- $basename = basename($filename, '.php');
- $continue = !empty($basename);
- }
-
- if ($continue)
+ if ($conf['php_extension_in_urls'] and get_extension($filename)!=='php')
+ continue;
+ $basename = basename($filename, '.php');
+ if (!empty($basename))
{
return $basename;
}
}
}
-
return '';
}
diff --git a/include/functions_plugins.inc.php b/include/functions_plugins.inc.php
index 14bb66271..5a5ea79e3 100644
--- a/include/functions_plugins.inc.php
+++ b/include/functions_plugins.inc.php
@@ -109,55 +109,50 @@ function trigger_event($event, $data=null)
{
global $pwg_event_handlers;
- // just for debugging
- trigger_action('pre_trigger_event',
- array('event'=>$event, 'data'=>$data) );
+ if ( isset($pwg_event_handlers['trigger']) )
+ {// just for debugging
+ trigger_action('trigger',
+ array('type'=>'event', 'event'=>$event, 'data'=>$data) );
+ }
if ( !isset($pwg_event_handlers[$event]) )
{
- trigger_action('post_trigger_event',
- array('event'=>$event, 'data'=>$data) );
return $data;
}
$args = array_slice(func_get_args(), 2);
foreach ($pwg_event_handlers[$event] as $priority => $handlers)
{
- if ( !is_null($handlers) )
+ foreach($handlers as $handler)
{
- foreach($handlers as $handler)
- {
- $all_args = array_merge( array($data), $args);
- $function_name = $handler['function'];
- $accepted_args = $handler['accepted_args'];
+ $all_args = array_merge( array($data), $args);
+ $function_name = $handler['function'];
+ $accepted_args = $handler['accepted_args'];
- if ( $accepted_args == 1 )
- $the_args = array($data);
- elseif ( $accepted_args > 1 )
- $the_args = array_slice($all_args, 0, $accepted_args);
- elseif ( $accepted_args == 0 )
- $the_args = NULL;
- else
- $the_args = $all_args;
+ if ( $accepted_args == 1 )
+ $the_args = array($data);
+ elseif ( $accepted_args > 1 )
+ $the_args = array_slice($all_args, 0, $accepted_args);
+ elseif ( $accepted_args == 0 )
+ $the_args = NULL;
+ else
+ $the_args = $all_args;
- $data = call_user_func_array($function_name, $the_args);
- }
+ $data = call_user_func_array($function_name, $the_args);
}
}
- trigger_action('post_trigger_event',
- array('event'=>$event, 'data'=>$data) );
+ trigger_action('trigger',
+ array('type'=>'post_event', 'event'=>$event, 'data'=>$data) );
return $data;
}
function trigger_action($event, $data=null)
{
global $pwg_event_handlers;
- if ($event!='pre_trigger_event'
- and $event!='post_trigger_event'
- and $event!='trigger_action')
+ if ( isset($pwg_event_handlers['trigger']) and $event!='trigger' )
{// special case for debugging - avoid recursive calls
- trigger_action('trigger_action',
- array('event'=>$event, 'data'=>$data) );
+ trigger_action('trigger',
+ array('type'=>'action', 'event'=>$event, 'data'=>$data) );
}
if ( !isset($pwg_event_handlers[$event]) )
@@ -168,25 +163,22 @@ function trigger_action($event, $data=null)
foreach ($pwg_event_handlers[$event] as $priority => $handlers)
{
- if ( !is_null($handlers) )
+ foreach($handlers as $handler)
{
- foreach($handlers as $handler)
- {
- $all_args = array_merge( array($data), $args);
- $function_name = $handler['function'];
- $accepted_args = $handler['accepted_args'];
+ $all_args = array_merge( array($data), $args);
+ $function_name = $handler['function'];
+ $accepted_args = $handler['accepted_args'];
- if ( $accepted_args == 1 )
- $the_args = array($data);
- elseif ( $accepted_args > 1 )
- $the_args = array_slice($all_args, 0, $accepted_args);
- elseif ( $accepted_args == 0 )
- $the_args = NULL;
- else
- $the_args = $all_args;
+ if ( $accepted_args == 1 )
+ $the_args = array($data);
+ elseif ( $accepted_args > 1 )
+ $the_args = array_slice($all_args, 0, $accepted_args);
+ elseif ( $accepted_args == 0 )
+ $the_args = NULL;
+ else
+ $the_args = $all_args;
- call_user_func_array($function_name, $the_args);
- }
+ call_user_func_array($function_name, $the_args);
}
}
}
@@ -229,20 +221,19 @@ function get_db_plugins($state='', $id='')
{
$query = '
SELECT * FROM '.PLUGINS_TABLE;
- if (!empty($state) or !empty($id) )
+ $clauses = array();
+ if (!empty($state))
+ {
+ $clauses[] = 'state="'.$state.'"';
+ }
+ if (!empty($id))
+ {
+ $clauses[] = 'id="'.$id.'"';
+ }
+ if (count($clauses))
{
- $query .= '
-WHERE 1=1';
- if (!empty($state))
- {
- $query .= '
- AND state="'.$state.'"';
- }
- if (!empty($id))
- {
$query .= '
- AND id="'.$id.'"';
- }
+ WHERE '. implode(' AND ', $clauses);
}
$result = pwg_query($query);
diff --git a/plugins/event_tracer/main.inc.php b/plugins/event_tracer/main.inc.php
index 05058ac07..af45bfd6c 100644
--- a/plugins/event_tracer/main.inc.php
+++ b/plugins/event_tracer/main.inc.php
@@ -80,22 +80,6 @@ class EventTracer
fclose( $file );
}
- function on_pre_trigger_event($event_info)
- {
- @$this->trigger_counts[$event_info['event']]++;
- $this->dump('pre_trigger_event', $event_info);
- }
- function on_post_trigger_event($event_info)
- {
- $this->dump('post_trigger_event', $event_info);
- }
-
- function on_trigger_action($event_info)
- {
- @$this->trigger_counts[$event_info['event']]++;
- $this->dump('trigger_action', $event_info);
- }
-
function on_page_tail()
{
if (1 || @$this->my_config['show_registered'])
@@ -129,8 +113,11 @@ class EventTracer
}
}
- function dump($event, $event_info)
+ function on_trigger($event_info)
{
+ if ($event_info['type']!='post_event')
+ @$this->trigger_counts[$event_info['event']]++;
+
foreach( $this->my_config['filters'] as $filter)
{
if ( preg_match( '/'.$filter.'/', $event_info['event'] ) )
@@ -143,7 +130,7 @@ class EventTracer
}
else
$s = '';
- pwg_debug($event.' "'.$event_info['event'].'" '.($this->trigger_counts[$event_info['event']]).' calls '.($s) );
+ pwg_debug($event_info['type'].' "'.$event_info['event'].'" '.($this->trigger_counts[$event_info['event']]).' calls '.($s) );
break;
}
}
@@ -165,9 +152,7 @@ $obj = new EventTracer();
$obj->load_config();
add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') );
-add_event_handler('pre_trigger_event', array(&$obj, 'on_pre_trigger_event') );
-add_event_handler('post_trigger_event', array(&$obj, 'on_post_trigger_event') );
add_event_handler('loc_begin_page_tail', array(&$obj, 'on_page_tail') );
-add_event_handler('trigger_action', array(&$obj, 'on_trigger_action') );
+add_event_handler('trigger', array(&$obj, 'on_trigger') );
set_plugin_data($plugin['id'], $obj);
?>
diff --git a/template/yoga/menubar.tpl b/template/yoga/menubar.tpl
index 99cac9b6d..8b1e8f4b6 100644
--- a/template/yoga/menubar.tpl
+++ b/template/yoga/menubar.tpl
@@ -1,7 +1,6 @@
{if !empty($blocks) }
<div id="menubar">
{foreach from=$blocks key=id item=block}
- {if ( not empty($block->template) or not empty($block->raw_content) )}
<dl id="{$id}">
{if not empty($block->template)}
{include file=$block->template|@get_extent:$id }
@@ -9,7 +8,6 @@
{$block->raw_content}
{/if}
</dl>
- {/if}
{/foreach}
</div>
{/if} \ No newline at end of file