Skip to content

Commit

Permalink
improve template : split theme from template itself
Browse files Browse the repository at this point in the history
	rest of the job : template (yoga), themes (clear dark), and php to handle them


git-svn-id: http://piwigo.org/svn/trunk@960 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
chrisaga committed Dec 3, 2005
1 parent 9731fc4 commit dc3c040
Show file tree
Hide file tree
Showing 32 changed files with 334 additions and 192 deletions.
5 changes: 3 additions & 2 deletions admin/cat_list.php
Expand Up @@ -298,8 +298,9 @@ function save_categories_order($categories)

foreach ($categories as $category)
{
$images_folder = PHPWG_ROOT_PATH.'template/';
$images_folder.= $user['template'].'/admin/images';
// TODO : not used anymore ?
//$images_folder = PHPWG_ROOT_PATH.'template/';
//$images_folder.= $user['template'].'/admin/images';

$base_url = PHPWG_ROOT_PATH.'admin.php?page=';
$cat_list_url = $base_url.'cat_list';
Expand Down
2 changes: 1 addition & 1 deletion admin/configuration.php
Expand Up @@ -243,7 +243,7 @@

$blockname = 'default.template_option';

foreach (get_templates() as $pwg_template)
foreach (get_themes() as $pwg_template)
{
if (isset($_POST['submit']))
{
Expand Down
2 changes: 1 addition & 1 deletion admin/user_list.php
Expand Up @@ -584,7 +584,7 @@ function get_filtered_user_list()

$blockname = 'template_option';

foreach (get_templates() as $pwg_template)
foreach (get_themes() as $pwg_template)
{
if (isset($_POST['pref_submit']))
{
Expand Down
6 changes: 6 additions & 0 deletions include/common.inc.php
Expand Up @@ -220,6 +220,12 @@
$user['username'] = $lang['guest'];
}

// include template/theme configuration
list($user['template'], $user['theme']) = explode('/', $user['template']);
// TODO : replace initial $user['template'] by $user['layout']

include(PHPWG_ROOT_PATH.'template/'.$user['template'].'/theme/'.$user['theme'].'/themeconf.inc.php');

// template instance
$template = new Template(PHPWG_ROOT_PATH.'template/'.$user['template']);
?>
35 changes: 31 additions & 4 deletions include/functions.inc.php
Expand Up @@ -533,11 +533,25 @@ function get_query_string_diff($rejects = array())
}

/**
* returns available templates
* returns available templates/themes
*/
function get_templates()
{
return get_dirs(PHPWG_ROOT_PATH.'template');
return get_dirs(PHPWG_ROOT_PATH.'theme');
}
function get_themes()
{
$themes = array();

foreach (get_dirs(PHPWG_ROOT_PATH.'template') as $template)
{
foreach (get_dirs(PHPWG_ROOT_PATH.'template/'.$template.'/theme') as $theme)
{
array_push($themes, $template.'/'.$theme);
}
}

return $themes;
}

/**
Expand Down Expand Up @@ -565,8 +579,7 @@ function get_thumbnail_src($path, $tn_ext = '')
}
else
{
$src = PHPWG_ROOT_PATH;
$src.= 'template/'.$user['template'].'/mimetypes/';
$src = get_themeconf('mime_icon_dir');
$src.= strtolower(get_extension($path)).'.png';
}

Expand Down Expand Up @@ -726,4 +739,18 @@ function l10n($key)

return isset($lang[$key]) ? $lang[$key] : $key;
}

/**
* returns the corresponding value from $themeconf if existing. Else, the key is
* returned
*
* @param string key
* @return string
*/
function get_themeconf($key)
{
global $themeconf;

return $themeconf[$key];
}
?>
3 changes: 1 addition & 2 deletions include/functions_html.inc.php
Expand Up @@ -43,8 +43,7 @@ function get_icon( $date )
$title = $lang['recent_image'].' ';
if ( $diff < $user['recent_period'] * $day_in_seconds )
{
$icon_url = './template/'.$user['template'].'/theme/';
$icon_url.= 'recent.png';
$icon_url = get_themeconf('icon_dir').'/recent.png';
$title .= $user['recent_period'];
$title .= '&nbsp;'.$lang['days'];
$size = getimagesize( $icon_url );
Expand Down
2 changes: 2 additions & 0 deletions include/template.php
Expand Up @@ -330,6 +330,8 @@ function compile($code, $do_not_echo = false, $retvar = '')
{
// PWG specific : communication between template and $lang
$code = preg_replace('/\{lang:([^}]+)\}/e', "l10n('$1')", $code);
// PWG specific : expand themeconf.inc.php variables
$code = preg_replace('/\{themeconf:([^}]+)\}/e', "get_themeconf('$1')", $code);

// replace \ with \\ and then ' with \'.
$code = str_replace('\\', '\\\\', $code);
Expand Down
6 changes: 3 additions & 3 deletions picture.php
Expand Up @@ -196,7 +196,7 @@
$cat_directory = dirname($row['path']);
$file_wo_ext = get_filename_wo_extension($row['file']);

$icon = PHPWG_ROOT_PATH.'template/'.$user['template'].'/mimetypes/';
$icon = get_themeconf('mime_icon_dir');
$icon.= strtolower(get_extension($row['file'])).'.png';

if (isset($row['representative_ext']) and $row['representative_ext'] != '')
Expand Down Expand Up @@ -609,7 +609,7 @@
$template->assign_block_vars(
'favorite',
array(
'FAVORITE_IMG' => PHPWG_ROOT_PATH.'template/'.$user['template'].'/theme/favorite.png',
'FAVORITE_IMG' => get_themeconf('icon_dir').'/favorite.png',
'FAVORITE_HINT' =>$lang['add_favorites_hint'],
'FAVORITE_ALT' =>$lang['add_favorites_alt'],
'U_FAVORITE' => $url
Expand All @@ -624,7 +624,7 @@
$template->assign_block_vars(
'favorite',
array(
'FAVORITE_IMG' => PHPWG_ROOT_PATH.'template/'.$user['template'].'/theme/del_favorite.png',
'FAVORITE_IMG' => get_themeconf('icon_dir').'/del_favorite.png',
'FAVORITE_HINT' =>$lang['del_favorites_hint'],
'FAVORITE_ALT' =>$lang['del_favorites_alt'],
'U_FAVORITE'=> $url
Expand Down
2 changes: 1 addition & 1 deletion profile.php
Expand Up @@ -205,7 +205,7 @@

$blockname = 'template_option';

foreach (get_templates() as $pwg_template)
foreach (get_themes() as $pwg_template)
{
if (isset($_POST['submit']))
{
Expand Down
33 changes: 33 additions & 0 deletions template-common/default-layout.css
@@ -0,0 +1,33 @@
/* $Id$ */

/* Set the width of the menubar for the galery */
#menubar {
width: 18em;
}
#content {
margin-left: 20em; /* = #menubar width + 2em */
}

/* Set the width of the menubar for the admin section */
BODY#theAdminPage #menubar {
width: 12em;
}
BODY#theAdminPage #content {
margin-left: 14em;
}

/* Set some sizes according to your maximum thumbnail width adn height */
#content UL.thumbnails SPAN, #content UL.thumbnails SPAN.wrap2 A {
width: 140px; /* max thumbnail width + 2px */
}
#content UL.thumbnails SPAN.wrap2 {
height: 140px; /* max thumbnail height + 2px */
}
#content DIV.comment BLOCKQUOTE {
margin-left: 150px; /*maximum thumbnail width + ~10px */
}

/* display/hide thumbnails legend */
#content UL.thumbnails SPAN.thumbLegend {
display: block; /* display: none; if you don't want legend */
}
7 changes: 5 additions & 2 deletions template/yoga/about.tpl
@@ -1,8 +1,11 @@
<div id="content">

<div class="titrePage">
<ul class="categoryActions">
<li><a href="{U_HOME}" title="{lang:return to homepage}"><img src="./template/yoga/theme/home.png" class="button" alt="{lang:home}"/></a></li>
<li>
<a href="{U_HOME}" title="{lang:return to homepage}">
<img src="{themeconf:icon_dir}/home.png" class="button" alt="{lang:home}"/>
</a>
</li>
</ul>
<h2>{lang:About}</h2>
</div>
Expand Down
4 changes: 2 additions & 2 deletions template/yoga/category.tpl
Expand Up @@ -104,10 +104,10 @@
<ul class="categoryActions">
<li>&nbsp;</li>
<!-- BEGIN caddie -->
<li><a href="{caddie.URL}" title="{lang:add to caddie}"><img src="./template/yoga/theme/caddie_add.png" class="button" alt="{lang:caddie}"/></a></li>
<li><a href="{caddie.URL}" title="{lang:add to caddie}"><img src="{themeconf:icon_dir}/caddie_add.png" class="button" alt="{lang:caddie}"/></a></li>
<!-- END caddie -->
<!-- BEGIN edit -->
<li><a href="{edit.URL}" title="{lang:edit category informations}"><img src="./template/yoga/theme/category_edit.png" class="button" alt="{lang:edit}"/></a></li>
<li><a href="{edit.URL}" title="{lang:edit category informations}"><img src="{themeconf:icon_dir}/category_edit.png" class="button" alt="{lang:edit}"/></a></li>
<!-- END edit -->
</ul>
<h2>{TITLE}</h2>
Expand Down
2 changes: 1 addition & 1 deletion template/yoga/comments.tpl
Expand Up @@ -3,7 +3,7 @@

<div class="titrePage">
<ul class="categoryActions">
<li><a href="{U_HOME}" title="{lang:return to homepage}"><img src="./template/yoga/theme/home.png" class="button" alt="{lang:home}"/></a></li>
<li><a href="{U_HOME}" title="{lang:return to homepage}"><img src="{themeconf:icon_dir}/home.png" class="button" alt="{lang:home}"/></a></li>
</ul>
<h2>{lang:User comments}</h2>
</div>
Expand Down
27 changes: 5 additions & 22 deletions template/yoga/content.css
@@ -1,12 +1,8 @@
/* $Id$ */
#content {
margin-left: 24em;
margin-right: 1em;
margin-bottom: 1em; /* when it's longer than menu bar */
}
BODY#theAdminPage #content {
margin-left: 14em;
}

BODY#theCommentsPage #content,
BODY#theRegisterPage #content,
Expand All @@ -21,33 +17,18 @@ BODY#theNotificationPage #content
margin: 1em;
}

#content H2 {
#content H2, H3 {
margin-bottom: 1ex;
}

#content H3 {
margin-bottom: 1ex;
text-align: center;
}

/* Thumbnails customization */
#content UL.thumbnails SPAN, #content UL.thumbnails SPAN.wrap2 A {
width: 140px; /* max thumbnail width + 2px */
}
#content UL.thumbnails SPAN.wrap2 {
height: 140px; /* max thumbnail height + 2px */
}
#content UL.thumbnails SPAN.wrap2 {
border: 1px solid #aaaaaa; /* thumbnails border color and style */
-moz-border-radius: 4px; /* round corners with Geko */
border-radius: 4px 4px; /* round corners with CSS3 compliant browsers */
}
#content UL.thumbnails SPAN.wrap2:hover {
border-color: yellow; /* thumbnails border color when mouse cursor is over it */
}
#content UL.thumbnails SPAN.thumbLegend {
font-size: 80%; /* font size */
height: 3em; /* max legend height (don't set auto to be Geko friendly)*/
display: block; /* display: none; if you don't want legend */
overflow: hidden; /* oversized legend is clipped */
}

Expand Down Expand Up @@ -179,7 +160,9 @@ ul.categoryActions {
}

#content DIV.comment BLOCKQUOTE {
margin: 1em 0.5em 0.5em 150px; /* margin-left corresponds to maximum thumbnail width + ~10px */
margin-top: 1em;
margin-right: 0.5em;
margin-bottom: 150px;
padding: 0.5em;
}

Expand Down

0 comments on commit dc3c040

Please sign in to comment.