move() public static method

Move a page
public static move ( integer $id, integer $droppedOn, string $typeOfDrop, string $tree, string $language = null ) : boolean
$id integer The id for the page that has to be moved.
$droppedOn integer The id for the page where to page has been dropped on.
$typeOfDrop string The type of drop, possible values are: before, after, inside.
$tree string The tree the item is dropped on, possible values are: main, meta, footer, root.
$language string The language to use, if not provided we will use the working language.
return boolean
Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent
     parent::execute();
     // get parameters
     $id = \SpoonFilter::getPostValue('id', null, 0, 'int');
     $droppedOn = \SpoonFilter::getPostValue('dropped_on', null, -1, 'int');
     $typeOfDrop = \SpoonFilter::getPostValue('type', null, '');
     $tree = \SpoonFilter::getPostValue('tree', array('main', 'meta', 'footer', 'root'), '');
     // init validation
     $errors = array();
     // validate
     if ($id === 0) {
         $errors[] = 'no id provided';
     }
     if ($droppedOn === -1) {
         $errors[] = 'no dropped_on provided';
     }
     if ($typeOfDrop == '') {
         $errors[] = 'no type provided';
     }
     if ($tree == '') {
         $errors[] = 'no tree provided';
     }
     // got errors
     if (!empty($errors)) {
         $this->output(self::BAD_REQUEST, array('errors' => $errors), 'not all fields were filled');
     } else {
         // get page
         $success = BackendPagesModel::move($id, $droppedOn, $typeOfDrop, $tree);
         // build cache
         BackendPagesModel::buildCache(BL::getWorkingLanguage());
         // output
         if ($success) {
             $this->output(self::OK, BackendPagesModel::get($id), 'page moved');
         } else {
             $this->output(self::ERROR, null, 'page not moved');
         }
     }
 }