Navigation Menu

Skip to content

Commit

Permalink
feature:2577
Browse files Browse the repository at this point in the history
Add functionnality in core files.

git-svn-id: http://piwigo.org/svn/trunk@13172 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
patdenice committed Feb 15, 2012
1 parent 97132d9 commit 46864ea
Show file tree
Hide file tree
Showing 6 changed files with 1,053 additions and 4 deletions.
25 changes: 24 additions & 1 deletion admin/include/themes.class.php
Expand Up @@ -48,6 +48,8 @@ function themes()
*/
function perform_action($action, $theme_id)
{
global $conf;

if (isset($this->db_themes_by_id[$theme_id]))
{
$crt_db_theme = $this->db_themes_by_id[$theme_id];
Expand Down Expand Up @@ -86,6 +88,12 @@ function perform_action($action, $theme_id)
break;
}

if ($this->fs_themes[$theme_id]['mobile'] and !empty($conf['mobile_theme']))
{
array_push($errors, l10n('You can activate only one mobile theme.'));
break;
}

if (file_exists($file_to_include))
{
include($file_to_include);
Expand All @@ -105,6 +113,11 @@ function perform_action($action, $theme_id)
\''.$this->fs_themes[$theme_id]['name'].'\')
;';
pwg_query($query);

if ($this->fs_themes[$theme_id]['mobile'])
{
conf_update_param('mobile_theme', $theme_id);
}
}
break;

Expand Down Expand Up @@ -164,6 +177,11 @@ function perform_action($action, $theme_id)
WHERE id= \''.$theme_id.'\'
;';
pwg_query($query);

if ($this->fs_themes[$theme_id]['mobile'])
{
conf_update_param('mobile_theme', '');
}
break;

case 'delete':
Expand Down Expand Up @@ -325,6 +343,7 @@ function get_fs_themes()
'uri' => '',
'description' => '',
'author' => '',
'mobile' => false,
);
$theme_data = implode( '', file($path.'/themeconf.inc.php') );

Expand Down Expand Up @@ -365,10 +384,14 @@ function get_fs_themes()
{
$theme['parent'] = $val[1];
}
if (preg_match('/["\']activable["\'].*?(true|false)/', $theme_data, $val))
if (preg_match('/["\']activable["\'].*?(true|false)/i', $theme_data, $val))
{
$theme['activable'] = get_boolean($val[1]);
}
if (preg_match('/["\']mobile["\'].*?(true|false)/i', $theme_data, $val))
{
$theme['mobile'] = get_boolean($val[1]);
}

// screenshot
$screenshot_path = $path.'/screenshot.png';
Expand Down
4 changes: 2 additions & 2 deletions admin/themes/default/template/themes_installed.tpl
Expand Up @@ -17,7 +17,7 @@ jQuery(document).ready(function() {
<div class="themeBoxes">
{foreach from=$active_themes item=theme}
<div class="themeBox{if $theme.is_default} themeDefault{/if}">
<div class="themeName">{$theme.name}{if $theme.is_default} <em>({'default'|@translate})</em>{/if}</div>
<div class="themeName">{$theme.name}{if $theme.is_default} <em>({'default'|@translate})</em>{/if} {if $theme.mobile} <em>({'mobile'|@translate})</em>{/if}</div>
<div class="themeShot"><a href="{$theme.screenshot}" class="preview-box" title="{$theme.name}"><img src="{$theme.screenshot}" alt=""></a></div>
<div class="themeActions">
<div>
Expand Down Expand Up @@ -47,7 +47,7 @@ jQuery(document).ready(function() {
<div class="themeBoxes">
{foreach from=$inactive_themes item=theme}
<div class="themeBox">
<div class="themeName">{$theme.name}</div>
<div class="themeName">{$theme.name}{if $theme.mobile} <em>({'mobile'|@translate})</em>{/if}</div>
<div class="themeShot"><a href="{$theme.screenshot}" class="preview-box" title="{$theme.name}"><img src="{$theme.screenshot}" alt=""></a></div>
<div class="themeActions">
<div>
Expand Down
24 changes: 23 additions & 1 deletion include/common.inc.php
Expand Up @@ -192,7 +192,29 @@ function sanitize_mysql_kv(&$v, $k)
}
else
{ // Classic template
$template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme'] );
$theme = $user['theme'];

if (!isset($_SESSION['is_mobile']))
{
include_once(PHPWG_ROOT_PATH.'include/mdetect.php');
$uagent_obj = new uagent_info();
if ($_SESSION['is_mobile'] = $uagent_obj->DetectMobileLong())
{
$_SESSION['use_mobile_theme'] = !empty($conf['mobile_theme']);
}
}
if ($_SESSION['is_mobile'])
{
if (isset($_REQUEST['mobile']))
{
$_SESSION['use_mobile_theme'] = get_boolean($_REQUEST['mobile']);
}
if ($_SESSION['use_mobile_theme'])
{
$theme = $conf['mobile_theme'];
}
}
$template = new Template(PHPWG_ROOT_PATH.'themes', $theme );
}

if ( !isset($conf['no_photo_yet']) )
Expand Down

0 comments on commit 46864ea

Please sign in to comment.