本文整理汇总了PHP中core::is_debug方法的典型用法代码示例。如果您正苦于以下问题:PHP core::is_debug方法的具体用法?PHP core::is_debug怎么用?PHP core::is_debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core
的用法示例。
在下文中一共展示了core::is_debug方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_domain
function get_domain()
{
if (core::is_debug()) {
return empty($this->ddomain) ? $this->domain : $this->ddomain;
}
return $this->domain;
}
示例2: construct_after
function construct_after()
{
$this->params->sid = 0 + $this->request->postget('sid', $this->params->sid);
$this->params->ctype_id = 0 + $this->request->postget('ctype_id', $this->params->ctype_id);
$this->params->pid = 0 + $this->request->postget('pid', $this->params->pid);
if (empty($this->params->pid) && empty($this->params->sid)) {
if (!core::is_debug()) {
throw new controller_exception('Empty pid / no sid');
} else {
$this->_where = null;
}
} else {
$this->_where = sprintf($this->_where, $this->params->ctype_id, $this->params->pid, $this->params->sid);
}
// $this->_where = sprintf($this->_where, $this->params->pid);
}
示例3: action_form_do
function action_form_do()
{
$aids = @$_COOKIE['anket'];
$aids = explode(',', trim($aids));
$aids = is_array($aids) ? $aids : array();
$id = core::lib('db')->escape($this->get_param('id'));
if (empty($id)) {
throw new controller_exception('Bad form id');
}
// debug
if (!core::is_debug() && in_array($id, $aids)) {
$this->set_template('anket/form/already');
return;
}
// load
$form = $this->get_context()->get_form_handle()->set_where('name = "%s"', $id)->set_limit(1)->load()->get_item();
if (!$form) {
throw new router_exception('Form not found');
}
$this->get_renderer()->set_current('anket_form', $form->load_secondary()->render());
if ($this->request->post('form_submit') == 'yes') {
$_post = $this->request->get_post();
/** @var anket_result_collection */
$pres = $this->context->get_result_handle();
$pres->set_current_form($form);
$_post['results'] = !empty($_post['q']) ? serialize($_post['q']) : '';
$_post['uip'] = core::lib('auth')->get_user_ip(1);
// debug
// if (loader::in_ajax() !== true) die('juststopped');
$pres->create($_post);
if (!in_array($id, $aids)) {
$aids[] = $id;
}
setcookie('anket', join(',', $aids), time() + 31104000, '/');
$result = ($item = $pres->get_last_item()) ? $item->render() : false;
if (!loader::in_ajax()) {
$this->set_template('anket/form/complete');
// result.form, result.option
$this->renderer->set_return($result);
} else {
$this->set_null_template();
$this->renderer->set_ajax_message('Обработка запроса')->set_ajax_data($result)->set_ajax_result(true)->set_ajax_redirect('/anket/complete/');
}
}
}
示例4: smarty_function_satblock
/**
* Block entry point
*
* @param array
* module // module tag
* action // block action
* cache // seconds, cache data
* other params
* @param Smarty3 $smarty
*/
function smarty_function_satblock($params, &$smarty)
{
if (empty($params['action'])) {
throw new block_exception('Bad action');
}
$orig_params = $params;
$orig_action = $params['action'];
// module.action
if (strpos($params['action'], '.') !== false) {
$t = explode('.', $params['action']);
$params['action'] = $t[1];
$params['module'] = $t[0];
}
$action = @$params['action'];
$module = @$params['module'];
$cache = @$params['cache'];
$cache_id = null;
$cacher = null;
$with_cache = false;
$cached = false;
$buffer = null;
$core = core::selfie();
// unpack params to local scope
// extract($params, EXTR_SKIP);
/**
* Cache block
*/
if (!empty($cache)) {
/** @var cache $cacher_factory */
$cacher_factory = core::lib('cache');
$cacher = $cacher_factory->has_memory() ? $cacher_factory->get_memory_handle() : $cacher_factory->get_file_handle();
if ($cacher) {
$cache_time = $cache;
unset($params['cache']);
$cache_id = 'block_' . md5(serialize($params));
$result = $cacher->get($cache_id, false);
if (null !== $result) {
core::dprint('..block cached "' . $orig_action . '" using ' . get_class($cacher), core::E_NOTICE);
$buffer = $result;
$cached = true;
}
$with_cache = true;
}
}
if (!$cached) {
try {
if (empty($module)) {
$module = 'core';
}
if ($pmod = core::module($module)) {
unset($params['action'], $params['module']);
// Run block action
$buffer = $pmod->run_block($action, $params);
if ($with_cache) {
$cacher->set($cache_id, $buffer, $cache_time);
}
}
} catch (module_exception $e) {
return '[block] module-error: ' . $e->getMessage();
} catch (block_exception $e) {
return '[block] error: ' . $e->getMessage();
}
}
// debug block
if (core::is_debug() && $core->cfg('debug_templates')) {
$dparams = array();
foreach ($orig_params as $pk => $pv) {
$dparams[] = sprintf('data-%s = "%s"' . PHP_EOL, $pk, $pv);
}
/** @var Smarty_Template_Source $source */
$source = $smarty->source;
// @todo how to get current line?
// $dparams []= sprintf('data-parent-template = "%s"' . PHP_EOL, $source->filepath);
$dsparams = join(' ', $dparams);
$buffer = <<<DBG
<satblock class="sat-block" {$dsparams}>
{$buffer}
</satblock>
DBG;
}
return $buffer;
}
示例5: display_error
/**
* DisplayError
*/
function display_error()
{
$title = $this->getMessage();
$err_no = $this->getCode();
// notify interactive user
if (!class_exists('loader', 0) || class_exists('loader', 0) && !loader::in_ajax() && !($err_no == router_exception::NOT_FOUND && $this instanceof router_exception)) {
if (!headers_sent()) {
header('', true, 500);
}
$message = '<style>* {font: 0.97em verdana;} a {text-decoration:none;background:#EFEFEF;padding:4px;} a:hover{background: red;}</style><h1>Ups! We have an error here.</h1>';
$subject = "Error " . ($this->log_id ? "#{$this->log_id}" : '') . " at " . (loader::in_shell() ? 'console' : $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$message .= "Please send report to <a href='mailto:" . $this->bugs_email . "?subject={$subject}'>Bugs mail</a>.<br/>";
$message .= 'Thank you.<br/><br/>';
$message .= 'Visit <a href="/">index</a> page.<br/><br/>';
echo $message;
// if debug
if (class_exists('core', 0) && core::is_debug()) {
echo '<br/>Error : ' . $title . ' : ' . $err_no;
echo '<br/><br/>' . nl2br($this->getTraceAsString());
}
}
}
示例6: init91
/**
кэш только для основного домена.
на алиасах не работает!
*/
function init91()
{
if (core::in_editor() || loader::in_ajax() || loader::in_shell()) {
return;
}
// @todo cancel on errors!
if (tf_exception::get_last_exception()) {
return;
}
// check current site
if (!($tsite = $this->get_current_site()) || !$tsite->is_staticable()) {
return;
}
/* save static cache!
skip logged in users, debug mode
*/
if ($this->get_core()->cfg('sat_use_static') && !core::lib('auth')->logged_in() && !core::is_debug()) {
$file = $this->get_static_node_path($tnode = $this->get_router()->get_current_node());
$pagination_filter = $this->get_router()->get_filter('pagination');
if ($pagination_filter && ($page = $pagination_filter->get_start())) {
$file = str_replace('/index.html', "/page/{$page}/index.html", $file);
}
core::dprint(array('generate staic : %s', $file), core::E_DEBUG4);
if (!file_exists($file)) {
$dir = dirname($file);
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
}
file_put_contents($file, core::lib('renderer')->get_buffer());
}
}
}
示例7: define
#!/usr/local/bin/php
<?php
/**
* Cron entry point
*
* @package TwoFace
* @author Golovkin Vladimir <r00t@skillz.ru> http://www.skillz.ru
* @copyright SurSoft (C) 2008
* @version $Id: cron.php,v 1.1.4.1.4.1 2009/01/27 17:55:51 surg30n Exp $
*/
// if (empty($_SERVER['argv'])) die('Karamba!');
define('IN_CRONTAB', 'Here!');
define('IN_MAIN', 'Here!');
set_time_limit(0);
require 'modules/core/loader.php';
// run crontab on single module
if (empty($_SERVER['argv']) && !core::is_debug()) {
die('Crontab direct access disabled');
}
// force debug
core::set_debug(666);
ini_set('display_errors', 'on');
error_reporting(E_ALL);
$module = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : false;
core::get_instance()->crontab($module);
示例8: render
/**
* Render filter
* @return object {data, pagination}
*/
function render()
{
$result = new collection_filter_result();
$data = $this->render_with_meta ? $this->collection->render2edt(true) : $this->collection->render();
$result->collection = $data;
$result->pagination = $this->pagination;
$result->filters = $this->render_filters();
$result->orders = $this->get_orders();
if (core::is_debug()) {
$result->sql = $this->collection->get_last_query();
}
// if template specified, render it
if ($this->template) {
$result->data = \View::make($this->template, array('data' => $result->data))->render();
}
return $result;
}
示例9: action_modify
function action_modify()
{
$item = $this->params->id ? $this->_load_id() : false;
$result = true;
if (is_callable(array($this, 'action_modify_before'))) {
$result = $this->action_modify_before($this->postdata, $item);
}
if ($result === false) {
if (!$this->is_message_set()) {
$this->set_message(i18n::T('Action canceled'), false);
}
} else {
$id = $this->collection->modify($this->get_postdata(), $this->params->id);
if (is_callable(array($this, 'action_modify_after'))) {
$this->action_modify_after($id);
}
if (!$this->is_message_set()) {
$newbie = $this->collection->get_last_item();
$data = $newbie ? array() : $newbie->render();
if (core::is_debug()) {
$data['_sql'] = $this->collection->connection()->get_last_query();
}
// return to form
if ($this->submit_type == 'apply') {
$this->set_redirect($this->get_edit_url($newbie));
}
// redirect `apply`
//$data['redirect'] = $newbie->get_urls
$this->set_message(!$id ? i18n::T('Action failed') : i18n::T($this->params->id ? 'Item modified' : 'Item added'), $id)->set_message_data($data);
}
}
}
示例10: output_end
/**
* Post out
* Finish output
*/
private function output_end($tpl, $return = false)
{
$this->_buffer = '';
if ($this->_is_null_template()) {
return;
}
/* display if template given
or return if $return passed
skip if template is empty (ajax)
*/
if (!empty($tpl)) {
$tpl .= loader::DOT_TPL;
// assign data
$this->get_parser()->assign($this->get_data());
core::dprint('[RENDER] using ' . $tpl . ' with ' . $this->get_main_template() . ' [' . $this->template_url . ']');
// in ajax dies silently, if no template found
try {
$this->_buffer = $this->get_parser()->fetch($tpl);
} catch (SmartyException $e) {
$this->_buffer = '<code>ParserException: ' . $e->getMessage() . (core::is_debug() ? nl2br($e->getTraceAsString()) : '') . '</code>';
}
// make some editor magic
if (core::in_editor()) {
core::lib('editor')->on_output_before($this->_buffer);
}
core::event('core_after_output', $this->_buffer);
// fix spaces (30260 -> 27611 time 0.0017)
// $html = preg_replace('#>[\s]{2,}<#smU', '><', $html);
// $html = str_replace(array("\n", "\r", ' '), '', $html);
// $this->tpl_parser->display($tpl);
$this->_buffer = trim($this->_buffer);
if ($return) {
return $this->_buffer;
} else {
echo $this->_buffer;
}
}
}