/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // $test = base_path();
     // dd($test);
     $input = Input::only('title', 'tagline', 'summary', 'photo', 'content', 'published_at');
     //form exceptions handled in start/global.php
     $this->articleForm->validate($input);
     // add user_id to the article create array
     $article = array_add($input, 'user_id', Auth::id());
     $article = Article::create($article);
     if (Input::has('photo')) {
         // upload photo to storage and set $article['photo'] to storage url
         $filename = 'articles/photo-' . str_random(12);
         Storage::upload(Input::file('photo'), $filename);
         $article->photo = Storage::url($filename);
         $article->save();
     }
     Session::flash('successMessage', "Added To Your Wolfpack: {$article->title}");
     Log::info("New Article created at id: {$article->id}");
     return Redirect::action('ArticlesController@index');
 }
Example #2
0
 public static function articles($sectionId)
 {
     $db = Core::getDb();
     $content = null;
     $articles = array();
     $q = $db->buildQuery("select id from articles a LEFT JOIN objects o ON o.object_id=a.object_id where featured=true and visible=true and ctime<=now() and section_id=%d order by ctime desc limit 4", $sectionId);
     $rs = $db->query($q);
     if ($rs && ($count = $db->numRows($rs))) {
         while ($o = $db->fetchObject($rs)) {
             $article = new Article($o->id);
             $articles[] = $article;
         }
     } else {
         return $content;
     }
     $widths = array();
     $widths[1] = array(780);
     $widths[2] = array(520, 260);
     $widths[3] = array(390, 195, 195);
     $widths[4] = array(195, 195, 195, 195);
     list($articles) = array_chunk($articles, 4);
     $count = count($articles);
     if (!$count) {
         return null;
     }
     $content .= "<div class=\"banner\">\n";
     foreach ($articles as $id => $article) {
         $width = $widths[$count][$id];
         $img = Storage::url($article->topImage());
         list($base, $ext) = Storage::splitExtension($img);
         $img = "{$base}.{$width}x250.c.{$ext}";
         $content .= "<div class=\"bannerItem\" style=\"width: {$width}px; background-image: url({$img});\">\n";
         $content .= "<a href=\"" . $article->url() . "\">" . $article->title() . "</a>";
         $content .= "</div>\n";
     }
     $content .= "<br class=\"spacer\">";
     $content .= "</div>\n";
     return $content;
 }
Example #3
0
 public static function albumImage($id, $label, $albumId, $selected = 0)
 {
     $db = Core::getDb();
     $template = new Template('forms/album-selectimage');
     $imgUrl = $selected ? Storage::url($selected, 75, 75, true) : "/kiki/img/blank.gif";
     $template->assign('label', $label);
     $template->assign('imgUrl', $imgUrl);
     $images = array();
     $q = $db->buildQuery("select p.storage_id from pictures p, album_pictures ap where ap.picture_id=p.id AND ap.album_id=%d", $albumId);
     $rs = $db->query($q);
     if ($rs && $db->numRows($rs)) {
         while ($o = $db->fetchObject($rs)) {
             $url = Storage::url($o->storage_id, 75, 75, true);
             $images[] = array('storageId' => $o->storage_id, 'url' => $url);
         }
     }
     $template->assign('images', $images);
     $template->assign('id', $id);
     $template->assign('selected', $selected);
     return $template->fetch();
 }
Example #4
0
 public function content()
 {
     // rjkcust
     setlocale("LC_TIME", "nl_NL.utf8");
     $start = strftime("%A %e %B %Y %R", strtotime($this->start));
     $end = strftime("%A %e %B %Y %R", strtotime($this->end));
     $imgUrl = Storage::url($this->topImage(), 320, 180, true);
     $content = "<img src=\"{$imgUrl}\" style=\"float: right; margin: 0 0 1em 1em;\">";
     $content .= Misc::markup($this->description);
     $content .= "<ul>";
     $content .= "<li>Wanneer?<p class=\"small\">{$start} (over " . Misc::relativeTime($this->start) . ")</p></li>";
     $content .= "<li>Waar?<p class=\"small\">" . $this->location . "</p></li>";
     $this->loadPublications();
     foreach ($this->publications as $publication) {
         $content .= "<li><a href=\"" . $publication->url() . "\" class=\"button\"><span class=\"buttonImg " . $publication->service() . "\"></span>" . $publication->service() . "</a></li>\n";
     }
     $content .= "</ul>";
     return $content;
 }
Example #5
0
                    <div class="form-group">
                        <label for="titulo">Status</label>
                        <select name="status" class="form-control" id="status">
                            <option value="0" {{ $status=='0' ? 'selected' : '' }}>Bloqueado</option>
                            <option value="1" {{ $status=='1' ? 'selected' : '' }}>Liberado</option>
                        </select>
                    </div>
                </div>

                <div class="col-md-3">
                    <div class="form-group">
                        <label for="imagem">
                            Imagem
                            <?php 
if (isset($model) && $model->imagem) {
    echo '<a href="' . Storage::url($model->imagem) . '" target="_new"><small>(ver)</small></a>';
}
?>
                        </label>
                        <input type="file" name="imagem" id="imagem" class="form-control">
                    </div>
                </div>

                <div class="col-md-6">
                    <div class="form-group">
                        <label for="titulo">Título</label>
                        <input type="text" id="titulo" name="titulo" class="form-control" value="{{ $titulo }}" required>
                    </div>
                </div>

            </div>
Example #6
0
 public function formItem($pictureId)
 {
     // Picture details
     $qPictureId = $this->db->escape($pictureId);
     $q = "select storage_id from pictures where id={$qPictureId}";
     $o = $this->db->getSingleObject($q);
     $storageId = $o->storage_id;
     $imgUrl = Storage::url($storageId, 75, 75, true);
     return "<div class=\"pictureFormItem\" id=\"pictureFormItem_{$pictureId}\"><div class=\"img-overlay\"><a class=\"removePicture\" href=\"#\"><img src=\"/kiki/img/iconic/black/trash_stroke_16x16.png\" alt=\"Delete\"></a></div><img src=\"{$imgUrl}\" alt=\"\"></div>";
     ob_start();
     include Template::file('forms/album-editpicture');
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
Example #7
0
<?php

/**
 * Handles Ajax album navigation.
 *
 * @package Kiki
 * @author Rob Kaper <http://robkaper.nl/>
 * @copyright 2011 Rob Kaper <http://robkaper.nl/>
 * @license Released under the terms of the MIT license.
 */
// include "../../lib/init.php";
list($dummy, $albumId) = explode("_", $_GET['album']);
$current = $_GET['current'];
$action = $_GET['action'];
if ($action == "navleft") {
    $id = Album::findPrevious($albumId, $current);
} else {
    $id = Album::findNext($albumId, $current);
}
$q = $db->buildQuery("select title, storage_id from pictures where id=%d", $id);
$o = $db->getSingleObject($q);
$response = array();
$response['id'] = $o ? $id : 0;
$response['title'] = $o ? $o->title : null;
$response['url'] = $o ? Storage::url($o->storage_id) : null;
$response['prev'] = Album::findPrevious($albumId, $id);
$response['next'] = Album::findNext($albumId, $id);
header('Content-type: application/json');
echo json_encode($response);
exit;
Example #8
0
 public function templateData()
 {
     $uAuthor = ObjectCache::getByType('\\Kiki\\User', $this->userId);
     $prevArticle = $this->getPrev();
     $nextArticle = $this->getNext();
     $data = array('id' => $this->id, 'url' => $this->url(), 'ctime' => strtotime($this->ctime), 'relTime' => Misc::relativeTime($this->ctime), 'title' => $this->title, 'body' => $this->body, 'author' => $uAuthor->name(), 'images' => array(), 'publications' => array(), 'likes' => $this->likes(), 'comments' => Comments::count($this->objectId), 'html' => array('comments' => Comments::show($this->objectId), 'editform' => $this->form(true, 'articles')));
     if ($nextArticle = $this->getNext()) {
         $data['next'] = array('id' => $nextArticle->id(), 'url' => $nextArticle->url(), 'title' => $nextArticle->title());
     }
     if ($prevArticle = $this->getPrev()) {
         $data['prev'] = array('id' => $prevArticle->id(), 'url' => $prevArticle->url(), 'title' => $prevArticle->title());
     }
     $publications = $this->publications();
     foreach ($publications as $publication) {
         $data['publications'][] = $publication->templateData();
     }
     $images = $this->images();
     foreach ($images as $image) {
         $data['images'][] = Storage::url($image);
     }
     // print_r( $data['images'] );
     return $data;
 }