]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
now using built-in radio input view
authorCash Costello <cash.costello@gmail.com>
Sat, 20 Jun 2009 16:05:56 +0000 (16:05 +0000)
committerCash Costello <cash.costello@gmail.com>
Sat, 20 Jun 2009 16:05:56 +0000 (16:05 +0000)
actions/edit_multi.php
views/default/input/multi_radio.php [deleted file]
views/default/tidypics/forms/edit_multi.php

index a857e92d70334e4709e3a96d110639e66f09dae1..7c03244a5865b77cdb746e2148948626d979487a 100644 (file)
@@ -7,19 +7,19 @@
        // Make sure we're logged in (send us to the front page if not)\r
        if (!isloggedin()) forward();\r
 \r
-       // Get input data       \r
-       $cover = get_input('cover');\r
+       // Get input data\r
        $title_array = get_input('title');\r
        $caption_array = get_input('caption');\r
        $tags_array = get_input('tags');\r
        $image_guid_array = get_input('image_guid');\r
        $container_guid = get_input('container_guid');\r
        $album_entity = get_entity($container_guid);\r
+       $cover = get_input('cover');\r
        $not_updated = array();\r
 \r
-       foreach($image_guid_array as $key => $im) {     \r
+       foreach($image_guid_array as $key => $im) {\r
                $image = get_entity($im);\r
-                               \r
+               \r
                if ($image->canEdit()) {\r
                        \r
                        // Convert string of tags into a preformatted array\r
@@ -27,7 +27,7 @@
 \r
                        //set description appropriately\r
                        $image->title = $title_array[$key];\r
-                                                                                                               \r
+                       \r
                        //set description appropriately\r
                        $image->description = $caption_array[$key];\r
 \r
@@ -43,7 +43,7 @@
                        }\r
                                \r
                        //if cover meta is sent from image save as metadata\r
-                       if ($cover == $im) {    \r
+                       if ($cover == $im) {\r
                                $album_entity->cover = $im;\r
                        }\r
                }\r
diff --git a/views/default/input/multi_radio.php b/views/default/input/multi_radio.php
deleted file mode 100644 (file)
index 3e3bb16..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php\r
-\r
-       /**\r
-        * Multi radio input\r
-        * This is for selection of cover image\r
-        * \r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * @uses $vars['options'] An array of strings representing the options for the radio field\r
-        * \r
-        */\r
-\r
-       $class = $vars['class'];\r
-       if (!$class) $class = "input-checkboxes";\r
-\r
-    foreach($vars['options'] as $label => $option) {\r
-\r
-           if ($vars['set'] != $vars['value']) {\r
-               $selected = "";\r
-           } else {\r
-                       $selected = "checked = \"checked\"";\r
-           }\r
-\r
-        $labelint = (int) $label;\r
-        if ("{$label}" == "{$labelint}") {\r
-               $label = $option;\r
-        }\r
-        \r
-        $disabled = "";\r
-        if ($vars['disabled']) $disabled = ' disabled="yes" '; \r
-        echo "<label><input type=\"radio\" $disabled {$vars['js']} name=\"{$vars['internalname']}\" {$selected} value=\"".htmlentities($vars['value'], null, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label><br />";\r
-    }\r
-\r
-?> 
\ No newline at end of file
index 24755e9cfc97b56a1e778b2b614953776ce60e56..01ffb3128e8dde99a7d58cbde38969e179e14113 100644 (file)
@@ -8,38 +8,49 @@
 <?php\r
 \r
        $file_array = $vars['file_array'];\r
+       \r
+       // make sure one of the images becomes the cover if there isn't one already\r
        $album_entity = get_entity($vars['album_guid']);\r
-       if(!$album_entity->cover) $no_cover = true;\r
+       if (!$album_entity->cover) $no_cover = true;\r
        \r
-       foreach($file_array as $key => $file_guid){\r
+       foreach ($file_array as $key => $file_guid){\r
                $entity = get_entity($file_guid);\r
                $guid = $entity->guid;\r
                $body = $entity->description;\r
                $tags = $entity->tags;\r
                $container_guid = $entity->container_guid;\r
-               if($no_cover && !$cover) $cover = $guid;\r
-                                               \r
-  echo '<div class="tidypics_edit_image_container">';          \r
-       echo '<img src="' . $vars['url'] . 'mod/tidypics/thumbnail.php?file_guid=' . $guid . '&size=small" border="0" class="tidypics_edit_images" alt="' . $title . '"/>';\r
-       echo '<div class="tidypics_image_info">';\r
-       echo '<p><label>' . elgg_echo('album:title') . '</label>';\r
-       echo elgg_view("input/text", array("internalname" => "title[$key]", "value" => $title,)) . "\n";\r
-       echo '</p>';\r
-         echo '<p><label>' . elgg_echo('caption') . "</label>";\r
-         echo elgg_view("input/text",array("internalname" => "caption[$key]", "value" => $body,)) . "\n";\r
-         echo "</p>";\r
-         echo '<p><label>' . elgg_echo("tags") . "</label>\n";\r
-         echo elgg_view("input/tags", array( "internalname" => "tags[$key]","value" => $tags)) . "\n";\r
-         echo '</p>';\r
-         echo '<input type="hidden" name="image_guid[' .$key. ']" value="'. $guid .'">' . "\n";\r
-         echo '<label>' . elgg_echo("album:cover") . '</label>';\r
-         echo elgg_view("input/multi_radio", array( "internalname" => "cover", "value" => $guid, 'options' => array(elgg_echo('album:cover:yes')), 'set' => $cover));\r
-       echo '</div>';\r
-  echo '</div>';\r
                \r
+               // first one is default cover if there isn't one already\r
+               if ($no_cover) {\r
+                       $val = $guid;\r
+                       $no_cover = false;\r
+               }\r
+               \r
+               echo '<div class="tidypics_edit_image_container">';\r
+               echo '<img src="' . $vars['url'] . 'mod/tidypics/thumbnail.php?file_guid=' . $guid . '&size=small" border="0" class="tidypics_edit_images" alt="' . $title . '"/>';\r
+               echo '<div class="tidypics_image_info">';\r
+               echo '<p><label>' . elgg_echo('album:title') . '</label>';\r
+               echo elgg_view("input/text", array("internalname" => "title[$key]", "value" => $title,)) . "\n";\r
+               echo '</p>';\r
+               echo '<p><label>' . elgg_echo('caption') . "</label>";\r
+               echo elgg_view("input/text",array("internalname" => "caption[$key]", "value" => $body,)) . "\n";\r
+               echo "</p>";\r
+               echo '<p><label>' . elgg_echo("tags") . "</label>\n";\r
+               echo elgg_view("input/tags", array( "internalname" => "tags[$key]","value" => $tags)) . "\n";\r
+               echo '</p>';\r
+               echo '<input type="hidden" name="image_guid[' .$key. ']" value="'. $guid .'">' . "\n";\r
+               \r
+               echo elgg_view("input/radio", array("internalname" => "cover",\r
+                                                                                       "value" => $val,\r
+                                                                                       'options' => array(     elgg_echo('album:cover') => $guid,\r
+                                                                                                                               ),\r
+                                                                                                       ));\r
+               echo '</div>';\r
+               echo '</div>';\r
        }\r
+       \r
 ?>\r
-<input type="hidden" name="container_guid" value="<?php echo $container_guid; ?>" />           \r
+<input type="hidden" name="container_guid" value="<?php echo $container_guid; ?>" />\r
 <p><input type="submit" name="submit" value="<?php echo elgg_echo('save'); ?>" /></p>\r
 </form>\r
 </div>
\ No newline at end of file