本文整理汇总了PHP中array_key_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP array_key_exists函数的具体用法?PHP array_key_exists怎么用?PHP array_key_exists使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_key_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionEdit
public function actionEdit($id)
{
$this->pageTitle = Yii::t('app', 'Редактирование категории');
$model = ShopCategories::model()->findByPk($id);
if (!$model) {
throw new CHttpException(404, Yii::t('app', 'Категория не найдена'));
}
//var_dump($model->url);die;
// var_dump($model->path);die;
//var_dump($model->breadcrumbs);
//die;
$this->breadcrumbs = array_merge($this->breadcrumbs, array('Редактирование категории "' . $model->title . '"'));
$possibleParents = $model->getPossibleParents();
if (!empty($_POST) && array_key_exists('ShopCategories', $_POST)) {
$this->performAjaxValidation($model);
$model->attributes = $_POST['ShopCategories'];
//var_dump($model->attributes);die;
if ($model->validate()) {
if ($model->save()) {
Yii::app()->user->setFlash('success', 'Категория "' . $model->title . '" успешно отредактирована');
Yii::app()->request->redirect($this->createUrl('index'));
}
}
}
//var_dump($possibleParents);die;
$this->render('edit', array('model' => $model, 'possibleParents' => $possibleParents));
}
示例2: __construct
function __construct($config = array())
{
parent::__construct($config);
if (array_key_exists('multi', $config)) {
$this->set_multi($config['multi']);
}
}
示例3: post_save
/**
* Save Force SSL option to post or page
*
* @param int $post_id
* @return int $post_id
*/
public function post_save($post_id)
{
if (array_key_exists($this->getPlugin()->getSlug(), $_POST)) {
if (!wp_verify_nonce($_POST[$this->getPlugin()->getSlug()], $this->getPlugin()->getSlug())) {
return $post_id;
}
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
if (@$_POST['post_type'] == 'page') {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} else {
if (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
}
$force_ssl = @$_POST['force_ssl'] == 1 ? true : false;
if ($force_ssl) {
update_post_meta($post_id, 'force_ssl', 1);
} else {
delete_post_meta($post_id, 'force_ssl');
}
$force_ssl_children = @$_POST['force_ssl_children'] == 1 ? true : false;
if ($force_ssl_children) {
update_post_meta($post_id, 'force_ssl_children', 1);
} else {
delete_post_meta($post_id, 'force_ssl_children');
}
}
return $post_id;
}
示例4: apply
/**
* {@inheritdoc}
*/
public function apply(DataSourceInterface $dataSource, $name, $data, array $options)
{
$expressionBuilder = $dataSource->getExpressionBuilder();
if (is_array($data) && !isset($data['type'])) {
$data['type'] = isset($options['type']) ? $options['type'] : self::TYPE_CONTAINS;
}
if (!is_array($data)) {
$data = ['type' => self::TYPE_CONTAINS, 'value' => $data];
}
$fields = array_key_exists('fields', $options) ? $options['fields'] : [$name];
$type = $data['type'];
$value = array_key_exists('value', $data) ? $data['value'] : null;
if (!in_array($type, [self::TYPE_NOT_EMPTY, self::TYPE_EMPTY], true) && '' === trim($value)) {
return;
}
if (1 === count($fields)) {
$dataSource->restrict($this->getExpression($expressionBuilder, $type, current($fields), $value));
return;
}
$expressions = [];
foreach ($fields as $field) {
$expressions[] = $this->getExpression($expressionBuilder, $type, $field, $value);
}
$dataSource->restrict($expressionBuilder->orX(...$expressions));
}
示例5: getCoupon
/**
* @return array
*/
public function getCoupon()
{
if (!array_key_exists('coupon', $this->request)) {
return array();
}
return $this->request['coupon'];
}
示例6: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$__internal_7088dc18de042b162a99a327c85232e1f7c79938f5c6e62a2f20a47464d52c5f = $this->env->getExtension("native_profiler");
$__internal_7088dc18de042b162a99a327c85232e1f7c79938f5c6e62a2f20a47464d52c5f->enter($__internal_7088dc18de042b162a99a327c85232e1f7c79938f5c6e62a2f20a47464d52c5f_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "WebProfilerBundle:Profiler:toolbar_item.html.twig"));
// line 1
if (isset($context["link"]) ? $context["link"] : $this->getContext($context, "link")) {
// line 2
echo " ";
ob_start();
// line 3
echo " <a href=\"";
echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("_profiler", array("token" => isset($context["token"]) ? $context["token"] : $this->getContext($context, "token"), "panel" => isset($context["name"]) ? $context["name"] : $this->getContext($context, "name"))), "html", null, true);
echo "\">";
echo twig_escape_filter($this->env, isset($context["icon"]) ? $context["icon"] : $this->getContext($context, "icon"), "html", null, true);
echo "</a>\n ";
$context["icon"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
}
// line 6
echo "<div class=\"sf-toolbar-block\">\n <div class=\"sf-toolbar-icon\">";
// line 7
echo twig_escape_filter($this->env, array_key_exists("icon", $context) ? _twig_default_filter(isset($context["icon"]) ? $context["icon"] : $this->getContext($context, "icon"), "") : "", "html", null, true);
echo "</div>\n <div class=\"sf-toolbar-info\">";
// line 8
echo twig_escape_filter($this->env, array_key_exists("text", $context) ? _twig_default_filter(isset($context["text"]) ? $context["text"] : $this->getContext($context, "text"), "") : "", "html", null, true);
echo "</div>\n</div>\n";
$__internal_7088dc18de042b162a99a327c85232e1f7c79938f5c6e62a2f20a47464d52c5f->leave($__internal_7088dc18de042b162a99a327c85232e1f7c79938f5c6e62a2f20a47464d52c5f_prof);
}
开发者ID:valeriemontoya90,项目名称:findWorker,代码行数:27,代码来源:8d4635b47ab8ab3bf3352cb81a02e822f23088a5da0711f03c5ad81c103fe122.php
示例7: has_attribute
private function has_attribute($attribute)
{
// get object_vars return an associative array with all attributes
$object_vars = get_object_vars($this);
// will not care the value only whether the key is exists
return array_key_exists($attribute, $object_vars);
}
示例8: getInstance
/**
* Returns class instance.
*
* @param string $type the table type
*
* @return PMA_RecentFavoriteTable
*/
public static function getInstance($type)
{
if (!array_key_exists($type, self::$_instances)) {
self::$_instances[$type] = new PMA_RecentFavoriteTable($type);
}
return self::$_instances[$type];
}
示例9: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$__internal_f6fbb0d538f0cf945a7cc2537fcd6ea50556067234df0d59685d58ab6cd80c70 = $this->env->getExtension("native_profiler");
$__internal_f6fbb0d538f0cf945a7cc2537fcd6ea50556067234df0d59685d58ab6cd80c70->enter($__internal_f6fbb0d538f0cf945a7cc2537fcd6ea50556067234df0d59685d58ab6cd80c70_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "@WebProfiler/Profiler/toolbar_item.html.twig"));
// line 1
if (isset($context["link"]) ? $context["link"] : $this->getContext($context, "link")) {
// line 2
echo " ";
ob_start();
// line 3
echo " <a href=\"";
echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("_profiler", array("token" => isset($context["token"]) ? $context["token"] : $this->getContext($context, "token"), "panel" => isset($context["name"]) ? $context["name"] : $this->getContext($context, "name"))), "html", null, true);
echo "\">";
echo twig_escape_filter($this->env, isset($context["icon"]) ? $context["icon"] : $this->getContext($context, "icon"), "html", null, true);
echo "</a>\n ";
$context["icon"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
}
// line 6
echo "<div class=\"sf-toolbar-block\">\n <div class=\"sf-toolbar-icon\">";
// line 7
echo twig_escape_filter($this->env, array_key_exists("icon", $context) ? _twig_default_filter(isset($context["icon"]) ? $context["icon"] : $this->getContext($context, "icon"), "") : "", "html", null, true);
echo "</div>\n <div class=\"sf-toolbar-info\">";
// line 8
echo twig_escape_filter($this->env, array_key_exists("text", $context) ? _twig_default_filter(isset($context["text"]) ? $context["text"] : $this->getContext($context, "text"), "") : "", "html", null, true);
echo "</div>\n</div>\n";
$__internal_f6fbb0d538f0cf945a7cc2537fcd6ea50556067234df0d59685d58ab6cd80c70->leave($__internal_f6fbb0d538f0cf945a7cc2537fcd6ea50556067234df0d59685d58ab6cd80c70_prof);
}
开发者ID:NotBadCode,项目名称:FinanceTest,代码行数:27,代码来源:02d42ef81b938fabb9028e93c7663e4c7dcdca2fdae35e978661f8a8aa0ccd29.php
示例10: get
/**
* Get an attribute from the container.
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function get($key, $default = null)
{
if (array_key_exists($key, $this->attributes)) {
return $this->attributes[$key];
}
return Misc::value($default);
}
示例11: errors
/**
* Returns an array of fields that have failed validation. On the current model. This method will
* actually run validation rules over data, not just return the messages.
*
* @param array $data The data to be checked for errors
* @param bool $newRecord whether the data to be validated is new or to be updated.
* @return array Array of invalid fields
* @see Validator::validates()
*/
public function errors(array $data, $newRecord = true)
{
$errors = [];
$requiredMessage = __d('cake', 'This field is required');
$emptyMessage = __d('cake', 'This field cannot be left empty');
foreach ($this->_fields as $name => $field) {
$keyPresent = array_key_exists($name, $data);
if (!$keyPresent && !$this->_checkPresence($field, $newRecord)) {
$errors[$name][] = isset($this->_presenceMessages[$name]) ? $this->_presenceMessages[$name] : $requiredMessage;
continue;
}
if (!$keyPresent) {
continue;
}
$providers = $this->_providers;
$context = compact('data', 'newRecord', 'field', 'providers');
$canBeEmpty = $this->_canBeEmpty($field, $context);
$isEmpty = $this->_fieldIsEmpty($data[$name]);
if (!$canBeEmpty && $isEmpty) {
$errors[$name][] = isset($this->_allowEmptyMessages[$name]) ? $this->_allowEmptyMessages[$name] : $emptyMessage;
continue;
}
if ($isEmpty) {
continue;
}
$result = $this->_processRules($name, $field, $data, $newRecord);
if ($result) {
$errors[$name] = $result;
}
}
return $errors;
}
示例12: isValid
public function isValid()
{
switch ($this->method) {
case self::METHOD_CREATE_LIST:
return array_key_exists('LIST_ID', $this->data) && $this->data['LIST_ID'] > 0;
break;
case self::METHOD_ADD_SUBSCRIBER:
return array_key_exists('UID', $this->data);
break;
case self::METHOD_GET_SENDERS:
return true;
break;
case self::METHOD_CREATE_CAMPAIGN_EMAIL:
case self::METHOD_CREATE_CAMPAIGN_SMS:
case self::METHOD_CREATE_CAMPAIGN_VOICE:
return array_key_exists('id', $this->data);
break;
case self::METHOD_SEND_SMS:
case self::METHOD_SEND_CALL:
case self::METHOD_SEND_EMAIL:
return !array_key_exists('ERROR', $this->data);
break;
case self::METHOD_ADD_SUBSCRIBER_BULK:
return $this->data['RESULT'] == 'OK';
break;
default:
return false;
}
}
示例13: editor
/**
* dijit.Editor
*
* @param string $id
* @param string $value
* @param array $params
* @param array $attribs
* @return string
*/
public function editor($id, $value = null, $params = array(), $attribs = array())
{
if (isset($params['plugins'])) {
foreach ($this->_getRequiredModules($params['plugins']) as $module) {
$this->dojo->requireModule($module);
}
}
// Previous versions allowed specifying "degrade" to allow using a
// textarea instead of a div -- but this is insecure. Removing the
// parameter if set to prevent its injection in the dijit.
if (isset($params['degrade'])) {
unset($params['degrade']);
}
$hiddenName = $id;
if (array_key_exists('id', $attribs)) {
$hiddenId = $attribs['id'];
} else {
$hiddenId = $hiddenName;
}
$hiddenId = $this->_normalizeId($hiddenId);
$textareaName = $this->_normalizeEditorName($hiddenName);
$textareaId = $hiddenId . '-Editor';
$hiddenAttribs = array('id' => $hiddenId, 'name' => $hiddenName, 'value' => $value, 'type' => 'hidden');
$attribs['id'] = $textareaId;
$this->_createGetParentFormFunction();
$this->_createEditorOnSubmit($hiddenId, $textareaId);
$attribs = $this->_prepareDijit($attribs, $params, 'textarea');
$html = '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket();
$html .= '<div' . $this->_htmlAttribs($attribs) . '>' . $value . "</div>\n";
// Embed a textarea in a <noscript> tag to allow for graceful
// degradation
$html .= '<noscript>' . $this->view->formTextarea($hiddenId, $value, $attribs) . '</noscript>';
return $html;
}
示例14: search
/**
* search user/corporation or alliance by name
* @param $f3
* @param $params
*/
public function search($f3, $params)
{
$accessData = [];
if (array_key_exists('arg1', $params) && array_key_exists('arg2', $params)) {
$searchType = strtolower($params['arg1']);
$searchToken = strtolower($params['arg2']);
$accessModel = null;
switch ($searchType) {
case 'user':
$accessModel = Model\BasicModel::getNew('UserModel');
break;
case 'corporation':
$accessModel = Model\BasicModel::getNew('CorporationModel');
break;
case 'alliance':
$accessModel = Model\BasicModel::getNew('AllianceModel');
break;
}
if (is_object($accessModel)) {
// find "active" entries that have their "sharing" option activated
$accessList = $accessModel->find(array("LOWER(name) LIKE :token AND " . "active = 1 AND " . "shared = 1 ", ':token' => '%' . $searchToken . '%'));
if ($accessList) {
foreach ($accessList as $accessObject) {
$accessData[] = $accessObject->getData();
}
}
}
}
echo json_encode($accessData);
}
示例15: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$__internal_820209f0de803f23c5c55988658f5e579064679e98e57a683a7a6b5b5e40ae76 = $this->env->getExtension("native_profiler");
$__internal_820209f0de803f23c5c55988658f5e579064679e98e57a683a7a6b5b5e40ae76->enter($__internal_820209f0de803f23c5c55988658f5e579064679e98e57a683a7a6b5b5e40ae76_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "@WebProfiler/Profiler/toolbar_item.html.twig"));
// line 1
echo "<div class=\"sf-toolbar-block sf-toolbar-block-";
echo twig_escape_filter($this->env, isset($context["name"]) ? $context["name"] : $this->getContext($context, "name"), "html", null, true);
echo " sf-toolbar-status-";
echo twig_escape_filter($this->env, array_key_exists("status", $context) ? _twig_default_filter(isset($context["status"]) ? $context["status"] : $this->getContext($context, "status"), "normal") : "normal", "html", null, true);
echo " ";
echo twig_escape_filter($this->env, array_key_exists("additional_classes", $context) ? _twig_default_filter(isset($context["additional_classes"]) ? $context["additional_classes"] : $this->getContext($context, "additional_classes"), "") : "", "html", null, true);
echo "\">\n ";
// line 2
if (array_key_exists("link", $context) ? _twig_default_filter(isset($context["link"]) ? $context["link"] : $this->getContext($context, "link"), true) : true) {
echo "<a href=\"";
echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("_profiler", array("token" => isset($context["token"]) ? $context["token"] : $this->getContext($context, "token"), "panel" => isset($context["name"]) ? $context["name"] : $this->getContext($context, "name"))), "html", null, true);
echo "\">";
}
// line 3
echo " <div class=\"sf-toolbar-icon\">";
echo twig_escape_filter($this->env, array_key_exists("icon", $context) ? _twig_default_filter(isset($context["icon"]) ? $context["icon"] : $this->getContext($context, "icon"), "") : "", "html", null, true);
echo "</div>\n ";
// line 4
if (array_key_exists("link", $context) ? _twig_default_filter(isset($context["link"]) ? $context["link"] : $this->getContext($context, "link"), true) : true) {
echo "</a>";
}
// line 5
echo " <div class=\"sf-toolbar-info\">";
echo twig_escape_filter($this->env, array_key_exists("text", $context) ? _twig_default_filter(isset($context["text"]) ? $context["text"] : $this->getContext($context, "text"), "") : "", "html", null, true);
echo "</div>\n</div>\n";
$__internal_820209f0de803f23c5c55988658f5e579064679e98e57a683a7a6b5b5e40ae76->leave($__internal_820209f0de803f23c5c55988658f5e579064679e98e57a683a7a6b5b5e40ae76_prof);
}
开发者ID:vodich,项目名称:platform,代码行数:32,代码来源:9c2a897d9c1e6daafd47c7a9f701f9746c956ddb486f22c51ad274ad4ca63c09.php