コード例 #1
0
 public function post_populate_tags($what)
 {
     if (Input::has('id')) {
         $id = Input::get('id');
         $tags = CmsBlog::find($id)->tags;
         $data = array();
         foreach ($tags as $tag) {
             $json = array();
             $json['value'] = $tag->id;
             $json['name'] = $tag->name;
             $data[] = $json;
         }
         header("Content-type: application/json");
         return json_encode($data);
     }
     return false;
 }
コード例 #2
0
 public function post_delete()
 {
     if (Input::has('blog_id')) {
         $bid = Input::get('blog_id');
         $blog = CmsBlog::find($bid);
         //CHECK IF BLOG EXISTS
         if (!empty($blog)) {
             //OK, DELETE
             $blog->pages()->delete();
             $blog->delete();
             Notification::success(LL('cms::alert.delete_blog_success', CMSLANG, array('blog' => $blog->name)), 2500);
             return Redirect::to_action('cms::blog', array($blog->lang));
         } else {
             Notification::error(LL('cms::alert.delete_blog_error', CMSLANG), 2500);
             return Redirect::to_action('cms::blog', array(LANG));
         }
     } else {
         Notification::error(LL('cms::alert.delete_blog_error', CMSLANG), 2500);
         return Redirect::to_action('cms::blog', array(LANG));
     }
 }
コード例 #3
0
 public function post_save_tags()
 {
     $auth = Auth::check();
     if ($auth and is_numeric(AUTHORID)) {
         $input = Input::get();
         //GRAB DATA
         $blog = new CmsBlog();
         if (!empty($input['blog_id'])) {
             $blog = CmsBlog::find($input['blog_id']);
             //CHECK OWNERSHIP
             if (CmsRole::role_fail($input['page_id'])) {
                 $msg = array('noaccess' => LL('cms::ajax_resp.ownership_error', CMSLANG)->get());
                 return json_encode($msg);
             }
         }
         $bid = Input::get('blog_id');
         $pid = Input::get('page_id');
         if (Input::get('as_values_tags_id') !== '') {
             $tags = substr(Input::get('as_values_tags_id'), 0, -1);
             if (substr($tags, 0, 1) == ',') {
                 $tags = substr($tags, 1);
             }
             $rels = explode(',', $tags);
             if (is_array($rels)) {
                 $blog->tags()->sync($rels);
             }
             $response = 'success';
             $msg = LL('cms::ajax_resp.blog_tags_success', CMSLANG)->get();
             $backurl = $input['back_url'];
         } else {
             $response = 'success';
             $msg = LL('cms::ajax_resp.blog_tags_success', CMSLANG)->get();
             $backurl = $input['back_url'];
         }
     } else {
         $bid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.blog_tags_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'blog_id', 'id' => $bid, 'pageid' => $pid, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }