本文整理汇总了PHP中S::keys方法的典型用法代码示例。如果您正苦于以下问题:PHP S::keys方法的具体用法?PHP S::keys怎么用?PHP S::keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S
的用法示例。
在下文中一共展示了S::keys方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: typography
function typography($str)
{
$str = S::capitalize(trim($str));
if ($str === '') {
return $str;
}
$lb = '(?<=|\\.\\.\\.|[…\\s"\'«“‘‛‹\\/\\<[{(])';
// left boundary
$rb = '($|[…\\s"\'»„”’‛›\\/\\>\\]})?!.,:;])';
// right boundary
$regexp = array($lb . '"([^"]*)"' . $rb => '«\\1»\\2', $lb . '([+-]?\\d+)[\\s^](F|C)' . $rb => '\\1°\\2\\3', $lb . '\\+-(\\d+)' . $rb => '±\\1\\2', $lb . '([+-]?\\d+)\\.(\\d+)' . $rb => '\\1,\\2\\3', '\\.\\.\\.+' => '…', ' -+ ' => ' — ');
$regexp = S::keys($regexp, '#"~?~u"');
return preg_replace(array_keys($regexp), array_values($regexp), $str);
}
示例2: get_show
function get_show($id = null)
{
if ($order = Order::find($id)) {
$this->title = array($id);
$this->order = $order;
if (!$this->accessible($order)) {
return false;
} else {
$setManagers = array();
if ($this->editable($order)) {
$this->layout = '.set';
if ($this->can('order.edit.manager')) {
$managers = User::where('perms', 'LIKE', '%manager%')->get();
$setManagers = S::keys($managers, function ($user) {
$name = __('vanemart::order.set.manager', $user->to_array());
return array($user->id, $name);
});
}
}
return compact('setManagers') + $order->to_array();
}
}
}
示例3: get_by_list
function get_by_list($name = 'main', $slides = false)
{
if ($name === '*') {
if ($route = \Vane\Route::current() and $route->lastServer) {
$name = \Bundle::element($route->lastServer->name);
$name = S::tryUnprefix(strtok($name, '@'), 'block.');
} else {
$name = null;
}
}
$default = $this->in('default', 'main');
if (!$name and !$default) {
return E_INPUT;
}
$query = ProductListItem::order_by('sort');
$name and $query->where('type', '=', $name);
$default and $query->or_where('type', '=', $default);
if ($list = $query->get()) {
if ($default and !S::first($list, array('?->type === ?', $name))) {
$type = $default;
} else {
$type = $name;
}
$list = S::keep($list, array('?->type === ?', $type));
$goods = S::keys(Product::all(prop('product', $list)), '?->id');
$ordered = array();
foreach ($list as $item) {
$product =& $goods[$item->product];
if ($product and (!$slides or $product->image)) {
$product->extra = $item->extra;
$ordered[] = $product;
}
}
$this->layout = $slides ? '.slides' : '.index';
return static::listResponse($slides ? 1000 : 320, $ordered);
}
}
示例4: viewData
function viewData($name, $value = null)
{
if (func_num_args() > 1 or is_array($name)) {
is_array($name) or $name = array($name => $value);
$alter = S::keys($name, function ($value, $name) {
if (!isset(LayoutAlter::$typeChars[$name[0]])) {
$name = "={$name}";
}
return array($name[0] . '. ' . substr($name, 1), "={$value}");
});
return $this->alter($alter);
} elseif (!$this->isViewEndpoint() and $view = $this->find('') and $block = $view->find($name)) {
return Rendering::likeViewVar($block, $this, $this->slugs);
}
}
示例5: use
$query->where(\DB::raw('DATE(created_at)'), $op, $date)->or_where(\DB::raw('DATE(updated_at)'), $op, $date);
});
}
if ($names = $block->in('names', '')) {
$query->where(function ($query) use($names) {
$query->raw_where('LOCATE(?, name) = 1', array($names))->raw_or_where('LOCATE(?, surname) = 1', array($names));
});
}
$can['filter'] += compact('date', 'names');
});
// Fired to add extra attributes to Orders retrieved with order.list.query.
//
//* $orders array of Order
Event::listen(VANE_NS . 'order.list.populate', function (array &$orders, Block_Order $block, array &$vars) {
$counts = OrderProduct::where_in('order', prop('id', $orders))->group_by('order')->select(array('*', \DB::raw('COUNT(1) AS count')))->get();
$counts = S::keys($counts, '?->order');
foreach ($orders as $order) {
$order->count = $counts[$order->id]->count;
}
});
Event::listen(VANE_NS . 'order.list.populate', function (array &$orders, Block_Order $block, array &$vars) {
$recentTime = time() - 3 * 24 * 3600;
foreach ($orders as $order) {
$order->recent = $order->updated_at >= $recentTime;
}
});
// Fired to do final preparations of variables returned to client/given to template.
Event::listen(VANE_NS . 'order.list.populate', function (array &$vars, Block_Order $block) {
});
/*-----------------------------------------------------------------------
| POST MODEL