Пример #1
0
 /**
  * @param array $attributes
  * @return string
  */
 public function _constructTagAttributes(array $attributes = array())
 {
     $attributes = Set::filter($attributes);
     $outputHtml = '';
     if ($attributes) {
         foreach ($attributes as $attName => $attValue) {
             if (is_array($attValue)) {
                 $attValue = implode(' ', $attValue);
             }
             $attName = trim($attName);
             $attValue = trim($attValue);
             switch ($attName) {
                 case 'value':
                     $attValue = htmlentities($attValue, ENT_QUOTES, 'utf-8');
                     break;
                 case 'disabled':
                     if ($attValue) {
                         $attValue = 'disabled';
                     }
                     break;
             }
             if ((!$attValue || !is_string($attName)) && $attValue !== 0 && $attValue !== '0') {
                 continue;
             }
             $outputHtml .= ' ' . $attName . '="' . esc_attr($attValue) . '"';
         }
     }
     return $outputHtml;
 }
Пример #2
0
 public function paragraphize($text, $options = array())
 {
     $output = '';
     $attrString = '';
     foreach ($options as $attr => $value) {
         $attrString .= ' ' . $attr . '="' . $value . '"';
     }
     if (strpos($text, '<p>') !== false) {
         if ($attrString) {
             $output = str_replace('<p>', '<p' . $attrString . '>', $text);
         }
     } else {
         $textChunks = Set::filter(explode(PHP_EOL, $text));
         foreach ($textChunks as $para) {
             $para = trim($para);
             if (strlen($para) <= 1) {
                 continue;
             }
             if ($attrString) {
                 $output .= '<p' . $attrString . '>' . $para . '</p>';
             } else {
                 $output .= '<p>' . $para . '</p>';
             }
         }
     }
     return $output ? $output : $text;
 }
Пример #3
0
 private function geraTabela()
 {
     $this->genSettings(function ($val, $key) {
         if (!empty($val)) {
             $val = htmlentities($val, ENT_QUOTES, "UTF-8");
             $this->settings['conditions']['AND']["{$this->modelClass}.{$key} LIKE"] = "%{$val}%";
         }
     }, [0, 3]);
     $this->genSettings(function ($val, $key) {
         if (!empty($val)) {
             $this->settings['conditions']["{$this->modelClass}.{$key}"] = $val;
         }
     }, [3, 4]);
     $this->genSettings(function ($val, $key) {
         if (!empty($val)) {
             $this->settings[$key] = $val;
         }
     }, [7, 4]);
     $this->Paginator->settings = array_merge($this->paginate, Set::filter($this->settings));
     extract($this->Paginator->settings);
     $this->set(compact('page', 'sort', 'direction'));
     try {
         return $this->Paginator->paginate();
     } catch (Exception $e) {
         $this->Paginator->settings['page'] = $this->request->params['paging'][$this->modelClass]['pageCount'];
     }
     return $this->Paginator->paginate();
 }
 protected function _render($options)
 {
     $metaFields = array_keys(Set::filter(Set::booleanize($this->getParam('metaFields'))));
     echo '<div class="line-meta-details">';
     echo $this->Html->postDetails($metaFields, array('prefixes' => array('author' => __('By', 'gummfw'), 'date' => __('/', 'gummfw'), 'comments' => __('/', 'gummfw'), 'category' => __('/', 'gummfw')), 'formats' => array('date' => 'd F Y')));
     echo '</div>';
 }
Пример #5
0
 function beforeSave($options = array())
 {
     // create contact's "display title" from name and surname
     if (isset($this->data['Contact']['kind']) && strtoupper($this->data['Contact']['kind']) == 'T' && isset($this->data['Contact']['name']) && isset($this->data['Contact']['surname'])) {
         $this->data['Contact']['title'] = implode(' ', Set::filter(array($this->data['Contact']['name'], $this->data['Contact']['surname'])));
     }
     return parent::beforeSave();
 }
Пример #6
0
 public function consultaVolumeAnalistas($tipo, $ids = null, $data_inicio = array(), $data_fim = array())
 {
     $this->recursive = -1;
     $conditions = Set::filter(array('GestaoEvento_Analista.id_analista' => isset($ids) ? $ids : null));
     $contain = array($tipo => array('conditions' => array("dt_chegada   >=" => !empty($data_inicio['data']) ? "{$data_inicio['data']} {$data_inicio['hora']}" : "0000-00-00 00:00", "dt_chegada   <=" => !empty($data_fim['data']) ? "{$data_fim['data']} {$data_fim['hora']}" : "9999-99-99 99:99")));
     $order = "{$this->alias}.{$this->displayField} ASC";
     $data = $this->find('all', compact('conditions', 'contain', 'order'));
     return $data;
 }
 function view($id = null)
 {
     $this->ProductionManager->recursive = 2;
     // Set User's ID in model which is needed for validation
     $this->ProductionManager->id = $this->Auth->user('id');
     $this->ProductionManager->role = $this->Auth->user('role');
     $admin = false;
     if (!empty($this->ProductionManager->role)) {
         //Only allow the user to update his own profile unless the person has the admin role
         if ($this->ProductionManager->role != "admin") {
             $id = $this->ProductionManager->id;
         } else {
             $admin = true;
         }
     }
     if (!$id) {
         $this->Session->setFlash(__('Invalid production manager', true));
         $this->redirect(array('action' => 'index'));
     }
     if (is_numeric($id)) {
         $production_manager = $this->ProductionManager->read(null, $id);
     } else {
         $production_manager = $this->ProductionManager->findBySlug($id);
     }
     //Find the user's account id
     $userAccount = $this->ProductionManager->User->find('first', array('conditions' => array('User.production_manager_id' => $production_manager['ProductionManager']['id'])));
     foreach ($production_manager['Project'] as $item => $value) {
         //debug($production_manager['Project'][$item]['complete']);
         if ($production_manager['Project'][$item]['complete'] == 1) {
             $completeProjects[] = $production_manager['Project'][$item];
         } else {
             $incompleteProjects[] = $production_manager['Project'][$item];
         }
     }
     if (empty($completeProjects)) {
         $completeProjects = null;
     }
     if (empty($incompleteProjects)) {
         $incompleteProjects = null;
     }
     $this->paginate['Project'] = array('recursive' => 2, 'order' => array('Project.complete' => 'asc'), 'limit' => 150, 'contain' => array('ProductionManager' => array('conditions' => array('ProductionManager.id =' => $production_manager['ProductionManager']['id'])), 'Client'));
     $projects = Set::filter($this->paginate('Project'));
     for ($i = 0; $i < count($projects); $i++) {
         if (!empty($projects[$i]['ProductionManager'][0])) {
             if ($projects[$i]['ProductionManager'][0]['id'] != $production_manager['ProductionManager']['id']) {
                 unset($projects[$i]);
             }
         } else {
             unset($projects[$i]);
         }
     }
     //debug($projects);
     $projects = array_values($projects);
     //debug($projects);
     $this->set(compact('production_manager', 'projects', 'completeProjects', 'incompleteProjects', 'userAccount'));
     //$this->set('production_manager', $this->ProductionManager->read(null, $id));
 }
Пример #8
0
 /**
  * Filters empty elements out of a route array, excluding '0'.
  *
  * @param array $var Either an array to filter, or value when in callback
  * @return mixed Either filtered array, or true/false when in callback
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::filter
  */
 public static function filter(array $var)
 {
     foreach ($var as $k => $v) {
         if (is_array($v)) {
             $var[$k] = Set::filter($v);
         }
     }
     return array_filter($var, array('Set', '_filter'));
 }
Пример #9
0
 function beforeFind(&$Model, $query = array())
 {
     $optionName = $this->settings[$Model->alias]['optionName'];
     if (isset($query[$optionName])) {
         $options = $query[$optionName];
         unset($query[$optionName]);
         $query = Set::merge($this->defaultQuery, $this->options($Model, $options), Set::filter($query));
     }
     return $query;
 }
Пример #10
0
 protected function _render($options)
 {
     $networks = Set::filter(Set::booleanize($this->getParam('socialNetworks')));
     echo '<div class="bluebox-share-options">';
     echo '<span>' . __('Share The Story', 'gummfw') . '</span>';
     echo '<div class="bluebox-details-social">';
     View::renderElement('social-links', array('networks' => $networks, 'accountMode' => 'share', 'additionalClass' => 'bluebox-shadows'));
     echo '</div>';
     echo '</div>';
 }
Пример #11
0
 public function consultaVolumeStatus(array $default = null, array $data_inicio = null, array $data_fim = null)
 {
     $this->recursive = -1;
     $this->virtualFields = ['quantidade' => 'COUNT(evento)'];
     $joins = [$this->joins['GestaoEvento_Evento']];
     $group = ['status'];
     $order = ['GestaoEvento_Status.status ASC'];
     $conditions = Set::filter(['GestaoEvento_Status.id_status' => $default, 'GestaoEvento_Evento.dt_chegada   >=' => !empty($data_inicio['data']) ? "{$data_inicio['data']} {$data_inicio['hora']}" : "0000-00-00 00:00", 'GestaoEvento_Evento.dt_chegada   <=' => !empty($data_fim['data']) ? "{$data_fim['data']} {$data_fim['hora']}" : "9999-99-99 99:99"]);
     return $this->find('all', compact('conditions', 'joins', 'order', 'group'));
 }
Пример #12
0
 public static function filter($input)
 {
     if (is_array($input)) {
         foreach ($input as &$value) {
             if (is_array($value)) {
                 $value = self::filter($value);
             }
         }
     }
     return Set::filter($input);
 }
 /**
  * @return void
  */
 public function render($fields)
 {
     $networks = Set::filter(Set::booleanize($this->getParam('socialNetworks')));
     $mode = $this->getParam('mode');
     // echo '<div class="bluebox-share-options">';
     //     echo '<span>' . __('Share The Story') . '</span>';
     echo '<div class="bluebox-details-social">';
     View::renderElement('social-links', array('networks' => $networks, 'accountMode' => $mode, 'additionalClass' => 'social-link bluebox-shadows'));
     echo '</div>';
     // echo '</div>';
 }
Пример #14
0
 /**
  * Trigger an event or array of events
  *
  * @param string|array $eventName
  * @param array $data (optional) Array of data to pass along to the event handler
  * @return array
  *
  */
 public function trigger(&$HandlerObject, $eventName, $data = array())
 {
     if (!is_array($eventName)) {
         $eventName = array($eventName);
     }
     $eventNames = Set::filter($eventName);
     foreach ($eventNames as $eventName) {
         $eventData = EventCore::__parseEventName($eventName);
         $return[$eventData['event']] = EventCore::__dispatchEvent($HandlerObject, $eventData['scope'], $eventData['event'], $data);
     }
     return $return;
 }
 protected function filterQueryPostsArgs($args)
 {
     global $woocommerce;
     if ($_args = $woocommerce->query->get_catalog_ordering_args()) {
         $args = array_merge($args, $_args);
     }
     if ($termIds = Set::filter(Set::booleanize($this->getParam('product_cat')))) {
         $termIds = array_keys($termIds);
         $args = Set::merge($args, array('tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => (array) $termIds))));
     }
     return $args;
 }
Пример #16
0
 public function filterEmpty($Model, $data)
 {
     if (!is_array($data)) {
         return $data;
     }
     foreach ($data as $key => $value) {
         if (is_array($value)) {
             $data[$key] = $this->filterEmpty($Model, $value);
         }
     }
     return Set::filter($data, true);
 }
Пример #17
0
 public function gerarListagemComSiglas($empresa = 'VIVO', $cn = null)
 {
     $this->recursive = -1;
     $this->virtualFields = ['nome_estacao' => "CONCAT('[',Geral_Estacao.estacao,']      ',Geral_Estacao.nome_estacao)"];
     $fields = ['GestaoEvento_Site.id_sites', 'GestaoEvento_Site.nome_estacao'];
     $joins = [$this->joins['Geral_Estacao']];
     $conditions = Set::filter(['Geral_Estacao.empresa' => $empresa, 'GestaoEvento_Site.cn_id' => $cn]);
     $order = ['Geral_Estacao.nome_estacao'];
     $data = $this->find('list', compact('fields', 'joins', 'conditions', 'order'));
     array_walk($data, function (&$item) {
         $item = html_entity_decode($item);
     });
     return $data;
 }
 private function geraTabela()
 {
     $this->genSettings(function ($val, $key) {
         if (!empty($val)) {
             $val = htmlentities($val, ENT_QUOTES, "UTF-8");
             $this->settings['conditions']['AND']["{$this->modelClass}.{$key} LIKE"] = "%{$val}%";
         }
     }, [0, 3]);
     $this->genSettings(function ($val, $key) {
         if (!empty($val)) {
             $this->settings['conditions']["{$this->modelClass}.{$key}"] = $val;
         }
     }, [3, 4]);
     if (isset($this->request->data['sla'])) {
         switch ($this->request->data['sla']) {
             case 'FORA':
                 $this->settings['conditions']["{$this->modelClass}.tempo_termino >"] = "{$this->modelClass}.sla";
                 break;
             case 'DENTRO':
                 $this->settings['conditions']["{$this->modelClass}.tempo_termino <="] = "{$this->modelClass}.sla";
                 break;
             case 'PROGRESSO':
                 $this->settings['conditions'][] = ["{$this->modelClass}.dt_fechamento IS NULL"];
                 $this->settings['conditions'][] = ["{$this->modelClass}.sla IS NOT NULL"];
                 break;
             case 'CADASTRO':
                 $this->settings['conditions'][] = ["{$this->modelClass}.sla IS NULL"];
                 break;
             default:
                 break;
         }
     }
     if (isset($this->request->data['tecnico'])) {
         $this->settings['conditions']['AND']['OR'] = array("{$this->modelClass}.tecnico_atuando_1" => $this->request->data['tecnico'], "{$this->modelClass}.tecnico_atuando_2" => $this->request->data['tecnico'], "{$this->modelClass}.tecnico_atuando_3" => $this->request->data['tecnico']);
     }
     $this->settings['conditions'][] = ["{$this->modelClass}.tecnico_atuando_1 IS NOT NULL"];
     $this->Paginator->settings = array_merge($this->paginate, Set::filter($this->settings));
     extract($this->Paginator->settings);
     $this->set(compact('page', 'sort', 'direction'));
     try {
         return $this->Paginator->paginate();
     } catch (Exception $e) {
         $this->Paginator->settings['page'] = $this->request->params['paging'][$this->modelClass]['pageCount'];
     }
     return $this->Paginator->paginate();
 }
Пример #19
0
 public function formatDateFields($results, $dates, $format = "%d/%m/%Y")
 {
     if (!empty($dates)) {
         $setResult = function ($val, $key) use(&$results, $format) {
             $innerKey = explode("/", $key);
             $results[$innerKey[0]][$innerKey[1]][$innerKey[2]] = CakeTime::format($val, $format);
         };
         $extracted = Set::extract($results, "/{$this->alias}");
         $dateExtracted = Set::classicExtract($extracted, '{\\w+}.{\\w+}.{' . implode("|", $dates) . '}');
         $applied = Set::apply("/", $dateExtracted, function ($val) {
             return count(Set::filter($val)) > 0 ? $val : null;
         });
         if ($applied) {
             $flatten = Set::flatten($applied, "/");
             array_walk($flatten, $setResult);
         }
     }
     return $results;
 }
Пример #20
0
 public function view($id = null)
 {
     $this->layout = null;
     #$this->disableDebugger();
     $field_id = $this->params['named']['field_id'];
     $contact_type_id = $this->params['pass'][0];
     $key = Configure::read('ADres.internal_api_key');
     $url = "/v1/index/{$contact_type_id}.json?api_key={$key}";
     $data = (array) $this->get_api($url);
     $email_column = $this->extract_email_column($data['fields'], $field_id);
     $email_addresses = Set::filter($this->extract_email_addresses($data['data'], $email_column));
     if ($this->data) {
         $this->chimp = new Chimp(EmailerAppController::chimp_api_key);
         $message = array('text' => $this->data['Mailer']['message'], 'subject' => $this->data['Mailer']['subject'], 'from_name' => $this->data['Mailer']['from'], 'from_email' => '*****@*****.**', 'to_email' => $email_addresses);
         $this->EmailLog->save(array('body' => $this->data['Mailer']['message'], 'subject' => $this->data['Mailer']['subject'], 'sent_to' => implode(',', $email_addresses), 'field_id' => $field_id, 'contact_type_id' => $contact_type_id));
         $this->chimp->sendEmail($message, true, false, array('Welcome Email'));
     }
     $this->redirect($this->referer(), null, true);
 }
Пример #21
0
 /**
  * A means for simply adding redirects
  */
 public function add()
 {
     $default = array('url' => null, 'redirect' => null, 'priority' => 100, 'callback' => null);
     $input = array_combine(array_keys($default), $this->args + array_fill(0, count($default), null));
     extract(array_merge($default, Set::filter($input)));
     if (empty($url) || strlen($url) < 3) {
         return $this->errorAndExit("Sorry, bad/missing input <url> = '{$url}'");
     }
     if (!in_array(substr($url, 0, 1), array('/', '#'))) {
         return $this->errorAndExit("Sorry, the input <url> should start with a '/' or a '#' you put in: '{$url}'");
     }
     if (empty($redirect) || strlen($redirect) < 3 && substr($url, 0, 1) != '/') {
         return $this->errorAndExit("Sorry, bad/missing input <redirect> = '{$redirect}'");
     }
     if (substr($redirect, 0, 1) !== '/' && substr($redirect, 0, 5) !== 'http' && strpos($redirect, '{callback}') === false) {
         return $this->errorAndExit("Sorry, the input <redirect> should start with a '/' or a 'http' you put inredirecturl'");
     }
     $save = array('SeoUri' => array('uri' => $url, 'is_approved' => 1), 'SeoRedirect' => compact('redirect', 'priority', 'callback'));
     $existing = $this->SeoUri->find('first', array('contain' => array('SeoRedirect'), 'conditions' => array('SeoUri.uri LIKE' => $url . '%')));
     if (!empty($existing) && isset($existing['SeoRedirect']['id']) && !empty($existing['SeoRedirect']['id'])) {
         $url = $existing;
         $this->out("Found an existing Uri...");
         $this->out("    {$url['SeoUri']['uri']} --> {$url['SeoRedirect']['redirect']}");
         $this->out("        Uri #{$url['SeoUri']['id']} --> redirect #{$url['SeoRedirect']['id']}");
         $this->out("        (active={$url['SeoRedirect']['is_active']}) (priority={$url['SeoRedirect']['priority']}) (callback={$url['SeoRedirect']['callback']})");
         $this->out();
         return $this->errorAndExit("Want to change it?  you're going to have to do so via the web interface.");
     }
     $this->SeoRedirect->clear();
     if ($this->SeoRedirect->save($save)) {
         $redirect = $this->SeoRedirect->find('first', array('contain' => array('SeoUri'), 'conditions' => array('SeoRedirect.id' => $this->SeoRedirect->id)));
         $this->out("Saved.");
         $this->out("    {$redirect['SeoUri']['uri']} --> {$redirect['SeoRedirect']['redirect']}");
         $this->out("        Uri #{$redirect['SeoUri']['id']} --> redirect #{$redirect['SeoRedirect']['id']}");
         $this->out("\t    (active={$redirect['SeoRedirect']['is_active']}) (priority={$redirect['SeoRedirect']['priority']}) (callback={$redirect['SeoRedirect']['callback']})");
     } else {
         $this->out("Errors");
         print_r($this->SeoUrl->errors);
         print_r($this->SeoUrl->validationErrors);
         print_r($this->SeoRedirect->validationErrors);
         $this->out();
     }
 }
Пример #22
0
 public function view($id = null)
 {
     $this->layout = null;
     #$this->disableDebugger();
     $field_id = $this->params['named']['field_id'];
     $contact_type_id = $this->params['pass'][0];
     $key = Configure::read('ADres.internal_api_key');
     $url = "/v1/index/{$contact_type_id}.json?api_key={$key}";
     $data = (array) $this->get_api($url);
     $email_column = $this->extract_email_column($data['fields'], $field_id);
     $email_addresses = Set::filter($this->extract_email_addresses($data['data'], $email_column));
     if ($this->data) {
         $this->aw_ses = new AmazonSES();
         $message = array("Subject.Data" => $this->data['Mailer']['subject'], "Body.Text.Data" => $this->data['Mailer']['message'], "Body.Html.Data" => $this->data['Mailer']['message']);
         $res = $this->aw_ses->send_email('*****@*****.**', array('ToAddresses' => $email_addresses), $message);
         if ($res->isOk()) {
             $this->EmailLog->save(array('body' => $this->data['Mailer']['message'], 'subject' => $this->data['Mailer']['subject'], 'sent_to' => implode(',', $email_addresses), 'field_id' => $field_id, 'contact_type_id' => $contact_type_id));
         }
     }
     $this->redirect($this->referer(), null, true);
 }
 function create($data = array(), $filterKey = false)
 {
     $defaults = array();
     $this->id = false;
     $this->data = array();
     $this->__exists = null;
     $this->validationErrors = array();
     if ($data !== null && $data !== false) {
         foreach ($this->schema() as $field => $properties) {
             if ($this->primaryKey !== $field && isset($properties['default'])) {
                 $defaults[$field] = $properties['default'];
             }
         }
         $this->set(Set::filter($defaults), null, false);
         $this->set($data);
     }
     if ($filterKey) {
         $this->set($this->primaryKey, false);
     }
     return $this->data;
 }
Пример #24
0
 /**
  * setup method
  *
  * @param mixed $Model
  * @param array $config
  * @return void
  * @access public
  */
 function setup(&$Model, $config = array())
 {
     if (!isset($config['fields'])) {
         $_fields = Set::filter($Model->schema());
         $config['fields'] = array();
         foreach ($_fields as $field => $data) {
             if (isset($data['type']) && $data['type'] == 'text') {
                 $config['fields'][] = $field;
             }
         }
     }
     $this->settings[$Model->alias] = Set::merge($this->_defaultSettings, $config);
     if (isset($config['methods'])) {
         foreach ($config['methods'] as $method => $params) {
             if ($params === true) {
                 $this->settings[$Model->alias]['methods'][$method] = $this->_defaultSettings['methods'][$method];
             } else {
                 $this->settings[$Model->alias]['methods'][$method] = am((array) $this->_defaultSettings['methods'][$method], $params);
             }
         }
     }
 }
    protected function _render($options)
    {
        global $post;
        $staffFields = $this->Wp->getOption('staff_member_description_fields');
        ?>
        <div class="bottom-staff-wrap">
            <div class="single-staff-left-wrap">
                <?php 
        if ($socialNetworks = Set::filter($post->PostMeta['social_networks_url'])) {
            foreach ($socialNetworks as $k => $v) {
                $networkName = str_replace('_url', '', $k);
                $networkPrettyName = Inflector::humanize($networkName);
                echo '<a href="' . $v . '" class="single-social-link" target="_blank">';
                echo $networkPrettyName;
                echo '<span class="icon-' . $networkName . '"></span>';
                echo '</a>';
            }
        }
        ?>
            </div>
            <div class="single-staff-right-wrap">
                <?php 
        foreach ($staffFields as $staffField) {
            $slugged = strtolower(Inflector::slug($staffField['title']));
            if (isset($post->PostMeta['staff_fields']) && isset($post->PostMeta['staff_fields'][$slugged]) && $post->PostMeta['staff_fields'][$slugged]) {
                echo '<div class="staff-extra-details">';
                echo '<div class="term">';
                echo '<strong><span class="' . $staffField['icon'] . '"></span>' . $staffField['title'] . '</strong>';
                echo '</div>';
                echo '<div class="description">' . $post->PostMeta['staff_fields'][$slugged] . '</div>';
                echo '</div>';
            }
        }
        ?>
            </div>
        </div>
<?php 
    }
Пример #26
0
 public function beforeRender($options)
 {
     global $post;
     $this->posts = GummRegistry::get('Model', 'Post')->findRelated($post, (int) $this->getParam('postsNumber'));
     if (!$this->posts) {
         return false;
     }
     $visibleNum = $this->getParam('layout') === 'blog' ? (int) $this->getParam('rows') : (int) $this->getParam('columns');
     if (count($this->posts) > $visibleNum) {
         if ($this->getParam('layout') === 'blog') {
             $this->shouldPaginate = true;
             $this->htmlClass .= 'flex-slider';
             $this->htmlElementData = array('data-direction-nav-container' => '#' . $this->id() . '-nav-controls', 'data-animation' => $this->getParam('flexSliderAnimation'), 'data-animation-loop' => '1', 'data-smooth-height' => '1');
         } else {
             $this->shouldPaginate = true;
             $this->htmlClass .= ' gumm-layout-element-slider';
             $this->htmlElementData = array('data-directional-nav' => '.heading-pagination', 'data-num-visible' => (int) $this->getParam('columns'));
         }
     }
     $this->supports['title'] = __('Related', 'gummfw');
     $this->htmlClass .= ' bluebox-related-blog-posts';
     $this->metaFields = array_keys(Set::filter(Set::booleanize($this->getParam('metaFields'))));
 }
Пример #27
0
 function _getTags(&$Model, $assoc_key, $assoc_model)
 {
     extract($this->settings);
     $tags = explode($separator, $Model->data[$assoc_key][$form_field]);
     if (Set::filter($tags)) {
         $tagIds = array();
         $tagData = array();
         foreach ($tags as $tag) {
             $tag = strtolower(trim($tag));
             $existingTag = $Model->{$assoc_key}->find('first', array('conditions' => array($assoc_key . '.' . $tag_field => $tag), 'recursive' => -1));
             if (empty($existingTag)) {
                 $Model->{$assoc_key}->id = null;
                 $Model->{$assoc_key}->saveField($tag_field, $tag);
                 $tagIds[] = $Model->{$assoc_key}->data[$assoc_key]['id'];
                 $tagData[] = $Model->{$assoc_key}->data;
             } elseif (!in_array($existingTag[$assoc_key]['id'], $tagIds)) {
                 $tagIds[] = $existingTag[$assoc_key]['id'];
                 $tagData[] = $existingTag;
             }
         }
         return $tagData;
     }
 }
Пример #28
0
 /**
  * Sets this helper's model and field properties to the dot-separated value-pair in $entity.
  *
  * @param mixed $entity A field name, like "ModelName.fieldName" or "ModelName.ID.fieldName"
  * @param boolean $setScope Sets the view scope to the model specified in $tagValue
  * @return void
  */
 public function setEntity($entity, $setScope = false)
 {
     if ($entity === null) {
         $this->_modelScope = false;
     }
     if ($setScope === true) {
         $this->_modelScope = $entity;
     }
     $parts = array_values(Set::filter(explode('.', $entity), true));
     if (empty($parts)) {
         return;
     }
     $count = count($parts);
     $lastPart = isset($parts[$count - 1]) ? $parts[$count - 1] : null;
     // Either 'body' or 'date.month' type inputs.
     if ($count === 1 && $this->_modelScope && $setScope == false || $count === 2 && in_array($lastPart, $this->_fieldSuffixes) && $this->_modelScope && $parts[0] !== $this->_modelScope) {
         $entity = $this->_modelScope . '.' . $entity;
     }
     // 0.name, 0.created.month style inputs.  Excludes inputs with the modelScope in them.
     if ($count >= 2 && is_numeric($parts[0]) && !is_numeric($parts[1]) && $this->_modelScope && strpos($entity, $this->_modelScope) === false) {
         $entity = $this->_modelScope . '.' . $entity;
     }
     $this->_association = null;
     $isHabtm = isset($this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type']) && $this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type'] === 'multiple' && $count == 1;
     // habtm models are special
     if ($count == 1 && $isHabtm) {
         $this->_association = $parts[0];
         $entity = $parts[0] . '.' . $parts[0];
     } else {
         // check for associated model.
         $reversed = array_reverse($parts);
         foreach ($reversed as $i => $part) {
             if ($i > 0 && preg_match('/^[A-Z]/', $part)) {
                 $this->_association = $part;
                 break;
             }
         }
     }
     $this->_entityPath = $entity;
     return;
 }
Пример #29
0
 /**
  * testFilter method
  *
  * @see Hash test cases, as Set::filter() is just a proxy.
  * @return void
  */
 public function testFilter()
 {
     $result = Set::filter(array('0', FALSE, TRUE, 0, array('one thing', 'I can tell you', 'is you got to be', FALSE)));
     $expected = array('0', 2 => TRUE, 3 => 0, 4 => array('one thing', 'I can tell you', 'is you got to be'));
     $this->assertSame($expected, $result);
 }
Пример #30
0
 /**
  * Determine which fields of a form should be used for hash.
  * Populates $this->fields
  *
  * @param mixed $field Reference to field to be secured
  * @param mixed $value Field value, if value should not be tampered with.
  * @return void
  * @access private
  */
 function __secure($field = null, $value = null)
 {
     if (!$field) {
         $field = $this->_View->entity();
     } elseif (is_string($field)) {
         $field = Set::filter(explode('.', $field), true);
     }
     if (!empty($this->request['_Token']['disabledFields'])) {
         foreach ((array) $this->request['_Token']['disabledFields'] as $disabled) {
             $disabled = explode('.', $disabled);
             if (array_values(array_intersect($field, $disabled)) === $disabled) {
                 return;
             }
         }
     }
     $field = implode('.', $field);
     if (!in_array($field, $this->fields)) {
         if ($value !== null) {
             return $this->fields[$field] = $value;
         }
         $this->fields[] = $field;
     }
 }