function reorder()
 {
     parse_str($_POST['data']);
     foreach ($snippets as $position => $snippet_id) {
         $snippet = Snippet::findById($snippet_id);
         $snippet->position = (int) $position + 1;
         $snippet->save();
     }
 }
Exemple #2
0
 /**
  * Saves the edited Snippet.
  *
  * @todo Merge _edit() and edit()
  *
  * @param string $id Snippet id.
  */
 public function edit($id)
 {
     // check if user have already enter something
     $snippet = Flash::get('post_data');
     if (empty($snippet)) {
         $snippet = Snippet::findById($id);
         if (!$snippet) {
             Flash::set('error', __('Snippet not found!'));
             redirect(get_url('snippet'));
         }
     }
     // check if trying to save
     if (get_request_method() == 'POST') {
         $this->_edit($id);
     }
     $this->display('snippet/edit', array('action' => 'edit', 'csrf_token' => SecureToken::generateToken(BASE_URL . 'snippet/edit'), 'filters' => Filter::findAll(), 'snippet' => $snippet));
 }
Exemple #3
0
 public function edit($id)
 {
     if (!($snippet = Snippet::findById($id))) {
         Flash::set('error', __('Snippet not found!'));
         redirect(get_url('snippet'));
     }
     // check if trying to save
     if (get_request_method() == 'POST') {
         return $this->_edit($id);
     }
     $this->display('snippet/edit', array('action' => 'edit', 'filters' => Filter::findAll(), 'snippet' => $snippet));
 }