diff options
Diffstat (limited to 'views')
-rw-r--r-- | views/default/account/forms/register.php | 2 | ||||
-rw-r--r-- | views/default/account/forms/useradd.php | 2 | ||||
-rw-r--r-- | views/default/output/friendlytime.php | 54 | ||||
-rw-r--r-- | views/default/output/friendlytitle.php | 18 | ||||
-rw-r--r-- | views/default/output/url.php | 16 | ||||
-rw-r--r-- | views/default/page_elements/elgg_topbar.php | 4 |
6 files changed, 84 insertions, 12 deletions
diff --git a/views/default/account/forms/register.php b/views/default/account/forms/register.php index 756efbb7e..b46e9df0b 100644 --- a/views/default/account/forms/register.php +++ b/views/default/account/forms/register.php @@ -13,7 +13,7 @@ $email = get_input('e'); $name = get_input('n'); $admin_option = false; -if (($_SESSION['user']->admin) && ($vars['show_admin'])) { +if (($_SESSION['user']->isAdmin()) && ($vars['show_admin'])) { $admin_option = true; } diff --git a/views/default/account/forms/useradd.php b/views/default/account/forms/useradd.php index 734854d08..cf0dcd7ca 100644 --- a/views/default/account/forms/useradd.php +++ b/views/default/account/forms/useradd.php @@ -9,7 +9,7 @@ */ $admin_option = false; -if (($_SESSION['user']->admin) && ($vars['show_admin'])) { +if (($_SESSION['user']->isAdmin()) && ($vars['show_admin'])) { $admin_option = true; } diff --git a/views/default/output/friendlytime.php b/views/default/output/friendlytime.php new file mode 100644 index 000000000..282d94c41 --- /dev/null +++ b/views/default/output/friendlytime.php @@ -0,0 +1,54 @@ +<?php +/** + * Friendly time + * Translates an epoch time into a human-readable time. + * + * @uses string $vars['time'] Unix-style epoch timestamp + */ + +$diff = time() - ((int) $vars['time']); + +$minute = 60; +$hour = $minute * 60; +$day = $hour * 24; + +if ($diff < $minute) { + $friendly_time = elgg_echo("friendlytime:justnow"); +} else if ($diff < $hour) { + $diff = round($diff / $minute); + if ($diff == 0) { + $diff = 1; + } + + if ($diff > 1) { + $friendly_time = sprintf(elgg_echo("friendlytime:minutes"), $diff); + } else { + $friendly_time = sprintf(elgg_echo("friendlytime:minutes:singular"), $diff); + } +} else if ($diff < $day) { + $diff = round($diff / $hour); + if ($diff == 0) { + $diff = 1; + } + + if ($diff > 1) { + $friendly_time = sprintf(elgg_echo("friendlytime:hours"), $diff); + } else { + $friendly_time = sprintf(elgg_echo("friendlytime:hours:singular"), $diff); + } +} else { + $diff = round($diff / $day); + if ($diff == 0) { + $diff = 1; + } + + if ($diff > 1) { + $friendly_time = sprintf(elgg_echo("friendlytime:days"), $diff); + } else { + $friendly_time = sprintf(elgg_echo("friendlytime:days:singular"), $diff); + } +} + +$timestamp = htmlentities(date(elgg_echo('friendlytime:date_format'), $vars['time'])); + +echo "<acronym title=\"$timestamp\">$friendly_time</acronym>"; diff --git a/views/default/output/friendlytitle.php b/views/default/output/friendlytitle.php new file mode 100644 index 000000000..a92726f69 --- /dev/null +++ b/views/default/output/friendlytitle.php @@ -0,0 +1,18 @@ +<?php +/** + * Friendly title + * Makes a URL-friendly title. + * + * @uses string $vars['title'] Title to create from. + */ + + +$title = $vars['title']; + +$title = trim($title); +$title = strtolower($title); +$title = preg_replace("/[^\w ]/","",$title); +$title = str_replace(" ","-",$title); +$title = str_replace("--","-",$title); + +echo $title; diff --git a/views/default/output/url.php b/views/default/output/url.php index 7e0281a43..87d3a68a1 100644 --- a/views/default/output/url.php +++ b/views/default/output/url.php @@ -20,14 +20,6 @@ $url = trim($vars['href']); if (!empty($url)) { - if ((substr_count($url, "http://") == 0) && (substr_count($url, "https://") == 0)) { - $url = "http://" . $url; - } - - if (array_key_exists('is_action', $vars) && $vars['is_action']) { - $url = elgg_add_action_tokens_to_url($url); - } - if (array_key_exists('target', $vars) && $vars['target']) { $target = "target = \"{$vars['target']}\""; } else { @@ -52,5 +44,13 @@ if (!empty($url)) { $text = htmlentities($url, ENT_QUOTES, 'UTF-8'); } + if ((substr_count($url, "http://") == 0) && (substr_count($url, "https://") == 0)) { + $url = "http://" . $url; + } + + if (array_key_exists('is_action', $vars) && $vars['is_action']) { + $url = elgg_add_action_tokens_to_url($url); + } + echo "<a href=\"{$url}\" $target $class $js>$text</a>"; }
\ No newline at end of file diff --git a/views/default/page_elements/elgg_topbar.php b/views/default/page_elements/elgg_topbar.php index f0808fb28..7db5940cd 100644 --- a/views/default/page_elements/elgg_topbar.php +++ b/views/default/page_elements/elgg_topbar.php @@ -31,7 +31,7 @@ <?php // The administration link is for admin or site admin users only - if ($vars['user']->admin || $vars['user']->siteadmin) { + if ($vars['user']->isAdmin()) { ?> <a href="<?php echo $vars['url']; ?>pg/admin/" class="admin"><?php echo elgg_echo("admin"); ?></a> @@ -55,4 +55,4 @@ </div> <?php } -?>
\ No newline at end of file +?> |