Ejemplo n.º 1
0
 function action_delete()
 {
     $news = ORM::factory('newsservice', $this->request->param('id', NULL));
     if (!$news->loaded() or $news->user_id != $this->user->id) {
         Message::set(Message::ERROR, Kohana::message('cabinet', 'news_not_found'));
         $this->request->redirect('cabinet');
     }
     if ($_POST) {
         $action = Arr::extract($_POST, array('submit', 'cancel'));
         if ($action['cancel']) {
             $this->request->redirect('cabinet/mews');
         }
         if ($action['submit']) {
             $title = $news->title;
             if ($news->image and file_exists($news->image) and is_writable($news->image)) {
                 unlink($news->image);
                 unlink(MyHelper::get_image_pict_name($news->image));
             }
             $news->delete();
             Message::set(Message::SUCCESS, 'Новость "' . $title . '" удалена');
             $this->request->redirect('cabinet/news');
         }
     }
     $this->view = View::factory('frontend/cabinet/delete')->set('url', 'cabinet/news/delete/' . $news->id)->set('text', 'Вы действительно хотите удалить новость ' . $news->title);
     $this->template->title = $this->site_name . 'Удаление новости';
     $this->template->bc['#'] = 'Удаление новости';
     $this->template->content = $this->view;
 }
Ejemplo n.º 2
0
        <?php 
    foreach ($news->order_by('date_create', 'DESC')->find_all() as $n) {
        ?>
            <li>
                <div class="title"><?php 
        echo HTML::anchor('news/' . $n->id, $n->service->name);
        ?>
</div>
                <div class="date"><?php 
        echo MyDate::show($n->date_create);
        ?>
</div>
                <div class="text">
                    <?php 
        if ($n->image and file_exists($n->image)) {
            echo HTML::image(MyHelper::get_image_pict_name($n->image), array('align' => 'left', 'style' => 'margin-top: 4px; margin-right: 6px;'));
        }
        ?>
                    <?php 
        echo Text::limit_words(strip_tags($n->text), 70);
        ?>
                </div>
                <div class="more"><?php 
        echo HTML::anchor('news/' . $n->id, 'Подробнее');
        ?>
</div>
            </li>
        <?php 
    }
    ?>
    </ul>