Esempio n. 1
0
 /**
  * Constructor.
  *
  * Creates a new wizard instance.
  *
  * @param  string  $root  Base directory to load the views from.
  * @param  string  $uri   Base uri of the wizard.
  */
 public function __construct($root, $uri = null)
 {
     // Auto-detect wizard uri, if none is given
     if (is_null($uri)) {
         $this->uriFromPath();
     } else {
         $this->uri($uri);
     }
     // Initialize wizard
     $this->queue = array();
     parent::__construct($root . DS . 'index.php');
 }
Esempio n. 2
0
 /**
  * A wizard callback used to install the custom field.
  *
  * @param   View   $view  Submitted view
  * @param   array  $form  Form data
  *
  * @return  boolean
  */
 public function installField($view, $form)
 {
     $path = kirby()->roots()->fields() . DS . 'comments';
     $target = new Folder($path);
     if ($target->exists()) {
         $view->errors(array('field' => 'A field with the same name already exists.'));
         return false;
     }
     $path = $this->hub()->finder()->resources() . DS . 'fields' . DS . 'comments';
     $source = new Folder($path);
     if (!$source->copy($target->root())) {
         $view->errors(array('field' => 'Could not copy custom field to target directory. Is the `site` folder writeable?'));
         return false;
     }
     return $this->redirect('home');
 }