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


PHP r::is方法代码示例

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


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

示例1: 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

示例2: 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

示例3: __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

示例4: 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

示例5: response

 /**
  * Generate the controller response.
  *
  * @param   string  $msg   Optional message to send with the response.
  * @param   integer $code  Response code to send.
  * @param   array   $data  Data to return.
  *
  * @return  Response
  */
 protected function response($msg, $code, $data)
 {
     if (!r::is('ajax')) {
         return $this->redirect('back', $data);
     }
     $response = array('status' => 'error', 'data' => $data, 'code' => $code, 'message' => $msg);
     return response::json($response, $code);
 }
开发者ID:buditanrim,项目名称:kirby-comments,代码行数:17,代码来源:controller.php

示例6: function

<?php

return function ($site, $pages, $page) {
    // handle the form submission
    if (r::is('post') and get('register')) {
        try {
            $user = $site->users()->create(array('username' => get('username'), 'email' => get('email'), 'password' => get('password'), 'language' => 'en'));
            // make sure the alert is being
            // displayed in the template
            $success = true;
        } catch (Exception $e) {
            // 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, 'success' => $success);
};
开发者ID:starckio,项目名称:Userskit,代码行数:22,代码来源:register.php

示例7: snippet

<?php

snippet('header');
?>

    <h1><?php 
echo $page->title()->html();
?>
</h1>

    <?php 
echo $page->text()->kirbytext();
?>

    <?php 
if (r::is('post') and get('register') !== null) {
    ?>
      <div class="uk-alert uk-alert-warning">
        <p>
          <?php 
    // Check for duplicate email addresses
    $duplicate = $site->users()->findBy('email', trim(get('email')));
    if (count($duplicate) === 0) {
        try {
            $user = $site->users()->create(array('username' => trim(get('username')), 'email' => trim(get('email')), 'password' => get('password'), 'firstName' => trim(get('firstname')), 'lastName' => trim(get('lastname')), 'language' => 'en', 'country' => get('country')));
            echo l::get('register-success');
        } catch (Exception $e) {
            echo l::get('register-failure');
        }
    } else {
        echo l::get('register-failure');
开发者ID:jenniferhail,项目名称:kirbypine,代码行数:31,代码来源:register.php

示例8: function

<?php

use Email;
use r as Request;
use Jevets\Kirby\Form;
return function ($site, $pages, $page) {
    $form = new Form(['name' => ['rules' => ['required'], 'message' => 'Name is required.'], 'email' => ['rules' => ['required', 'email'], 'message' => 'Valid email is required'], 'phone' => [], 'message' => []]);
    if (Request::is('post')) {
        if ($form->validates()) {
            // send an email
            $body = snippet('emails/contact', $form->data(), true);
            $email = new Email(['to' => c::get('app.email.to'), 'from' => c::get('app.email.from'), 'subject' => 'Contact Form Submission (' . $form->data('name') . ')', 'replyto' => $form->data('email'), 'body' => $body]);
            $email->send();
            // notify the user
            flash('messages.success', ["We got your message! We'll be back in touch very soon."]);
            go('contact');
        } else {
            flash('messages.errors', ["There were errors with your submission..."]);
        }
        go($page->url());
    }
    return compact('form');
};
开发者ID:evendev,项目名称:gorge-kirby,代码行数:23,代码来源:contact.php

示例9: on

 public function on($action, $callback)
 {
     // auto-trigger the submit event when the form is being echoed
     if (r::is('post')) {
         $callback($this);
     }
     $this->fields->append('csrf', static::field('hidden', array('name' => 'csrf', 'value' => panel()->csrf())));
 }
开发者ID:kristianhalte,项目名称:super_organic,代码行数:8,代码来源:form.php

示例10: sort

 protected function sort($page)
 {
     if (!r::is('post') or get('action') != 'sort') {
         return;
     }
     $filenames = get('filenames');
     $counter = 0;
     foreach ($filenames as $filename) {
         if ($file = $page->file($filename)) {
             $counter++;
             try {
                 $file->update('sort', $counter);
             } catch (Exception $e) {
             }
         }
     }
     $this->redirect($page, 'files');
 }
开发者ID:irenehilber,项目名称:kirby-base,代码行数:18,代码来源:files.php

示例11: function

<?php

return function ($site, $pages, $page) {
    // handle the form submission
    if (r::is('post') and get('update')) {
        try {
            $user = $site->user()->update(array('firstname' => get('firstname'), 'lastname' => get('lastname'), 'email' => get('email'), 'bio' => get('bio'), 'link' => get('link'), 'language' => 'en'));
            if (get('password') === '') {
                // No password change
            } else {
                // Update password
                $user = $site->user()->update(array('password' => get('password')));
            }
            // make sure the alert is being
            // displayed in the template
            $success = true;
        } catch (Exception $e) {
            // 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, 'success' => $success);
};
开发者ID:starckio,项目名称:Userskit,代码行数:28,代码来源:account.php

示例12: testIs

 public function testIs()
 {
     $this->assertTrue(r::is('GET'));
     $this->assertFalse(r::is('ajax'));
 }
开发者ID:aoimedia,项目名称:kosmonautensofa,代码行数:5,代码来源:RTest.php

示例13: function

<?php

return function ($site, $pages, $page) {
    // get source page
    $source = $_GET["source"];
    // form submission
    if (r::is("post") and get("login")) {
        // fetch the user, run login method
        if ($user = $site->user(get("username")) and $user->login(get("password"))) {
            if ($user->hasRole("external")) {
                // check source page
                switch ($source) {
                    case "Google":
                        // check user
                        switch ($user->username()) {
                            case "okgoogle":
                                // approved access
                                go($source);
                                break;
                            default:
                                // prevent page access
                                $accessError = true;
                        }
                        break;
                    case "Learnmetrics":
                        // check user
                        switch ($user->username()) {
                            case "fromdata":
                                // approved access
                                go($source);
                                break;
开发者ID:lucienlizlepiorz,项目名称:lucien.design,代码行数:31,代码来源:login.php

示例14: go

<?php

// Honeypot trap for robots
if (r::is('post') and get('subject') != '') {
    go(url('error'));
}
$cart = Cart::getCart();
$shipping = s::get('shipping');
$discount = getDiscount($cart);
// Set transaction status
if (get('giftCertificatePaid') == 'true') {
    $status = 'paid';
} else {
    $status = 'pending';
}
// Set the timestamp so txn-id and txn-date use the same value
$timestamp = date('U');
// Create a YAML-structured list of products
$items = [];
foreach ($cart->getItems() as $i => $item) {
    // Look for downloads
    foreach (page($item->uri)->variants()->toStructure() as $variant) {
        if (str::slug($variant->name()) == $item->variant) {
            if ($variant->download_files()->isNotEmpty()) {
                // Build full URLs for downloads
                $files = [];
                foreach (explode(',', $variant->download_files()) as $filename) {
                    $files[] = url($item->uri) . '/' . $filename;
                }
                // Add downloads properties
                $item->downloads = ['files' => $files, 'expires' => $variant->download_days()->isEmpty() ? NULL : $timestamp + $variant->download_days()->value * 60 * 60 * 24];
开发者ID:samnabi,项目名称:shopkit,代码行数:31,代码来源:order.create.php

示例15: function

<?php

use Crazy\Form;
return function ($site, $pages, $page) {
    $event = $page->parent();
    $order = new CrazyEventOrder($event);
    $form = new Form(['guest' => []]);
    if (r::is('post')) {
        // Add a new guest
        if (get('add_guest') && ($guest = get('guest'))) {
            if ($event->seatsAvailable(1 + count($order->guests()))) {
                $order->addGuest(htmlspecialchars($guest));
            } else {
                $form->addError('guest', 'Sorry, there are no more seats available.');
            }
        }
        // Remove a guest
        if ($removeId = get('remove_guest')) {
            // the field is submitted as "id-[$id]"
            $id = substr($removeId, 3);
            $order->removeGuest($id);
        }
        go($page->url());
    }
    return ['event' => $event, 'studio' => $order->studio(), 'form' => $form, 'order' => $order];
};
开发者ID:evendev,项目名称:paintcrazy,代码行数:26,代码来源:tickets.php


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