本文整理汇总了PHP中arr::take方法的典型用法代码示例。如果您正苦于以下问题:PHP arr::take方法的具体用法?PHP arr::take怎么用?PHP arr::take使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arr
的用法示例。
在下文中一共展示了arr::take方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public static function execute()
{
if ($uri = trim(router::$uri, '/')) {
router::$arguments = explode('/', $uri);
router::$module = array_shift(router::$arguments);
router::$controller = array_shift(router::$arguments);
router::$action = array_shift(router::$arguments);
} else {
//当$uri 为空,则尝试Query_string模式
router::$arguments = $_GET;
router::$module = arr::take('module', router::$arguments);
router::$controller = arr::take('controller', router::$arguments);
router::$action = arr::take('action', router::$arguments);
}
}
示例2: render
public static function render($datas = array(), $attrs = array())
{
$datas = empty($datas) ? table::$datas : $datas;
$attrs = empty($attrs) ? table::$attrs : $attrs;
$titles = arr::take('titles', $attrs);
$footer = table::$footer;
$attrs['class'] = empty($attrs['class']) ? 'table' : 'table ' . $attrs['class'];
//渲染表格
$html[] = '';
$html[] = '<table' . html::attributes($attrs) . '>';
if (is_array($titles)) {
$html[] = ' <thead>';
$html[] = ' <tr class="title">';
foreach ($titles as $name => $title) {
$html[] = ' <th class="' . $name . '"><b>' . $title . '</b></th>';
}
$html[] = ' </tr>';
$html[] = ' </thead>';
}
$html[] = ' <tbody>';
if (is_array($datas) && !empty($datas)) {
$i = 0;
foreach ($datas as $row) {
$html[] = '';
$html[] = ' <tr class="item ' . ($i % 2 == 0 ? 'odd' : 'even') . ' ' . $row['class'] . '">';
foreach ($row['data'] as $key => $value) {
if (is_string($value)) {
$html[] = ' <td class="' . $key . '">' . $value . '</td>';
} else {
$data = arr::take('value', $value);
$html[] = ' <td' . html::attributes($value) . '>' . $data . '</td>';
}
}
$html[] = ' </tr>';
$i++;
}
} else {
$html[] = ' <tr><td colspan="' . count($titles) . '"><div class="zotop-empty">' . zotop::t('未能找到符合要求的数据') . '</div></td></tr>';
}
$html[] = ' </tbody>';
if (!empty($footer)) {
$html[] = ' <tr class="footer"><td colspan="' . count($titles) . '">' . $footer . '</td></tr>';
}
$html[] = '</table>';
return implode("\n", $html);
}
示例3: xheditor_rc1
function xheditor_rc1($attrs)
{
$attrs['class'] = isset($attrs['class']) ? 'editor ' . $attrs['class'] : 'editor';
$tools = array('image' => '<a href="' . zotop::url('system/image/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-imageuploader button-icon"></span><span class="button-text">插入图片</span></a>', 'file' => '<a href="' . zotop::url('system/file/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-fileuploader button-icon"></span><span class="button-text">插入文件</span></a>', 'template' => '<a href="' . zotop::url('system/file/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-template button-icon"></span><span class="button-text">插入模板</span></a>');
$tools = zotop::filter('editor.tools', $tools);
$tools = arr::take('tools', $attrs) === false ? array() : $tools;
$url = zotop::module('xheditor', 'url');
$html[] = html::script($url . '/editor/xheditor-zh-cn.min.js');
$html[] = html::script($url . '/common/global.js');
if (is_array($tools) && !empty($tools)) {
$html[] = '<div class="field-toolbar">';
foreach ($tools as $tool) {
$html[] = ' ' . $tool;
}
$html[] = '</div>';
}
$html[] = ' ' . field::textarea($attrs);
return implode("\n", $html);
}
示例4: row
public static function row($rows, $classname = '')
{
static $i = 0;
if (is_array($rows)) {
$html[] = '';
$html[] = ' <tr class="item ' . ($i % 2 == 0 ? 'odd' : 'even') . ' ' . $classname . '">';
foreach ($rows as $key => $value) {
if (is_string($value)) {
$html[] = ' <td class="' . $key . '">' . $value . '</td>';
} else {
$inner = arr::take('inner', $value);
$html[] = ' <td class="' . $key . '" ' . html::attributes($value) . '>' . $inner . '</td>';
}
}
$html[] = ' </tr>';
$i++;
}
echo implode("\n", $html);
}
示例5: edit
public function edit($data, $id)
{
$data['updatetime'] = TIME;
$data['link'] = (int) $data['link'];
$color = arr::take('title_color', $data);
$weight = arr::take('title_weight', $data);
$data['style'] = (empty($color) ? '' : 'color:' . $color . ';') . (empty($weight) ? '' : 'font-weight:' . $weight . ';');
if (empty($data['title'])) {
$this->error(1, '标题不能为空');
return false;
}
if (!$data['link'] && empty($data['content'])) {
$this->error(1, '内容不能为空');
return false;
}
if ($data['link'] && empty($data['url'])) {
$this->error(1, '转向链接不能为空');
return false;
}
$this->update($data);
}
示例6: execute
/**
* 解析URI
*
* URI 由模块名/控制器/动作/参数组成,采用如下的格式:
*
* @code php
* module/controller/action/param1/vlaue1/param2/value2
* @endcode
*
*/
public static function execute()
{
if ($uri = trim(router::$uri, '/')) {
router::$arguments = explode('/', $uri);
//分配module、controller、action
router::$module = array_shift(router::$arguments);
router::$controller = array_shift(router::$arguments);
router::$action = array_shift(router::$arguments);
//处理参数
$arguments = array();
for ($i = 0, $cnt = count(router::$arguments); $i < $cnt; $i++) {
$arguments[$i] = rawurldecode(router::$arguments[$i]);
}
router::$arguments = $arguments;
//unset($_GET['zotop']);
//$_GET = array_merge($_GET, array('module'=>router::$module,'controller'=>router::$controller,'action'=>router::$action), $arguments);
} else {
//当$uri 为空,则尝试Query_string模式
router::$arguments = $_GET;
router::$module = arr::take('module', router::$arguments);
router::$controller = arr::take('controller', router::$arguments);
router::$action = arr::take('action', router::$arguments);
}
}
示例7: edit
public function edit($data, $id)
{
$data['updatetime'] = TIME;
$data['link'] = (int) $data['link'];
$color = arr::take('title_color', $data);
$weight = arr::take('title_weight', $data);
$data['style'] = (empty($color) ? '' : 'color:' . $color . ';') . (empty($weight) ? '' : 'font-weight:' . $weight . ';');
if (empty($data['title'])) {
$this->error('标题不能为空');
return false;
}
if (!$data['link'] && empty($data['content'])) {
$this->error('内容不能为空');
return false;
}
if ($data['link'] && empty($data['url'])) {
$this->error('转向链接不能为空');
return false;
}
$this->update($data, $id);
//更新文件全局编号和状态
$file = zotop::model('system.file');
$file->refresh($this->globalid($id));
}
示例8: control
public static function control($attrs)
{
$html[] = '';
if (is_array($attrs)) {
$type = arr::take('type', $attrs);
$type = isset($type) ? $type : 'text';
$html[] = field::get($type, $attrs);
} else {
$html[] = $attrs;
}
return implode("\n", $html);
}
示例9: group
/**
* 控件组
*
* @param $attrs array 控件参数
* @return string 控件代码
*/
public static function group($attrs)
{
$html[] = '<div class="field-group">';
$fields = arr::take('fields', $attrs);
if (is_array($fields)) {
foreach ($fields as $field) {
if (is_array($field)) {
$type = arr::take('type', $field);
$type = isset($type) ? $type : 'text';
$field['class'] = isset($field['class']) ? 'short ' . $field['class'] : 'short';
$html[] = ' <div class="field-group-item">';
$html[] = ' <label for="' . $field['name'] . '">' . arr::take('label', $field) . '</label>';
$html[] = ' ' . field::get($type, $field);
$html[] = ' </div>';
} else {
$html[] = $field;
}
}
} else {
$html[] = $fields;
}
$html[] = '</div>';
return implode("\n", $html);
}
示例10: description
public static function description(&$attrs)
{
$description = arr::take('description', $attrs);
if ($description) {
return '<span class="field-description">' . $description . '</span>';
}
return '';
}
示例11: checkbox
public static function checkbox($attrs, $value = '', $checked = false, $label = '')
{
if (!is_array($attrs)) {
$attrs = array('name' => $attrs, 'value' => $value, 'checked' => $checked, 'label' => $label);
}
$attrs['type'] = 'checkbox';
$attrs['id'] = empty($attrs['id']) ? $attrs['name'] : $attrs['id'];
if ($checked == TRUE or isset($attrs['checked']) and $attrs['checked'] == TRUE) {
$attrs['checked'] = 'checked';
} else {
unset($attrs['checked']);
}
$label = arr::take('label', $attrs);
$label = empty($label) ? '' : ' <label for="' . $attrs['id'] . '">' . $label . '</label>';
return html::input($attrs) . $label;
}
示例12: array_take
/**
* 数组arr::take的重写,从数组中弹出键,类似于array_pop,但是是根据键名弹出
*
* @param string $key 弹出的键名
* @param array $array 目标数组
* @param boolean $bool 是否区分大小写
* @return $mix 被弹出 的数据
*/
function array_take($key, &$array, $bool = TRUE)
{
return arr::take($key, $array, $bool);
}