configurable favicon, configurable vfs image store for images, logos, icons

This commit is contained in:
Klaus Leithoff 2009-05-13 14:33:36 +00:00
parent cf5fe6a101
commit 86f1dde06f
4 changed files with 75 additions and 57 deletions

View File

@ -75,6 +75,11 @@
</td> </td>
</tr> </tr>
<tr class="row_off">
<td>{lang_Enter_the_VFS-Path_where_additional_images,_icons_or_logos_can be_placed_(and_found_by_EGroupwares_applications)._The_path_MUST_start_with_/,and_be_readable_by_all_users}:</td>
<td><input name="newsettings[vfs_image_dir]" value="{value_vfs_image_dir}"></td>
</tr>
<tr class="th"> <tr class="th">
<td colspan="2">&nbsp;<b>{lang_appearance}</b></td> <td colspan="2">&nbsp;<b>{lang_appearance}</b></td>
</tr> </tr>
@ -100,6 +105,11 @@
</tr> </tr>
<tr class="row_on"> <tr class="row_on">
<td>{lang_Enter_the_URL_or_filename_(in_your_templates_image_directory)_of_your_favicon_(the_little_icon_that_appears_in_the_browsers_tabs)}:</td>
<td><input name="newsettings[favicon_file]" value="{value_favicon_file}"></td>
</tr>
<tr class="row_off">
<td>{lang_Show_an_asterisk_(*)_to_mark_untranslated_strings}:</td> <td>{lang_Show_an_asterisk_(*)_to_mark_untranslated_strings}:</td>
<td> <td>
<select name="newsettings[markuntranslated]"> <select name="newsettings[markuntranslated]">
@ -109,14 +119,14 @@
</td> </td>
</tr> </tr>
<tr class="row_off"> <tr class="row_on">
<td>{lang_How_big_should_thumbnails_for_linked_images_be_(maximum_in_pixels)_?}:</td> <td>{lang_How_big_should_thumbnails_for_linked_images_be_(maximum_in_pixels)_?}:</td>
<td> <td>
<input name="newsettings[link_list_thumbnail]" value="{value_link_list_thumbnail}" size="5"> <input name="newsettings[link_list_thumbnail]" value="{value_link_list_thumbnail}" size="5">
</td> </td>
</tr> </tr>
<tr class="row_on"> <tr class="row_off">
<td>{lang_Enable_the_spellcheck_in_the_ritch_text_editor_?}:</td> <td>{lang_Enable_the_spellcheck_in_the_ritch_text_editor_?}:</td>
<td> <td>
<select name="newsettings[enabled_spellcheck]"> <select name="newsettings[enabled_spellcheck]">
@ -126,7 +136,7 @@
</td> </td>
</tr> </tr>
<tr class="row_off"> <tr class="row_on">
<td>{lang_Complete_path_to_aspell_program}:</td> <td>{lang_Complete_path_to_aspell_program}:</td>
<td> <td>
<input name="newsettings[aspell_path]" value="{value_aspell_path}" size="40"> <input name="newsettings[aspell_path]" value="{value_aspell_path}" size="40">

View File

@ -809,6 +809,7 @@ class common
function find_image($appname,$image) function find_image($appname,$image)
{ {
$imagedir = '/'.$appname.'/templates/'.$GLOBALS['egw_info']['user']['preferences']['common']['template_set'].'/images'; $imagedir = '/'.$appname.'/templates/'.$GLOBALS['egw_info']['user']['preferences']['common']['template_set'].'/images';
$vfs_imagedir = $GLOBALS['egw_info']['server']['vfs_image_dir'];
if (!@is_array(self::$found_files[$appname])) if (!@is_array(self::$found_files[$appname]))
{ {
@ -853,6 +854,22 @@ class common
} }
$d->close(); $d->close();
} }
if (!isset(self::$found_files['vfs']) && egw_vfs::file_exists($vfs_imagedir) &&
egw_vfs::is_dir($vfs_imagedir) && ($d = egw_vfs::opendir($vfs_imagedir)))
{
while (($entry = readdir($d)) !== false)
{
if (!egw_vfs::is_dir($vfs_imagedir.'/'.$entry))
{
if (list($type,$subtype) = explode('/',egw_vfs::mime_content_type($vfs_imagedir.'/'.$entry)))// && $type == 'image')
{
if ($type == 'image' || $type == 'application') self::$found_files['vfs'][$entry] = $vfs_imagedir;
}
}
}
closedir($d);
}
} }
if (!$GLOBALS['egw_info']['server']['image_type']) if (!$GLOBALS['egw_info']['server']['image_type'])
@ -865,64 +882,44 @@ class common
// priority: : PNG->JPG->GIF // priority: : PNG->JPG->GIF
$img_type=array('.png','.jpg','.gif'); $img_type=array('.png','.jpg','.gif');
} }
$imgfile = '';
// first look in the instance specific image dir in vfs
foreach(array_merge($img_type,array('')) as $type)
{
// first look in the instance specific image dir in vfs
if(self::$found_files['vfs'][$image.$type]==$vfs_imagedir)
{
$imgfile = egw::link(egw_vfs::download_url(self::$found_files['vfs'][$image.$type].'/'.$image.$type));
break;
}
// then look in the selected template dir
if(self::$found_files[$appname][$image.$type]==$imagedir)
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$type].'/'.$image.$type;
break;
}
//then look everywhere else
if (isset(self::$found_files[$appname][$image.$type]))
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$type].'/'.$image.$type;
break;
}
}
// first look in the selected template dir if (empty($imgfile))
if(@self::$found_files[$appname][$image.$img_type[0]]==$imagedir)
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[0]].'/'.$image.$img_type[0];
}
elseif(@self::$found_files[$appname][$image.$img_type[1]]==$imagedir)
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[1]].'/'.$image.$img_type[1];
}
elseif(@self::$found_files[$appname][$image.$img_type[2]]==$imagedir)
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[2]].'/'.$image.$img_type[2];
}
// then look everywhere else
elseif(isset(self::$found_files[$appname][$image.$img_type[0]]))
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[0]].'/'.$image.$img_type[0];
}
elseif(isset(self::$found_files[$appname][$image.$img_type[1]]))
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[1]].'/'.$image.$img_type[1];
}
elseif(isset(self::$found_files[$appname][$image.$img_type[2]]))
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[2]].'/'.$image.$img_type[2];
}
elseif(isset(self::$found_files[$appname][$image]))
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image].'/'.$image;
}
else
{ {
// searching the image in the api-dirs // searching the image in the api-dirs
if (!isset(self::$found_files['phpgwapi'])) if (!isset(self::$found_files['phpgwapi']))
{ {
$this->find_image('phpgwapi',''); $this->find_image('phpgwapi','');
} }
foreach(array_merge($img_type,array('')) as $type)
if(isset(self::$found_files['phpgwapi'][$image.$img_type[0]]))
{ {
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image.$img_type[0]].'/'.$image.$img_type[0]; if(isset(self::$found_files['phpgwapi'][$image.$type]))
} {
elseif(isset(self::$found_files['phpgwapi'][$image.$img_type[1]])) $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image.$type].'/'.$image.$type;
{ break;
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image.$img_type[1]].'/'.$image.$img_type[1]; }
}
elseif(isset(self::$found_files['phpgwapi'][$image.$img_type[2]]))
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image.$img_type[2]].'/'.$image.$img_type[2];
}
elseif(isset(self::$found_files['phpgwapi'][$image]))
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image].'/'.$image;
}
else
{
$imgfile = '';
} }
} }
return $imgfile; return $imgfile;

View File

@ -241,10 +241,20 @@ abstract class egw_framework
} }
if($app!='wiki') $robots ='<meta name="robots" content="none" />'; if($app!='wiki') $robots ='<meta name="robots" content="none" />';
if (substr($GLOBALS['egw_info']['server']['favicon_file'],0,4) == 'http')
{
$var['favicon_file'] = $GLOBALS['egw_info']['server']['favicon_file'];
}
else
{
$var['favicon_file'] = $GLOBALS['egw']->common->image('phpgwapi',$GLOBALS['egw_info']['server']['favicon_file']?$GLOBALS['egw_info']['server']['favicon_file']:'favicon.ico');
}
return $this->_get_css()+array( return $this->_get_css()+array(
'img_icon' => EGW_IMAGES_DIR . '/favicon.ico', #'img_icon' => EGW_IMAGES_DIR . '/favicon.ico',
'img_shortcut' => EGW_IMAGES_DIR . '/favicon.ico', 'img_icon' => $var['favicon_file'],
#'img_shortcut' => EGW_IMAGES_DIR . '/favicon.ico',
'img_shortcut' => $var['favicon_file'],
'pngfix' => $pngfix, 'pngfix' => $pngfix,
'slider_effects' => $slider_effects, 'slider_effects' => $slider_effects,
'simple_show_hide' => $simple_show_hide, 'simple_show_hide' => $simple_show_hide,

View File

@ -889,8 +889,9 @@ class html
{ {
$name = $GLOBALS['egw']->link('/index.php',$name); $name = $GLOBALS['egw']->link('/index.php',$name);
} }
if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://') if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://' || stripos($name,'etemplate/thumbnail.php') )
{ {
if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://')) $name = '/'.$name;
$url = $name; $url = $name;
} }
else // no URL, so try searching the image else // no URL, so try searching the image
@ -912,7 +913,7 @@ class html
$path = EGW_SERVER_ROOT.$url; $path = EGW_SERVER_ROOT.$url;
} }
if (is_null($path) || !@is_readable($path)) if (is_null($path) || (!@is_readable($path) && stripos($path,'webdav.php')===false))
{ {
// if the image-name is a percentage, use a progressbar // if the image-name is a percentage, use a progressbar
if (substr($name,-1) == '%' && is_numeric($percent = substr($name,0,-1))) if (substr($name,-1) == '%' && is_numeric($percent = substr($name,0,-1)))