예제 #1
0
 /**
  * Show the header section of the page
  *
  * Shows a stub page and the bookmark form.
  *
  * @return void
  */
 function showHeader()
 {
     $this->elementStart('div', array('id' => 'header'));
     $this->elementStart('address');
     $this->element('a', array('class' => 'url', 'href' => common_local_url('public')), '');
     $this->elementEnd('address');
     if (common_logged_in()) {
         $form = new BookmarkForm($this, $this->title, $this->url);
         $form->show();
     }
     $this->elementEnd('div');
 }
예제 #2
0
 /**
  * Handler method
  *
  * @param array $args is ignored since it's now passed in in prepare()
  *
  * @return void
  */
 function handle($args = null)
 {
     $this->startHTML('text/xml;charset=utf-8');
     $this->elementStart('head');
     $this->element('title', null, _('Bookmark form'));
     $this->elementEnd('head');
     $this->elementStart('body');
     $bf = new BookmarkForm($this, $this->title, $this->url, null, null, $this->thumbnail);
     $bf->show();
     $this->elementEnd('body');
     $this->elementEnd('html');
 }
예제 #3
0
 public function actionUpdatebookmark($id)
 {
     $app = Yii::app();
     if ($app->user->isGuest) {
         $header = 'Доступно после регистрации';
         $this->render('bookmark-form-guest', array('app' => $app, 'header' => $header));
     } else {
         $modelBookmark = Bookmarks::model()->findByPk($id);
         if ($modelBookmark === null) {
             throw new CHttpException(404, 'Ошибка загрузки раздела');
         }
         if ($modelBookmark->user_id != $app->user->id) {
             throw new CHttpException(401, 'Ошибка доступа');
         }
         if (isset($_POST['delete'])) {
             $modelBookmark->delete();
             Yii::app()->user->setFlash('success', 'Закладка удалена');
             if ($modelBookmark->section_id == 0) {
                 $return_arr = array('my/index');
             } else {
                 $return_arr = array('my/section', 'id' => $modelBookmark->section_id);
             }
             $app->cache->delete(Bookmarks::CACHE_BOOKMARKS_LIST . $modelBookmark->section_id . $app->user->id);
             return $this->redirect($return_arr);
         }
         $model = new BookmarkForm();
         $model->attributes = $modelBookmark->attributes;
         $header = 'Редактирование закладки';
         if ($model->section_id == 0) {
             $cancel_url = $this->createUrl('my/index');
         } else {
             $cancel_url = $this->createUrl('my/section', array('id' => $model->section_id));
         }
         $icons_list = Bookmarks::model()->getBookMarkIconsList();
         if (isset($_POST['BookmarkForm'])) {
             $model->attributes = $_POST['BookmarkForm'];
             if ($model->validate()) {
                 $modelBookmark->attributes = $model->attributes;
                 $modelBookmark->save();
                 Yii::app()->user->setFlash('success', 'Сохранено');
                 if ($modelBookmark->section_id == 0) {
                     $return_arr = array('my/index');
                 } else {
                     $return_arr = array('my/section', 'id' => $modelBookmark->section_id);
                 }
                 return $this->redirect($return_arr);
             }
             //echo'<pre>';print_r($model);echo'</pre>';die;
         }
         $this->render('bookmark-form-update', array('app' => $app, 'model' => $model, 'header' => $header, 'cancel_url' => $cancel_url, 'icons_list' => $icons_list));
     }
 }
예제 #4
0
 /**
  * Show the bookmark form
  *
  * @return void
  */
 function showContent()
 {
     if (!empty($this->error)) {
         $this->element('p', 'error', $this->error);
     }
     $form = new BookmarkForm($this, $this->title, $this->url, $this->tags, $this->description);
     $form->show();
     return;
 }