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


PHP r::ajax方法代码示例

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


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

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

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

示例3: array

/* Custom Panel Stylesheet
---------------------------------------
Define a custom stylesheet to load in to the panel. See:
getkirby.com/docs/cheatsheet/options/panel.stylesheet
*/
c::set('panel.stylesheet', 'assets/css/panel.css');
/* Kirby Configuration
---------------------------------------
By default you don't have to configure anything to
make Kirby work. For more fine-grained configuration
please check out getkirby.com/docs/advanced/options
and getkirby.com/blog/multi-environment-setup
*/
// Routes
//
c::set('routes', array(array('pattern' => '(:any)', 'method' => 'ALL', 'action' => function ($path) {
    if (!r::ajax()) {
        header::notfound();
        return site()->visit($path);
    }
    $page = page($path);
    $has_api_method = method_exists($page, 'api');
    return response::json(array('has_api_method' => $has_api_method));
}), array('pattern' => 'get/users.json', 'method' => 'ALL', 'action' => function () {
    // if(!r::ajax()) {
    // 	return header::forbidden();
    // }
    // $users = site()->users()->toArray();
    // $r = array_combine($users,site()->users()->toArray()); // format for kirby select field
    return response::json(array("first" => 'Rafe', "middle" => 'Jackson', "last" => 'Goldberg'));
})));
开发者ID:rafegoldberg,项目名称:zazu,代码行数:31,代码来源:config.php

示例4: run

 /**
  * Iterate through every route to find a matching route.
  *
  * @param  string $path Optional path to match against
  * @return Route
  */
 public function run($path = null)
 {
     $method = r::method();
     $ajax = r::ajax();
     $https = r::ssl();
     $routes = a::get($this->routes, $method, array());
     // detect path if not set manually
     if ($path === null) {
         $path = implode('/', (array) url::fragments(detect::path()));
     }
     // empty urls should never happen
     if (empty($path)) {
         $path = '/';
     }
     foreach ($routes as $route) {
         if ($route->https and !$https) {
             continue;
         }
         if ($route->ajax and !$ajax) {
             continue;
         }
         // handle exact matches
         if ($route->pattern == $path) {
             $this->route = $route;
             break;
         }
         // We only need to check routes with regular expression since all others
         // would have been able to be matched by the search for literal matches
         // we just did before we started searching.
         if (strpos($route->pattern, '(') === false) {
             continue;
         }
         $preg = '#^' . $this->wildcards($route->pattern) . '$#u';
         // If we get a match we'll return the route and slice off the first
         // parameter match, as preg_match sets the first array item to the
         // full-text match of the pattern.
         if (preg_match($preg, $path, $parameters)) {
             $this->route = $route;
             $this->route->arguments = array_slice($parameters, 1);
             break;
         }
     }
     if ($this->route and $this->filterer($this->route->filter) !== false) {
         return $this->route;
     } else {
         return null;
     }
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:54,代码来源:router.php

示例5: redirect

 public function redirect($obj = '/', $action = false, $force = false)
 {
     if ($force === false and $redirect = get('_redirect')) {
         $url = purl($redirect);
     } else {
         $url = purl($obj, $action);
     }
     if (r::ajax()) {
         $user = $this->site()->user();
         die(response::json(array('direction' => $this->direction(), 'user' => $user ? $user->username() : false, 'url' => $url)));
     } else {
         go($url);
     }
 }
开发者ID:biggtfish,项目名称:Clean-Blog-Kirby-Theme,代码行数:14,代码来源:panel.php

示例6: function

<?php

return function ($site, $pages, $page) {
    //set variables
    $url = null;
    $data = null;
    $status = null;
    //if page is accessed thorugh ajax
    if (r::ajax()) {
        //store sanitized $_POST variables
        $currentTestData = r::postData(array('test', 'user', 'data'));
        //get logged user (if any)
        if ($user = Auth::loggedUser()) {
            //get user's session page
            $userSession = site()->find(implode(DS, array(c::get('sessions.folder'), $user->session())));
            //istantiate testSession object
            $tSession = new testSession($userSession, $user->username());
            //get user's current session status
            $userSessionStatus = $user->status();
            //if ajaxed $currentTestData equals user's current session status
            if (str::lower($currentTestData['test']) == str::lower($userSessionStatus)) {
                //if it was possitble to update user's results file (by appending $currentTestData)
                if (f::append($tSession->getUserResultsFile(), PHP_EOL . a::json($currentTestData))) {
                    //set updated user's session status to next avalibale test
                    $updatedStatus = $tSession->getNextTest($currentTestData['test']);
                    //if there aren't tests available, set user's session statuts to completed session
                    if (!$updatedStatus) {
                        $updatedStatus = c::get('session.status.completed');
                    }
                    //update user's session status to next avalibale test
                    $user->update(array('status' => $updatedStatus));
开发者ID:alkaest2002,项目名称:risky2,代码行数:31,代码来源:cerebro.php

示例7: testAjax

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

示例8: redirect

 public function redirect($obj = '/', $action = false, $force = false)
 {
     if ($force === false and $redirect = get('_redirect')) {
         $url = purl($redirect);
     } else {
         $url = purl($obj, $action);
     }
     if (r::ajax()) {
         // set the username of the current user
         if ($user = site()->user()) {
             header('Panel-User: ' . $user->username());
         }
         die(response::json(array('url' => $url)));
     } else {
         go($url);
     }
 }
开发者ID:ssigur,项目名称:portfolio-2015,代码行数:17,代码来源:panel.php


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