Esempio n. 1
0
 public function __construct(Grav $grav, GravConfig $config, $name)
 {
     parent::__construct($grav, $config, $name);
     // $this->init();
     $baseUrlRelative = $grav['base_url_relative'];
     $this->name = $name;
     $this->path = THEMES_DIR . $name;
     $this->url = $baseUrlRelative . '/' . USER_PATH . basename(THEMES_DIR) . '/' . $this->name;
 }
 /**
  * Handle deleting a file from a blueprint
  *
  * @return bool True if the action was performed.
  */
 protected function taskRemoveFileFromBlueprint()
 {
     $uri = $this->grav['uri'];
     $this->taskRemoveMedia();
     $field = $uri->param('field');
     $blueprint = $uri->param('blueprint');
     $this->grav['config']->set($blueprint . '.' . $field, '');
     if (substr($blueprint, 0, 7) == 'plugins') {
         Plugin::saveConfig(substr($blueprint, 8));
     }
     if (substr($blueprint, 0, 6) == 'themes') {
         Theme::saveConfig(substr($blueprint, 7));
     }
     $redirect = base64_decode($uri->param('redirect'));
     $route = $this->grav['config']->get('plugins.admin.route');
     if (substr($redirect, 0, strlen($route)) == $route) {
         $redirect = substr($redirect, strlen($route) + 1);
     }
     $this->post = array('_redirect' => $redirect);
     return true;
 }
Esempio n. 3
0
 /**
  * Handle deleting a file from a blueprint
  *
  * @return bool True if the action was performed.
  */
 protected function taskRemoveFileFromBlueprint()
 {
     $uri = $this->grav['uri'];
     $blueprint = base64_decode($uri->param('blueprint'));
     $path = base64_decode($uri->param('path'));
     $proute = base64_decode($uri->param('proute'));
     $type = $uri->param('type');
     $field = $uri->param('field');
     $this->taskRemoveMedia();
     if ($type == 'pages') {
         $page = $this->admin->page(true, $proute);
         $keys = explode('.', preg_replace('/^header./', '', $field));
         $header = (array) $page->header();
         $data_path = implode('.', $keys);
         $data = Utils::getDotNotation($header, $data_path);
         if (isset($data[$path])) {
             unset($data[$path]);
             Utils::setDotNotation($header, $data_path, $data);
             $page->header($header);
         }
         $page->save();
     } else {
         $blueprint_prefix = $type == 'config' ? '' : $type . '.';
         $blueprint_name = str_replace('/blueprints', '', str_replace('config/', '', $blueprint));
         $blueprint_field = $blueprint_prefix . $blueprint_name . '.' . $field;
         $files = $this->grav['config']->get($blueprint_field);
         foreach ($files as $key => $value) {
             if ($key == $path) {
                 unset($files[$key]);
             }
         }
         $this->grav['config']->set($blueprint_field, $files);
         switch ($type) {
             case 'config':
                 $data = $this->grav['config']->get($blueprint_name);
                 $config = $this->admin->data($blueprint, $data);
                 $config->save();
                 break;
             case 'themes':
                 Theme::saveConfig($blueprint_name);
                 break;
             case 'plugins':
                 Plugin::saveConfig($blueprint_name);
                 break;
         }
     }
     $this->admin->json_response = ['status' => 'success', 'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_SUCCESSFUL')];
     return true;
 }