本文整理汇总了PHP中lib函数的典型用法代码示例。如果您正苦于以下问题:PHP lib函数的具体用法?PHP lib怎么用?PHP lib使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lib函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Construct the class.
*
* @return void
*/
public function __construct($name = null)
{
$name = is_null($name) ? 'cart' : $name;
$this->session = session('cart.' . $name);
$this->collection = lib('items');
$this->setCart($name);
}
示例2: getAffiliation
public function getAffiliation($reseller_id, $array = true)
{
$metiers = Model::Segmentreseller()->where(['reseller_id', '=', (int) $reseller_id])->with('segment');
$out = $marches = [];
foreach ($metiers as $metier) {
if (isset($metier['segment'])) {
switch ($metier['segment']['id']) {
case 413:
$marches[413] = ['id' => 413, 'name' => $metier['segment']['name']];
$opt_data = lib('forms')->getOptionsMacroData(413);
if (isAke($opt_data, 'affiliation_resto', null) == 1) {
$marches[413]['name'] = $marches[413]['name'] . ' ' . 'resto';
} elseif (isAke($opt_data, 'affiliation_snack', null) == 1) {
$marches[413]['name'] = $marches[413]['name'] . ' ' . 'snack';
} elseif (isAke($opt_data, 'affiliation_vin', null) == 1) {
$marches[413]['name'] = $marches[413]['name'] . ' ' . 'vin';
}
break;
default:
$seg = repo('segment')->getFamilyFromItem($metier['segment']['id']);
if (isset($seg[0]['id'])) {
$marches[$seg[0]['id']] = $seg[0];
}
}
}
}
$out['txt'] = '';
$vir = '';
foreach ($marches as $marche) {
$out['txt'] = $vir . $marche['name'];
$vir = ', ';
}
$out['tab'] = $marches;
return $array ? $out['tab'] : $out['txt'];
}
示例3: render
function render(){
$dom = lib('htmldom')->str_get_dom($this->inner);
$head = '';
$tabs = '';
$iterator = 1;
foreach ( $dom->find('tab') as $tab){
$display = ($iterator==$this->selected)?'block':'none';
$class = ($iterator==$this->selected)?'selected':'';
$head .= "<a class='$class' href='javascript:;' onclick='
$(this).parent().find(\"a\").removeClass(\"selected\");
$(this).addClass(\"selected\");
$(this).parent().parent().find(\".tabs_body\ .tab\").hide();
$(this).parent().parent().find(\".tabs_body\ .tab:nth-child($iterator)\").show();
'>$tab->title</a>";
$tabs .= "<div style='display:$display;' class='tab'>$tab</div>";
$iterator++;
}
?>
<div class="tabs">
<div class="tabs_head"><?=$head?></div>
<div class="tabs_body"><?=$tabs?></div>
</div>
<?
}
示例4: offreout
public function offreout($reseller_id)
{
$collection = [];
$advices = Model::Advice()->where(['table', '=', 'offreout'])->where(['reseller_id', '=', (int) $reseller_id])->where(['created_at', '>', strtotime(Config::get('advice.maxperiod', '-3 month'))])->cursor();
foreach ($advices as $advice) {
$account = Model::Account()->find((int) $advice['account_id']);
if ($account) {
$row = [];
$row['id'] = $advice['id'];
$row['positive'] = $advice['positive'];
$row['negative'] = $advice['negative'];
$row['account_id'] = $account->id;
$row['firstname'] = $account->firstname;
$rates = Model::Advicerate()->where(['advice_id', '=', (int) $advice['id']])->cursor();
$row['rates'] = [];
foreach ($rates as $rate) {
$category = Model::Adviceratecategory()->find((int) $rate['adviceratecategory_id']);
if ($category) {
$row['rates'][] = ['rate' => $rate['rate'], 'name' => $category['name'], 'order' => $category['order'], 'ponderation' => $category['ponderation']];
}
}
if (!empty($row['rates'])) {
$row['rates'] = array_values(lib('collection', [$row['rates']])->sortBy('order')->toArray());
}
$collection[] = $row;
}
}
// return $collection;
return empty($collection) ? [['id' => 1, 'account_id' => 28, 'firstname' => 'Pierre-Emmanuel', 'positive' => "Un accueil digne d'un 4 étoiles.", 'negative' => "Ma table était en plein courant d'air. Pas de pain en rab...", 'rates' => [['name' => 'Qualité', 'rate' => 6, 'ponderation' => 1], ['name' => 'Accueil', 'rate' => 8, 'ponderation' => 1], ['name' => 'Service', 'rate' => 8, 'ponderation' => 1]]], ['id' => 2, 'account_id' => 30, 'firstname' => 'Nicolas', 'positive' => "Très bon sommelier.", 'negative' => "Pas de parking à proximité.", 'rates' => [['name' => 'Qualité', 'rate' => 8, 'ponderation' => 1], ['name' => 'Accueil', 'rate' => 10, 'ponderation' => 1], ['name' => 'Service', 'rate' => 6, 'ponderation' => 1]]]] : $collection;
}
示例5: boot
public function boot()
{
spl_autoload_register(function ($class) {
lib('middleware')->listen($class);
});
return $this;
}
示例6: user_create
function user_create($Username, $Password)
{
global $pdo;
if (user_exists($Username)) {
return false;
}
$stmt = $pdo->prepare('
INSERT INTO `users`
(
`username`
, `password`
) VALUES (
:username
, :password
)');
$stmt->bindValue(':username', s($Username));
$stmt->bindValue(':password', user_hash($Password, $Username));
$stmt->execute();
$uid = $pdo->lastInsertId();
$stmt->closeCursor();
// Create a group for the new user
lib('Group');
$gid = group_create(s($Username), 'user');
group_add($gid, $uid);
return $uid;
}
示例7: __callStatic
public static function __callStatic($m, $a)
{
if (!isset(self::$i)) {
self::$i = lib('redys', ['blazz.store']);
}
return call_user_func_array([static::$i, $m], $a);
}
示例8: start
function start($lifespan, $name=''){
if ($this->fragment_name!=''){die('Nested fragment cache not supported.');}
$x = debug_backtrace();
if($name==''){
$this->fragment_name = md5(lib('uri')->_selfURL().'||'.$x[0]['line']);
}else{
$this->fragment_name = $name;
}
?><!-- START Fragment <?=$this->fragment_name?>--><?
// if file does not exist, make preparations to cache and return true, so segment is executed
if(!file_exists($this->fragment_path . $this->fragment_name)){
$this->newly_cached = true;
ob_start();
return true;
}else{
// cache exists, let's see if it is still valid by checking it's age against the $lifespan variable
$fModify = filemtime($this->fragment_path . $this->fragment_name);
$fAge = time() - $fModify;
if ($fAge > ($lifespan * 60)){
// file is old, let's re-cache
$this->newly_cached = true;
ob_start();
return true;
}
// no need to redo
return false;
}
}
示例9: getInstance
public static function getInstance($ns)
{
if (!isset(self::$collections[$ns])) {
self::$collections[$ns] = lib('myiterator');
}
return self::$collections[$ns];
}
示例10: background
public function background()
{
$file = realpath(APPLICATION_PATH . DS . '..' . DS . 'public' . DS . 'scripts' . DS . 'later.php');
if (File::exists($file)) {
$cmd = 'php ' . $file;
lib('utils')->backgroundTask($cmd);
}
}
示例11: instance
public static function instance($ns = 'core')
{
$i = isAke(self::$instances, $ns, false);
if (!$i) {
self::$instances[$ns] = $i = lib('now', [$ns]);
}
return $i;
}
示例12: __callStatic
public static function __callStatic($f, $a)
{
$f = strtolower($f);
if (!empty($a)) {
return lib($f, $a);
}
return lib($f);
}
示例13: session
function session($name = 'core', $adapter = 'session', $ttl = 3600)
{
switch ($adapter) {
case 'session':
return lib('session', [$name]);
case 'redis':
return RedisSession::instance($name, $ttl);
}
}
示例14: SignUp
function SignUp($data)
{
lib("users");
if (is_string($res = CreateUser($data['username'], $data['password'], $data['email']))) {
echo "<div class='error'>{$res}</div>" . PHP_EOL;
} else {
echo "Done. <a href='./'>Login</a> now." . PHP_EOL;
}
}
示例15: config
private static function config()
{
Config::set('app.module.dir', __DIR__);
Config::set('app.module.dirstorage', __DIR__ . DS . 'storage');
lib('app');
Alias::facade('Run', 'AppLib', 'Thin');
Run::makeInstance();
Config::set('directory.store', STORAGE_PATH);
}