コード例 #1
0
ファイル: Router.php プロジェクト: ponticlaro/bebop-http-api
 /**
  * Sets Api URL prefix
  * 
  */
 public function setBaseUrl($url)
 {
     if (is_string($url)) {
         $this->config->set('base_url', trim($url, '/') . '/');
     }
     return $this;
 }
コード例 #2
0
 public function __construct($message, $http_status, array $options = array())
 {
     // Set message
     $this->message = $message;
     // Set defaults
     $this->http_status = self::DEFAULT_HTTP_STATUS;
     // Set options
     $this->data = new Collection();
     $this->data->set($options);
 }
コード例 #3
0
 /**
  * Captures custom date arguments
  * 
  * @param  array $args
  * @return void
  */
 protected function __captureCustomDateArgs(array &$args = array())
 {
     foreach ($args as $key => $value) {
         if (preg_match('/^year\\:/', $key) || preg_match('/^month\\:/', $key) || preg_match('/^day\\:/', $key) || preg_match('/^week\\:/', $key) || preg_match('/^hour\\:/', $key) || preg_match('/^minute\\:/', $key) || preg_match('/^second\\:/', $key)) {
             $data = explode(':', $key);
             $date_key = isset($data[0]) ? $data[0] : null;
             $compare = isset($data[1]) ? $data[1] : '=';
             unset($args[$key]);
             if (array_key_exists(strtolower($compare), static::$comparator_map)) {
                 $compare = static::$comparator_map[$compare];
                 $values = explode(',', $value);
                 $value = count($values) == 1 && !in_array($compare, array('IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN')) ? $values[0] : $values;
                 $data = array($date_key => $value, 'compare' => $compare);
                 if (!$this->clean_args->hasKey('date_query')) {
                     $relation = 'AND';
                     if (isset($args['date_relation'])) {
                         $relation = $args['date_relation'];
                         unset($args['date_relation']);
                     }
                     $this->clean_args->set('date_query.relation', $relation);
                 }
                 $this->clean_args->push($data, 'date_query');
             }
         }
     }
 }
コード例 #4
0
ファイル: Metabox.php プロジェクト: ponticlaro/bebop-cms
 /**
  * Wrapper that executes callback 
  * 
  * @param  \WP_Post                  $post    Post being edited
  * @param  \Ponticlaro\Bebop\Metabox $metabox This metabox instance
  * @return void
  */
 public function __callbackWrapper($post, $metabox)
 {
     // Get fields from callback function or sections
     $this->__setMetaFields();
     // Collect meta fields data
     if ($meta_fields = $this->meta_fields->getAll()) {
         foreach ($meta_fields as $meta_field) {
             $this->data->set($meta_field, get_post_meta($post->ID, $meta_field));
         }
     }
     // Execute callback
     if ($callback = $this->getCallback()) {
         call_user_func_array($callback, array($this->data, $post, $this));
     }
     // Render sections
     $sections = $this->getAllSections();
     if ($sections) {
         foreach ($sections as $section) {
             $section->render($this->data->getAll());
         }
     }
     if ($callback || $sections) {
         $id = $this->getId();
         // Add nonce field for security
         wp_nonce_field('metabox_' . $id . '_saving_meta', 'metabox_' . $id . '_nonce');
     }
 }
コード例 #5
0
 /**
  * Sets the value for self_closing
  * 
  * @param boolean $value Boolean stating if the element should have a closing tag
  */
 public function setSelfClosing($value)
 {
     if (is_bool($value)) {
         $this->config->set('self_closing', $value);
     }
     return $this;
 }
コード例 #6
0
ファイル: Shortcode.php プロジェクト: ponticlaro/bebop-cms
 /**
  * Sets a single default attribute
  * 
  * @param string                          $key   Attribute key
  * @param mixed                           $value Attribute value
  * @return Ponticlaro\Bebop\Cms\Shortcode        This class instance
  */
 public function setDefaultAttr($key, $value)
 {
     if (is_string($key)) {
         $this->default_attributes->set($key, $value);
     }
     return $this;
 }
コード例 #7
0
ファイル: Tab.php プロジェクト: ponticlaro/bebop-cms
 /**
  * Sets data to be passed to the function
  * 
  * @return void
  */
 private function __setData()
 {
     $options = $this->options->getAll();
     if ($options) {
         foreach ($options as $option) {
             $this->data->set($option, get_option($option));
         }
     }
 }
コード例 #8
0
 /**
  * Creates single instance of the MultiContentList plugin
  * 
  * @param  string $title  Instance Title. Also used to create a slugified key
  * @param  array  $config Configuration array
  * @return object         Ponticlaro\Bebop\UI\Plugins\MultiContentList
  */
 private function __createInstance($title, array $config = array())
 {
     // Create slugified $key from $title
     $key = Utils::slugify($title);
     // Set default configuration values
     $this->__config->set(array('key' => $key, 'title' => $title, 'mode' => 'default'));
     // Set configuration values from input
     $this->__config->set($config);
     return $this;
 }
コード例 #9
0
ファイル: PostType.php プロジェクト: ponticlaro/bebop-cms
 /**
  * Sets the plural name
  * 
  * @param  string                         $name Plural name to be set
  * @return \Ponticlaro\Bebop\Cms\PostType       PostType instance
  */
 protected function __setPluralName($name)
 {
     if (!is_string($name)) {
         throw new \Exception('PostType plural name must be a string.');
     }
     $this->config->set('plural_name', $name);
     if (!$this->getLabel('menu_name')) {
         $this->setLabel('menu_name', $name);
     }
     return $this;
 }
コード例 #10
0
ファイル: View.php プロジェクト: ponticlaro/bebop-mvc
 /**
  * Sets an array of key/values pairs on the vars collection
  * 
  * @param array   $vars  List of vars to be set
  * @param boolean $merge True if these vars should merge with existing ones, false otherwise
  */
 public function setVars(array $vars = array(), $merge = true)
 {
     if ($merge) {
         // Get current vars
         $current_vars = $this->vars->getAll();
         // Merge with new vars
         $vars = array_merge($current_vars, $vars);
     }
     $this->vars->set($vars);
     return $this;
 }
コード例 #11
0
ファイル: Taxonomy.php プロジェクト: ponticlaro/bebop-cms
 /**
  * Sets the plural name
  * 
  * @param  string                         $name Plural name to be set
  * @return \Ponticlaro\Bebop\Cms\Taxonomy       Taxonomy instance
  */
 protected function __setPluralName($name)
 {
     if (!is_string($name)) {
         throw new \Exception('Taxonomy plural name must be a string.');
     }
     $this->config->set('plural_name', $name);
     if (!$this->config->get('label')) {
         $this->config->set('label', $name);
     }
     return $this;
 }
コード例 #12
0
ファイル: Option.php プロジェクト: ponticlaro/bebop-db
 /**
  * Sets a single key/value pair
  * 
  * @param string $key   
  * @param mixed  $value 
  */
 public function set($keys, $value = true)
 {
     if (is_array($keys)) {
         foreach ($keys as $key => $value) {
             $this->data->set($key, $value);
         }
     }
     if (is_string($keys)) {
         $this->data->set($keys, $value);
     }
     $this->__autosave();
     return $this;
 }
コード例 #13
0
ファイル: Config.php プロジェクト: ponticlaro/bebop-cms
 /**
  * Adds single configuration item object to build config
  * 
  * @param  string     $hook         Hook ID
  * @param  string     $env          Environment ID
  * @param  string     $section_name Configuraton section
  * @param  ConfigItem $config_obj   Configuraton item object
  * @return void
  */
 protected function addConfigItem($hook, $env, $section_name, ConfigItem $config_obj)
 {
     // Getting the correct configuration id
     $id = $hook == 'presets' ? $config_obj->getId() : $config_obj->getUniqueId();
     // Define path for config item
     $path = "{$hook}.{$env}.{$section_name}.{$id}";
     // Check if we have a previous configuration
     $prev_config_obj = $this->config->get($path);
     // Merge new configuration with existing one
     if ($prev_config_obj) {
         $config_obj = $prev_config_obj->merge($config_obj);
     }
     // Add config item to its correct path
     $this->config->set($path, $config_obj);
     // Handle configuration item requirements
     if ($hook != 'presets' && ($requirements_config = $config_obj->getRequirements())) {
         $this->processHookEnvConfig($hook, $env, $requirements_config);
     }
 }