public function info() { if (!is_null($this->info)) { return $this->info; } return $this->info = new Obj(data::read($this->root . DS . 'package.json')); }
protected function form($user = null) { $mode = $user ? 'edit' : 'add'; $fields = data::read(panel()->roots()->forms() . DS . 'user.' . $mode . '.php', 'yaml'); $content = $user ? $user->data() : array(); // add all languages $fields['language']['options'] = array(); $fields['language']['default'] = kirby()->option('panel.language', 'en'); foreach (panel()->languages() as $code => $lang) { $fields['language']['options'][$code] = $lang->title(); } // add all roles $fields['role']['options'] = array(); $fields['role']['default'] = site()->roles()->findDefault()->id(); foreach (site()->roles() as $role) { $fields['role']['options'][$role->id()] = $role->name(); } // make the role selector readonly when the user is not an admin if (!site()->user()->isAdmin()) { $fields['role']['readonly'] = true; } // make sure the password is never shown in the form unset($content['password']); return new Form($fields, $content); }
public function load($name) { // make sure there's no path included in the name $name = basename(strtolower($name)); if (isset(static::$cache[$name])) { $this->file = static::$cache[$name]['file']; $this->name = static::$cache[$name]['name']; $this->yaml = static::$cache[$name]['yaml']; return true; } // find the matching blueprint file $file = kirby()->get('blueprint', $name); if ($file) { $this->file = $file; $this->name = $name; $this->yaml = data::read($this->file, 'yaml'); // remove the broken first line unset($this->yaml[0]); static::$cache[$name] = array('file' => $this->file, 'name' => $this->name, 'yaml' => $this->yaml); return true; } else { if ($name == 'default') { throw new Exception(l('blueprints.error.default.missing')); } else { return $this->load('default'); } } }
public function _extend($params) { $extends = $params['extends']; $snippet = f::resolve(kirby()->roots()->blueprints() . DS . 'fields' . DS . $extends, array('yml', 'php', 'yaml')); if (empty($snippet)) { throw new Exception(l('fields.error.extended')); } $yaml = data::read($snippet, 'yaml'); $params = a::merge($yaml, $params); return $params; }
public function _extend($params) { $extends = $params['extends']; $files = glob(kirby()->roots()->blueprints() . DS . 'fields' . DS . $extends . '.{yml,yaml,php}', GLOB_BRACE); if (empty($files)) { throw new Exception(l('fields.error.extended')); } $yaml = data::read($files[0], 'yaml'); $params = a::merge($yaml, $params); return $params; }
public function _extend($params) { $extends = $params['extends']; $file = kirby()->get('blueprint', 'fields/' . $extends); if (empty($file) || !is_file($file)) { throw new Exception(l('fields.error.extended')); } $yaml = data::read($file, 'yaml'); $params = a::merge($yaml, $params); return $params; }
public function __construct($name) { $this->name = $name; $this->file = static::$root . DS . $name . '.php'; $this->yaml = data::read($this->file, 'yaml'); // remove the broken first line unset($this->yaml[0]); $this->title = a::get($this->yaml, 'title', 'Page'); $this->preview = a::get($this->yaml, 'preview', 'page'); $this->deletable = a::get($this->yaml, 'deletable', true); $this->pages = new Blueprint\Pages(a::get($this->yaml, 'pages', true)); $this->files = new Blueprint\Files(a::get($this->yaml, 'files', true)); }
public function load() { // get the user role and load the // correspondant blueprint if available $this->name = basename(strtolower($this->user->role())); // try to find a user blueprint $file = f::resolve(static::$root . DS . $this->name, array('yml', 'php', 'yaml')); if ($file) { $this->file = $file; $this->yaml = data::read($this->file, 'yaml'); // remove the broken first line unset($this->yaml[0]); } }
public function load() { // get the user role and load the // correspondant blueprint if available $this->name = basename(strtolower($this->user->role())); // try to find a user blueprint $files = glob(static::$root . DS . $this->name . '.{php,yaml,yml}', GLOB_BRACE); if (!empty($files)) { $this->file = $files[0]; $this->yaml = data::read($this->file, 'yaml'); // remove the broken first line unset($this->yaml[0]); } }
protected function form($user = null) { $mode = $user ? 'edit' : 'add'; $fields = data::read(root('panel.app') . DS . 'forms' . DS . 'user.' . $mode . '.php', 'yaml'); $content = $user ? $user->data() : array(); // add all languages $fields['language']['options'] = array(); $fields['language']['default'] = c::get('panel.language', 'en'); foreach (app::languages() as $code => $lang) { $fields['language']['options'][$code] = $lang->title(); } // make sure the password is never shown in the form unset($content['password']); return new Form($fields, $content); }
/** * get all data for the user */ public function data() { if (!is_null($this->data)) { return $this->data; } // get all data from the account file $this->data = data::read($this->file(), 'yaml'); // make sure all keys are lowercase $this->data = array_change_key_case($this->data, CASE_LOWER); // remove garbage unset($this->data[0]); // add the username $this->data['username'] = $this->username; // return the data array return $this->data; }
public function __construct($page, $file) { $data = data::read($file); if (!is_array($data) or empty($data)) { throw new Exception('Invalid web mention'); } if (empty($data['url'])) { throw new Exception('No url found'); } $this->data = $data; $this->page = $page; $this->file = $file; $this->author = new Author($this); $this->id = sha1($file); $this->convertTwitterFavorite(); $this->convertTwitterRepost(); $this->field('title', 'name'); $this->field('text'); $this->field('url'); $this->field('type'); $this->field('rsvp'); $this->date = new Field($this->page, 'date', strtotime($data['published'])); }
/** * Read the plugin package file and * return the info as array */ protected function info() { $this->info = data::read($this->tmp . '/package.json'); // get the extension type if (!isset($this->info['type'])) { throw new RuntimeException('Invalid Kirby Plugin Type'); } // check for a valid type if (!in_array($this->type(), ['plugin', 'field', 'tag'])) { throw new RuntimeException('Invalid Kirby Plugin Type: "' . $this->type() . '"'); } if (!isset($this->info['name'])) { throw new RuntimeException('Invalid Kirby Plugin Name'); } $this->output->writeln(''); $this->output->writeln('<comment>Discovered a ' . $this->type() . ' with the name "' . $this->name() . '"</comment>'); $this->output->writeln(''); $this->output->writeln('<info>Description: ' . "\t" . $this->description() . '</info>'); $this->output->writeln('<info>Repository: ' . "\t" . $this->repo() . '</info>'); $this->output->writeln('<info>Version: ' . "\t" . $this->version() . '</info>'); $this->output->writeln('<info>Author: ' . "\t" . $this->author() . '</info>'); $this->output->writeln('<info>License: ' . "\t" . $this->license() . '</info>'); $this->output->writeln('<info></info>'); }
private function mergeFile($file) { $file_merge = static::$root . DS . $file . '.php'; if (file_exists($file_merge)) { // read yaml-data of passed file $yaml_merge = data::read($file_merge, 'yaml'); // remove the broken first line: unset($yaml_merge[0]); // merge $this->mergeData($yaml_merge); } }
public static function form($id, $data = array()) { $fields = data::read(root('panel.app') . DS . 'forms' . DS . $id . '.php', 'yaml'); return new Form($fields, $data); }
public function form($id, $data = array()) { $fields = data::read($this->roots->forms . DS . $id . '.php', 'yaml'); return new Form($fields, $data); }
/** * Returns all logdata in an array * * @return array */ protected function logdata() { if (!is_null($this->logdata)) { return $this->logdata; } else { $data = (array) data::read($this->logfile, 'json'); $login = $this; // remove old entries $data = array_filter($data, function ($entry) use($login) { return $entry['time'] > time() - $login->logexpiry; }); return $this->logdata = $data; } }
public function rebuild() { foreach ($this->folder()->children() as $year) { foreach ($year->children() as $month) { foreach ($month->children() as $day) { foreach ($day->children() as $item) { $data = data::read($item->root() . DS . 'item.yaml'); $item = new Item($this, $data['type'], $data); $item->store(); } } } } }