本文整理汇总了PHP中Set::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Set::filter方法的具体用法?PHP Set::filter怎么用?PHP Set::filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set::filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _constructTagAttributes
/**
* @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: paragraphize
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: geraTabela
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();
}
示例4: _render
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: beforeSave
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: consultaVolumeAnalistas
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;
}
示例7: view
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: filter
/**
* 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: beforeFind
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: _render
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: consultaVolumeStatus
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: filter
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);
}
示例13: render
/**
* @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: trigger
/**
* 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;
}
示例15: filterQueryPostsArgs
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;
}