本文整理汇总了PHP中static::items方法的典型用法代码示例。如果您正苦于以下问题:PHP static::items方法的具体用法?PHP static::items怎么用?PHP static::items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::items方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createCollection
/**
* Creates collection of items.
*
* Override it if you need to implement
* derived collection that requires specific initialization.
*
* @param array $items
*
* @return static
*/
protected function createCollection(array $items)
{
$collection = new static();
$itemsRef =& $collection->items();
$itemsRef = $items;
return $collection;
}
示例2: load
/**
* Loads a config file or array.
*
* @param mixed $file string file | config array
* @param mixed $group null for no group, true for group is filename, false for not storing in the master config
* @return array the (loaded) config array
*/
public static function load($file, $group = null)
{
$config = array();
if (is_array($file)) {
$config = $file;
} elseif (is_string($file)) {
$info = pathinfo($file);
$type = 'json';
if (isset($info['extension'])) {
$type = $info['extension'];
}
$loadMethod = 'read' . ucfirst($type);
if (method_exists(get_called_class(), $loadMethod)) {
$config = static::$loadMethod($file);
} else {
throw new \Exception(sprintf('Invalid config type "%s".', $type));
}
} else {
throw new \Exception('Invalid config specified.');
}
if ($group === null) {
static::$items = array_merge(static::$items, $config);
} else {
if (!isset(static::$items[$group])) {
static::$items[$group] = array();
}
static::$items[$group] = array_merge(static::$items[$group], $config);
}
return $config;
}
示例3: load
public static function load($file, $group = null, $reload = false)
{
if (!is_array($file) && array_key_exists($file, static::$loaded_files) and !$reload) {
return false;
}
$config = array();
if (is_array($file)) {
$config = $file;
} elseif ($paths = \Fuel::find_file('config', $file, '.php', true)) {
// Reverse the file list so that we load the core configs first and
// the app can override anything.
$paths = array_reverse($paths);
foreach ($paths as $path) {
$config = \Fuel::load($path) + $config;
}
}
if ($group === null) {
static::$items = $reload ? $config : static::$items + $config;
} else {
$group = $group === true ? $file : $group;
if (!isset(static::$items[$group]) or $reload) {
static::$items[$group] = array();
}
static::$items[$group] = static::$items[$group] + $config;
}
if (!is_array($file)) {
static::$loaded_files[$file] = true;
}
return $config;
}
示例4: load
public static function load($file)
{
if (file_exists($file) === false) {
return false;
}
static::$items = array_merge(static::$items, require $file);
return true;
}
示例5: load
public static function load()
{
if (file_exists(PATH . 'config.php') === false) {
return false;
}
static::$items = (require PATH . 'config.php');
return true;
}
示例6: menuitems
/**
* Returns an array of menu items grouped by menu.
*
* @param array $config An array of configuration options.
*
* @return array
*
* @since 1.6
*/
public static function menuitems($config = array())
{
if (empty(static::$items)) {
$menus = static::menus();
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('a.id AS value, a.title AS text, a.level, a.menutype')->from('#__menu AS a')->where('a.parent_id > 0')->where('a.client_id = 0');
// Filter on the published state
if (isset($config['published'])) {
if (is_numeric($config['published'])) {
$query->where('a.published = ' . (int) $config['published']);
} elseif ($config['published'] === '') {
$query->where('a.published IN (0,1)');
}
}
$query->order('a.lft');
$db->setQuery($query);
$items = $db->loadObjectList();
// Collate menu items based on menutype
$lookup = array();
foreach ($items as &$item) {
if (!isset($lookup[$item->menutype])) {
$lookup[$item->menutype] = array();
}
$lookup[$item->menutype][] =& $item;
$item->text = str_repeat('- ', $item->level) . $item->text;
}
static::$items = array();
$user = JFactory::getUser();
$aclcheck = !empty($config['checkacl']) ? (int) $config['checkacl'] : 0;
foreach ($menus as &$menu) {
if ($aclcheck) {
$action = $aclcheck == $menu->id ? 'edit' : 'create';
if (!$user->authorise('core.' . $action, 'com_menus.menu.' . $menu->id)) {
continue;
}
}
// Start group:
$optGroup = new stdClass();
$optGroup->value = '<OPTGROUP>';
$optGroup->text = $menu->text;
static::$items[] = $optGroup;
// Special "Add to this Menu" option:
static::$items[] = JHtml::_('select.option', $menu->value . '.1', JText::_('JLIB_HTML_ADD_TO_THIS_MENU'));
// Menu items:
if (isset($lookup[$menu->value])) {
foreach ($lookup[$menu->value] as &$item) {
static::$items[] = JHtml::_('select.option', $menu->value . '.' . $item->value, $item->text);
}
}
// Finish group:
$closeOptGroup = new stdClass();
$closeOptGroup->value = '</OPTGROUP>';
$closeOptGroup->text = $menu->text;
static::$items[] = $closeOptGroup;
}
}
return static::$items;
}
示例7: load
/**
* Loads a config file.
*
* @param mixed $file string file | config array | Config_Interface instance
* @param mixed $group null for no group, true for group is filename, false for not storing in the master config
* @param bool $reload true to force a reload even if the file is already loaded
* @param bool $overwrite true for array_merge, false for \Arr::merge
* @return array the (loaded) config array
*/
public static function load($file, $group = null, $reload = false, $overwrite = false)
{
if (!$reload and !is_array($file) and !is_object($file) and array_key_exists($file, static::$loaded_files)) {
$group === true and $group = $file;
if ($group === null or $group === false or !isset(static::$items[$group])) {
return false;
}
return static::$items[$group];
}
$config = array();
if (is_array($file)) {
$config = $file;
} elseif (is_string($file)) {
$info = pathinfo($file);
$type = 'php';
if (isset($info['extension'])) {
$type = $info['extension'];
// Keep extension when it's an absolute path, because the finder won't add it
if ($file[0] !== '/' and $file[1] !== ':') {
$file = substr($file, 0, -(strlen($type) + 1));
}
}
$class = '\\Config_' . ucfirst($type);
if (class_exists($class)) {
static::$loaded_files[$file] = true;
$file = new $class($file);
} else {
throw new \FuelException(sprintf('Invalid config type "%s".', $type));
}
}
if ($file instanceof Config_Interface) {
try {
$config = $file->load($overwrite, !$reload);
} catch (\ConfigException $e) {
$config = array();
}
$group = $group === true ? $file->group() : $group;
}
if ($group === null) {
static::$items = $reload ? $config : ($overwrite ? array_merge(static::$items, $config) : \Arr::merge(static::$items, $config));
static::$itemcache = array();
} else {
$group = $group === true ? $file : $group;
if (!isset(static::$items[$group]) or $reload) {
static::$items[$group] = array();
}
static::$items[$group] = $overwrite ? array_merge(static::$items[$group], $config) : \Arr::merge(static::$items[$group], $config);
$group .= '.';
foreach (static::$itemcache as $key => $value) {
if (strpos($key, $group) === 0) {
unset(static::$itemcache[$key]);
}
}
}
return $config;
}
示例8: loadFile
/**
* Load a complete config file to merge with the config class's items.
* Only support for php files that return an array:
* <code>
* <?php
* return array(
* 'key' = 'item',
* 'key2' = [
* 'key' => 'item'
* ]
* );
* </code>
*
* @param $file
* @throws \InvalidArgumentException
* @throws \Exception
* @static
* @access public
* @return void
*/
public static function loadFile($file)
{
if (Helpers::fileExists($file) === false) {
throw new \InvalidArgumentException(sprintf('File [%s] is not found or readable.', $file));
}
if (strtolower(pathinfo($file)['extension']) == 'php') {
$data = (require_once $file);
if (is_array($data) == false && $data instanceof \Travsersable == false) {
throw new \Exception('Supplied file for loading should return an array.');
}
}
static::$items = array_merge(static::$items, $data);
}
示例9: newKuesioner
public static function newKuesioner($data)
{
$k = new static();
$k->title = $data['title'];
$k->user_id = auth()->user()->id;
$k->gelombang_id = Gelombang::getActive()->id;
$k->save();
$i = 1;
foreach ($data['pertanyaan'] as $q) {
$p = new KuesionerItem();
$p->label = $q;
$p->type = 'input';
$p->priority = $i;
$k->items()->save($p);
$i++;
}
}
示例10: existing
/**
* Get a list of the available content language items.
*
* @param boolean $all True to include All (*)
* @param boolean $translate True to translate All
*
* @return string
*
* @see JFormFieldContentLanguage
* @since 1.6
*/
public static function existing($all = false, $translate = false)
{
if (empty(static::$items)) {
// Get the database object and a new query object.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Build the query.
$query->select('a.lang_code AS value, a.title AS text, a.title_native')->from('#__languages AS a')->where('a.published >= 0')->order('a.title');
// Set the query and load the options.
$db->setQuery($query);
static::$items = $db->loadObjectList();
if ($all) {
array_unshift(static::$items, new JObject(array('value' => '*', 'text' => $translate ? JText::alt('JALL', 'language') : 'JALL_LANGUAGE')));
}
}
return static::$items;
}
示例11: menuitems
/**
* Returns an array of menu items grouped by menu.
*
* @param array $config An array of configuration options.
*
* @return array
*
* @since 1.6
*/
public static function menuitems($config = array())
{
if (empty(static::$items)) {
$menus = static::menus();
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('a.id AS value, a.title AS text, a.level, a.menutype')->from('#__menu AS a')->where('a.parent_id > 0')->where('a.client_id = 0');
// Filter on the published state
if (isset($config['published'])) {
if (is_numeric($config['published'])) {
$query->where('a.published = ' . (int) $config['published']);
} elseif ($config['published'] === '') {
$query->where('a.published IN (0,1)');
}
}
$query->order('a.lft');
$db->setQuery($query);
$items = $db->loadObjectList();
// Collate menu items based on menutype
$lookup = array();
foreach ($items as &$item) {
if (!isset($lookup[$item->menutype])) {
$lookup[$item->menutype] = array();
}
$lookup[$item->menutype][] =& $item;
$item->text = str_repeat('- ', $item->level) . $item->text;
}
static::$items = array();
foreach ($menus as &$menu) {
// Start group:
static::$items[] = JHtml::_('select.optgroup', $menu->text);
// Special "Add to this Menu" option:
static::$items[] = JHtml::_('select.option', $menu->value . '.1', JText::_('JLIB_HTML_ADD_TO_THIS_MENU'));
// Menu items:
if (isset($lookup[$menu->value])) {
foreach ($lookup[$menu->value] as &$item) {
static::$items[] = JHtml::_('select.option', $menu->value . '.' . $item->value, $item->text);
}
}
// Finish group:
static::$items[] = JHtml::_('select.optgroup', $menu->text);
}
}
return static::$items;
}
示例12: load
/**
* Loads a config file.
*
* @param mixed $file string file | config array | Config_Interface instance
* @param mixed $group null for no group, true for group is filename, false for not storing in the master config
* @param bool $overwrite true for array_merge, false for \Arr::merge
* @return array the (loaded) config array
*/
public static function load($file, $group = null, $reload = false, $overwrite = false)
{
if (!$reload and !is_array($file) and !is_object($file) and array_key_exists($file, static::$loaded_files)) {
return false;
}
$config = array();
if (is_array($file)) {
$config = $file;
} elseif (is_string($file)) {
$info = pathinfo($file);
$type = isset($info['extension']) ? $info['extension'] : 'php';
$file = $info['filename'];
$class = '\\Config_' . ucfirst($type);
if (class_exists($class)) {
static::$loaded_files[$file] = true;
$file = new $class($file);
} else {
throw new \FuelException(sprintf('Invalid config type "%s".', $type));
}
}
if ($file instanceof Config_Interface) {
try {
$config = $file->load($overwrite);
} catch (\ConfigException $e) {
$config = array();
}
$group = $group === true ? $file->group() : $group;
}
if ($group === null) {
static::$items = $reload ? $config : ($overwrite ? array_merge(static::$items, $config) : \Arr::merge(static::$items, $config));
} else {
$group = $group === true ? $file : $group;
if (!isset(static::$items[$group]) or $reload) {
static::$items[$group] = array();
}
static::$items[$group] = $overwrite ? array_merge(static::$items[$group], $config) : \Arr::merge(static::$items[$group], $config);
}
return $config;
}
示例13: refresh
public function refresh()
{
static::$items = [];
static::$assignments = [];
}
示例14: removeAll
public function removeAll()
{
static::$items = static::$roles = static::$permissions = null;
$this->saveToFile([], $this->path);
return true;
}
示例15: load
/**
* @param $filepath Charge le fichier de configuration spécifié et définit $items
*/
public static function load($filepath)
{
static::$items = (include ROOT . '/app/config/' . $filepath . '.config.php');
}