]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #3489 added input/output views for tag and location
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 9 Jun 2011 22:15:56 +0000 (22:15 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 9 Jun 2011 22:15:56 +0000 (22:15 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@9163 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/users.php
views/default/input/location.php [new file with mode: 0644]
views/default/input/tag.php [new file with mode: 0644]
views/default/output/location.php [new file with mode: 0644]
views/default/output/tag.php [new file with mode: 0644]
views/default/output/tags.php

index a7765a5e5239726239f0d861310c2ac46d31aa2c..832bcd5298392dbeca70f0037c5eeee9272a79b4 100644 (file)
@@ -1345,7 +1345,7 @@ function elgg_profile_fields_setup() {
        $profile_defaults = array (
                'description' => 'longtext',
                'briefdescription' => 'text',
-               'location' => 'tags',
+               'location' => 'location',
                'interests' => 'tags',
                'skills' => 'tags',
                'contactemail' => 'email',
@@ -1379,7 +1379,7 @@ function elgg_profile_fields_setup() {
 
        // register any tag metadata names
        foreach ($CONFIG->profile_fields as $name => $type) {
-               if ($type == 'tags') {
+               if ($type == 'tags' || $type == 'location' || $type == 'tag') {
                        elgg_register_tag_metadata_name($name);
                        // register a tag name translation
                        add_translation(get_current_language(), array("tag_names:$name" => elgg_echo("profile:$name")));
diff --git a/views/default/input/location.php b/views/default/input/location.php
new file mode 100644 (file)
index 0000000..d7ae2bb
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Location input field
+ *
+ * @uses $vars['entity'] The ElggEntity that has a location
+ * @uses $vars['value']  The default value for the location
+ */
+
+$defaults = array(
+       'class' => 'elgg-input-location',
+       'disabled' => FALSE,
+);
+
+if (isset($vars['entity'])) {
+       $defaults['value'] = $vars['entity']->location;
+       unset($vars['entity']);
+}
+
+$vars = array_merge($defaults, $vars);
+
+echo elgg_view('input/tag', $vars);
diff --git a/views/default/input/tag.php b/views/default/input/tag.php
new file mode 100644 (file)
index 0000000..a78ec31
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Elgg tag input
+ *
+ * Accepts a single tag value
+ *
+ * @uses $vars['value'] The default value for the tag
+ */
+
+$defaults = array(
+       'class' => 'elgg-input-tag',
+       'disabled' => FALSE,
+);
+
+$vars = array_merge($defaults, $vars);
+
+echo elgg_view('input/text', $vars);
\ No newline at end of file
diff --git a/views/default/output/location.php b/views/default/output/location.php
new file mode 100644 (file)
index 0000000..e3619d2
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Display a location
+ *
+ * @uses $vars['entity'] The ElggEntity that has a location
+ * @uses $vars['value']  The location string if the entity is not passed
+ */
+
+if (isset($vars['entity'])) {
+       $vars['value'] = $vars['entity']->location;
+       unset($vars['entity']);
+}
+
+echo elgg_view('output/tag', $vars);
diff --git a/views/default/output/tag.php b/views/default/output/tag.php
new file mode 100644 (file)
index 0000000..abae9c4
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Elgg single tag output
+ *
+ * @uses $vars['value']   String
+ * @uses $vars['type']    The entity type, optional
+ * @uses $vars['subtype'] The entity subtype, optional
+ *
+ */
+
+if (!empty($vars['subtype'])) {
+       $subtype = "&subtype=" . urlencode($vars['subtype']);
+} else {
+       $subtype = "";
+}
+if (!empty($vars['object'])) {
+       $object = "&object=" . urlencode($vars['object']);
+} else {
+       $object = "";
+}
+
+if (isset($vars['value'])) {
+       if (!empty($vars['type'])) {
+               $type = "&type={$vars['type']}";
+       } else {
+               $type = "";
+       }
+       $url = elgg_get_site_url() . 'search?q=' . urlencode($vars['value']) . "&search_type=tags{$type}{$subtype}{$object}";
+       echo elgg_view('output/url', array('href' => $url, 'text' => $vars['value'], 'rel' => 'tag'));
+}
index 57cb21ea750437b1bad79f0485f42cb0f5157abc..6dedfacc7bdfa76ced9600692de46adbf22ede8d 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 if (isset($vars['entity'])) {
-       $defaults['value'] = $vars['entity']->tags;
+       $vars['tags'] = $vars['entity']->tags;
        unset($vars['entity']);
 }