]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Removed output/action_link view as it duplicated much of output/url.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 21 Jan 2010 21:04:44 +0000 (21:04 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 21 Jan 2010 21:04:44 +0000 (21:04 +0000)
Improved output/url view.

git-svn-id: http://code.elgg.org/elgg/trunk@3827 36083f99-b078-4883-b0ff-0f9b5a30f544

views/default/output/action_link.php [deleted file]
views/default/output/url.php

diff --git a/views/default/output/action_link.php b/views/default/output/action_link.php
deleted file mode 100644 (file)
index 1f64d4f..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-/**
- * Elgg action link
- * Creates a link to an action that includes action tokens
- *
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
- *
- * @uses $vars['text'] The text of the link
- * @uses $vars['href'] The address
- * @uses $vars['confirm'] The dialog text
- *
- */
-
-// always generate missing action tokens
-$link = elgg_validate_action_url($vars['href']);
-
-if (isset($vars['class']) && $vars['class']) {
-       $class = 'class="' . $vars['class'] . '"';
-} else {
-       $class = '';
-}
-?>
-<a href="<?php echo $link; ?>" <?php echo $class; ?> ><?php echo htmlentities($vars['text'], ENT_QUOTES, 'UTF-8'); ?></a>
\ No newline at end of file
index 190b08c21350d10cf18abb810f3c1ecdaed6ccde..b77ffbf00f6685794d4e7d7c3e14fff9a061f2ea 100644 (file)
@@ -8,26 +8,45 @@
  * @author Curverider Ltd
  * @link http://elgg.org/
  *
- * @uses $vars['value'] The URL to display
+ * @uses string $vars['href'] The string to display in the <a></a> tags
+ * @uses string $vars['text'] The string between the <a></a> tags.
+ * @uses bool $vars['target'] Set the target="" attribute.
+ * @uses string $vars['class'] what to add in class=""
+ * @uses string $vars['js'] Javascript to insert in <a> tag
+ * @uses bool $vars['is_action'] Is this a link to an action?
  *
  */
 
-$val = trim($vars['value']);
-if (!empty($val)) {
-       if ((substr_count($val, "http://") == 0) && (substr_count($val, "https://") == 0)) {
-               $val = "http://" . $val;
+$url = trim($vars['href']);
+
+if (!empty($url)) {
+       if (array_key_exists('is_action', $vars) && $vars['is_action']) {
+               $url = elgg_validate_action_url($url);
+       }
+
+       if (array_key_exists('target', $vars) && $vars['target']) {
+               $target = "target = \"{$vars['target']}\"";
+       } else {
+               $target = '';
        }
 
-       if ($vars['is_action']) {
-               $ts = time();
-               $token = generate_action_token($ts);
+       if (array_key_exists('class', $vars) && $vars['class']) {
+               $class = "class = \"{$vars['class']}\"";
+       } else {
+               $class = '';
+       }
+
+       if (array_key_exists('js', $vars) && $vars['js']) {
+               $js = "{$vars['target']}";
+       } else {
+               $js = '';
+       }
 
-               $sep = "?";
-               if (strpos($val, '?')>0) {
-                       $sep = "&";
-               }
-               $val = "$val{$sep}__elgg_token=$token&__elgg_ts=$ts";
+       if (array_key_exists('text', $vars) && $vars['text']) {
+               $text = htmlentities($vars['text'], ENT_QUOTES, 'UTF-8');
+       } else {
+               $text = htmlentities($url, ENT_QUOTES, 'UTF-8');
        }
 
-       echo "<a href=\"{$val}\" target=\"_blank\">". htmlentities($val, ENT_QUOTES, 'UTF-8'). "</a>";
+       echo "<a href=\"{$url}\" $target $class $js>$text</a>";
 }
\ No newline at end of file