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


PHP r类代码示例

本文整理汇总了PHP中r的典型用法代码示例。如果您正苦于以下问题:PHP r类的具体用法?PHP r怎么用?PHP r使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了r类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 function __construct($item)
 {
     parent::__construct($item);
     $this->buildString();
     $this->runMethods();
     $this->showObject();
 }
开发者ID:rex,项目名称:RubyPHP,代码行数:7,代码来源:class.string.rubyphp.php

示例2: login

 public function login($welcome = null)
 {
     if ($user = panel()->site()->user()) {
         go(panel()->urls()->index());
     }
     $message = l('login.error');
     $error = false;
     $form = panel()->form('login');
     $form->cancel = false;
     $form->save = l('login.button');
     $form->centered = true;
     if (r::is('post') and get('_csfr') and csfr(get('_csfr'))) {
         $data = $form->serialize();
         $user = site()->user(str::lower($data['username']));
         if (!$user) {
             $error = true;
         } else {
             if (!$user->hasPanelAccess()) {
                 $error = true;
             } else {
                 if (!$user->login(get('password'))) {
                     $error = true;
                 } else {
                     go(panel()->urls()->index());
                 }
             }
         }
     }
     if ($username = s::get('username')) {
         $form->fields->username->value = html($username, false);
     }
     return layout('login', array('meta' => new Snippet('meta'), 'welcome' => $welcome ? l('login.welcome') : '', 'form' => $form, 'error' => $error ? $message : false));
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:33,代码来源:auth.php

示例3: layout

 public function layout($type, $data = array())
 {
     $version = panel()->version();
     $base = panel()->urls()->index();
     $cssbase = panel()->urls()->css();
     $jsbase = panel()->urls()->js();
     $defaults = array('title' => panel()->site()->title() . ' | Panel', 'direction' => panel()->direction(), 'meta' => $this->snippet('meta'), 'css' => css($cssbase . '/panel.css?v=' . $version), 'js' => js($jsbase . '/dist/panel.min.js?v=' . $version), 'content' => '', 'bodyclass' => '');
     switch ($type) {
         case 'app':
             $defaults['topbar'] = '';
             $defaults['csrf'] = panel()->csrf();
             $defaults['formcss'] = css($cssbase . '/form.min.css?v=' . $version);
             $defaults['formjs'] = js($jsbase . '/dist/form.min.js?v=' . $version);
             $defaults['appjs'] = js($jsbase . '/dist/app.min.js?v=' . $version);
             // plugin stuff
             $defaults['pluginscss'] = css($base . '/plugins/css?v=' . $version);
             $defaults['pluginsjs'] = js($base . '/plugins/js?v=' . $version);
             break;
         case 'base':
             break;
     }
     $data = array_merge($defaults, $data);
     if (r::ajax() and $type == 'app') {
         $panel = panel();
         $user = $panel->site()->user();
         $response = array('user' => $user ? $user->username() : false, 'direction' => $panel->direction(), 'title' => $data['title'], 'content' => $data['topbar'] . $data['content']);
         return response::json($response);
     } else {
         return new Layout($type, $data);
     }
 }
开发者ID:biggtfish,项目名称:Clean-Blog-Kirby-Theme,代码行数:31,代码来源:base.php

示例4: sort

 protected function sort($page)
 {
     // handle sorting
     if (r::is('post') and $action = get('action') and $id = get('id')) {
         $subpage = $this->page($page->id() . '/' . $id);
         switch ($action) {
             case 'sort':
                 try {
                     $subpage->sort(get('to'));
                 } catch (Exception $e) {
                     // no error handling, because if sorting
                     // breaks, the refresh will fix it.
                 }
                 break;
             case 'toggle':
                 try {
                     $subpage->toggle('last');
                 } catch (Exception $e) {
                     // no error handling, because if sorting
                     // breaks, the refresh will fix it.
                 }
                 break;
             case 'hide':
                 try {
                     $subpage->hide();
                 } catch (Exception $e) {
                     // no error handling, because if sorting
                     // breaks, the refresh will fix it.
                 }
                 break;
         }
         $this->redirect($page, 'subpages');
     }
 }
开发者ID:dmak78,项目名称:panel,代码行数:34,代码来源:subpages.php

示例5: __construct

 public function __construct()
 {
     $endpoint = $this;
     if ($page = page('webmention') and kirby()->path() == $page->uri()) {
         if (r::is('post')) {
             try {
                 $endpoint->start();
                 header::status(202);
                 tpl::set('status', 'success');
                 tpl::set('alert', null);
             } catch (Exception $e) {
                 header::status(400);
                 tpl::set('status', 'error');
                 tpl::set('alert', $e->getMessage());
             }
         } else {
             tpl::set('status', 'idle');
         }
     } else {
         kirby()->routes(array(array('pattern' => 'webmention', 'method' => 'GET|POST', 'action' => function () use($endpoint) {
             try {
                 $endpoint->start();
                 echo response::success('Yay', 202);
             } catch (Exception $e) {
                 echo response::error($e->getMessage());
             }
         })));
     }
 }
开发者ID:aizlewood,项目名称:2016,代码行数:29,代码来源:endpoint.php

示例6: values

 public function values($values = null)
 {
     if (is_null($values)) {
         return array_merge($this->values, r::data());
     }
     $this->values = array_merge($this->values, $values);
     return $this;
 }
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:8,代码来源:form.php

示例7: index

 public function index()
 {
     if (isset($this->index)) {
         return $this->index;
     }
     if (r::cli()) {
         return $this->index = '/';
     } else {
         return $this->index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
     }
 }
开发者ID:aoimedia,项目名称:kosmonautensofa,代码行数:11,代码来源:urls.php

示例8: index

 public function index()
 {
     if (isset($this->index)) {
         return $this->index;
     }
     // this value is used by the Panel
     $this->indexDetected = true;
     if (r::cli()) {
         return $this->index = '/';
     } else {
         return $this->index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
     }
 }
开发者ID:parasutcom,项目名称:styleguide,代码行数:13,代码来源:urls.php

示例9: handle

 /**
  * Handle an incomming request.
  */
 public static function handle($pageId, $lang)
 {
     if (r::data('token') != c::get('slack.verify')) {
         return response::error('Forbidden', 403);
     }
     $history = static::api('channels.history', ['channel' => r::data('channel_id')]);
     if (!empty($history['error'])) {
         // Something went wrong ... maybe:
         $msg = ['channel_not_found' => ':lock: Sorry, but this is a private channel'];
         $err = $history['error'];
         return response::json(isset($msg[$err]) ? $msg[$err] : $err);
     }
     $messages = $history['messages'];
     if (!empty(r::data('text'))) {
         $messages = array_values(array_filter($messages, function ($m) {
             return stristr($m['text'], r::data('text'));
         }));
     }
     if (empty($messages)) {
         return response::json(":mag: Sorry, I couldn't find the post you're looking for");
     }
     $m = $messages[0];
     $a = @$m['attachments'][0];
     $img = @$a['image_url'];
     if (empty($img)) {
         $img = @$a['thumb_url'];
     }
     if (empty($img)) {
         return response::json(":warning: I'll only publish posts with images");
     }
     $page = site()->visit($pageId, $lang);
     $dir = $page->root();
     $ext = preg_replace('/.+?(\\.\\w+)($|[#?].*)/', '$1', $img);
     $file = $dir . DS . $m['ts'] . $ext;
     // Output success message early because of short slackbot timeouts
     $msg = ':metal: *' . r::data('text', 'last') . '* post is now live' . ' on <' . $page->url() . '>';
     echo $msg;
     flush();
     error_log($msg);
     $user = static::api('users.info', ['user' => $m['user']]);
     $meta = ['title' => $a['title'], 'date' => date('d.m.Y', $m['ts']), 'description' => @$a['text'], 'linkurl' => $a['from_url'], 'author' => $user['user']['profile']['real_name'], 'avatar' => $m['user'] . '.jpg', 'comment' => static::format(@$m['text']), 'slack' => '1'];
     data::write($file . '.txt', $meta, 'kd');
     // Download the avatar image
     $avatar = $dir . DS . $meta['avatar'];
     static::download($user['user']['profile']['image_72'], $avatar);
     // Download the image
     static::download($img, $file);
     // Response has already been sent
     return false;
 }
开发者ID:yours-truly,项目名称:kirby-slack,代码行数:53,代码来源:slack.php

示例10: index

 public function index()
 {
     if (isset($this->index)) {
         return $this->index;
     }
     if (r::cli()) {
         $index = '/';
     } else {
         $index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
     }
     // fix index URL for the Panel
     if (function_exists('panel')) {
         $index = dirname($index);
     }
     return $this->index = $index;
 }
开发者ID:nsteiner,项目名称:kdoc,代码行数:16,代码来源:urls.php

示例11: _getOrds

 /**
  * Retourne un tableau des caractères de $sInputString sous leur forme ordinale.
  * 
  * @param string $sInputString Chaîne de caractères dont les caractères sont à retourner en ordinal.
  * @return array Tableau indexé.
  */
 protected function _getOrds($sInputString)
 {
     $aOrds = array();
     if ($this->_oString->getEncoding() === Encoding::UTF_8) {
         $sString = mb_convert_encoding($sInputString, Encoding::UCS_4BE, Encoding::UTF_8);
         for ($iCharIndex = 0; $iCharIndex < mb_strlen($sString, Encoding::UCS_4BE); $iCharIndex++) {
             // Calcul de la valeur totale des 4 bits
             $sStringChar = mb_substr($sString, $iCharIndex, 1, Encoding::UCS_4BE);
             $aUnpackedData = unpack('N', $sStringChar);
             $aOrds[] = $aUnpackedData[1];
         }
     } else {
         r::char()->setModifiers($this->_m())->matchAll($sInputString, $aChars);
         foreach ($aChars as $sChar) {
             $aOrds[] = ord($sChar);
         }
     }
     return $aOrds;
 }
开发者ID:subtonix,项目名称:aouka_lunch,代码行数:25,代码来源:Obfuscate.php

示例12: login

 /**
  * Dashboard /login action
  *
  * @return void
  */
 public function login()
 {
     if (site()->user()) {
         go('dashboard');
     }
     // save the flashed redirect
     flash('login.redirect', flash('login.redirect'));
     if (r::is('post')) {
         if ($this->form->validates()) {
             $user = site()->user($this->form->data('username'));
             if ($user && $user->login($this->form->data('password'))) {
                 flash('messages.success', 'Logged in!');
                 if (get('_redirect')) {
                     go(get('_redirect'));
                 }
             } else {
                 $this->form->addErrors(['login' => 'Invalid username and password']);
             }
         }
         go('login');
     }
     $this->render('dashboard/login', ['pageTitle' => 'Login', 'form' => $this->form, 'page' => page()]);
 }
开发者ID:evendev,项目名称:paintcrazy,代码行数:28,代码来源:Dashboard.php

示例13: error

 public static function error($message, $type, $file, $line)
 {
     // remove everything that has been rendered so far
     if (ob_get_level()) {
         ob_end_clean();
     }
     if (class_exists('kirby') and !is_null(kirby::$instance)) {
         $kirby = kirby::$instance;
     } else {
         $kirby = null;
     }
     if (r::ajax()) {
         if (terror::debug()) {
             echo response::error($message, 400, array('type' => $type, 'file' => $file, 'line' => $line));
         } else {
             echo response::error('Unexpected error', 400);
         }
     } else {
         header::status(400);
         static::view($message, $type, $file, $line, $kirby);
     }
     die;
 }
开发者ID:chrishiam,项目名称:LVSL,代码行数:23,代码来源:terror.php

示例14: launch

 /**
  * Starts the router, renders the page and returns the response
  *
  * @return mixed
  */
 public function launch()
 {
     // this will trigger the configuration
     $site = $this->site();
     // force secure connections if enabled
     if ($this->option('ssl') and !r::secure()) {
         // rebuild the current url with https
         go(url::build(array('scheme' => 'https')));
     }
     // set the timezone for all date functions
     date_default_timezone_set($this->options['timezone']);
     // load all extensions
     $this->extensions();
     // load all plugins
     $this->plugins();
     // load all models
     $this->models();
     // start the router
     $this->router = new Router($this->routes());
     $this->route = $this->router->run($this->path());
     // check for a valid route
     if (is_null($this->route)) {
         header::status('500');
         header::type('json');
         die(json_encode(array('status' => 'error', 'message' => 'Invalid route or request method')));
     }
     // call the router action with all arguments from the pattern
     $response = call($this->route->action(), $this->route->arguments());
     // load all language variables
     // this can only be loaded once the router action has been called
     // otherwise the current language is not yet available
     $this->localize();
     // build the response
     $this->response = $this->component('response')->make($response);
     // store the current language in the session
     if ($this->site()->multilang() && ($language = $this->site()->language())) {
         s::set('language', $language->code());
     }
     return $this->response;
 }
开发者ID:kgchoy,项目名称:main-portfolio-website,代码行数:45,代码来源:kirby.php

示例15: function

<?php

return function ($site, $pages, $page) {
    // don't show the login screen to already logged in users
    if ($site->user()) {
        go('/');
    }
    // handle the form submission
    if (r::is('post') and get('login')) {
        // fetch the user by username and run the
        // login method with the password
        if ($user = $site->user(get('username')) and $user->login(get('password'))) {
            // redirect to the homepage
            // if the login was successful
            go('/');
        } else {
            // make sure the alert is being
            // displayed in the template
            $error = true;
        }
    } else {
        // nothing has been submitted
        // nothing has gone wrong
        $error = false;
    }
    return array('error' => $error);
};
开发者ID:stefanzweifel,项目名称:dirby,代码行数:27,代码来源:login.php


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