Skip to content

Commit

Permalink
Created xml feed.
Browse files Browse the repository at this point in the history
  • Loading branch information
abenson committed Mar 15, 2012
1 parent b1ee6ec commit 3cccf0d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 33 deletions.
20 changes: 16 additions & 4 deletions application/controllers/api.php
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions application/controllers/image.php
Expand Up @@ -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/';
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions application/views/album/images.php
Expand Up @@ -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>
Expand Down
41 changes: 16 additions & 25 deletions application/views/feed/xml.php
@@ -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.