Exemplo n.º 1
0
 public function update($type, $ID)
 {
     if (Input::exists('post') && $ID == Input::get('id')) {
         //Update post
         PostModel::load()->update(array('Title' => Input::get('title'), 'Updated' => time(), 'Slug' => Input::toSlug(Input::get('title')), 'Start_date' => strtotime(Input::get('start_date')), 'End_date' => strtotime(Input::get('end_date')), 'Body' => Input::get('body'), 'User_ID' => Session::get('User')), Input::get('id'));
         //clean up
         CategoryItemModel::load()->delete('Post_ID', Input::get('id'));
         //update records
         foreach ($_POST['category'] as $category_id) {
             CategoryItemModel::load()->create(array('Cat_ID' => $category_id, 'Post_ID' => Input::get('id')));
         }
         //clean up records
         UploadItemModel::load()->delete('Post_ID', Input::get('id'));
         //update records
         foreach ($_POST['upload'] as $upload) {
             UploadItemModel::load()->create(array('Upload_ID' => $upload, 'Post_ID' => Input::get('id')));
         }
         Session::set('SUCCESS', i18n::get("FEEDBACK_SUCCESS", 'system'));
         Redirect::to($this->project_url . "admin/update/post/{$type}/" . Input::get('id'));
     } else {
         return (object) array('data' => PostModel::load($type)->get(array(array('ID', '=', $ID))), 'categories' => CategoryModel::load()->read(), 'post_cat' => CategoryItemModel::load()->get(array(array('Post_ID', '=', $ID))), 'upload_item' => UploadItemModel::load()->get(array(array('Post_ID', '=', $ID))), 'uploads' => UploadModel::load()->read());
     }
 }
Exemplo n.º 2
0
use thom855j\PHPI18n\I18n, thom855j\PHPHtml\Form, thom855j\PHPHttp\Input;
?>
<h2 class="sub-header"><?php 
i18n::output('POST_CREATE', $this->controller);
?>
</h2> 
<?php 
Form::start($this->project_url, 'post', true);
Form::label('title', i18n::get('POST_TITLE', $this->controller), "class='control-label'");
Form::input('text', 'title', Input::exists(Input::get('title')), "class='form-control' required");
Form::label('start_date', i18n::get('POST_START', $this->controller), "class='control-label'");
Form::input('text', 'start_date', date($this->date_format), "class='form-control' required");
Form::label('end_date', i18n::get('POST_END', $this->controller), "class='control-label'");
Form::input('text', 'end_date', null, "class='form-control' required");
Form::label('body', i18n::get('POST_CONTENT', $this->controller), "class='control-label'");
Form::textarea('body', " class='form-control'", Input::exists(Input::get('body')));
foreach ($this->results->categories as $cat) {
    if ($cat->Parent_ID == 0 || $cat->ID == $cat->Parent_ID) {
        $options[] = Form::options($cat->ID, '-' . $cat->Label);
    } else {
        $options[] = Form::options($cat->ID, $cat->Label);
    }
}
if (isset($this->results->uploads)) {
    $path = $this->project_url . '/public/uploads/thumbs/';
    foreach ($this->results->uploads as $upload) {
        $selected = '';
        $thumb = '';
        foreach ($this->results->upload_item as $upload_item) {
            $thumb = $path . $upload->Slug;
            if ($upload_item->Upload_ID == $upload->ID) {