aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRedMatrix <info@friendica.com>2015-01-02 12:10:50 +1100
committerRedMatrix <info@friendica.com>2015-01-02 12:10:50 +1100
commit817b54688e8cea4c7671a8326ce4cf815e1b62d6 (patch)
treeb1e398a186c77fa99b67dc6a99195713582fc4a4
parentdb811ca975e6880ff6540a61c216e7e2432ea75e (diff)
parent85e76773a04995884e798a89cc285f48377bcb62 (diff)
downloadvolse-hubzilla-817b54688e8cea4c7671a8326ce4cf815e1b62d6.tar.gz
volse-hubzilla-817b54688e8cea4c7671a8326ce4cf815e1b62d6.tar.bz2
volse-hubzilla-817b54688e8cea4c7671a8326ce4cf815e1b62d6.zip
Merge pull request #805 from pafcu/moretpl
Move some HTML out to templates
-rw-r--r--include/datetime.php47
-rw-r--r--include/permissions.php38
-rw-r--r--mod/new_channel.php7
-rw-r--r--mod/settings.php8
-rwxr-xr-xmod/setup.php2
-rw-r--r--view/js/mod_new_channel.js2
-rw-r--r--view/js/mod_settings.js4
-rw-r--r--view/tpl/field_select_grouped.tpl12
-rwxr-xr-xview/tpl/install_settings.tpl2
-rwxr-xr-xview/tpl/new_channel.tpl5
-rw-r--r--view/tpl/select_timezone.tpl11
-rwxr-xr-xview/tpl/settings.tpl7
12 files changed, 53 insertions, 92 deletions
diff --git a/include/datetime.php b/include/datetime.php
index 59dad2045..346d03bd4 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -14,25 +14,17 @@ function timezone_cmp($a, $b) {
return ( t($a) < t($b)) ? -1 : 1;
}
-// emit a timezone selector grouped (primarily) by continent
-
-function select_timezone($current = 'America/Los_Angeles') {
-
+// Return timezones grouped (primarily) by continent
+function get_timezones( ){
$timezone_identifiers = DateTimeZone::listIdentifiers();
-
- $o ='<select id="timezone_select" name="timezone">';
usort($timezone_identifiers, 'timezone_cmp');
$continent = '';
+ $continents = array();
foreach($timezone_identifiers as $value) {
$ex = explode("/", $value);
if(count($ex) > 1) {
- if($ex[0] != $continent) {
- if($continent != '')
- $o .= '</optgroup>';
- $continent = $ex[0];
- $o .= '<optgroup label="' . t($continent) . '">';
- }
+ $continent = t($ex[0]);
if(count($ex) > 2)
$city = substr($value,strpos($value,'/')+1);
else
@@ -40,35 +32,14 @@ function select_timezone($current = 'America/Los_Angeles') {
}
else {
$city = $ex[0];
- if($continent != t('Miscellaneous')) {
- $o .= '</optgroup>';
- $continent = t('Miscellaneous');
- $o .= '<optgroup label="' . t($continent) . '">';
- }
+ $continent = t('Miscellaneous');
}
$city = str_replace('_', ' ', t($city));
- $selected = (($value == $current) ? " selected=\"selected\" " : "");
- $o .= "<option value=\"$value\" $selected >$city</option>";
- }
- $o .= '</optgroup></select>';
- return $o;
-}
-
-// return a select using 'field_select_raw' template, with timezones
-// groupped (primarily) by continent
-// arguments follow convetion as other field_* template array:
-// 'name', 'label', $value, 'help'
-function field_timezone($name='timezone', $label='', $current = 'America/Los_Angeles', $help){
- $options = select_timezone($current);
- $options = str_replace('<select id="timezone_select" name="timezone">','', $options);
- $options = str_replace('</select>','', $options);
-
- $tpl = get_markup_template('field_select_raw.tpl');
- return replace_macros($tpl, array(
- '$field' => array($name, $label, $current, $help, $options),
- ));
-
+ if(!x($continents,$ex[0])) $continents[$ex[0]] = array();
+ $continents[$continent][$value] = $city;
+ }
+ return $continents;
}
// General purpose date parse/convert function.
diff --git a/include/permissions.php b/include/permissions.php
index 9e60223fb..ccbde1a7c 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -800,38 +800,18 @@ function get_role_perms($role) {
}
/**
- * @brief Creates a HTML select field with all available roles.
+ * @brief Returns a list or roles, grouped by type
*
* @param string $current The current role
- * @return string Returns the complete HTML code for this privacy-role-select field.
+ * @return string Returns an array of roles, grouped by type
*/
-function role_selector($current) {
-
- if(! $current)
- $current = 'custom';
-
+function get_roles() {
$roles = array(
- 'social' => array( t('Social Networking'),
- array('social' => t('Mostly Public'), 'social_restricted' => t('Restricted'), 'social_private' => t('Private'))),
- 'forum' => array( t('Community Forum'),
- array('forum' => t('Mostly Public'), 'forum_restricted' => t('Restricted'), 'forum_private' => t('Private'))),
- 'feed' => array( t('Feed Republish'),
- array('feed' => t('Mostly Public'), 'feed_restricted' => t('Restricted'))),
- 'special' => array( t('Special Purpose'),
- array('soapbox' => t('Celebrity/Soapbox'), 'repository' => t('Group Repository'))),
- 'other' => array( t('Other'),
- array('custom' => t('Custom/Expert Mode'))));
-
- $o = '<select name="permissions_role" id="privacy-role-select">';
- foreach($roles as $k => $v) {
- $o .= '<optgroup label="'. htmlspecialchars($v[0]) . '">';
- foreach($v[1] as $kk => $vv) {
- $selected = (($kk === $current) ? ' selected="selected"' : '');
- $o .= '<option value="' . $kk . '"' . $selected . '>' . htmlspecialchars($vv) . '</option>';
- }
- $o .= '</optgroup>';
- }
- $o .= '</select>';
+ t('Social Networking') => array('social' => t('Mostly Public'), 'social_restricted' => t('Restricted'), 'social_private' => t('Private')),
+ t('Community Forum') => array('forum' => t('Mostly Public'), 'forum_restricted' => t('Restricted'), 'forum_private' => t('Private')),
+ t('Feed Republish') => array('feed' => t('Mostly Public'), 'feed_restricted' => t('Restricted')),
+ t('Special Purpose') => array('soapbox' => t('Celebrity/Soapbox'), 'repository' => t('Group Repository')),
+ t('Other') => array('custom' => t('Custom/Expert Mode')));
- return $o;
+ return $roles;
}
diff --git a/mod/new_channel.php b/mod/new_channel.php
index 185fc7c28..047048f0a 100644
--- a/mod/new_channel.php
+++ b/mod/new_channel.php
@@ -115,11 +115,8 @@ function new_channel_content(&$a) {
'$nick_desc' => t('Your nickname will be used to create an easily remembered channel address (like an email address) which you can share with others.'),
'$label_import' => t('Or <a href="import">import an existing channel</a> from another location'),
'$name' => $name,
- '$label_role' => t('Channel Type'),
- '$questionmark' => t('?'),
- '$what_is_role' => t('What is this?'),
- '$help_role' => t('Please choose a channel type (such as social networking or community forum) and privacy requirements so we can select the best permissions for you'),
- '$role_select' => role_selector(($privacy_role) ? $privacy_role : 'social'),
+ '$help_role' => t('Please choose a channel type (such as social networking or community forum) and privacy requirements so we can select the best permissions for you'),
+ '$role' => array('permissions_role' , t('Channel Type'), ($privacy_role) ? $privacy_role : 'social', '<a href="help/roles" target="_blank">'.t('Read more about roles').'</a>',get_roles()),
'$nickname' => $nickname,
'$submit' => t('Create')
));
diff --git a/mod/settings.php b/mod/settings.php
index bb1ec8cb8..59ce98a2a 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -1018,12 +1018,10 @@ function settings_content(&$a) {
'$uid' => local_user(),
'$form_security_token' => get_form_security_token("settings"),
'$nickname_block' => $prof_addr,
-
-
'$h_basic' => t('Basic Settings'),
'$username' => array('username', t('Full Name:'), $username,''),
'$email' => array('email', t('Email Address:'), $email, ''),
- '$timezone' => array('timezone_select' , t('Your Timezone:'), select_timezone($timezone), ''),
+ '$timezone' => array('timezone_select' , t('Your Timezone:'), $timezone, '', get_timezones()),
'$defloc' => array('defloc', t('Default Post Location:'), $defloc, t('Geographical location to display on your posts')),
'$allowloc' => array('allow_location', t('Use Browser Location:'), ((get_pconfig(local_user(),'system','use_browser_location')) ? 1 : ''), ''),
@@ -1052,9 +1050,7 @@ function settings_content(&$a) {
'$aclselect' => populate_acl($perm_defaults,false),
'$suggestme' => $suggestme,
'$group_select' => $group_select,
- '$role_lbl' => t('Channel permissions category:'),
-
- '$role_select' => role_selector($permissions_role),
+ '$role' => array('permissions_role' , t('Channel permissions category:'), $permissions_role, '', get_roles()),
'$profile_in_dir' => $profile_in_dir,
'$hide_friends' => $hide_friends,
diff --git a/mod/setup.php b/mod/setup.php
index 044def15a..6f2c7c074 100755
--- a/mod/setup.php
+++ b/mod/setup.php
@@ -349,7 +349,7 @@ function setup_content(&$a) {
'$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')),
- '$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''),
+ '$timezone' => array('timezone', t('Please select a default timezone for your website'), $timezone, '', get_timezones()),
'$baseurl' => $a->get_baseurl(),
diff --git a/view/js/mod_new_channel.js b/view/js/mod_new_channel.js
index 492267ff9..c4d5408f2 100644
--- a/view/js/mod_new_channel.js
+++ b/view/js/mod_new_channel.js
@@ -1,5 +1,5 @@
$(document).ready(function() {
-// $("#privacy-role-select").sSelect();
+// $("#id_permissions_role").sSelect();
$("#newchannel-name").blur(function() {
$("#name-spinner").spin('small');
var zreg_name = $("#newchannel-name").val();
diff --git a/view/js/mod_settings.js b/view/js/mod_settings.js
index ff859936a..0db0dd165 100644
--- a/view/js/mod_settings.js
+++ b/view/js/mod_settings.js
@@ -9,8 +9,8 @@ $(document).ready(function() {
'transition' : 'elastic'
});
- $("#privacy-role-select").change(function() {
- var role = $("#privacy-role-select").val();
+ $("#id_permissions_role").change(function() {
+ var role = $("#id_permissions_role").val();
if(role == 'custom')
$('#advanced-perm').show();
else
diff --git a/view/tpl/field_select_grouped.tpl b/view/tpl/field_select_grouped.tpl
new file mode 100644
index 000000000..c7fb4f322
--- /dev/null
+++ b/view/tpl/field_select_grouped.tpl
@@ -0,0 +1,12 @@
+ <div class='field select'>
+ <label for='id_{{$field.0}}'>{{$field.1}}</label>
+ <select name='{{$field.0}}' id='id_{{$field.0}}'>
+ {{foreach $field.4 as $group=>$opts}}
+ <optgroup label='{{$group}}'>
+ {{foreach $opts as $opt=>$val}}
+ <option value="{{$opt}}" {{if $opt==$field.2}}selected="selected"{{/if}}>{{$val}}</option>{{/foreach}}
+ {{/foreach}}
+ </optgroup>
+ </select>
+ <span class='field_help'>{{$field.3}}</span>
+ </div>
diff --git a/view/tpl/install_settings.tpl b/view/tpl/install_settings.tpl
index f4fd82fdb..62dcbb8b3 100755
--- a/view/tpl/install_settings.tpl
+++ b/view/tpl/install_settings.tpl
@@ -20,7 +20,7 @@
{{include file="field_input.tpl" field=$adminmail}}
{{include file="field_input.tpl" field=$siteurl}}
-{{$timezone}}
+{{include file="field_select_grouped.tpl" field=$timezone}}
<input id="install-submit" type="submit" name="submit" value="{{$submit}}" />
diff --git a/view/tpl/new_channel.tpl b/view/tpl/new_channel.tpl
index 241846eb4..ff2011181 100755
--- a/view/tpl/new_channel.tpl
+++ b/view/tpl/new_channel.tpl
@@ -5,10 +5,7 @@
<div id="newchannel-desc" class="descriptive-paragraph">{{$desc}}</div>
<div id="newchannel-role-help" class="descriptive-paragraph">{{$help_role}}</div>
-
- <label for="newchannel-role" id="label-newchannel-role" class="newchannel-label" >{{$label_role}}</label>
- {{$role_select}}
- <div class="newchannel-role-morehelp"><a href="help/roles" title="{{$what_is_role}}" target="_blank">{{$questionmark}}</a></div>
+ {{include file="field_select_grouped.tpl" field=$role}}
<div id="newchannel-role-end" class="newchannel-field-end"></div>
diff --git a/view/tpl/select_timezone.tpl b/view/tpl/select_timezone.tpl
new file mode 100644
index 000000000..2820a54f4
--- /dev/null
+++ b/view/tpl/select_timezone.tpl
@@ -0,0 +1,11 @@
+{{* TODO: Make id configurabel *}}
+<select id='timezone_select' name='timezone'>
+{{foreach $continents as $continent => $cities}}
+<optgroup label="{{$continent}}">
+{{foreach $cities as $city => $value}}
+<option value='{{$value}}' {{if $value == $selected}}selected='selected'{{/if}}>{{$city}}</option>
+{{/foreach}}
+</optgroup>
+{{/foreach}}
+</select>
+
diff --git a/view/tpl/settings.tpl b/view/tpl/settings.tpl
index 9e53d4f98..894f0fe83 100755
--- a/view/tpl/settings.tpl
+++ b/view/tpl/settings.tpl
@@ -9,7 +9,7 @@
<h3 class="settings-heading">{{$h_basic}}</h3>
{{include file="field_input.tpl" field=$username}}
-{{include file="field_custom.tpl" field=$timezone}}
+{{include file="field_select_grouped.tpl" field=$timezone}}
{{include file="field_input.tpl" field=$defloc}}
{{include file="field_checkbox.tpl" field=$allowloc}}
@@ -22,10 +22,7 @@
<h3 class="settings-heading">{{$h_prv}}</h3>
-<div class="field custom">
-<label for="privacy-role-select">{{$role_lbl}}</label>
-{{$role_select}}
-</div>
+{{include file="field_select_grouped.tpl" field=$role}}
<div id="advanced-perm" style="display:{{if $permissions_set}}none{{else}}block{{/if}};">
{{include file="field_checkbox.tpl" field=$hide_presence}}