예제 #1
1
 /**
  * Handles the request to execute a task.
  *
  * Responsible for parsing the tasks to execute & also any config items that
  * should be passed to the tasks
  */
 public function action_execute()
 {
     if (empty($this->_task)) {
         return $this->action_help();
     }
     $task = $this->_retrieve_task();
     $defaults = $task->get_config_options();
     if (!empty($defaults)) {
         if (Arr::is_assoc($defaults)) {
             $options = array_keys($defaults);
             $options = call_user_func_array(array('CLI', 'options'), $options);
             $config = Arr::merge($defaults, $options);
         } else {
             // Old behavior
             $config = call_user_func_array(array('CLI', 'options'), $defaults);
         }
     } else {
         $config = array();
     }
     // Validate $config
     $validation = Validation::factory($config);
     $validation = $task->build_validation($validation);
     if (!$validation->check()) {
         echo View::factory('minion/error/validation')->set('errors', $validation->errors($task->get_errors_file()));
     } else {
         // Finally, run the task
         echo $task->execute($config);
     }
 }
예제 #2
0
 public function get(Model $from, array $conditions = array())
 {
     // Create the query on the model_through
     $query = call_user_func(array($this->model_to, 'query'));
     // set the model_from's keys as where conditions for the model_through
     $join = array('table' => array($this->table_through, 't0_through'), 'join_type' => null, 'join_on' => array(), 'columns' => $this->select_through('t0_through'));
     reset($this->key_from);
     foreach ($this->key_through_from as $key) {
         if ($from->{current($this->key_from)} === null) {
             return array();
         }
         $query->where('t0_through.' . $key, $from->{current($this->key_from)});
         next($this->key_from);
     }
     reset($this->key_to);
     foreach ($this->key_through_to as $key) {
         $join['join_on'][] = array('t0_through.' . $key, '=', 't0.' . current($this->key_to));
         next($this->key_to);
     }
     $conditions = \Arr::merge($this->conditions, $conditions);
     foreach (\Arr::get($conditions, 'where', array()) as $key => $condition) {
         is_array($condition) or $condition = array($key, '=', $condition);
         $query->where($condition);
     }
     foreach (\Arr::get($conditions, 'order_by', array()) as $field => $direction) {
         if (is_numeric($field)) {
             $query->order_by($direction);
         } else {
             $query->order_by($field, $direction);
         }
     }
     $query->_join($join);
     return $query->get();
 }
예제 #3
0
 public function get(Model $from, array $conditions = array())
 {
     $query = call_user_func(array($this->model_to, 'query'));
     reset($this->key_to);
     foreach ($this->key_from as $key) {
         // no point running a query when a key value is null
         if ($from->{$key} === null) {
             return array();
         }
         $query->where(current($this->key_to), $from->{$key});
         next($this->key_to);
     }
     $conditions = \Arr::merge($this->conditions, $conditions);
     foreach (\Arr::get($conditions, 'where', array()) as $key => $condition) {
         is_array($condition) or $condition = array($key, '=', $condition);
         $query->where($condition);
     }
     foreach (\Arr::get($conditions, 'order_by', array()) as $field => $direction) {
         if (is_numeric($field)) {
             $query->order_by($direction);
         } else {
             $query->order_by($field, $direction);
         }
     }
     return $query->get();
 }
예제 #4
0
 protected function resolve($item, $property)
 {
     $items = array();
     $arrowPos = strpos($property, '->');
     if ($arrowPos !== false) {
         $propertyMatch = mb_substr($property, 0, $arrowPos);
     } else {
         $propertyMatch = $property;
     }
     $match = $item->{$propertyMatch};
     if (empty($match)) {
         return array();
     }
     if ($arrowPos !== false) {
         if (is_array($match)) {
             foreach ($match as $matched) {
                 $items = \Arr::merge($items, $this->resolve($matched, mb_substr($property, $arrowPos + 2)));
             }
         } else {
             $items = \Arr::merge($items, $this->resolve($match, mb_substr($property, $arrowPos + 2)));
         }
     } else {
         if (is_array($match)) {
             $items = \Arr::merge($items, $match);
         } else {
             $items[] = $match;
         }
     }
     return $items;
 }
예제 #5
0
 /**
  * Return the query builder for this model
  * 
  * @return \Api\Rest_Query
  */
 protected function getQuery($params = array())
 {
     if (!$this->query) {
         $this->query = new Rest_Query($this->model, $this->plural, 'data', \Arr::merge($this->params, $params), $this->field);
     }
     return $this->query;
 }
예제 #6
0
 /**
  * @param array $data
  * @param null $id
  */
 public function __construct($data = array(), $id = NULL)
 {
     $klass = get_called_class();
     $meta = $klass::meta();
     $this->_options = Arr::merge($this->_options, Arr::get($meta, "options"));
     $this->__fields = Arr::get($meta, "fields");
     $this->__2m_fields = Arr::get($meta, "2m_fields", array());
     if ($this->__instance === NULL) {
         $this->__instance = Arr::get($this->_options, "model");
     }
     $this->__relations = $this->__load_relations();
     if ($data instanceof ORM) {
         $data = $data->as_array();
     }
     $columns = Arr::get($this->_options, "model")->list_columns();
     if ($id !== NULL) {
         $this->__instance = Arr::get($this->_options, "model")->where(Arr::get($this->_options, "model")->primary_key(), "=", $id)->find();
         $iterated = array();
         foreach ($this->__instance->as_array() as $key => $value) {
             $iterated[$key] = $value;
         }
         $data = Arr::merge($iterated, $data);
     }
     foreach ($columns as $column) {
         $name = $column["column_name"];
         $field = $this->__create_field($name, $column, $data);
         $field->theme(Arr::get($this->_options, "theme"));
         if (in_array($name, Arr::get($this->_options, "display_fields")) || empty($this->_options["display_fields"])) {
             if (!in_array($name, Arr::get($this->_options, "except_fields"))) {
                 $this->add_field($field);
             }
         }
     }
     $this->__load_2m($data);
 }
예제 #7
0
 public function action_index()
 {
     $username = $this->request->param('username');
     $this->view = new View_Message_Create();
     $this->view->username = $username;
     if ($this->request->method() == HTTP_Request::POST) {
         try {
             $post = $this->request->post();
             $receiver = ORM::factory('User')->where('username', '=', $post['receiver'])->find();
             if (!$receiver->loaded()) {
                 return Hint::error('Cannot find a user with the username: '******'You cannot send a message to yourself!');
             }
             $message_data = Arr::merge($this->request->post(), array('sender_id' => $this->user->id, 'receiver_id' => $receiver->id));
             $message = ORM::factory('Message')->create_message($message_data, array('receiver_id', 'subject', 'content', 'sender_id'));
             $message_data_sent = Arr::merge($this->request->post(), array('receiver_id' => $this->user->id, 'sender_id' => $receiver->id, 'sent' => 1, 'read' => 1));
             ORM::factory('Message')->create_message($message_data_sent, array('receiver_id', 'subject', 'content', 'sender_id', 'sent', 'read'));
             Hint::success('You have sent a message');
             $this->redirect(Route::get('message.inbox')->uri());
         } catch (ORM_Validation_Exception $e) {
             Hint::error($e->errors('models'));
         }
     }
 }
예제 #8
0
 public function load($group)
 {
     if (!count($this->_sources)) {
         throw new JsonApiApplication_Exception("No configuration sources attached");
     }
     if (empty($group)) {
         throw new JsonApiApplication_Exception("Need to specify a config group");
     }
     if (!is_string($group)) {
         throw new JsonApiApplication_Exception("Config group must be a string");
     }
     if (strpos($group, ".") !== FALSE) {
         list($group, $path) = explode(".", $group, 2);
     }
     if (isset($this->_groups[$group])) {
         if (isset($path)) {
             return Arr::path($this->_groups[$group], $path, NULL, ".");
         }
         return $this->_groups[$group];
     }
     $config = array();
     $sources = array_reverse($this->_sources);
     foreach ($sources as $source) {
         if ($source instanceof JsonApiApplication_Config_Reader) {
             if ($source_config = $source->load($group)) {
                 $config = Arr::merge($config, $source_config);
             }
         }
     }
     $this->_groups[$group] = new JsonApiApplication_Config_Group($this, $group, $config);
     if (isset($path)) {
         return Arr::path($config, $path, NULL, ".");
     }
     return $this->_groups[$group];
 }
예제 #9
0
파일: rss.php 프로젝트: MenZil-Team/cms
 /**
  * Create a feed from the given parameters
  *
  * @param   array   $info      Feed information
  * @param   array   $items     Items to add to the feed
  * @param   string  $encoding  Define which encoding to use [Optional]
  *
  * @return  string
  *
  * @throws  Feed_Exception
  *
  * @uses    Arr::merge
  * @uses    URL::is_absolute
  * @uses    URL::site
  */
 public function create(array $info, array $items, $encoding = NULL)
 {
     $generator = array('title' => Feed::NAME, 'link' => '', 'generator' => Feed::getGenerator());
     $info = Arr::merge($generator, $info);
     $feed = $this->prepareXML($encoding);
     foreach ($info as $name => $value) {
         if ($name === 'image') {
             // Create an image element
             $image = $feed->channel->addChild('image');
             if (!isset($value['link'], $value['url'], $value['title'])) {
                 throw new Feed_Exception('Feed images require a link, url, and title');
             }
             if (URL::is_absolute($value['url'])) {
                 // Convert URIs to URLs
                 $value['url'] = URL::site($value['url'], TRUE);
             }
             // Create the image elements
             $image->addChild('link', $value['link']);
             $image->addChild('url', $value['url']);
             $image->addChild('title', $value['title']);
         } else {
             if (($name === 'pubDate' or $name === 'lastBuildDate') and (is_int($value) or ctype_digit($value))) {
                 // Convert timestamps to RFC 822 formatted dates
                 $value = date('r', $value);
             } elseif (($name === 'link' or $name === 'docs') and URL::is_absolute($value)) {
                 // Convert URIs to URLs
                 $value = URL::site($value, TRUE);
             }
             // Add the info to the channel
             $feed->channel->addChild($name, $value);
         }
     }
     foreach ($items as $item) {
         // Add the item to the channel
         $row = $feed->channel->addChild('item');
         foreach ($item as $name => $value) {
             if ($name === 'pubDate' and (is_int($value) or ctype_digit($value))) {
                 // Convert timestamps to RFC 822 formatted dates
                 $value = date('r', $value);
             } elseif (($name === 'link' or $name === 'guid') and URL::is_absolute($value)) {
                 // Convert URIs to URLs
                 $value = URL::site($value, TRUE);
             }
             // Add the info to the row
             $row->addChild($name, $value);
         }
     }
     if (function_exists('dom_import_simplexml')) {
         // Convert the feed object to a DOM object
         $feed = dom_import_simplexml($feed)->ownerDocument;
         // DOM generates more readable XML
         $feed->formatOutput = TRUE;
         // Export the document as XML
         $feed = $feed->saveXML();
     } else {
         // Export the document as XML
         $feed = $feed->asXML();
     }
     return $feed;
 }
예제 #10
0
파일: digg.php 프로젝트: azuya/mmi-api
 /**
  * Verify the access token.
  *
  * @param	array	an associative array of auth settings
  * @return	OAuthToken
  * @link	http://digg.com/api/docs/1.0/detail/oauth.verify
  */
 public function verify_access_token()
 {
     // Configure the auth settings
     $auth_config = array();
     if ($this->is_valid_token(NULL, TRUE)) {
         $token = $this->_token;
         $auth_config = array('token_key' => $token->key, 'token_secret' => $token->secret);
     }
     $auth_config = Arr::merge($this->_auth_config, $auth_config);
     // Configure the HTTP method, URL, and request parameters
     $http_method = MMI_HTTP::METHOD_POST;
     $url = $this->_api_url;
     $parms = array('method' => 'oauth.verify');
     // Verify the request token
     $verified = 0;
     $response = $this->_auth_request($auth_config, $http_method, $url, $parms);
     if ($response instanceof MMI_Curl_Response) {
         $http_status_code = $response->http_status_code();
         if (intval($http_status_code) === 200) {
             $data = $this->_decode_xml($response->body(), TRUE);
             if (is_array($data)) {
                 $verified = intval(Arr::path($data, '@attributes.verified', 0));
             }
         }
     }
     unset($response);
     return $verified === 1;
 }
예제 #11
0
 /**
  * Create an OpAuth instance
  *
  * @param  array any call-time configuration to be used
  * @param  bool  whether or not Opauth should run automatically
  */
 public static function forge($config = array(), $autorun = true)
 {
     // deal with passing only the autorun value
     if (func_num_args() == 1 and is_bool($config)) {
         $autorun = $config;
         $config = array();
     }
     // merge the default config with the runtime config
     $config = \Arr::merge(\Config::get('opauth'), $config);
     // define the transport system we use
     $config['callback_transport'] = 'get';
     // make sure we have a remotes table
     if (!isset($config['table']) and ($config['table'] = static::$provider_table) === null) {
         throw new \OpauthException('No providers table configured. At the moment, only SimpleAuth and OrmAuth can be auto-detected.');
     }
     // and a security salt
     if (empty($config['security_salt'])) {
         throw new \OpauthException('There is no "security_salt" defined in the opauth.php configuration file.');
     }
     // set some defaults, just in case
     isset($config['security_iteration']) or $config['security_iteration'] = 300;
     isset($config['security_timeout']) or $config['security_timeout'] = '2 minutes';
     if (empty($config['path'])) {
         $parsed_url = parse_url(\Uri::base() . \Request::main()->uri->get());
         $path = explode('/', trim($parsed_url['path'], '/'));
         // construct the path if needed
         //			$path = \Request::main()->uri->get_segments();
         $params = count(\Request::active()->route->method_params);
         while ($params-- > 0) {
             array_pop($path);
         }
         $config['path'] = '/' . implode('/', $path) . '/';
     }
     // and construct the callback URL if needed
     if (empty($config['callback_url'])) {
         // pop the method name from the path
         $path = explode('/', trim($config['path'], '/'));
         array_pop($path);
         // and add 'callback' as the controller callback action
         $config['callback_url'] = '/' . implode('/', $path) . '/callback/';
     }
     // determine the name of the provider we want to call
     if (!$autorun) {
         // we're processing a callback
         $config['provider'] = 'Callback';
     } else {
         if (empty($config['provider'])) {
             $parsed_url = parse_url(\Uri::base() . \Request::main()->uri->get());
             $provider = explode('/', substr($parsed_url['path'], strlen($config['path'])));
             $config['provider'] = ucfirst($provider[0]);
         }
         // check if we have a strategy defined for this provider
         $strategies = \Config::get('opauth.Strategy', array());
         if (!array_key_exists(strtolower($config['provider']), array_change_key_case($strategies))) {
             throw new \OpauthException('Opauth strategy "' . $config['provider'] . '" is not supported');
         }
     }
     // return the created Auth_Opauth object
     return new static($config, $autorun);
 }
예제 #12
0
파일: install.php 프로젝트: ortodesign/cms
 protected function __construct()
 {
     $this->_installer = new Installer();
     $default = $this->_installer->default_params();
     $this->_options = Arr::merge($this->_options, $default);
     parent::__construct();
 }
예제 #13
0
 public function __construct($options)
 {
     if (!isset($options["choices"])) {
         throw new Kohana_Exception("You should define a list of a choices into a factory for Choice field");
     }
     $this->_options = Arr::merge($this->_options, $options);
 }
예제 #14
0
파일: types.php 프로젝트: ortodesign/cms
 public function get_options()
 {
     $uid = $this->param('uid', NULL, TRUE);
     $options = ORM::factory('email_type', (int) $uid)->data();
     $options = Arr::merge($options, Config::get('email', 'default_template_data', array()));
     $this->response($options);
 }
예제 #15
0
파일: google.php 프로젝트: azuya/mmi-api
 /**
  * Get a request token.
  *
  * @throws	Kohana_Exception
  * @param	string	the callback URL
  * @param	array	an associative array of auth settings
  * @return	OAuthToken
  */
 public function get_request_token($oauth_callback = NULL, $auth_config = array())
 {
     // Configure the auth settings
     if (!is_array($auth_config)) {
         $auth_config = array();
     }
     $auth_config = Arr::merge($this->_auth_config, $auth_config);
     // Configure the HTTP method and the URL
     $http_method = $this->_request_token_http_method;
     $url = $this->_request_token_url;
     $this->_ensure_parm('Request token URL', $url);
     // Configure the auth scope parameter
     $scope = Arr::get($auth_config, 'scope');
     $this->_ensure_parm('Authorization scope', $scope);
     $parms['scope'] = $scope;
     // Configure the OAuth callback URL
     if (!isset($oauth_callback)) {
         $oauth_callback = $this->auth_callback_url();
     }
     if (!empty($oauth_callback)) {
         $parms['oauth_callback'] = $oauth_callback;
     }
     // Make the request and extract the token
     $response = $this->_auth_request($auth_config, $http_method, $url, $parms);
     $token = NULL;
     if ($this->_validate_curl_response($response, 'Invalid request token')) {
         $token = $this->_extract_token($response);
     }
     return $token;
 }
예제 #16
0
파일: File.php 프로젝트: kodicms/core
 /**
  * 
  * @param string $name
  */
 public function __construct($name = '')
 {
     $this->_name = $name;
     if ($file = $this->find_file()) {
         $this->_path = pathinfo($file, PATHINFO_DIRNAME);
         $this->_file = $file;
         $this->name = pathinfo($file, PATHINFO_FILENAME);
     } else {
         $this->_path = pathinfo($this->name, PATHINFO_DIRNAME);
         if (empty($this->_path) or $this->_path == '.') {
             $this->_path = DOCROOT . $this->_folder;
             $this->_file = $this->_path . DIRECTORY_SEPARATOR . $this->name;
         } else {
             $this->_file = $this->name;
         }
         $this->name = pathinfo($this->name, PATHINFO_FILENAME);
     }
     if (strpos($this->_file, EXT) === FALSE) {
         $this->_file .= EXT;
     }
     $settings = FileSystem::load_merged_array($this->_folder, '.settings');
     if (isset($settings[$this->name]) and is_array($settings[$this->name])) {
         $this->_settings = Arr::merge($this->_settings, $settings[$this->name]);
     }
     if ($this->is_exists() and !Auth::has_permissions($this->get_roles())) {
         $this->set_read_only();
     }
 }
예제 #17
0
 /**
  * Supplier driver forge.
  *
  * @param	string			$supplier		Supplier id or friendly name
  * @param	array			$config				Config array
  * @return  Supplier instance
  */
 public static function forge($supplier, $config = array())
 {
     $model = Model_Supplier::query();
     if (is_int($supplier)) {
         $model = $model->where('id', $supplier)->get_one();
     } elseif (is_string($supplier)) {
         $model = $model->where('slug', $supplier)->get_one();
     } elseif ($supplier instanceof Model_Supplier) {
         $model = $supplier;
     } else {
         throw new SupplierException('Invalid Supplier!');
     }
     if (!$model instanceof Model_Supplier) {
         throw new SupplierException('Supplier ' . $supplier . ' not found');
     }
     if (\Arr::get($config, 'filter_disabled', false) === true and $model->enabled !== 1) {
         throw new SupplierException('This supplier (' . $model->name . ') has been disabled.');
     }
     if (isset($model->driver) and empty($model->driver)) {
         throw new SupplierException('This supplier (' . $model->name . ') has no driver to be used.');
     }
     $driver = ucfirst(strtolower(isset($model->driver) ? $model->driver : $model->slug));
     $class = 'Indigo\\Erp\\Stock\\Supplier_' . $driver;
     if (!class_exists($class, true)) {
         throw new \FuelException('Could not find Supplier driver: ' . $driver);
     }
     $config = \Arr::merge(static::$_defaults, \Config::get('supplier.drivers.' . strtolower($driver), array()), $config);
     $driver = new $class($model, $config);
     return $driver;
 }
예제 #18
0
파일: page.php 프로젝트: MenZil-Team/cms
 /**
  * Setting the display of pages
  *
  * @uses  Arr::merge
  * @uses  Config::load
  * @uses  Message::success
  */
 public function action_settings()
 {
     $this->title = __('Page Settings');
     $post = Config::load('page');
     $action = Route::get('admin/page')->uri(array('action' => 'settings'));
     $vocabs = array(__('none'));
     $view = View::factory('admin/page/settings')->set('vocabs', $vocabs)->set('post', $post)->set('action', $action);
     $vocabs = Arr::merge($vocabs, ORM::factory('term')->where('lft', '=', 1)->where('type', '=', 'page')->find_all()->as_array('id', 'name'));
     if ($this->valid_post('page_settings')) {
         unset($_POST['page_settings'], $_POST['_token'], $_POST['_action']);
         $cats = $post->get('category', array());
         foreach ($_POST as $key => $value) {
             if ($key == 'category') {
                 $terms = array_diff($cats, $value);
                 if ($terms) {
                     DB::delete('posts_terms')->where('parent_id', 'IN', array_values($terms))->execute();
                 }
             }
             $post->set($key, $value);
         }
         Log::info('Page Settings updated.');
         Message::success(__('Page Settings updated!'));
         $this->request->redirect(Route::get('admin/page')->uri(array('action' => 'settings')), 200);
     }
     $this->response->body($view);
 }
예제 #19
0
파일: form.php 프로젝트: refo/kohana
	/**
	 * Construct the form object
	 *
	 * @access public
	 * @param mixed $alias. (default: NULL)
	 * @param mixed $driver. (default: NULL)
	 * @return void
	 */
	public function __construct($alias = NULL, $driver = NULL, array $options = NULL)
	{
		// Setup options array
		$options = func_get_args();
		$options = Formo::args(__CLASS__, __FUNCTION__, $options);

		// Load the config file
		$this->set('config', Kohana::$config->load('formo'));

		// Set the default alias and driver if necessary
		(empty($options['alias']) AND $options['alias'] = $this->get('config')->form_alias);
		(empty($options['driver']) AND $options['driver'] = $this->get('config')->form_driver);
		(empty($options['kind']) AND $options['kind'] = $this->get('config')->kind);
		
		// Always process the driver first
		$driver = $options['driver'];
		unset($options['driver']);
		$options = Arr::merge(array('driver' => $driver), $options);

		// Load the orm config file
		if ($orm_file = Arr::get($this->get('config'), 'ORM') !== NULL)
		{
			$this->set('orm_config', $orm_file);
		}

		// Run validator setup
		$this->_setup_validation();

		// Load the options
		$this->_load_options($options);
	}
예제 #20
0
파일: Config.php 프로젝트: NegoCore/core
 /**
  * Load modules config
  *
  * @param $group
  * @param $module
  * @return mixed
  * @throws Kohana_Exception
  */
 public function load($group, $module)
 {
     if (empty($group) || empty($module)) {
         throw new Twig_Exception("Need to specify a config group and module name");
     }
     if (!is_string($group) || !is_string($module)) {
         throw new Twig_Exception("Config group and module name must be a string");
     }
     if (strpos($group, '.') !== FALSE) {
         // Split the config group and path
         list($group, $path) = explode('.', $group, 2);
     }
     if (isset($this->_config_groups[$group])) {
         if (isset($path)) {
             return Arr::path($this->_config_groups[$group], $path, NULL, '.');
         }
         return $this->_config_groups[$group];
     }
     $config = array();
     $file = $this->_get_config_file($group, $module);
     if (is_file($file)) {
         $config = Arr::merge($config, Kohana::load($file));
     }
     $this->_config_groups[$group] = new Config_Group(Kohana::$config, $group, $config);
     if (isset($path)) {
         return Arr::path($config, $path, NULL, '.');
     }
     return $this->_config_groups[$group];
 }
예제 #21
0
 /**
  * @param   array  $array1      initial array
  * @param   array  $array2,...  array to merge
  *
  * @return array
  */
 public static function merge($array1, $array2)
 {
     $result = [];
     for ($i = 0; $i < func_num_args(); $i++) {
         $result = parent::merge($result, static::asArray(func_get_arg($i)));
     }
     return $result;
 }
예제 #22
0
	protected function get_filter_type() {
		$types = DB::select_array(array('type'))
			->distinct(TRUE)
			->from(Kohana::config('dblog.table'))
			->execute()
			->as_array('type', 'type');
		return Arr::merge($types, array('' => __('any')));
	}
예제 #23
0
 protected function _get_options($element_name, array $options = NULL)
 {
     if (!empty($options)) {
         return Arr::merge($this->get_config($element_name), $options);
     } else {
         return $this->get_config($element_name);
     }
 }
예제 #24
0
 public function __construct($config = array())
 {
     // Append default auth configuration
     $config = Arr::merge((array) Kohana::config('paypal'), $config);
     // Save the config in the object
     $this->config = $config;
     $this->paypal_url = isset($config['url']) ? $config['url'] : 'https://www.paypal.com/cgi-bin/webscr';
 }
예제 #25
0
 public final function set_global($key, $value = NULL)
 {
     if (is_array($key) and Arr::is_assoc($key)) {
         Kostache::$globals = Arr::merge(Kostache::$globals, $key);
     } else {
         Kostache::$globals[$key] = $value;
     }
 }
예제 #26
0
 static function fetch($type)
 {
     $data = array();
     foreach (self::$data as $values) {
         $data = Arr::merge($data, $values[$type]);
     }
     return implode("\r\n", array_unique($data));
 }
예제 #27
0
파일: base.php 프로젝트: elevenone/witty
 /**
  * set config
  *
  * @param string | array $key config's key or an array, if array is provided , ignore the 2nd param
  * @param string $val config value
  */
 public function set_config($key, $val = NULL)
 {
     if (is_string($key)) {
         $this->_config[$key] = $val;
     } elseif (is_array($key)) {
         $this->_config = Arr::merge($this->_config, $key);
     }
 }
예제 #28
0
파일: themer.php 프로젝트: sajans/cms
 public static function select_theme()
 {
     foreach (self::$routes as $key => $route) {
         if (in_array($key, self::$route_search)) {
             self::$selected_theme = Arr::merge(self::$selected_theme, $route);
         }
     }
 }
예제 #29
0
 /**
  * Loads the config file(s).
  *
  * @param   bool  $overwrite  Whether to overwrite existing values
  * @return  array  the config array
  */
 public function load($overwrite = false, $cache = true)
 {
     $paths = $this->find_file($cache);
     $config = array();
     foreach ($paths as $path) {
         $config = $overwrite ? array_merge($config, $this->load_file($path)) : \Arr::merge($config, $this->load_file($path));
     }
     return $config;
 }
예제 #30
0
 /**
  * {@inheritdoc}
  */
 public function register()
 {
     // \Fuel\Agent\Agent
     $this->container->add('agent', function (array $config = [], $method = 'browscap') {
         $configInstance = $this->container->get('configInstance');
         $config = \Arr::merge($configInstance->load('agent', true), $config);
         return new Agent($config, $method);
     });
 }