Permalink
Browse files

Created xml feed.

  • Loading branch information...
1 parent b1ee6ec commit 3cccf0d27863d6a4e5022cc024a005ebf31122e0 abenson committed Mar 15, 2012
@@ -131,22 +131,34 @@ public function feed($type, $album_id)
}
}
- protected function output_json_feed($album_id)
+ protected function get_feed($album_id)
{
- header('Content-Type: text/javascript; charset=utf8');
+ $this->load->model('album_model');
$this->load->model('comment_model');
+ $album = $this->album_model->find_by_id($album_id);
$image_data = $this->image_model->get_feed($album_id);
foreach ($image_data as $image)
{
$image->comments = $this->comment_model->get_comments_by_image_id($image->id);
+ $image->url = base_url() . 'uploads/' . $image->file_name;
}
- echo json_encode($image_data);
+ $album->images = $image_data;
+
+ return $album;
+ }
+
+ protected function output_json_feed($album_id)
+ {
+ header('Content-Type: text/javascript; charset=utf8');
+
+ echo json_encode($this->get_feed($album_id));
}
protected function output_xml_feed($album_id)
{
header("Content-Type: application/xhtml+xml; charset=utf-8");
- $data['feed'] = json_encode($this->image_model->get_feed($album_id));
+ $data['album'] = $this->get_feed($album_id);
+
$this->load->view('feed/xml', $data);
}
@@ -32,7 +32,7 @@ public function edit($album_id, $image_id)
if ($this->is_method_post() == TRUE)
{
- if (! empty($_FILES['file']['tmp_name']))
+ if ( ! empty($_FILES['file']['tmp_name']))
{
// Upload file if image has been selected.
$config['upload_path'] = './uploads/';
@@ -96,7 +96,7 @@ public function edit($album_id, $image_id)
'full_path' => $upload_info['full_path'],
'published' => $this->input->post('published'),
'updated_at' => $now,
- 'updated_by' => $this->input->post('user_id')
+ 'updated_by' => $this->get_user_id()
);
$this->image_model->update($image_data, $image_id);
@@ -63,8 +63,8 @@
<a href="<?php echo $img_url; ?>" class="btn img-fancy" title="<?php echo $image->caption; ?>"><i class="icon-zoom-in"></i></a>
<a href="<?php echo site_url("image/download/$image->id"); ?>" class="btn" title="Download"><i class="icon-download"></i></a>
<a href="<?php echo site_url("image/edit/$album->id/$image->id"); ?>" class="btn" title="Edit"><i class="icon-pencil"></i></a>
- <a href="<?php echo site_url("image/tags/$image->id"); ?>" class="btn" title="Tags"><i class="icon-tags"></i></a>
- <a href="<?php echo site_url("image/comments/$image->id"); ?>" class="btn" title="Comments"><i class="icon-comment"></i></a>
+ <?php /*<a href="<?php echo site_url("image/tags/$image->id"); ?>" class="btn" title="Tags"><i class="icon-tags"></i></a>
+ <a href="<?php echo site_url("image/comments/$image->id"); ?>" class="btn" title="Comments"><i class="icon-comment"></i></a> */ ?>
<a href="<?php echo site_url("image/remove/$album->id/$image->id"); ?>" class="btn btn-danger" title="Delete"
onclick="confirm('Are you sure you wish to delete this image?')"><i class="icon-remove icon-white"></i></a>
</div>
@@ -1,28 +1,19 @@
<?php echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL; ?>
<album>
- <title></title>
- <thumbWidth></thumbwidth>
- <thumbHeight></thumbheight>
- <categories>
- <category>
- <name></name>
- <images>
- <image>
- <title></title>
- <caption></caption>
- <fileName></filename>
- <path></path>
- <comments>
- <comment>
- <poster></poster>
- <message></message>
- </comment>
- </comments>
- <tags>
- <tag></tag>
- </tags>
- </image>
- </images>
- </category>
- </categories>
+ <title><![CDATA[<?php echo $album->name; ?>]]></title>
+ <images>
+ <?php foreach ($album->images as $image): ?>
+ <image>
+ <title><![CDATA[<?php echo $image->title; ?>]]></title>
+ <caption><![CDATA[<?php echo $image->caption; ?>]]></caption>
+ <filename><?php echo $image->file_name; ?></filename>
+ <url><?php echo $image->url; ?></url>
+ <comments>
+ <?php foreach ($image->comments as $comment): ?>
+ <comment><![CDATA[<?php echo $comment; ?>]]></comment>
+ <?php endforeach; ?>
+ </comments>
+ </image>
+ <? endforeach; ?>
+ </images>
</album>

0 comments on commit 3cccf0d

Please sign in to comment.