|
[Tikiwiki-cvs] tiki/lib/smarty_tiki function.tree.php, NONE,
1.1.2.1 block.self_link.php, 1.1.2.8,
1.1.2.9 function.icon.php, 1.1.2.6, 1.1.2.7 function.query.php,
1.1.2.13, 1.1.2.14 modifier.iconify.php, 1.7.2.1,
1.7.2.2 modifier.kbsize.php, 1.4, 1.4.2.1
From: <nyloth@us...> - 2008-02-27 15:26
|
Update of /cvsroot/tikiwiki/tiki/lib/smarty_tiki
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2072/lib/smarty_tiki
Modified Files:
Tag: BRANCH-1-10
block.self_link.php function.icon.php function.query.php
modifier.iconify.php modifier.kbsize.php
Added Files:
Tag: BRANCH-1-10
function.tree.php
Log Message:
[NEW][ENH] Complete revamping of file galleries
Most important IHM modifications are:
* New gallery explorer (like windows one),
* New subgal path (like breadcrumbs / directory path),
* New wrench icon + contextual menu for actions on files and subgals to replace the old 'Actions' column (it can be disabled in admin > look & feel > other options > Use context menus for actions ),
* New 'Other Sort' icon and column on the right (only if some fields are configured to be displayed in popup) to allow the user to sort on popup fields too (the 'Other Sort' icon will display the list of available fields with links to sort on them. It will dynamically replace the empty 'Other Sort' column by the selected one),
* Merge files and subgals tables (like most common filemanagers),
* Galleries now have only one feature-full display configuration (used for both files and subgals), were you can choose, for each field, between :
- hide field,
- show field as a column,
- show field in the "informations" tooltip/popup,
- show in both areas,
(for "locked by" field, there is also a show as an 'icon' option),
* Use new AJAX-enabled pagination, sort and other links,
* Now handle subgals size (and sort on subgal size),
* Add an option to limit the number of displayed rows,
* Some tikineat theme improvements on filegals and icons hover for IE
Most important Code modifications are:
* Rewrite of get_files() function to handle subgals too (and more options),
* Modify some db field names to make it easier to handle files and subgals the same way (e.g. all 'downloads' fields are now named 'hits' fields),
* many factorization and code cleaning,
* now check permissions when retrieving files and subgals list from DB with new perms functions (this simplifies perms check and fix total number of items to count only items visible to user),
* New smarty tree function to make tiki trees using phplayers and tiki famfamfam icons,
* smarty block self_link : new param '_script' to specify another script than the current one (this disable AJAX for this link when the current script is different),
* smarty query function now handles 'form_input' as '_type' param to return hidden fields needed for forms to keep current URL args,
* smarty iconify modifier now benefits from icon function and accepts a second param to put an alt/title text for the icon
--- NEW FILE: function.tree.php ---
<?php
// $header: $
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
header("location: index.php");
exit;
}
/*
* JavaScript Tree
*
* That smarty function is mostly intended to be used in .tpl files
* syntax: {tree}
*
*/
function smarty_function_tree($params, &$smarty) {
global $prefs;
if ( $prefs['feature_phplayers'] != 'y' ) {
echo tra('phplayers are not available on this site');
return;
}
global $tikiphplayers;
include_once('lib/phplayers_tiki/tiki-phplayers.php');
require_once $smarty->_get_plugin_filepath('function', 'query');
if ( ! function_exists('data2struct') ) {
function data2struct(&$data, $level = 1, $expanded = 0) {
static $cur = 0;
$ret = '';
if ( is_array($data) && $level > 0 ) {
$cur++;
$link = '';
if ( isset($data['link']) && $data['link'] != '') {
$link = $data['link'];
} elseif ( isset($data['link_id']) && isset($data['link_var']) && $data['link_id'] > 0 ) {
$link = smarty_function_query(array(
'_type' => 'absolute_path',
$data['link_var'] => $data['link_id'],
'offset' => 'NULL' // Always go back to the first page of the destination
), $smarty);
}
if ( isset($data['current']) ) $data['name'] = '<b>'.$data['name'].'</b>';
$name = $data['name'] . ( isset($data['addon']) ? ' '.$data['addon'] : '' );
$ret .= str_repeat('.', $level).'|'.$name.'|'.$link.$add.'||folder.png';
if ( $expanded == $cur ) $ret .= '||1';
$ret .= "\n";
if ( is_array($data['data']) ) {
foreach ( $data['data'] as $d ) {
$ret .= data2struct($d, $level + 1);
}
}
}
return $ret;
}
}
$structure = '';
if ( ! isset($params['type']) ) $params['type'] = 'tree';
if ( ! isset($params['expanded']) ) $params['expanded'] = 0;
if ( isset($params['data']) && is_array($params['data']) ) {
$item_expanded = ( $params['type'] == 'phptree' ) ? 0 : $params['expanded'];
$structure = data2struct($params['data'], 1, $item_expanded);
}
return $tikiphplayers->mkMenu($structure, '', $params['type'], '', 0, $params['expanded']);
}
?>
Index: block.self_link.php
===================================================================
RCS file: /cvsroot/tikiwiki/tiki/lib/smarty_tiki/Attic/block.self_link.php,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -d -r1.1.2.8 -r1.1.2.9
--- block.self_link.php 14 Feb 2008 20:48:11 -0000 1.1.2.8
+++ block.self_link.php 27 Feb 2008 15:18:47 -0000 1.1.2.9
@@ -24,6 +24,7 @@
* _icon_class : CSS class to use for the icon's IMG tag
* _title : tooltip to display when the mouse is over the link. Use $content when _icon is used.
* _alt : alt attribute for the icon's IMG tag (use _title if _alt is not specified).
+ * _script : specify another script than the current one (this disable AJAX for this link when the current script is different).
*/
function smarty_block_self_link($params, $content, &$smarty, $repeat) {
global $prefs;
@@ -43,13 +44,24 @@
} elseif ( $params['_sort_arg'] != '' and ! isset($params[$params['_sort_arg']]) ) {
$params[$params['_sort_arg']] = $params['_sort_field'].'_asc,'.$params['_sort_field'].'_desc';
}
+ // Complete _script path if needed
+ if ( isset($params['_script']) ) {
+ if ( $params['_script'] != '' && $_SERVER['PHP_SELF'][0] == '/' && strpos($params['_script'], '/') === false ) {
+ $params['_script'] = dirname($_SERVER['PHP_SELF']).'/'.$params['_script'];
+ }
+ if ( $params['_script'] == $_SERVER['PHP_SELF'] ) {
+ $params['_script'] = '';
+ }
+ } else {
+ $params['_script'] = '';
+ }
$params['_type'] = $default_type;
$ret = smarty_function_query($params, $smarty);
if ( $params['_tag'] == 'y' ) {
- if ( $params['_ajax'] == 'y' ) {
+ if ( $params['_ajax'] == 'y' && $params['_script'] == '' ) {
require_once $smarty->_get_plugin_filepath('block', 'ajax_href');
if ( ! isset($params['_htmlelement']) ) $params['_htmlelement'] = 'tiki-center';
if ( ! isset($params['_template']) ) $params['_template'] = basename($_SERVER['PHP_SELF'], '.php').'.tpl';
@@ -90,7 +102,7 @@
$ret = "<a $link>".$content.'</a>';
- if ( isset($params['_sort_field']) ) {
+ if ( $params['_sort_field'] != '' ) {
require_once $smarty->_get_plugin_filepath('function', 'show_sort');
$ret .= "<a $link style='text-decoration:none;'>".smarty_function_show_sort(
array('sort' => $params['_sort_arg'], 'var' => $params['_sort_field']),
Index: function.icon.php
===================================================================
RCS file: /cvsroot/tikiwiki/tiki/lib/smarty_tiki/Attic/function.icon.php,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -d -r1.1.2.6 -r1.1.2.7
--- function.icon.php 14 Feb 2008 20:45:41 -0000 1.1.2.6
+++ function.icon.php 27 Feb 2008 15:18:47 -0000 1.1.2.7
@@ -17,7 +17,7 @@
function smarty_function_icon($params, &$smarty) {
if ( ! is_array($params) || ! isset($params['_id']) ) return;
- $basedirs = array('pics/icons', 'images', 'img/icons');
+ $basedirs = array('pics/icons', 'images', 'img/icons', 'pics/icons/mime');
$icons_extension = '.png';
$notag = false;
$default_class = 'icon';
Index: function.query.php
===================================================================
RCS file: /cvsroot/tikiwiki/tiki/lib/smarty_tiki/Attic/function.query.php,v
retrieving revision 1.1.2.13
retrieving revision 1.1.2.14
diff -u -d -r1.1.2.13 -r1.1.2.14
--- function.query.php 7 Feb 2008 14:47:18 -0000 1.1.2.13
+++ function.query.php 27 Feb 2008 15:18:47 -0000 1.1.2.14
@@ -45,36 +45,60 @@
}
$ret = '';
- $sep = '&';
- if ( function_exists('http_build_query') ) {
- $ret = http_build_query($query, '', $sep);
- } else {
+ if ( isset($params['_type']) && $params['_type'] == 'form_input' ) {
foreach ( $query as $k => $v ) {
- if ( $ret != '' ) $ret .= $sep;
- if ( is_array($v) ) {
- foreach ( $v as $vk => $vv ) {
- $ret .= urlencode($k.'['.$vk.']').'='.urlencode($vv);
- }
- } else {
- $ret .= urlencode($k).'='.urlencode($v);
- }
+ $ret .= '<input type="hidden"'
+ .' name="'.htmlspecialchars($k, ENT_QUOTES, 'UTF-8').'"'
+ .' value="'.htmlspecialchars($v, ENT_QUOTES, 'UTF-8').'" />'."\n";
+ }
+ } else {
+ $sep = '&';
+ if ( function_exists('http_build_query') ) {
+ $ret = http_build_query($query, '', $sep);
+ } else {
+ foreach ( $query as $k => $v ) {
+ if ( $ret != '' ) $ret .= $sep;
+ if ( is_array($v) ) {
+ foreach ( $v as $vk => $vv ) {
+ $ret .= urlencode($k.'['.$vk.']').'='.urlencode($vv);
+ }
+ } else {
+ $ret .= urlencode($k).'='.urlencode($v);
+ }
+ }
}
}
+
}
if ( is_array($params) && isset($params['_type']) ) {
global $base_host;
+
+ // If specified, use _script argument to determine the php script to link to
+ // ... else, use PHP_SELF server var
+ if ( isset($params['_script']) && $params['_script'] != '' ) {
+ $php_self = $params['_script'];
+
+ // If _script does not already specifies the directory and if there is one in PHP_SELF server var, use it
+ if ( strpos($php_self, '/') === false && $_SERVER['PHP_SELF'][0] == '/' ) {
+ $php_self = dirname($_SERVER['PHP_SELF']).'/'.$php_self;
+ }
+
+ } else {
+ $php_self = $_SERVER['PHP_SELF'];
+ }
+
switch ( $params['_type'] ) {
case 'absolute_uri':
- $ret = $base_host.$_SERVER['PHP_SELF'].'?'.$ret;
+ $ret = $base_host.$php_self.'?'.$ret;
break;
case 'absolute_path':
- $ret = $_SERVER['PHP_SELF'].'?'.$ret;
+ $ret = $php_self.'?'.$ret;
break;
case 'relative':
- $ret = basename($_SERVER['PHP_SELF']).'?'.$ret;
+ $ret = basename($php_self).'?'.$ret;
break;
- case 'arguments': /* default */
+ case 'form_input': case 'arguments': /* default */
}
}
Index: modifier.iconify.php
===================================================================
RCS file: /cvsroot/tikiwiki/tiki/lib/smarty_tiki/modifier.iconify.php,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -d -r1.7.2.1 -r1.7.2.2
--- modifier.iconify.php 20 Jan 2008 20:00:50 -0000 1.7.2.1
+++ modifier.iconify.php 27 Feb 2008 15:18:47 -0000 1.7.2.2
@@ -14,17 +14,20 @@
* Purpose: Returns a filetype icon if the filetype is known and there's an icon in pics/icons/mime. Returns a default file type icon in any other case
* -------------------------------------------------------------
*/
-function smarty_modifier_iconify($string)
+require_once $smarty->_get_plugin_filepath('function', 'icon');
+
+function smarty_modifier_iconify($string, $filetype = null)
{
-
- $filetype=strtolower(substr($string,strrpos($string, '.')+1));
-
- if(file_exists("pics/icons/mime/$filetype".".png")) {
- return "<img border='0' src='pics/icons/mime/{$filetype}.png' alt='{$filetype}' width='16' height='16' />";
- } else {
- return "<img border='0' src='pics/icons/mime/default.png' alt='{$filetype}' width='16' height='16' />";
- }
-
+ global $smarty;
+ $ext = strtolower(substr($string, strrpos($string, '.') + 1));
+ $icon = file_exists("pics/icons/mime/$ext.png") ? $ext : 'default';
+
+ return smarty_function_icon(array(
+ '_id' => 'pics/icons/mime/'.$icon.'.png',
+ 'alt' => ( $filetype === null ? $icon : $filetype ),
+ 'class' => ''
+ ), $smarty);
+
}
?>
Index: modifier.kbsize.php
===================================================================
RCS file: /cvsroot/tikiwiki/tiki/lib/smarty_tiki/modifier.kbsize.php,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -d -r1.4 -r1.4.2.1
--- modifier.kbsize.php 26 May 2007 16:12:26 -0000 1.4
+++ modifier.kbsize.php 27 Feb 2008 15:18:47 -0000 1.4.2.1
@@ -16,6 +16,8 @@
*/
function smarty_modifier_kbsize($string, $bytes = false, $nb_decimals = 2)
{
+ if ( $string == '' ) return '';
+
// 1024 x 1024 = 1048576
if ( $string > 1048576 ) $string = number_format($string/1048576,$nb_decimals).' M';
elseif ( $string > 1024 ) $string = number_format($string/1024,$nb_decimals).' K';
|
| Thread | Author | Date |
|---|---|---|
| [Tikiwiki-cvs] tiki/lib/smarty_tiki function.tree.php, NONE, 1.1.2.1 block.self_link.php, 1.1.2.8, 1.1.2.9 function.icon.php, 1.1.2.6, 1.1.2.7 function.query.php, 1.1.2.13, 1.1.2.14 modifier.iconify.php, 1.7.2.1, 1.7.2.2 modifier.kbsize.php, 1.4, 1.4.2.1 | <nyloth@us...> |