当前位置: 首页>>代码示例>>PHP>>正文


PHP S::keys方法代码示例

本文整理汇总了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);
}
开发者ID:SerdarSanri,项目名称:VaneMart,代码行数:14,代码来源:core.php

示例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();
         }
     }
 }
开发者ID:SerdarSanri,项目名称:VaneMart,代码行数:23,代码来源:Order.php

示例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);
     }
 }
开发者ID:SerdarSanri,项目名称:VaneMart,代码行数:37,代码来源:Group.php

示例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);
     }
 }
开发者ID:SerdarSanri,项目名称:VaneMart,代码行数:15,代码来源:Layout.php

示例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
开发者ID:SerdarSanri,项目名称:VaneMart,代码行数:31,代码来源:events.php


注:本文中的S::keys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。