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


PHP response::error方法代码示例

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


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

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

示例2: run

function run($page)
{
    $templates = c::get('autopublish.templates', array('project', 'item'));
    if (!$templates || in_array($page->template(), $templates)) {
        try {
            $page->toggle('last');
        } catch (Exception $e) {
            return response::error($e->getMessage());
        }
    }
}
开发者ID:sarahgarcin,项目名称:journal,代码行数:11,代码来源:autopublish.php

示例3: autocomplete

 public function autocomplete($mode)
 {
     switch ($mode) {
         case 'usernames':
             $result = site()->users()->map(function ($user) {
                 return $user->username();
             })->toArray();
             break;
         case 'emails':
             $result = site()->users()->map(function ($user) {
                 return $user->email();
             })->toArray();
             break;
         case 'uris':
             $result = site()->index()->map(function ($page) {
                 return $page->id();
             })->toArray();
             // sort results alphabetically
             sort($result);
             break;
         case 'field':
             $index = get('index', 'siblings');
             // siblings, children, template, all
             $id = get('uri');
             $page = page($id);
             switch ($index) {
                 case 'siblings':
                 case 'children':
                     $pages = $page->{$index}();
                     break;
                 case 'template':
                     $template = get('template', $page->template());
                     $pages = site()->index()->filterBy('template', $template);
                     break;
                 case 'pages':
                 case 'all':
                     $pages = site()->index();
                     break;
                 default:
                     if ($page = site()->page($index)) {
                         $pages = $page->children();
                     } else {
                         return response::json(array());
                     }
             }
             $result = $pages->pluck(get('field', 'tags'), get('separator', true), true);
             break;
         default:
             return response::error('Invalid autocomplete method');
     }
     return response::json(array_values($result));
 }
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:52,代码来源:helpers.php

示例4: delete

 public function delete($username)
 {
     $user = $this->user($username);
     if (!$user) {
         return response::error(l('users.avatar.delete.error.missing'));
     }
     if ($avatar = $user->avatar()) {
         if (f::remove($avatar->root())) {
             return response::success(l('users.avatar.delete.success'));
         }
     }
     return response::error(l('users.avatar.delete.error'));
 }
开发者ID:kompuser,项目名称:panel,代码行数:13,代码来源:avatars.php

示例5: delete

 public function delete($username)
 {
     $user = $this->user($username);
     if (!$user) {
         return response::error(l('users.error.missing'));
     }
     try {
         $user->delete();
         return response::success('success');
     } catch (Exception $e) {
         return response::error(l('users.delete.error'));
     }
 }
开发者ID:kompuser,项目名称:panel,代码行数:13,代码来源:users.php

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

示例7: avgimgcolorhook

function avgimgcolorhook($file)
{
    if (!$file->isImage()) {
        return;
    }
    try {
        if ($file->avgcolor() == "") {
            require_once kirby()->roots()->index() . '/vendor/autoload.php';
            $color = \ColorThief\ColorThief::getColor($file->root(), 100);
            $file->update(['avgcolor' => rgb2hex($color)]);
        }
    } catch (Exception $e) {
        return response::error($e->getMessage());
    }
}
开发者ID:lyoshenka,项目名称:travelblog,代码行数:15,代码来源:avg_img_color.php

示例8: autothumbhook

function autothumbhook($file)
{
    if (!c::get('autothumb.enabled', false) || !$file->isImage()) {
        return;
    }
    try {
        $height = c::get('autothumb.height', 500);
        $quality = c::get('autothumb.quality', 70);
        $dimensions = clone $file->dimensions();
        $dimensions->fitHeight($height);
        $thumb = thumb($file, ['width' => $dimensions->width(), 'height' => $dimensions->height(), 'quality' => $quality]);
        echo $thumb->root();
    } catch (Exception $e) {
        return response::error($e->getMessage());
    }
}
开发者ID:lyoshenka,项目名称:travelblog,代码行数:16,代码来源:autothumb.php

示例9: delete

 public function delete($username)
 {
     $user = $this->user($username);
     if (!$user) {
         return response::error(l('users.avatar.delete.error.missing'));
     }
     if (!site()->user()->isAdmin() and !$user->isCurrent()) {
         return response::error('You are not allowed to delete the avatar of this user');
     }
     if ($avatar = $user->avatar()) {
         if (f::remove($avatar->root())) {
             return response::success(l('users.avatar.delete.success'));
         }
     }
     return response::error(l('users.avatar.delete.error'));
 }
开发者ID:williampan,项目名称:w,代码行数:16,代码来源:avatars.php

示例10: delete

 public function delete($username)
 {
     $user = $this->user($username);
     if (!$user) {
         return response::error(l('users.error.missing'));
     }
     if (!site()->user()->isAdmin() and !$user->isCurrent()) {
         return response::error('You are not allowed to delete this user');
     }
     try {
         $user->delete();
         return response::success('success');
     } catch (Exception $e) {
         return response::error(l('users.delete.error'));
     }
 }
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:16,代码来源:users.php

示例11: login

 public function login()
 {
     $user = app::$site->users()->find(str::lower(get('username')));
     $message = l('login.error');
     if (!$user) {
         return response::error($message);
     }
     try {
         if (!$user->login(get('password'))) {
             throw new Exception($message);
         }
         return response::success(l('login.success'));
     } catch (Exception $e) {
         return response::error($e->getMessage());
     }
 }
开发者ID:kompuser,项目名称:panel,代码行数:16,代码来源:auth.php

示例12: thumb

 public function thumb($id, $filename)
 {
     $page = $this->page($id);
     $file = $this->file($page, $filename);
     $width = intval(get('width'));
     $height = intval(get('height'));
     if (!$file->canHavePreview()) {
         return response::error('No preview available', 404);
     }
     if (!$file->canHaveThumb()) {
         go($file->url());
     }
     if (get('crop') == true) {
         $thumb = $file->crop($width, $height, 80);
     } else {
         $thumb = $file->resize($width, $height, 80);
     }
     go($thumb->url());
 }
开发者ID:irenehilber,项目名称:kirby-base,代码行数:19,代码来源:files.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: foreach

    try {
        // Make sure we're on a product page
        if ($page->template() !== 'product') {
            return true;
        }
        // Numeric stock, price and sale price
        $variants = $page->variants()->yaml();
        foreach ($variants as $key => $variant) {
            if (!is_numeric($variant['price'])) {
                $variants[$key]['price'] = preg_replace('/[^0-9.]/', '', $variant['price']);
            }
            if (!is_numeric($variant['sale_price'])) {
                $variants[$key]['sale_price'] = preg_replace('/[^0-9.]/', '', $variant['sale_price']);
            }
            if (!is_numeric($variant['stock'])) {
                $variants[$key]['stock'] = preg_replace('/[^0-9.]/', '', $variant['stock']);
            }
        }
        // Numeric tax rates
        $taxes = $page->tax()->yaml();
        foreach ($taxes as $key => $tax) {
            if (!is_numeric($tax['rate'])) {
                $taxes[$key]['rate'] = preg_replace('/[^0-9.]/', '', $tax['rate']);
            }
        }
        // Save changes
        $page->update(['variants' => yaml::encode($variants), 'tax' => yaml::encode($taxes)]);
    } catch (Exception $e) {
        return response::error($e->getMessage());
    }
});
开发者ID:samnabi,项目名称:shopkit,代码行数:31,代码来源:hooks.php

示例15: set_error

 public static function set_error($code = 1, $msg = '')
 {
     self::$error = self::code_to_msg($code, $msg);
     return false;
 }
开发者ID:GStepOne,项目名称:CI,代码行数:5,代码来源:class.response.php


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