1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +02:00

Move icon path storage to media-manager. Icon-picker updated.

This commit is contained in:
CaMer0n
2010-03-13 08:12:38 +00:00
parent 123b763082
commit 568859aef2
2 changed files with 35 additions and 84 deletions

View File

@@ -64,7 +64,7 @@ class media_admin extends e_admin_dispatcher
'main/import' => array('caption'=> "Batch Media Import", 'perm' => 'A'),
'cat/list' => array('caption'=> 'Media Categories', 'perm' => 'A'),
// 'cat/create' => array('caption'=> "Create Category", 'perm' => 'A'),
'main/icons' => array('caption'=> IMALAN_71, 'perm' => 'A'),
// 'main/icons' => array('caption'=> IMALAN_71, 'perm' => 'A'),
'main/settings' => array('caption'=> LAN_PREFS, 'perm' => 'A'),
'main/avatar' => array('caption'=> IMALAN_23, 'perm' => 'A')

View File

@@ -9,96 +9,47 @@
function iconpicker_shortcode($parm)
{
require_once (e_HANDLER."file_class.php");
require_once(e_HANDLER.'admin_handler.php');
$parms = array();
parse_str($parm, $parms);
$name = varset($parms['id']);
$sql = e107::getDb();
$frm = e107::getForm();
$tp = e107::getParser();
// $sc_parameters is currently being used to select the media-category.
$e107 = &e107::getInstance();
$qry = "SELECT * FROM `#core_media` WHERE media_userclass IN (".USERCLASS_LIST.") ";
$qry .= vartrue($sc_parameters) ? " AND media_category = '".$sc_parameters."' " : " AND `media_category` REGEXP '_icon_16|_icon_32|_icon_48|_icon_64' ";
$qry .= "ORDER BY media_category,media_name";
$fl = new e_file();
$parms = array();
parse_str($parm, $parms);
if(!varset($parms['path']))
{
$parms['path'] = e_IMAGE."icons/";
$parms['path_omit'] = e_IMAGE."icons/";
}
$parms['path'] = explode('|', $parms['path']);
$iconlist = array();
foreach($parms['path'] as $iconpath)
{
$tmp = $fl->get_files($iconpath, '\.jpg|\.gif|\.png|\.JPG|\.GIF|\.PNG');
if($tmp)
$str = "";
$size_section = array();
$lastsize = "";
if($sql->db_Select_gen($qry))
{
$iconlist += $tmp;
}
unset($tmp);
}
$iconlist = multiarray_sort($iconlist, 'fname');
$tmp = array(16, 32, 48, 64, 128);
$tmp1 = array();
$name = varset($parms['id']);
global $iconpool,$tp;
$iconlist = $iconpool; // this overrides most of the code above - needs reviewing.
foreach($iconlist as $folder)
{
// $filepath = varsettrue($parms['path_omit']) ? str_replace(explode('|', $parms['path_omit']), "", $icon['path'].$icon['fname']) : $e107->tp->createConstants($icon['path'], 1).$icon['fname'];
// $filepath_abs = str_replace(array(e_IMAGE, e_FILE, e_PLUGIN), array(e_IMAGE_ABS, e_FILE_ABS, e_PLUGIN_ABS), $icon['path'].$icon['fname']);
foreach($folder as $icon)
{
$filepath = $icon;
$filepath_abs = $tp->replaceConstants($icon,"abs");
$icon_file = basename($filepath_abs);
$str = "<a href='#{$filepath}' title='{$filepath}' onclick=\"e107Helper.insertText('{$filepath}','{$name}','{$name}-iconpicker'); return false; \"><img class='icon picker list%%size%%' src='{$filepath_abs}' alt='{$icon_file}' /></a>";
foreach ($tmp as $isize)
while($row = $sql->db_Fetch())
{
if(strpos($icon_file, '_'.$isize.'.') !== false)
list($tmp,$tmp2,$size) = explode("_",$row['media_category']);
if($lastsize!='' && ($size != $lastsize))
{
$tmp1[$isize] = varset($tmp1[$isize]).str_replace('%%size%%', ' S'.$isize, $str);
continue 2;
$size_section[] = $str;
$str = "";
}
$str .= "<a href='#".$row['media_url']."' title='{$filepath}' onclick=\"e107Helper.insertText('{$row['media_url']}','{$name}','{$name}-iconpicker'); return false; \"><img class='icon picker list%%size%%' src='".$tp->replaceConstants($row['media_url'])."' alt='{$row['media_name']}' /></a>";
$lastsize = $size;
}
$tmp1['other'] = varset($tmp1['other']).$str;//other
return '<div id="'.$name.'-iconpicker-ajax"><div class="field-spacer iconpicker">'.str_replace('%%size%%', '', implode('</div><div class="field-spacer iconpicker">', $size_section)).'</div></div>';
}
}
/*foreach($iconlist as $icon)
{
$filepath = varsettrue($parms['path_omit']) ? str_replace(explode('|', $parms['path_omit']), "", $icon['path'].$icon['fname']) : $e107->tp->createConstants($icon['path'], 1).$icon['fname'];
$filepath_abs = str_replace(array(e_IMAGE, e_FILE, e_PLUGIN), array(e_IMAGE_ABS, e_FILE_ABS, e_PLUGIN_ABS), $icon['path'].$icon['fname']);
$str = "<a href='#{$filepath}' title='{$filepath}' onclick=\"e107Helper.insertText('{$filepath}','{$name}','{$name}-iconpicker'); return false; \"><img class='icon picker list%%size%%' src='{$filepath_abs}' alt='{$filepath}' /></a>";
foreach ($tmp as $isize)
{
if(strpos($icon['fname'], '_'.$isize.'.') !== false)
{
$tmp1[$isize] = varset($tmp1[$isize]).str_replace('%%size%%', ' S'.$isize, $str);
continue 2;
}
}
$tmp1['other'] = varset($tmp1['other']).$str;//other
}*/
return $tmp1 ? '<div id="'.$name.'-iconpicker-ajax"><div class="field-spacer iconpicker">'.str_replace('%%size%%', '', implode('</div><div class="field-spacer iconpicker">', $tmp1)).'</div></div>' : '';
}
?>