]> git.mxchange.org Git - friendica.git/commitdiff
allow individual choice of mobile themes
authorZach Prezkuta <fermion@gmx.com>
Thu, 6 Sep 2012 23:24:34 +0000 (17:24 -0600)
committerZach Prezkuta <fermion@gmx.com>
Thu, 6 Sep 2012 23:24:34 +0000 (17:24 -0600)
17 files changed:
boot.php
include/auth.php
include/oauth.php
include/security.php
mod/admin.php
mod/community.php
mod/directory.php
mod/home.php
mod/login.php
mod/manage.php
mod/register.php
mod/search.php
mod/settings.php
view/field_themeselect.tpl
view/settings_display.tpl
view/theme/frost-mobile/field_themeselect.tpl
view/theme/frost/field_themeselect.tpl

index 74707fbc942ab771425c53299f44ad55c7c35c88..93942aa3ff5f6fcd4c0e61c5b8e0cef47d8924e8 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -1088,9 +1088,12 @@ if(! function_exists('profile_load')) {
 
                $a->profile = $r[0];
 
+               $a->profile['mobile-theme'] = get_pconfig($profile_uid, 'system', 'mobile_theme');
+
 
                $a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
                $_SESSION['theme'] = $a->profile['theme'];
+               $_SESSION['mobile-theme'] = $a->profile['mobile-theme'];
 
                /**
                 * load/reload current theme info
@@ -1510,6 +1513,12 @@ if(! function_exists('current_theme')) {
                if($is_mobile) {
                        $system_theme = ((isset($a->config['system']['mobile-theme'])) ? $a->config['system']['mobile-theme'] : '');
                        $theme_name = ((isset($_SESSION) && x($_SESSION,'mobile-theme')) ? $_SESSION['mobile-theme'] : $system_theme);
+
+                       if($theme_name === '---') {
+                               // user has selected to have the mobile theme be the same as the normal one
+                               $system_theme = '';
+                               $theme_name = '';
+                       }
                }
                if(!$is_mobile || ($system_theme === '' && $theme_name === '')) {
                        $system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
index cba6a67a7fd7ec5124b919540bc3b6bf118013cc..f10704eda5a5df8c868de11115ac9e54ab85851c 100644 (file)
@@ -10,14 +10,13 @@ function nuke_session() {
        unset($_SESSION['administrator']);
        unset($_SESSION['cid']);
        unset($_SESSION['theme']);
+       unset($_SESSION['mobile-theme']);
        unset($_SESSION['page_flags']);
        unset($_SESSION['submanage']);
        unset($_SESSION['my_url']);
        unset($_SESSION['my_address']);
        unset($_SESSION['addr']);
        unset($_SESSION['return_url']);
-       unset($_SESSION['theme']);
-       unset($_SESSION['page_flags']);
 }
 
 
index 2724dcf7cf506fb2184414c004456659d69bf039..103d4c2fa9458a306f4f37e1600f8d493595678a 100644 (file)
@@ -145,6 +145,7 @@ class FKOAuth1 extends OAuthServer {
                }
                $_SESSION['uid'] = $record['uid'];
                $_SESSION['theme'] = $record['theme'];
+               $_SESSION['mobile-theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme');
                $_SESSION['authenticated'] = 1;
                $_SESSION['page_flags'] = $record['page-flags'];
                $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $record['nickname'];
index 4621148cd921d0094f9f2a5046defa6e15bf0ffe..10bb692bbb2dfff5624c0851413c13ee86682a3a 100644 (file)
@@ -6,6 +6,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
 
        $_SESSION['uid'] = $user_record['uid'];
        $_SESSION['theme'] = $user_record['theme'];
+       $_SESSION['mobile-theme'] = get_pconfig($user_record['uid'], 'system', 'mobile_theme');
        $_SESSION['authenticated'] = 1;
        $_SESSION['page_flags'] = $user_record['page-flags'];
        $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname'];
index cc13e27b144134f08831ebafa0d212224ca52eba..db4d4cff25b8289d1fa9ab275442c13b3d4fd374 100644 (file)
@@ -329,11 +329,11 @@ function admin_page_site_post(&$a){
        }
        set_config('system','language', $language);
        set_config('system','theme', $theme);
-        if ( $theme_mobile === '---' ) {
-            del_config('system','mobile-theme');
-        } else {
-           set_config('system','mobile-theme', $theme_mobile);
-        }
+       if ( $theme_mobile === '---' ) {
+               del_config('system','mobile-theme');
+       } else {
+               set_config('system','mobile-theme', $theme_mobile);
+       }
        set_config('system','maximagesize', $maximagesize);
        set_config('system','max_image_length', $maximagelength);
        set_config('system','jpeg_quality', $jpegimagequality);
@@ -399,16 +399,18 @@ function admin_page_site(&$a) {
        /* Installed themes */
        $theme_choices = array();
        $theme_choices_mobile = array();
-        $theme_choices_mobile["---"] = t("Don't apply a special theme for mobile devices.");
+       $theme_choices_mobile["---"] = t("No special theme for mobile devices");
        $files = glob('view/theme/*');
        if($files) {
                foreach($files as $file) {
                        $f = basename($file);
                        $theme_name = ((file_exists($file . '/experimental')) ?  sprintf("%s - \x28Experimental\x29", $f) : $f);
-                        $theme_choices[$f] = $theme_name;
-                        if (file_exists($file . '/mobile')) {
-                            $theme_choices_mobile[$f] = $theme_name;
-                        }
+            if (file_exists($file . '/mobile')) {
+                $theme_choices_mobile[$f] = $theme_name;
+            }
+                       else {
+                $theme_choices[$f] = $theme_name;
+                       }
                }
        }
        
index 354f68528dab479e8e1565ec08b75d64fbf20841..4f6c3d3c94c399c724023cb752968925881f52b2 100644 (file)
@@ -1,8 +1,10 @@
 <?php
 
 function community_init(&$a) {
-       if(! local_user())
+       if(! local_user()) {
                unset($_SESSION['theme']);
+               unset($_SESSION['mobile-theme']);
+       }
 
 
 }
index 8a5685c9a5b34dfb5235bfbdc378839996a89a32..833a4f81cc0da7deb5c68b27c6997de2907b506d 100644 (file)
@@ -9,8 +9,10 @@ function directory_init(&$a) {
                $a->page['aside'] .= findpeople_widget();
 
        }
-       else
+       else {
                unset($_SESSION['theme']);
+               unset($_SESSION['mobile-theme']);
+       }
 
 
 }
index 0320c1b3988a5b20bd2cda7fc02bf443de78a120..6ed36b7638c1ce39c62adb3be61cc6f0a9f4e764 100644 (file)
@@ -22,6 +22,8 @@ function home_content(&$a) {
 
        if(x($_SESSION,'theme'))
                unset($_SESSION['theme']);
+       if(x($_SESSION,'mobile-theme'))
+               unset($_SESSION['mobile-theme']);
 
        $o .= '<h1>' . ((x($a->config,'sitename')) ? sprintf( t("Welcome to %s") ,$a->config['sitename']) : "" ) . '</h1>';
        if(file_exists('home.html'))
index 10b4d3001d6a69562d987a528394ffbfc34e029e..d09fc1868f55adb2525f734666abeae77c22be38 100644 (file)
@@ -3,8 +3,11 @@
 function login_content(&$a) {
        if(x($_SESSION,'theme'))
                unset($_SESSION['theme']);
+       if(x($_SESSION,'mobile-theme'))
+               unset($_SESSION['mobile-theme']);
+
        if(local_user())
                goaway(z_root());
        return login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true);
 
-}
\ No newline at end of file
+}
index 96d420c7863d1e903192c476c09b46ade51b543e..4bc7a3baba9113860c1b2bf43a8e91deef8cd2ab 100644 (file)
@@ -63,6 +63,7 @@ function manage_post(&$a) {
        unset($_SESSION['administrator']);
        unset($_SESSION['cid']);
        unset($_SESSION['theme']);
+       unset($_SESSION['mobile-theme']);
        unset($_SESSION['page_flags']);
        unset($_SESSION['return_url']);
        if(x($_SESSION,'submanage'))
index de86808cb45670d4a3bcc5a6b87a906623a44dee..6bf287d4245b0c70ce12d3395b9f4ad216216d10 100644 (file)
@@ -193,6 +193,8 @@ function register_content(&$a) {
 
        if(x($_SESSION,'theme'))
                unset($_SESSION['theme']);
+       if(x($_SESSION,'mobile-theme'))
+               unset($_SESSION['mobile-theme']);
 
 
        $username     = ((x($_POST,'username'))     ? $_POST['username']     : ((x($_GET,'username'))     ? $_GET['username']              : ''));
index 8f73b92448d7630e02fd1fc105612dcf7853fd92..300eb912c13c59412786c36b6c6a9c98974d6959 100644 (file)
@@ -50,8 +50,10 @@ function search_init(&$a) {
                $a->page['aside'] .= search_saved_searches();
 
        }
-       else
+       else {
                unset($_SESSION['theme']);
+               unset($_SESSION['mobile-theme']);
+       }
 
 
 
index c0244e69751fe141f978d52c3b1310f9af84b694..a7b2791a92fe9321a071e77bc8c6a6ca9d983958 100644 (file)
@@ -236,17 +236,22 @@ function settings_post(&$a) {
                check_form_security_token_redirectOnErr('/settings/display', 'settings_display');
 
                $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme']))  : $a->user['theme']);
+               $mobile_theme = ((x($_POST,'mobile_theme')) ? notags(trim($_POST['mobile_theme']))  : '');
                $nosmile = ((x($_POST,'nosmile')) ? intval($_POST['nosmile'])  : 0);  
                $browser_update   = ((x($_POST,'browser_update')) ? intval($_POST['browser_update']) : 0);
                $browser_update   = $browser_update * 1000;
                if($browser_update < 10000)
-                       $browser_update = 40000;
+                       $browser_update = 10000;
 
                $itemspage_network   = ((x($_POST,'itemspage_network')) ? intval($_POST['itemspage_network']) : 40);
                if($itemspage_network > 100)
-                                       $itemspage_network = 40;
+                       $itemspage_network = 100;
 
 
+               if($mobile_theme !== '') {
+                       set_pconfig(local_user(),'system','mobile_theme',$mobile_theme);
+               }
+
                set_pconfig(local_user(),'system','update_interval', $browser_update);
                set_pconfig(local_user(),'system','itemspage_network', $itemspage_network);
                set_pconfig(local_user(),'system','no_smilies',$nosmile);
@@ -497,10 +502,11 @@ function settings_post(&$a) {
        require_once('include/profile_update.php');
        profile_change();
 
-       $_SESSION['theme'] = $theme;
+       //$_SESSION['theme'] = $theme;
        if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) {
 
                // FIXME - set to un-verified, blocked and redirect to logout
+               // Why? Are we verifying people or email addresses?
 
        }
 
@@ -704,6 +710,9 @@ function settings_content(&$a) {
                $default_theme = get_config('system','theme');
                if(! $default_theme)
                        $default_theme = 'default';
+               $default_mobile_theme = get_config('system','mobile-theme');
+               if(! $mobile_default_theme)
+                       $mobile_default_theme = 'none';
 
                $allowed_themes_str = get_config('system','allowed_themes');
                $allowed_themes_raw = explode(',',$allowed_themes_str);
@@ -715,19 +724,27 @@ function settings_content(&$a) {
 
                
                $themes = array();
+               $mobile_themes = array("---" => t('No special theme for mobile devices'));
                $files = glob('view/theme/*');
                if($allowed_themes) {
                        foreach($allowed_themes as $th) {
                                $f = $th;
                                $is_experimental = file_exists('view/theme/' . $th . '/experimental');
                                $unsupported = file_exists('view/theme/' . $th . '/unsupported');
+                               $is_mobile = file_exists('view/theme/' . $th . '/mobile');
                                if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){ 
                                        $theme_name = (($is_experimental) ?  sprintf("%s - \x28Experimental\x29", $f) : $f);
-                                       $themes[$f]=$theme_name;
+                                       if($is_mobile) {
+                                               $mobile_themes[$f]=$theme_name;
+                                       }
+                                       else {
+                                               $themes[$f]=$theme_name;
+                                       }
                                }
                        }
                }
                $theme_selected = (!x($_SESSION,'theme')? $default_theme : $_SESSION['theme']);
+               $mobile_theme_selected = (!x($_SESSION,'mobile-theme')? $default_mobile_theme : $_SESSION['mobile-theme']);
                
                $browser_update = intval(get_pconfig(local_user(), 'system','update_interval'));
                $browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
@@ -753,7 +770,8 @@ function settings_content(&$a) {
                        '$baseurl' => $a->get_baseurl(true),
                        '$uid' => local_user(),
                
-                       '$theme'        => array('theme', t('Display Theme:'), $theme_selected, '', $themes),
+                       '$theme'        => array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview'),
+                       '$mobile_theme' => array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, ''),
                        '$ajaxint'   => array('browser_update',  t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')),
                        '$itemspage_network'   => array('itemspage_network',  t("Number of items to display per page:"), $itemspage_network, t('Maximum of 100 items')),
                        '$nosmile'      => array('nosmile', t("Don't show emoticons"), $nosmile, ''),
index 5847d86646b1eb3211bb5110e80d4cf48dd914b7..1b3ede36c30ac5b6454cf6175b49fc429553061e 100644 (file)
@@ -1,7 +1,7 @@
        <script>$(function(){ previewTheme($("#id_$field.0")[0]); });</script>
        <div class='field select'>
                <label for='id_$field.0'>$field.1</label>
-               <select name='$field.0' id='id_$field.0' onchange="previewTheme(this);" >
+               <select name='$field.0' id='id_$field.0' {{ if $field.5=='preview' }}onchange="previewTheme(this);"{{ endif }} >
                        {{ for $field.4 as $opt=>$val }}<option value="$opt" {{ if $opt==$field.2 }}selected="selected"{{ endif }}>$val</option>{{ endfor }}
                </select>
                <span class='field_help'>$field.3</span>
index 70895a1f89e0067c417d13f29bef438fc62f1f7b..24fc1102706fe9bc36d2fda10edfcaf840aec6d3 100644 (file)
@@ -4,6 +4,7 @@
 <input type='hidden' name='form_security_token' value='$form_security_token'>
 
 {{inc field_themeselect.tpl with $field=$theme }}{{endinc}}
+{{inc field_themeselect.tpl with $field=$mobile_theme }}{{endinc}}
 {{inc field_input.tpl with $field=$ajaxint }}{{endinc}}
 {{inc field_input.tpl with $field=$itemspage_network }}{{endinc}}
 {{inc field_checkbox.tpl with $field=$nosmile}}{{endinc}}
index 612ab1030a5c56e25c6c18c50f5156b4d712bdac..3aa973d47bff95c4c8252b436873685a91f3f261 100644 (file)
@@ -1,7 +1,7 @@
 
        <div class='field select'>
                <label for='id_$field.0'>$field.1</label>
-               <select name='$field.0' id='id_$field.0' onchange="previewTheme(this);" >
+               <select name='$field.0' id='id_$field.0' {{ if $field.5=='preview' }}onchange="previewTheme(this);"{{ endif }} >
                        {{ for $field.4 as $opt=>$val }}<option value="$opt" {{ if $opt==$field.2 }}selected="selected"{{ endif }}>$val</option>{{ endfor }}
                </select>
                <span class='field_help'>$field.3</span>
index 612ab1030a5c56e25c6c18c50f5156b4d712bdac..3aa973d47bff95c4c8252b436873685a91f3f261 100644 (file)
@@ -1,7 +1,7 @@
 
        <div class='field select'>
                <label for='id_$field.0'>$field.1</label>
-               <select name='$field.0' id='id_$field.0' onchange="previewTheme(this);" >
+               <select name='$field.0' id='id_$field.0' {{ if $field.5=='preview' }}onchange="previewTheme(this);"{{ endif }} >
                        {{ for $field.4 as $opt=>$val }}<option value="$opt" {{ if $opt==$field.2 }}selected="selected"{{ endif }}>$val</option>{{ endfor }}
                </select>
                <span class='field_help'>$field.3</span>