當前位置: 首頁>>代碼示例>>PHP>>正文


PHP s::set方法代碼示例

本文整理匯總了PHP中s::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP s::set方法的具體用法?PHP s::set怎麽用?PHP s::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在s的用法示例。


在下文中一共展示了s::set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: paginated

 public function paginated($mode = 'sidebar')
 {
     if ($limit = $this->page->blueprint()->pages()->limit()) {
         $hash = sha1($this->page->id());
         switch ($mode) {
             case 'sidebar':
                 $id = 'pages.' . $hash;
                 $var = 'page';
                 break;
             case 'subpages/visible':
                 $id = 'subpages.visible.' . $hash;
                 $var = 'visible';
                 break;
             case 'subpages/invisible':
                 $id = 'subpages.invisible.' . $hash;
                 $var = 'invisible';
                 break;
         }
         $children = $this->paginate($limit, array('page' => get($var, s::get($id)), 'omitFirstPage' => false, 'variable' => $var, 'method' => 'query'));
         // store the last page
         s::set($id, $children->pagination()->page());
         return $children;
     } else {
         return $this;
     }
 }
開發者ID:irenehilber,項目名稱:kirby-base,代碼行數:26,代碼來源:children.php

示例2: flush

 /**
  * Remove old values from the Session’s flash data.
  */
 public static function flush()
 {
     // Make sure the session is started
     s::start();
     // Retrieve the flash data
     $registry = s::get(self::$namespace);
     // Clean up registry
     if (!empty($registry)) {
         foreach ($registry as $key => $expiry) {
             $expiry++;
             // Remove all old values from the session
             if ($expiry > 1) {
                 s::remove($key);
                 unset($registry[$key]);
             } else {
                 $registry[$key] = $expiry;
             }
         }
         // Write registry back to session
         if (!empty($registry)) {
             s::set(self::$namespace, $registry);
         } else {
             s::remove(self::$namespace);
         }
     }
 }
開發者ID:buditanrim,項目名稱:kirby-comments,代碼行數:29,代碼來源:session.php

示例3: set

 /**
  * Set flash data
  *
  * @param  string  $key
  * @param  mixed  $value
  * @return void
  */
 public static function set($key, $value)
 {
     if (!isset($data[$key])) {
         static::$data[$key] = $value;
     }
     Session::set(self::sessionKey(), static::$data);
 }
開發者ID:jevets,項目名稱:kirby-flash,代碼行數:14,代碼來源:Flash.php

示例4: edit

 function edit()
 {
     events::observe('save', 'templates', 'apps', '_save');
     events::observer();
     $tmpl_file = events::get('tmpl_file');
     $app = events::get('app');
     if (events::detect('restore')) {
         self::restoreVersion($app, $tmpl_file, events::get('restore'));
     }
     admin::components('tabs', 'validator');
     f::set('app', $app);
     f::set('tmpl_file', $tmpl_file);
     s::set('app', $app);
     s::set('tmpl_file', $tmpl_file);
     $file = SYS_ROOT . 'tmpls/' . ADMIN_SITE . '/' . $app . '/' . $tmpl_file;
     $code = files::get($file);
     f::set('tmpl_code', $code);
     self::getApps();
     /*
     	Load versions
     */
     db::table('templates_versions');
     db::where('app', $app);
     db::where('tmpl_file', $tmpl_file);
     db::order('version_date', 'DESC');
     $res = db::select();
     while ($row = mysql_fetch_assoc($res)) {
         $row['version_date'] = dt::date2print('%H:%i %d.%m.%Y', $row['version_date']);
         $row['version_code'] = '{non}' . htmlspecialchars($row['version_code']) . '{/non}';
         s::roll('versions', $row);
     }
 }
開發者ID:rigidus,項目名稱:ea,代碼行數:32,代碼來源:apps.module.php

示例5: login

 public static function login($redirect = '/')
 {
     if (self::user()) {
         go(url($redirect));
     }
     self::kill();
     $password = get('password');
     $username = get('username');
     if (empty($username) || empty($password)) {
         return false;
     }
     // try to find the user
     $account = self::load($username);
     if (!$account) {
         return array('status' => 'error', 'msg' => l::get('auth.error', 'Invalid username or password'));
     }
     // check for matching usernames
     if (str::lower($account->username()) != str::lower($username)) {
         return array('status' => 'error', 'msg' => l::get('auth.error', 'Invalid username or password'));
     }
     // check for a matching password
     if (!self::checkPassword($account, $password)) {
         return array('status' => 'error', 'msg' => l::get('auth.error', 'Invalid username or password'));
     }
     // generate a random token
     $token = str::random();
     // add the username.
     $account->token = $token;
     // store the token in the cookie
     // and the user data in the session
     cookie::set('authFrontend', $token, 60 * 60 * 24);
     s::set('authFrontend.' . $token, $account->username());
     go(url($redirect));
 }
開發者ID:scheibome,項目名稱:kirbycms-extensions,代碼行數:34,代碼來源:auth.php

示例6: login

 function login()
 {
     s::restart();
     $password = get('password');
     $username = get('username');
     if (empty($username) || empty($password)) {
         return array('status' => 'error', 'msg' => l::get('login.error'));
     }
     $account = self::load($username);
     if (!$account) {
         return array('status' => 'error', 'msg' => l::get('login.error'));
     }
     // check for matching usernames
     if (str::lower($account['username']) != str::lower($username)) {
         return array('status' => 'error', 'msg' => l::get('login.error'));
     }
     // check for a matching password
     if (!self::checkPassword($account, $password)) {
         return array('status' => 'error', 'msg' => l::get('login.error'));
     }
     // generate a random token
     $token = str::random();
     // add the username.
     // It's only the key of the array so far.
     $account['token'] = $token;
     // store the token in the cookie
     // and the user data in the session
     cookie::set('auth', $token, 60 * 60 * 24);
     s::set($token, $account);
     // assign the user data to this obj
     $this->_ = $account;
     return array('status' => 'success', 'msg' => l::get('login.success'));
 }
開發者ID:codecuts,項目名稱:lanningsmith-website,代碼行數:33,代碼來源:user.php

示例7: show

 function show($name)
 {
     foreach (self::$errors as $k => $v) {
         $show .= '<li>' . $v . '</li>';
     }
     s::set($name, '<ul>' . $show . '</ul>');
 }
開發者ID:rigidus,項目名稱:ea,代碼行數:7,代碼來源:errors.php

示例8: signup

 protected function signup()
 {
     $self = $this;
     $form = $this->form('installation/signup', array(), function ($form) use($self) {
         $form->validate();
         if (!$form->isValid()) {
             return false;
         }
         try {
             // fetch all the form data
             $data = $form->serialize();
             // make sure that the first user is an admin
             $data['role'] = 'admin';
             // try to create the new user
             $user = site()->users()->create($data);
             // store the new username for the login screen
             s::set('username', $user->username());
             // try to login the user automatically
             if ($user->hasPanelAccess()) {
                 $user->login($data['password']);
             }
             // redirect to the login
             $self->redirect('login');
         } catch (Exception $e) {
             $form->alert($e->getMessage());
         }
     });
     return $this->modal('index', compact('form'));
 }
開發者ID:irenehilber,項目名稱:kirby-base,代碼行數:29,代碼來源:installation.php

示例9: index

 public function index()
 {
     if (site()->users()->count() > 0) {
         go(panel()->urls()->login());
     }
     if ($problems = installation::check()) {
         $content = view('installation/check', array('problems' => $problems));
     } else {
         $form = panel()->form('installation', array('language' => kirby()->option('panel.language', 'en')));
         $form->cancel = false;
         $form->save = l('installation.signup.button');
         $form->centered = true;
         foreach (panel()->languages() as $lang) {
             $form->fields()->get('language')->options[$lang->code()] = $lang->title();
         }
         $form->on('submit', function ($form) {
             try {
                 // fetch all the form data
                 $data = $form->serialize();
                 // make sure that the first user is an admin
                 $data['role'] = 'admin';
                 // try to create the new user
                 $user = panel()->site()->users()->create($data);
                 // store the new username for the login screen
                 s::set('username', $user->username());
                 // redirect to the login
                 go(panel()->urls()->login() . '/welcome');
             } catch (Exception $e) {
                 $form->alert($e->getMessage());
             }
         });
         $content = view('installation/signup', array('form' => $form));
     }
     return layout('installation', array('meta' => new Snippet('meta'), 'content' => $content));
 }
開發者ID:aoimedia,項目名稱:kosmonautensofa,代碼行數:35,代碼來源:installation.php

示例10: delete

 public function delete($id)
 {
     if (!array_key_exists($id, $this->data)) {
         return;
     }
     unset($this->data[$id]);
     s::set('cart', $this->data);
 }
開發者ID:CelineDesign,項目名稱:shopkit,代碼行數:8,代碼來源:Cart.php

示例11: set

 public static function set($name, $value, $type = 'plain')
 {
     $messages = s::get('messages') ? s::get('messages') : array();
     $message = new stdClass();
     $message->name = $name;
     $message->value = $value;
     $message->type = $type;
     $messages[$name] = $message;
     s::set('messages', $messages);
 }
開發者ID:aoimedia,項目名稱:aurer-kirby,代碼行數:10,代碼來源:message.php

示例12: add_to_visited_links

function add_to_visited_links($url)
{
    $url = rtrim($url, '/');
    $visited_links = s::get('visited_links');
    if (!$visited_links) {
        $visited_links = array();
    }
    array_push($visited_links, $url);
    s::set('visited_links', array_unique($visited_links));
}
開發者ID:arnaudjuracek,項目名稱:www-boite-noire,代碼行數:10,代碼來源:outils.php

示例13: show

 function show()
 {
     $event = web::getEvent();
     if ($event === false) {
         $year = date('Y');
     } else {
         $year = $event;
     }
     s::set('info_date_select', htmlspecialchars($year));
     $sql = "SELECT `section_year` as date FROM `info_sections` WHERE `section_view`='0'  GROUP BY `date` ORDER BY `date` DESC";
     $res = db::query($sql);
     $rows = mysql_num_rows($res);
     if ($rows > 1) {
         s::add('info_date_selector', '<ul class="years">');
         while ($row = mysql_fetch_assoc($res)) {
             if ($row['date'] == $year) {
                 $row['date'] = '<li><span>' . $row['date'] . '</span></li>';
             } else {
                 $row['date'] = '<li><a href="' . web::get('page_folder') . '' . $row['date'] . '/">' . $row['date'] . '</a></li>';
             }
             s::add('info_date_selector', $row['date']);
         }
         s::add('info_date_selector', '</ul>');
     }
     $files = array();
     db::table('info_files');
     $r = db::select();
     while ($a = mysql_fetch_assoc($r)) {
         $files[$a['section_id']][] = $a;
     }
     db::table('info_sections');
     db::order('section_order', 'DESC');
     db::where('section_year', $year);
     $r = db::select();
     if (db::rows() == 0) {
         web::error404();
     }
     while ($a = mysql_fetch_assoc($r)) {
         if ($a['section_view'] == '0') {
             s::roll('sections', $a);
         } else {
             s::roll('sections_view', $a);
         }
         if (isset($files[$a['section_id']])) {
             foreach ($files[$a['section_id']] as $v) {
                 $v['file_icon'] = files::getFileIco($v['file_type']);
                 $v['file_size'] = files::parseSizeSmart($v['file_size']);
                 s::roll('items' . $a['section_id'], $v);
             }
         }
     }
 }
開發者ID:rigidus,項目名稱:ea,代碼行數:52,代碼來源:main.handler.php

示例14: configure

 public static function configure()
 {
     if (is_null(static::$site)) {
         static::$site = kirby::panelsetup();
     }
     // load all available routes
     static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'api.php');
     static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'views.php');
     // setup the blueprint root
     blueprint::$root = c::get('root.site') . DS . 'blueprints';
     // start the router
     static::$router = new Router();
     static::$router->register(static::$routes);
     // content language switcher variable
     if (static::$site->multilang()) {
         if ($language = server::get('http_language') or $language = s::get('lang')) {
             static::$site->visit('/', $language);
         }
         app::$language = static::$site->language()->code();
         s::set('lang', app::$language);
     }
     // load the interface language file
     if (static::$site->user()) {
         $languageCode = static::$site->user()->language();
     } else {
         $languageCode = c::get('panel.language', 'en');
     }
     // validate the language code
     if (!in_array($languageCode, static::languages()->keys())) {
         $languageCode = 'en';
     }
     // store the interface language
     app::$interfaceLanguage = $languageCode;
     $language = (require root('panel.app.languages') . DS . $languageCode . '.php');
     // set all language variables
     l::$data = $language['data'];
     // register router filters
     static::$router->filter('auth', function () {
         if (!app::$site->user()) {
             go('panel/login');
         }
     });
     // check for a completed installation
     static::$router->filter('isInstalled', function () {
         if (app::$site->users()->count() == 0) {
             go('panel/install');
         }
     });
     // only use the fragments of the path without params
     static::$path = implode('/', (array) url::fragments(detect::path()));
 }
開發者ID:kompuser,項目名稱:panel,代碼行數:51,代碼來源:app.php

示例15: start

 function start()
 {
     db::connect();
     if (!router::get(1)) {
         return true;
     }
     self::$map = array('mode' => router::get(0), 'app' => router::get(1), 'module' => 'main', 'action' => router::get(2), 'id' => router::get(4));
     s::set('SYS_PATH', 'http://' . SERVER . SYS_DIR);
     define('APP', APPS . self::get('app') . '/');
     s::set('APP', APP);
     define('MODULE', APP . self::get('module') . '/');
     s::set('MODULE', MODULE);
     if (stristr(self::$map['mode'], 'admin')) {
         self::$map['mode'] = 'admin';
     } else {
         self::$map['mode'] = 'web';
     }
     if (self::$map['mode'] == 'admin') {
         if (defined('ADMIN_USER_SITE_ID')) {
             admin::observer();
             define('ADMIN_SITE_ID', ADMIN_USER_SITE_ID);
             s::set('ADMIN_SITE_ID', ADMIN_USER_SITE_ID);
             db::table('admin_sites');
             db::where('site_id', ADMIN_USER_SITE_ID);
             db::limit(1);
             $row = db::select();
             define('ADMIN_SITE', db::get('site_domain'));
             s::set('ADMIN_SITE', ADMIN_SITE);
         }
     } else {
         web::getSite();
         $lang = lang::gets(LANG_INDEX, SITE_ID);
         /*
         	Authentification webUser
         */
         web::observer();
     }
     /*
     	Set params
     */
     params::send();
     if (router::get(0) == 'feed' || router::get(0) == 'rss') {
         self::$map['module'] = 'feed';
     }
     if (self::$map['mode'] == 'admin') {
         load::module(self::get('app'), self::get('module'), self::get('action'));
     } else {
         load::handler(self::get('app'), self::get('module'), self::get('action'));
     }
 }
開發者ID:rigidus,項目名稱:ea,代碼行數:50,代碼來源:loader.php


注:本文中的s::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。