本文整理汇总了PHP中Set::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Set::check方法的具体用法?PHP Set::check怎么用?PHP Set::check使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: returnSection
public function returnSection($section, $locale = 'en_us')
{
$en_us = $this->returnEnSection($section);
//get the us version of the section first
if ($locale == 'en_us') {
return $en_us;
}
//query up the languages
if (Set::check(self::$sections, $section . "." . $locale)) {
return self::$sections[$section][$locale];
} else {
$old_locale = $this->locale;
$this->setLanguage($locale);
$lang = $this->find("all", array("conditions" => array("Phrase.section" => $section)));
$this->setLanguage($old_locale);
foreach ($en_us as $k => $v) {
$p = Set::extract("/Phrase[token=/" . $k . "/i]/value", $lang);
if (count($p) > 0) {
$en_us[$k] = $p[0];
}
}
//cache the data
self::$sections[$section][$locale] = $en_us;
}
return self::$sections[$section][$locale];
}
示例2: index
function index()
{
$this->Phrase->recursive = 0;
$phrases = $this->paginate('Phrase');
$this->set('phrases', $phrases);
//get the list of locales
$this->loadModel("Locale");
//$locales = $this->Locale->find("list",array("fields"=>array("Locale.locale","Locale.name"),"order"=>array("name"=>"ASC")));
$locales = Lang::localeList();
$this->set("locales", $locales);
//set the incoming locale to the session
if (!empty($this->request->data)) {
if (Set::check($this->request->data, "Phrase.selectLocale")) {
$this->Session->write("ControlPanel.translate_locale", $this->request->data['Phrase']['selectLocale']);
}
}
//get the locale from the session
if ($this->Session->check("ControlPanel.translate_locale")) {
$translate_locale = $this->Session->read("ControlPanel.translate_locale");
} else {
$translate_locale = 'en_us';
$this->request->data['Phrase']['selectLocale'] = 'en_us';
}
$this->request->data['Phrase']['selectLocale'] = $translate_locale;
$this->Phrase->setLanguage($translate_locale);
//get the trnaslated phrases
$ids = Set::extract("/Phrase/id", $phrases);
//pr($this->Session->read());
$locale_phrases = $this->Phrase->find('all', array("conditions" => array("Phrase.id" => $ids)));
$this->set("locale_phrases", $locale_phrases);
}
示例3: specialValues
function specialValues($fieldName, $options = array())
{
$this->setEntity($fieldName);
$specialValues = array('true' => true, 'false' => false, 'null' => null, 'undefined' => null);
$spcFieldOpt = array('label' => __('Special value', true), 'options' => array_combine(array_keys($specialValues), array_keys($specialValues)), 'empty' => __('none', true));
$hasSpecial = null;
$value = $this->value($fieldName);
$view =& ClassRegistry::getObject('view');
$entity = $view->entity();
foreach ($this->specialValues as $spc => $val) {
if ($value === $val) {
$hasSpecial = $spc;
}
}
if (!$hasSpecial && !empty($entity) && (empty($this->data) || !Set::check($this->data, join('.', $entity)))) {
$hasSpecial = 'undefined';
}
if ($hasSpecial) {
$options['value'] = '';
$spcFieldOpt['value'] = $hasSpecial;
}
if (empty($options['after'])) {
$options['after'] = '';
}
$options['after'] .= $this->Form->input($fieldName . '_spc', $spcFieldOpt);
return $this->Form->input($fieldName, $options);
}
示例4: afterFind
function afterFind($results, $primary = false)
{
if ($primary == true) {
if (Set::check($results, '0.0')) {
$fieldName = key($results[0][0]);
foreach ($results as $key => $value) {
$results[$key][$this->alias][$fieldName] = $value[0][$fieldName];
unset($results[$key][0]);
}
}
}
return $results;
}
示例5: tagcloud
/**
* Return tags from database.
*
* @return array
*/
function tagcloud(&$controller)
{
$term_id = Configure::read('Tagcloud.term');
$query = "SELECT count(*) as tag_count, Term.title, Term.id, Term.slug\n FROM nodes_terms as nt\n JOIN terms as Term ON Term.id = nt.term_id\n WHERE Term.vocabulary_id = {$term_id}\n GROUP BY nt.term_id";
$tags = ClassRegistry::init('Term')->query($query);
if (Set::check($tags, '0.0')) {
$fieldName = key($tags[0][0]);
foreach ($tags as $key => $value) {
$tags[$key]['Term'][$fieldName] = $value[0][$fieldName];
unset($tags[$key][0]);
}
}
return $tags;
}
示例6: view
/**
* view method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function view($id = null)
{
if (!$this->Group->exists($id)) {
throw new NotFoundException(__('Usuário Inválido!'));
}
$options = array('conditions' => array('Group.' . $this->Group->primaryKey => $id));
$this->set('group', $this->Group->find('first', $options));
//Obtenção do aroId do grupo selecionado.
$aro = $this->Acl->Aro->find('first', array('conditions' => array('Aro.model' => 'Group', 'Aro.foreign_key' => $id)));
$aroId = $aro['Aro']['id'];
//Obtendo os membros do grupo selecionado (Pode ser usuarios e grupos).
$members = $this->Acl->Aro->query('SELECT * FROM aros AS Aro
INNER JOIN users AS User ON Aro.foreign_key = User.id
WHERE Aro.parent_id = ' . $aroId);
$this->set('members', $members);
//debug($members);
//lista de usuários.
$this->loadModel('User');
$users = $this->User->find('list');
$this->set(compact('users'));
//Obtendo as permissões do grupo.
$this->loadModel('Page');
$pages = $this->Page->find('all', array('conditions' => array('Page.enable' => 1), 'order' => 'Page.name'));
//debug($pages);
$lista = array();
$aros_aco_id = NULL;
$aco_parent_id = NULL;
foreach ($pages as $page) {
//Check permissão
$check_permission = $this->Acl->check(array('Group' => array('id' => $id)), array('Page' => array('id' => $page['Page']['id'])));
//.....
$direct_permission = $this->Acl->Aco->Permission->find('first', array('conditions' => array('Aco.model' => 'Page', 'Aco.foreign_key' => $page['Page']['id'], 'Aro.model' => 'Group', 'Aro.foreign_key' => $id)));
//debug($direct_permission);
if (Set::check($direct_permission, 'Permission')) {
$aco_parent_id = $direct_permission['Aco']['parent_id'];
$aros_aco_id = $direct_permission['Permission']['id'];
$direct_permission = true;
}
$page_acos = $this->Acl->Aco->find('first', array('conditions' => array('Aco.model' => 'Page', 'Aco.foreign_key' => $page['Page']['id']), 'fields' => 'Aco.parent_id'));
$aco_parent_id = $page_acos['Aco']['parent_id'];
//debug($aco_parent_id);
$lista[] = array('aco_parent_id' => $aco_parent_id, 'aros_aco_id' => $aros_aco_id, 'page_id' => $page['Page']['id'], 'pageName' => $page['Page']['name'], 'check_permission' => $check_permission, 'direct_permission' => $direct_permission);
$aros_aco_id = NULL;
$aco_parent_id = NULL;
}
$this->set('permissions', $lista);
//debug($lista);
//debug($this->Acl->Aco->find('all'));
}
示例7: connect
/**
* Connects to the database. Options are specified in the $config instance variable.
*
* @return boolean Connected.
* @throws MissingConnectionException
*/
public function connect()
{
if ($this->connected !== true) {
if (Set::check($this->config, 'login')) {
$this->config = Set::insert($this->config, 'request.uri.user', Set::get($this->config, 'login'));
}
if (Set::check($this->config, 'password')) {
$this->config = Set::insert($this->config, 'request.uri.pass', Set::get($this->config, 'password'));
}
try {
$this->Socket = new HttpSocket($this->config);
$this->connected = true;
} catch (SocketException $e) {
throw new MissingConnectionException(array('class' => $e->getMessage()));
}
}
return $this->connected;
}
示例8: view
/**
* view method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function view($id = null)
{
if (!$this->User->exists($id)) {
throw new NotFoundException(__('Usuário Inválido!'));
}
$options = array('conditions' => array('User.' . $this->User->primaryKey => $id));
$this->set('user', $this->User->find('first', $options));
//Obtendo os grupos que este usuário pertence.
$belongs = $this->Acl->Aro->query("SELECT Aro.id, Aro.parent_id, parent.image_path, parent.name\n FROM aros AS Aro\n INNER JOIN ( SELECT aros.id, all_groups.image_path, all_groups.name \n FROM aros \n INNER JOIN ( SELECT groups.id, groups.image_path, groups.name FROM groups ) AS all_groups \n ON aros.foreign_key = all_groups.id ) AS parent \n ON Aro.parent_id = parent.id \n WHERE Aro.model = 'User' AND Aro.foreign_key = " . $id);
$this->set('belongs', $belongs);
//debug($belongs);
//lista de grupos.
$this->loadModel('Group');
$groups = $this->Group->find('list');
$this->set(compact('groups'));
//Obtendo as permissões do usuário.
$this->loadModel('Page');
$pages = $this->Page->find('all', array('conditions' => array('Page.enable' => 1), 'order' => 'Page.name'));
//debug($pages);
$lista = array();
$aros_aco_id = NULL;
$aco_parent_id = NULL;
foreach ($pages as $page) {
//Check permissão
$check_permission = $this->Acl->check(array('User' => array('id' => $id)), array('Page' => array('id' => $page['Page']['id'])));
//permissões diretas
$direct_permission = $this->Acl->Aco->Permission->find('first', array('conditions' => array('Aco.model' => 'Page', 'Aco.foreign_key' => $page['Page']['id'], 'Aro.model' => 'User', 'Aro.foreign_key' => $id)));
//debug($direct_permission);
if (Set::check($direct_permission, 'Permission')) {
$aco_parent_id = $direct_permission['Aco']['parent_id'];
$aros_aco_id = $direct_permission['Permission']['id'];
$direct_permission = true;
}
$page_acos = $this->Acl->Aco->find('first', array('conditions' => array('Aco.model' => 'Page', 'Aco.foreign_key' => $page['Page']['id']), 'fields' => 'Aco.parent_id'));
$aco_parent_id = $page_acos['Aco']['parent_id'];
//debug($aco_parent_id);
$lista[] = array('aco_parent_id' => $aco_parent_id, 'aros_aco_id' => $aros_aco_id, 'page_id' => $page['Page']['id'], 'pageName' => $page['Page']['name'], 'check_permission' => $check_permission, 'direct_permission' => $direct_permission);
$aros_aco_id = NULL;
$aco_parent_id = NULL;
}
$this->set('permissions', $lista);
//debug($lista);
//debug($this->Acl->Aco->Permission->find('all'));
}
示例9: add
/**
* Add a menu item
*
* @param string $path dot separated path in the array.
* @param array $options menu options array
* @return void
*/
public static function add($path, $options)
{
$pathE = explode('.', $path);
$pathE = array_splice($pathE, 0, count($pathE) - 2);
$parent = join('.', $pathE);
if (!empty($parent) && !Set::check(self::$_items, $parent)) {
$title = Inflector::humanize(end($pathE));
$o = array('title' => $title);
self::_setupOptions($o);
self::add($parent, $o);
}
self::_setupOptions($options);
$current = Set::extract($path, self::$_items);
if (!empty($current)) {
self::_replace(self::$_items, $path, $options);
} else {
self::$_items = Set::insert(self::$_items, $path, $options);
}
}
示例10: getMinimalData
function getMinimalData(&$model, $fields, $data = null, $findOptions = array(), $priorityRes = true)
{
if (is_null($data)) {
$data = $model->data;
}
//debug($data);
//////// get fields and contain ////////
$contain = array();
$findFields = array();
foreach ($fields as &$field) {
if (substr($field, 0, strlen($model->alias) + 1) == $model->alias . '.') {
$findFields[] = $field;
$field = $model->alias . '.' . $field;
} elseif (($pos = strrpos($field, '.')) == false) {
$findFields[] = $model->alias . '.' . $field;
} else {
$path = substr($field, 0, $pos);
$depth = count(explode('.', $path));
$f = substr($field, $pos + 1);
if ($depth > 1) {
$contain = Set::insert($contain, $path . '.fields', array('id', $f));
} else {
$contain = Set::insert($contain, $path, array());
if (!in_array($path . '.id', $findFields)) {
$findFields[] = $path . '.id';
}
$findFields[] = $field;
}
}
}
if (!in_array($model->alias . '.id', $findFields)) {
$findFields[] = $model->alias . '.id';
}
//////// normalize Data ////////
list($data, $oldFormat) = $model->unifiedResult($data, null, null, true);
App::import('Lib', 'SetMulti');
$data = SetMulti::group($data, $model->alias . '.id', array('singleArray' => false));
//debug($data);
//////// get ids ////////
$ids = array();
foreach ($data as $entry) {
foreach ($fields as $field) {
if (!Set::check($entry, $field)) {
$ids[] = $entry[$model->alias]['id'];
continue 2;
}
}
}
//////// query ////////
$findOpt = array('fields' => $findFields, 'conditions' => array($model->alias . '.id' => $ids), 'contain' => $contain);
$findOpt = array_merge($findOpt, $findOptions);
//debug($findOpt);
$completion = $model->find('all', $findOpt);
//debug($completion);
//////// merge data ////////
foreach ($completion as $c) {
$id = $c[$model->alias]['id'];
if ($priorityRes) {
$data[$id] = Set::merge($data[$id], $c);
} else {
$data[$id] = Set::merge($c, $data[$id]);
}
}
$data = array_values($data);
$data = $this->unifiedResult($model, $data, null, $oldFormat);
//debug($data);
return $data;
}
示例11: get_more_params
function get_more_params($excepts = array())
{
$datas = $_GET;
$excepts = am($this->excepts, array('page'));
//On va parcourir les exemptions
foreach ($excepts as $except) {
if (Set::check($_GET, $except)) {
$datas = Set::remove($datas, $except);
$exceptPath = explode('.', $except);
if (count(Set::classicExtract($datas, $exceptPath[0])) == 0) {
$datas = Set::remove($datas, $exceptPath[0]);
}
}
}
$moreParams = '';
if (count($datas) > 0) {
$moreParams = $this->_recursive_params($datas);
}
return $moreParams;
}
示例12: _is_valid_value
/**
* Cette fonction est en charge de contrôler la valeur d'un champ est valide
*
* @param varchar $valueToCheck Valeur du champ à contrôler
* @param varchar $validationRule Règle de validation
* @param array $insertErrorIn Indique le chemin pour l'insertion de l'erreur
* @param array $errors Erreurs
* @return array Tableau d'erreurs
* @access protected
* @author koéZionCMS
* @version 0.1 - 20/03/2015
*/
protected function _is_valid_value($valueToCheck, $validationRule, $insertErrorIn, $errors)
{
include CONFIGS . DS . 'messages.php';
//Inclusion des éventuels messages d'erreurs
$isValid = $this->Validation->check($valueToCheck, $validationRule['rule']);
//Lancement de la règle
$allowEmpty = $validationRule['allowEmpty'] && empty($valueToCheck);
//Génération du booléen allowEmpty
//On injecte le message en cas d'erreur
if (!$isValid && !$allowEmpty) {
if (Set::check($Errorsmessages, $validationRule['message'])) {
$errors[$insertErrorIn] = Set::classicExtract($Errorsmessages, $validationRule['message']);
} else {
$errors[$insertErrorIn] = $validationRule['message'];
}
}
return $errors;
}
示例13: testWritingWithFunkyKeys
function testWritingWithFunkyKeys()
{
$set = new Set();
$set->insert('Session Test', "test");
$this->assertEqual($set->extract('Session Test'), 'test');
$set->remove('Session Test');
$this->assertFalse($set->check('Session Test'));
$this->assertTrue($set->insert('Session Test.Test Case', "test"));
$this->assertTrue($set->check('Session Test.Test Case'));
}
示例14: dma_codes
public function dma_codes()
{
$this->loadStuff();
$month = false;
$year = false;
$domain_id = false;
$sql_filter = '';
if (Set::check($this->request->data, "Filters.report_month.month")) {
$month = $this->request->data['Filters']['report_month']['month'];
} else {
$month = $this->request->data['Filters']['report_month']['month'] = date("m");
}
//get the year
if (Set::check($this->request->data, "Filters.report_year.year")) {
$year = $this->request->data['Filters']['report_year']['year'];
} else {
$year = $this->request->data['Filters']['report_year']['year'] = date("Y");
}
//get the domain id
if (Set::check($this->request->data, "Filters.dim_domain_id")) {
$domain_id = $this->request->data['Filters']['dim_domain_id'];
}
//make the pv report
$report = $this->FactPageView->query("SELECT COUNT(*) AS `total`,DimDmaCode.dma_code,DimDmaCode.dma_location\n\t\t\tFROM fact_page_views AS `FactPageView` \n\t\t\tINNER JOIN dim_dates AS `DimDate` ON (DimDate.id = FactPageView.dim_date_id)\n\t\t\tINNER JOIN dim_domains AS `DimDomain` ON (DimDomain.id = FactPageView.dim_domain_id)\n\t\t\tINNER JOIN dim_dma_codes AS `DimDmaCode` ON (DimDmaCode.id = FactPageView.dim_dma_code_id)\n\t\t\tWHERE DimDate.report_month = '{$month}' AND DimDate.report_year = '{$year}' {$sql_filter}\n\t\t\tGROUP BY DimDmaCode.dma_code\n\t\t\tORDER BY total DESC");
$uniques = $this->FactPageView->query("SELECT COUNT(*) AS `total`,dma_code\n\t\t\tFROM (\n\t\t\t\tSELECT DISTINCT(session),DimDmaCode.dma_code AS `dma_code`\n\t\t\t\tFROM fact_page_views AS `FactPageView`\n\t\t\t\tINNER JOIN dim_dates AS `DimDate` ON (DimDate.id = FactPageView.dim_date_id)\n\t\t\t\tINNER JOIN dim_domains AS `DimDomain` ON (DimDomain.id = FactPageView.dim_domain_id)\n\t\t\t\tINNER JOIN dim_dma_codes AS `DimDmaCode` ON (DimDmaCode.id = FactPageView.dim_dma_code_id)\n\t\t\t\tWHERE DimDate.report_month = '{$month}' AND DimDate.report_year = '{$year}' {$sql_filter}\n\t\t\t) AS Traffic\n\t\t\tGROUP BY dma_code");
$berra = $this->FactPageView->query("SELECT SUM(uniques) AS `total`,dma_code\n\t\t\tFROM (\n\t\t\t\tSELECT COUNT(*) AS `uniques`,dma_code,report_hour,report_day\n\t\t\t\tFROM (\n\t\t\t\t\tSELECT DISTINCT(session),DimDmaCode.dma_code AS `dma_code`,DimDate.report_day AS `report_day`,DimDate.report_hour AS `report_hour`\n\t\t\t\t\tFROM fact_page_views AS `FactPageView`\n\t\t\t\t\tINNER JOIN dim_dates AS `DimDate` ON (DimDate.id = FactPageView.dim_date_id)\n\t\t\t\t\tINNER JOIN dim_domains AS `DimDomain` ON (DimDomain.id = FactPageView.dim_domain_id)\n\t\t\t\t\tINNER JOIN dim_dma_codes AS `DimDmaCode` ON (DimDmaCode.id = FactPageView.dim_dma_code_id)\n\t\t\t\t\tWHERE DimDate.report_month = '{$month}' AND DimDate.report_year = '{$year}' {$sql_filter}\n\t\t\t\t) AS Traffic\n\t\t\t\tGROUP BY dma_code,report_day,report_hour\n\t\t\t) AS Traffic\n\t\t\tGROUP BY dma_code");
$unq = array();
$b_unq = array();
foreach ($uniques as $v) {
$unq[$v['Traffic']['dma_code']] = $v[0]['total'];
}
foreach ($berra as $v) {
$b_unq[$v['Traffic']['dma_code']] = $v[0]['total'];
}
//fill in the report
foreach ($report as $k => $v) {
$report[$k][0]['uniques'] = $unq[$v['DimDmaCode']['dma_code']];
$report[$k][0]['berra'] = $b_unq[$v['DimDmaCode']['dma_code']];
}
//get some select lists
$domainList = $this->DimDomain->selectList();
$this->set(compact("report", "domainList"));
}
示例15: _multiParseAttributes
function _multiParseAttributes($data, $keys, $default = array())
{
$def = array('exclude' => null, 'insertBefore' => ' ', 'insertAfter' => null, 'isolate' => false);
$def = array_merge($def, $default);
if ($def['isolate']) {
$attrs = array();
} else {
$attrs = $data;
}
foreach (Set::normalize($keys) as $key => $opt) {
$opt = array_merge($def, (array) $opt);
if (Set::check($data, $key)) {
$parsed = false;
$unparsed = Set::extract($key, $data);
if ($unparsed !== false) {
$parsed = $this->_parseAttributes($unparsed, $opt['exclude'], $opt['insertBefore'], $opt['insertAfter']);
}
$attrs = Set::insert($attrs, $key, $parsed);
}
}
return $attrs;
}