예제 #1
0
 /**
  * Adds a single context container to the bottom of the list
  * 
  * @param  string                                 $id Context Container ID
  * @param  string                                 $fn Context Container function
  * @return Ponticlaro\Bebop\Common\ContextManager     Context Manager instance
  */
 public function append($id, $fn)
 {
     if (is_string($id) && is_callable($fn)) {
         $this->contexts->push(new ContextContainer($id, $fn));
     }
     return $this;
 }
예제 #2
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');
             }
         }
     }
 }
예제 #3
0
 /**
  * Adds a single tab
  * 
  * @param string $title Tab title
  * @param mixed  $args  Tab callable or array of arguments
  */
 public function addTab($title, $args)
 {
     if (is_string($title) && (is_callable($args) || is_array($args))) {
         $id = $this->__trackable_id . '-' . Utils::slugify($title, array('separator' => '-'));
         $this->tabs->push(new Tab($id, $title, $args));
     }
     return $this;
 }
예제 #4
0
 /**
  * Calls to undefined functions
  * 
  * @param  string $name Function name
  * @param  array  $args Function arguments
  * @return object       This class instance
  */
 public function __call($name, array $args = [])
 {
     // Quick method to add sections
     if (ModuleFactory::canManufacture($name)) {
         $args = isset($args[0]) && is_array($args[0]) ? $args[0] : [];
         $section = ModuleFactory::create($name, $args);
         $this->sections->push($section);
     }
     return $this;
 }
예제 #5
0
 /**
  * Adds single taxonomy
  * 
  * @param string $taxonomy
  */
 public function addTaxonomy($taxonomy)
 {
     if (!is_string($taxonomy)) {
         throw new \Exception('PostType taxonomy must be a string.');
     }
     if (!$this->taxonomies->hasValue($taxonomy)) {
         $this->taxonomies->push($taxonomy);
     }
     return $this;
 }
예제 #6
0
 /**
  * Adds a single list
  * 
  * @param \Ponticlaro\Bebop\UI\Plugins\ContentList $list  ContentList instance
  */
 public function addList(\Ponticlaro\Bebop\UI\Plugins\ContentList\ContentList $list, array $data = array())
 {
     // Override list data
     if ($data) {
         $list->setData($data);
     }
     // Store list
     $this->__lists->push($list);
     return $this;
 }
예제 #7
0
 /**
  * Appends a children to element
  * 
  * @param  mixed  $el HTML string or ElementAbstract
  * @return object     This class instance
  */
 public function append($el)
 {
     if (!$this->isSelfClosing()) {
         if (!is_string($el) && !$el instanceof ElementAbstract) {
             throw new \Exception('Element children must be either strings or children of \\Ponticlaro\\Bebop\\Html\\ElementAbstract.');
         }
         $this->config->push($el, 'children');
     }
     return $this;
 }
예제 #8
0
 /**
  * Adds single post_type
  * 
  * @param  string                         $post_type
  * @return \Ponticlaro\Bebop\Cms\Taxonomy            Taxonomy instance
  */
 public function addPostType($post_type)
 {
     if (is_a($post_type, 'Ponticlaro\\Bebop\\PostType')) {
         $post_type = $post_type->getId();
     }
     if (!is_string($post_type)) {
         throw new \Exception('Taxonomy post type must be either a string or a \\Ponticlaro\\Bebop\\PostType instance.');
     }
     $this->post_types->push(Utils::slugify($post_type));
     return $this;
 }
예제 #9
0
 /**
  * Internal function to add route instance to routes list
  * 
  * @param  \Ponticlaro\Bebop\Api\Route $route Route instance
  * @return void
  */
 protected function __pushRoute(\Ponticlaro\Bebop\HttpApi\Route $route)
 {
     $this->routes->push($route);
 }
예제 #10
0
 /**
  * Adds configuration to target hook
  * 
  * @param string $hook   Hook ID
  * @param mixed  $config Configuration JSON file or array
  */
 public function addToHook($hook, $config)
 {
     $this->hooks->push($config, $hook);
     return $this;
 }