本文整理汇总了PHP中ArrayHelper::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper::remove方法的具体用法?PHP ArrayHelper::remove怎么用?PHP ArrayHelper::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayHelper
的用法示例。
在下文中一共展示了ArrayHelper::remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareContent
protected function prepareContent($content)
{
if (is_array($content)) {
if (!isset($content['class']) && isset($content[0])) {
$content['class'] = ArrayHelper::remove($content, 0);
}
if (!isset($content['options']) && isset($content[1])) {
if (is_bool($content[1])) {
$content['asButton'] = ArrayHelper::remove($content, 1);
} else {
$content['options'] = ArrayHelper::remove($content, 1);
}
}
if (!isset($content['asButton'])) {
$content['asButton'] = ArrayHelper::remove($content, 2, false);
}
$class = $content['class'];
$options = isset($content['options']) ? $content['options'] : [];
$asButton = $content['asButton'];
if ($asButton) {
Html::addCssClass($tagOptions, 'input-group-btn');
} else {
Html::addCssClass($tagOptions, 'input-group-addon');
}
if (class_exists($class)) {
$inContent = $class::widget($options);
} else {
$inContent = $class;
}
$content = Html::tag('span', $inContent, $tagOptions);
} else {
if ($content instanceof Widget) {
Html::addCssClass($tagOptions, 'input-group-btn');
} else {
Html::addCssClass($tagOptions, 'input-group-addon');
}
$content = Html::tag('span', $content, $tagOptions);
}
return $content;
}
示例2: activeHint
/**
* @inheritDoc
*/
public static function activeHint($model, $attribute, $options = [])
{
$hint = isset($options['hint']) ? $options['hint'] : '';
if (empty($hint)) {
return '';
}
$tag = ArrayHelper::remove($options, 'tag', 'div');
unset($options['hint']);
return static::tag($tag, $hint, $options);
}
示例3: getInput
/**
* Generates an input
*/
protected function getInput($type, $list = false, $armodel = false)
{
if (!$armodel) {
$armodel = $this->model;
}
if ($this->hasModel($armodel)) {
$input = 'active' . ucfirst($type);
$this->options = $this->name ? array_merge($this->options, ['name' => $this->name]) : $this->options;
return $list ? Html::$input($armodel, $this->attribute, $this->data, $this->options) : Html::$input($armodel, $this->attribute, $this->options);
}
$input = $type;
$checked = false;
if ($type == 'radio' || $type == 'checkbox') {
$this->options['value'] = $this->value;
$checked = ArrayHelper::remove($this->options, 'checked', false);
}
return $list ? Html::$input($this->name, $this->value, $this->data, $this->options) : ($type == 'checkbox' || $type == 'radio' ? Html::$input($this->name, $checked, $this->options) : Html::$input($this->name, $this->value, $this->options));
}
示例4: renderSelectOptions
public static function renderSelectOptions($selection, $items, &$tagOptions = [])
{
$lines = [];
$encodeSpaces = ArrayHelper::remove($tagOptions, 'encodeSpaces', false);
$encode = ArrayHelper::remove($tagOptions, 'encode', true);
if (isset($tagOptions['prompt'])) {
$prompt = $encode ? static::encode($tagOptions['prompt']) : $tagOptions['prompt'];
if ($encodeSpaces) {
$prompt = str_replace(' ', ' ', $prompt);
}
$lines[] = static::tag('option', $prompt, ['value' => '']);
}
$options = isset($tagOptions['options']) ? $tagOptions['options'] : [];
$groups = isset($tagOptions['groups']) ? $tagOptions['groups'] : [];
unset($tagOptions['prompt'], $tagOptions['options'], $tagOptions['groups']);
$options['encodeSpaces'] = ArrayHelper::getValue($options, 'encodeSpaces', $encodeSpaces);
$options['encode'] = ArrayHelper::getValue($options, 'encode', $encode);
foreach ($items as $key => $value) {
if (is_array($value)) {
$groupAttrs = isset($groups[$key]) ? $groups[$key] : [];
if (!isset($groupAttrs['label'])) {
$groupAttrs['label'] = $key;
}
$attrs = ['options' => $options, 'groups' => $groups, 'encodeSpaces' => $encodeSpaces, 'encode' => $encode];
$content = static::renderSelectOptions($selection, $value, $attrs);
$lines[] = static::tag('optgroup', "\n" . $content . "\n", $groupAttrs);
} else {
$attrs = isset($options[$key]) ? $options[$key] : [];
$attrs['value'] = (string) $key;
$attrs['selected'] = $selection !== null && (!is_array($selection) && !strcmp($key, $selection) || is_array($selection) && in_array($key, $selection));
$text = $encode ? static::encode($value) : $value;
if ($encodeSpaces) {
$text = str_replace(' ', ' ', $text);
}
$lines[] = static::tag('option', $text, $attrs);
}
}
return implode("\n", $lines);
}
示例5: process
public function process($image, $actions, $dir, $file, $render = FALSE)
{
// Set the "create" function
switch ($image['type']) {
case IMAGETYPE_JPEG:
$create = 'imagecreatefromjpeg';
break;
case IMAGETYPE_GIF:
$create = 'imagecreatefromgif';
break;
case IMAGETYPE_PNG:
$create = 'imagecreatefrompng';
break;
}
// Set the "save" function
switch (strtolower(substr(strrchr($file, '.'), 1))) {
case 'jpg':
case 'jpeg':
$save = 'imagejpeg';
break;
case 'gif':
$save = 'imagegif';
break;
case 'png':
$save = 'imagepng';
break;
}
// Make sure the image type is supported for import
if (empty($create) or !function_exists($create)) {
throw new CException('image type not allowed');
}
// Make sure the image type is supported for saving
if (empty($save) or !function_exists($save)) {
throw new CException('image type not allowed');
}
// Load the image
$this->image = $image;
// Create the GD image resource
$this->tmp_image = $create($image['file']);
// Get the quality setting from the actions
$quality = ArrayHelper::remove('quality', $actions);
if ($status = $this->execute($actions)) {
// Prevent the alpha from being lost
imagealphablending($this->tmp_image, TRUE);
imagesavealpha($this->tmp_image, TRUE);
switch ($save) {
case 'imagejpeg':
// Default the quality to 95
$quality === NULL and $quality = 95;
break;
case 'imagegif':
// Remove the quality setting, GIF doesn't use it
unset($quality);
break;
case 'imagepng':
// Always use a compression level of 9 for PNGs. This does not
// affect quality, it only increases the level of compression!
$quality = 9;
break;
}
if ($render === FALSE) {
// Set the status to the save return value, saving with the quality requested
$status = isset($quality) ? $save($this->tmp_image, $dir . $file, $quality) : $save($this->tmp_image, $dir . $file);
} else {
// Output the image directly to the browser
switch ($save) {
case 'imagejpeg':
header('Content-Type: image/jpeg');
break;
case 'imagegif':
header('Content-Type: image/gif');
break;
case 'imagepng':
header('Content-Type: image/png');
break;
}
$status = isset($quality) ? $save($this->tmp_image, NULL, $quality) : $save($this->tmp_image);
}
// Destroy the temporary image
imagedestroy($this->tmp_image);
}
return $status;
}