本文整理汇总了PHP中core::dprint方法的典型用法代码示例。如果您正苦于以下问题:PHP core::dprint方法的具体用法?PHP core::dprint怎么用?PHP core::dprint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core
的用法示例。
在下文中一共展示了core::dprint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activate
/**
* Activate filter
*/
function activate()
{
core::dprint('Activate RSS');
tpl_loader::set_template('rss');
core::lib('renderer')->set_content_type('text/xml');
// 'application/rss+xml'
}
示例2: run
/**
* Run block
* Called from module::run_block
*
* Params passed to 'block.data'
* action converted to object!
*
* Extended params passed to {$block.params}
*
* @throws modules_exception
*/
function run($action, $params)
{
$_tag = $this->get_context()->get_tag();
core::dprint('[BLOCK] start ' . $_tag . '::' . $action, core::E_DEBUG);
$return = false;
// @todo check for callable
if (is_callable(array($this, $action))) {
if (!empty($params)) {
// convert parameters to object
$c_params = functions::array2object($params);
$data = call_user_func(array($this, $action), $c_params);
} else {
$data = call_user_func(array($this, $action));
}
// get block builtin properties
$props = $this->get_block($action);
// assign params
$props['params'] = $params;
$return = $this->get_context()->get_core()->lib('renderer')->render_block($props, $data);
} else {
throw new modules_exception('Not callable action supplied - ' . $action);
}
core::dprint('[/BLOCK] end ' . $_tag . '::' . $action, core::E_DEBUG);
return $return;
}
示例3: run
function run()
{
/**@var tf_sat $sat */
$sat = core::module('sat');
$site = $sat->get_current_site();
$json_file = loader::get_public('assets/' . $site->domain . '.json');
$last_mod = @filemtime($json_file);
$tree_last_mod = 0;
if ($last_mod) {
$last_node = $sat->get_node_handle()->set_where('site_id = %d', $sat->get_current_site_id())->set_order('updated_at DESC')->load_first();
$tree_last_mod = $last_node ? $last_node->updated_at : 0;
core::dprint(__METHOD__ . ': cached');
// uptodate
if ($tree_last_mod <= $last_mod) {
$this->renderer->set_ajax_answer(file_get_contents($json_file))->ajax_flush();
return;
}
}
core::dprint(__METHOD__ . ': fetch!');
$tree = $sat->get_current_site_tree();
$allowedKeys = array('title', 'url');
array_walk($tree, function (&$v) use($allowedKeys) {
$v = array_intersect_key($v, array_flip($allowedKeys));
});
$tree = array_values($tree);
// cache
file_put_contents($json_file, functions::json_encode($tree));
$this->renderer->set_ajax_answer($tree)->ajax_flush();
}
示例4: _init_smarty3
/**
* Load smarty3
* @param mixed $params
* @return Smarty3
*/
static function _init_smarty3($params)
{
$smarty = false;
// check smarty autoload
$status = class_exists('Smarty');
$file = loader::get_public() . loader::DIR_EXT . 'smarty3/Smarty.php';
if (!file_exists($file)) {
throw new lib_exception('Smarty3 file not found');
}
require $file;
if (!class_exists('Smarty3', false)) {
throw new lib_exception('Smarty3 class not found');
}
$smarty = new Smarty3();
$smarty->debugging = isset($params['debugging']) ? $params['debugging'] : core::selfie()->cfg('debug_templates', false);
$smarty->caching = isset($params['caching']) ? $params['caching'] : false;
$smarty->cache_lifetime = isset($params['cache_lifetime']) ? $params['cache_lifetime'] : 120;
$smarty->cache_locking = true;
$smarty->compile_check = isset($params['compile_check']) ? $params['compile_check'] : true;
$smarty->force_compile = isset($params['force_compile']) ? $params['force_compile'] : false;
$smarty->merge_compiled_includes = false;
$smarty->error_reporting = error_reporting() & ~E_NOTICE;
$smarty->addPluginsDir(loader::get_public() . loader::DIR_EXT . 'smarty3/plugins');
// add asset compiler plugin
$smarty->addPluginsDir(loader::get_public(loader::DIR_EXT . 'smarty-sacy'));
core::dprint(array('[smarty3] dist:%s %s debugging: %s, caching: %s, force: %s, ttl: %d', $status ? 'composer' : 'old', Smarty3::SMARTY_VERSION, $smarty->debugging ? 'yes' : 'no', $smarty->caching ? 'yes' : 'no', $smarty->force_compile ? 'yes' : 'no', $smarty->cache_lifetime), core::E_RENDER);
$template = core::selfie()->cfg('template');
self::$parser = $smarty;
self::set_template($template);
return $smarty;
}
示例5: activate
/**
* Activate filter
*/
function activate()
{
core::dprint('Activate RSS');
// tpl_loader::set_template('');
core::lib('renderer')->set_page_template('root.embed');
tf_request::set_ident('embed', 'yes');
}
示例6: run
/**
* Remember!
* Assign current item in controller for comment linking!
*/
function run()
{
if (loader::in_ajax() !== true) {
throw new controller_exception('Cant touch this ' . __METHOD__);
return false;
}
core::dprint('run comment modify');
$pctl = core::modules()->get_router()->get_controller();
$user = core::lib('auth')->get_user();
/**
* Parent item, must be assigned thru @see module_controller::set_current_item()
* @var abs_collection_item
*/
$post = $pctl->get_current_item();
// var_dump(get_class($post), core::get_modules()->get_router()->get_name());
if (!$post) {
throw new controller_exception('No item assigned');
}
if (!$post->has_behavior('sat.commentable')) {
throw new controller_exception('Not commentable');
}
$comments = $post->behavior('sat.commentable')->get_attach_model();
//get_comments();
$request = core::lib('request');
$renderer = core::lib('renderer');
$user_id = core::lib('auth')->get_user()->id;
$pid = (int) $request->post('pid', 0);
$limit = core::selfie()->cfg('comment_interval', 60);
$auth = core::lib('auth');
/** @var aregistry $sd */
$sd = $auth->get_current_session()->get_storage();
$time = $sd->comments_last_time;
//$time = $comments->get_last_time($pid, $user_id);
// disallow by interval
if ($time && $time + $limit > time()) {
$pctl->set_null_template();
$renderer->set_ajax_answer(array('status' => false, 'id' => 0, 'message' => vsprintf(i18n::T('sat\\comment_interval_restriction'), $time + $limit - time())))->ajax_flush();
// else core::get_instance()->set_message(array('content', 'comment_interval_restriction'));
return;
// exit
}
$sd->comments_last_time = time();
$username = functions::request_var('username', '');
$text = functions::request_var('text', '');
$api = functions::request_var('api');
$id = $comments->modify(array('user_ip' => core::lib('auth')->get_user_ip(true), 'user_id' => $user_id, 'ctype_id' => $post->get_ctype_id(), 'username' => $username, 'pid' => $pid, 'text' => $text, 'type' => functions::request_var('type', 0), 'tpid' => functions::request_var('tpid', 0), 'api' => $api));
$comment = $comments->get_item_by_id($id);
if (!$comment) {
throw new controller_exception('[ajax] Comment create failed');
}
$comment->load_secondary();
$renderer->set_data('comment', $comment->render())->set_ajax_answer(array('status' => true, 'id' => $id))->set_ajax_message(i18n::T('sat\\comment_posted'));
//->set_main_template('content/comment/view');
$renderer->ajax_flush('shared/comments/comment');
// alright, update counter
return $id;
}
示例7: load_level
function load_level(&$i)
{
core::dprint(array('load:: %d - %s', $i, $this->title));
$this->load_secondary();
if ($i > 1) {
--$i;
foreach ($this->_childrens as $c) {
$c->load_level($i);
}
}
return $this;
}
示例8: init
function init($root)
{
if ($root) {
$this->_root = $root;
$file = $this->_root . 'template.php';
if (file_exists($file)) {
core::dprint(array('Load template config : %s', $file), core::E_DEBUG3);
$this->init_config($this->_normalize(include $file));
}
}
return $this;
}
示例9: set_current
/**
* Doamin matched in initial_route
*/
function set_current()
{
$this->_current = true;
if (0 != $this->template) {
$core = core::get_instance();
$templates = $core->get_cfg_var('templates');
if (isset($templates[$this->template])) {
core::dprint(array('SITE_LAYOUT : %s', $templates[$this->template]), core::E_DEBUG1);
core::lib('renderer')->set_layout($templates[$this->template]);
}
}
}
示例10: convert_from
/** utf8-cp1251 */
static function convert_from($input)
{
if (empty($input)) {
return $input;
}
if (self::$_charset == self::UNICODE) {
return $input;
}
if (is_array($input)) {
return self::convert_from_array($input);
}
$return = is_string($input) ? iconv(self::UNICODE, str_replace('-', '', self::$_charset), $input) : $input;
if (!$return) {
core::dprint(array('strings::convert_from fail %s', $input), core::E_DEBUG3);
}
return $return;
}
示例11: upload_file
/**
* Upload
* @param array $_FILES[key]
* @param string dst_path (dir)
* @param string force use name
* @param array config for uploader
* force_override => bool
*/
function upload_file(array $file_data, $to_file, $use_name = false, $config = array())
{
if (!is_dir($to_file) || !is_writable($to_file)) {
throw new uploader_exception('Destanation not available ' . $to_file);
}
// $file_type = $file_data['type'];
$file_tmpfile = $file_data['tmp_name'];
$file_name = $file_data['name'];
$file_size = $file_data['size'];
if (substr($to_file, -1, 1) != '/') {
$to_file .= '/';
}
if ($file_size <= 0) {
throw new uploader_exception('Nothing uploaded ' . $to_file);
}
if ($use_name) {
$file_name = $use_name;
} else {
// remove bad charz
$file_name = preg_replace('[^a-z0-9_]i', '', $file_name);
if (substr($file_name, 0, 1) == '.') {
$file_name = date('jny_His') . $file_name;
}
//пустое имя файла заменяем на дату
}
$to_file = $to_file . $file_name;
if (file_exists($to_file) && empty($config['force_override'])) {
throw new uploader_exception("File {$file_name} exists. Cant overwrite.");
}
$u_uploadsucc = false;
core::dprint(array('Uploading %s -> %s', $file_tmpfile, $to_file));
if (!empty($file_tmpfile) && is_file($file_tmpfile)) {
if (copy($file_tmpfile, $to_file)) {
$u_uploadsucc = true;
@chmod($to_file, 0777);
} else {
if (move_uploaded_file($file_tmpfile, $to_file)) {
$u_uploadsucc = true;
@chmod($to_file, 0777);
}
}
$l_size_after = filesize($to_file);
}
return $to_file;
}
示例12: smarty_function_block
/**
* Block entry point
*
* @param array
* module // module tag
* action // block action
* cache // seconds, cache data
* other params
*/
function smarty_function_block($params, &$smarty)
{
$core = core::get_instance();
foreach ($params as $k => $v) {
if (!isset(${$k})) {
${$k} = $v;
}
}
$cache_this = false;
// $core->time_check('c1', true, true);
if (isset($cache)) {
$cacher_factory = core::lib('cache');
if ($cacher_factory->has_memory()) {
$cacher = $cacher_factory->get_memory_handle();
$cache_time = $cache;
unset($params['cache']);
$cache_id = 'block_' . md5(serialize($params));
$result = $cacher->get($cache_id, false);
if (false !== $result) {
core::dprint('cache hit : ' . $params['action'] . ' - ' . $core->time_check('c1', true));
return $result;
}
$cache_this = true;
}
}
try {
if (empty($module)) {
$module = 'core';
}
if ($pmod = $core->module($module)) {
unset($params['action'], $params['module']);
$result = $pmod->run_block($action, $params);
if ($cache_this) {
$cacher->set($cache_id, $result, $cache_time);
}
// core::var_dump('no cache : ' . $cache_id, $core->time_check('c1', true));
return $result;
}
} catch (modules_exception $e) {
return '[block] ' . $e->getMessage();
}
return false;
}
示例13: get
/**
* Create a database handle
* Factory method
* @param array params
*/
public static function get(array $config)
{
$engine = $config['engine'];
if (isset(self::$dbs[$engine])) {
return self::$dbs[$engine];
}
$engine_script = loader::get_root() . loader::DIR_MODULES . 'core/dbal/' . $engine . loader::DOT_PHP;
core::dprint('[db] ' . $engine_script);
fs::req($engine_script, true);
if (!isset($config['server'])) {
$config['server'] = 'localhost';
}
// create instance
$class = "{$engine}_db";
try {
return self::$dbs[$engine] = new $class($config['server'], $config['login'], $config['password'], $config['database'], $config['prefix']);
} catch (dbal_exception $e) {
return false;
}
}
示例14: run
/**
* Run
* PHP5.4: Declaration of users_controller::run() should be compatible with front_controller::run($route, $params) : 2048
* @return template
*/
public function run($r, $params = null)
{
// base routes
if ($this->router->get_current_route()) {
return parent::run($r, $params);
}
$this->set_section_name('users');
// default action
if (empty($r->action)) {
$r->action = 'users';
}
$this->set_req($r);
if (!is_callable(array($this, $r->action))) {
throw new controller_exception('No such action', router_exception::ERROR);
}
// call method
core::dprint('users_controller::' . $r->action);
call_user_func(array($this, $r->action), $r);
return $this->get_template();
}
示例15: Threader
/**
* Threader::Threader()
*
* The constructor which opens the process.
*
* @param mixed $cmd - Execute a shell command
* @param mixed $vars - Pass arguments to shell command
* @param string $name - Identifies your thread (useful for debug)
* @return void
*/
function Threader($cmd = null, $vars = null, $name = null, $stdout_file = null)
{
$descriptorspec = array(self::STDIN => array("pipe", "r"), self::STDOUT => array("pipe", "w"), self::STDERR => array("pipe", "w"));
if ($stdout_file) {
$this->_stdout_file = $stdout_file;
$descriptorspec[self::STDOUT] = array("file", $stdout_file, "w");
core::dprint('[THREAD] LOG ' . $stdout_file);
}
$pipes = array();
if (!empty($cmd)) {
$this->threadName = $name;
try {
// if ($err = stream_get_contents($pipes[2]))
$command = "{$cmd} {$vars}";
$this->rid = proc_open($command, $descriptorspec, $this->pipes, null, null);
@stream_set_blocking($this->pipes[self::STDIN], 0);
@stream_set_blocking($this->pipes[self::STDOUT], 0);
@stream_set_blocking($this->pipes[self::STDERR], 0);
@stream_set_write_buffer($this->pipes[self::STDIN], 0);
@stream_set_write_buffer($this->pipes[self::STDOUT], 0);
@stream_set_write_buffer($this->pipes[self::STDERR], 0);
/*
stream_set_blocking($this->pipes[self::STDIN] , 0);
stream_set_blocking($this->pipes[self::STDOUT] , 0);
stream_set_blocking($this->pipes[self::STDERR] , 0);
// don't buffer stdout or stderr
stream_set_write_buffer($this->pipes[self::STDIN], 0);
stream_set_write_buffer($this->pipes[self::STDOUT], 0);
stream_set_write_buffer($this->pipes[self::STDERR], 0);
*/
// Display the current STDOUT meta data.
// print_r(stream_get_meta_data($this->pipes[self::STDIN]));
core::dprint("[THREAD] " . $command);
$this->active = true;
} catch (exception $e) {
$this->active = false;
$this->error = $e->getMessage();
}
}
}