本文整理汇总了PHP中Utils::debug方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::debug方法的具体用法?PHP Utils::debug怎么用?PHP Utils::debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils
的用法示例。
在下文中一共展示了Utils::debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setslug
/**
* Generate a new slug for the post.
*
* @return string The slug
*/
protected function setslug()
{
$value = '';
// determine the base value from:
// - the new slug
if (isset($this->newfields['term']) && $this->newfields['term'] != '') {
$value = $this->newfields['term'];
} elseif ($this->fields['term'] != '') {
$value = $this->fields['term'];
} elseif (isset($this->newfields['term_display']) && $this->newfields['term_display'] != '') {
$value = $this->newfields['term_display'];
} elseif ($this->fields['term_display'] != '') {
$value = $this->fields['term_display'];
}
// make sure our slug is unique
$slug = Plugins::filter('term_setslug', $value);
$slug = Utils::slugify($slug);
$postfix = '';
$postfixcount = 0;
do {
if (!($slugcount = DB::get_row('SELECT COUNT(term) AS ct FROM {terms} WHERE term = ? AND vocabulary_id = ?;', array($slug . $postfix, $this->fields['vocabulary_id'])))) {
Utils::debug(DB::get_errors());
exit;
}
if ($slugcount->ct != 0) {
$postfix = "-" . ++$postfixcount;
}
} while ($slugcount->ct != 0);
return $this->newfields['term'] = $slug . $postfix;
}
示例2: action_plugin_activation
public function action_plugin_activation($file)
{
DB::register_table('abbrev');
/*
* Create the database table, or upgrade it
*/
$dbms = DB::get_driver_name();
$sql = 'CREATE TABLE ' . DB::table('abbrev') . ' ' . '(';
if ($dbms == 'sqlite') {
$sql .= 'xid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,';
} else {
if ($dbms == 'mysql') {
$sql .= 'xid INT(9) NOT NULL AUTO_INCREMENT,' . 'UNIQUE KEY xid (xid),';
} else {
$sql .= 'xid INT(9) NOT NULL AUTO_INCREMENT,' . 'UNIQUE KEY xid (xid),';
}
}
$sql .= 'abbrev VARCHAR(255),' . 'caseful INTEGER DEFAULT 0,' . "prefix VARCHAR(16) DEFAULT '\\b'," . "postfix VARCHAR(16) DEFAULT '\\b'," . 'priority INTEGER DEFAULT 100,' . 'definition VARCHAR(255)' . ')';
if (!DB::dbdelta($sql)) {
Utils::debug(DB::get_errors());
}
if ($file == str_replace('\\', '/', $this->get_file())) {
ACL::create_token(self::PLUGIN_TOKEN, _t('Allow use of Abbrev plugin'), 'Category', false);
$group = UserGroup::get_by_name('admin');
$group->grant(self::PLUGIN_TOKEN);
}
}
示例3: grab
public function grab($method, $vars = array())
{
$url = 'http://api.flickr.com/services/rest/';
$url .= '?method=' . $method;
foreach ($vars as $key => $val) {
$url .= '&' . $val . '=' . $val;
}
Utils::debug($url);
}
示例4: act_uninstall
public function act_uninstall($handler, $theme)
{
try {
$package = HabariPackages::remove($handler->handler_vars['guid']);
Session::notice("{$package->name} {$package->version} was uninstalled.");
} catch (Exception $e) {
Session::error('Could not complete uninstall: ' . $e->getMessage());
if (DEBUG) {
Utils::debug($e);
}
}
}
示例5: action_block_content_textlinkads
public function action_block_content_textlinkads($block)
{
if (!Cache::has('textlinkads')) {
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$inventory_key = 'NYWSW7HTCIN307VV7BBD';
$tla_uri = 'http://www.text-link-ads.com/xml.php?inventory_key=' . $inventory_key . '&referer=' . urlencode($request_uri) . '&user_agent=' . urlencode($user_agent);
Cache::set('textlinkads', RemoteRequest::get_contents($tla_uri));
Utils::debug('Cache set');
}
$xml = new SimpleXMLElement(Cache::get('textlinkads'));
$links = array();
foreach ($xml->Link as $link) {
$ad = new StdClass();
$ad->before = (string) $link->BeforeText;
$ad->after = (string) $link->AfterText;
$ad->text = (string) $link->Text;
$ad->url = (string) $link->URL;
$links[(string) $link->LinkID] = $ad;
}
$block->links = $links;
}
示例6: act
/**
* The UserThemeHandler's act() method differs from ActionHandler's
* act() method in one distinct way: if the Handler's theme variable
* registers an override action via Theme->register_action(), then
* that function is called instead of the default handler action.
*
* @param action the action that was in the URL rule
* @return bool did the action succeed?
*/
public function act($action)
{
$this->action = $action;
$action_method = 'act_' . $action;
$before_action_method = 'before_' . $action_method;
$after_action_method = 'after_' . $action_method;
$this->theme->{$before_action_method}();
try {
$handled = false;
$handled = Plugins::filter('theme_act_' . $action, $handled, $this->theme);
if (!$handled) {
$this->theme->{$action_method}();
}
} catch (Error $e) {
EventLog::log($e->humane_error(), 'error', 'theme', 'habari', print_r($e, 1));
Session::error($e->humane_error());
//Should we display any error here?
if (DEBUG) {
Utils::debug($e);
}
}
$this->theme->{$after_action_method}();
}
示例7: action_auth_ajax_drupal_import_comments
/**
* The plugin sink for the auth_ajax_drupal_import_comments hook.
* Responds via authenticated ajax to requests for comment importing.
*
* @param AjaxHandler $handler The handler that handled the request, contains $_POST info
*/
public function action_auth_ajax_drupal_import_comments($handler)
{
$valid_fields = array('db_name', 'db_host', 'db_user', 'db_pass', 'db_prefix', 'import_comments', 'commentindex', 'entry_type', 'page_type', 'tag_vocab');
$inputs = array_intersect_key($_POST->getArrayCopy(), array_flip($valid_fields));
extract($inputs);
$drupaldb = $this->drupal_connect($db_host, $db_name, $db_user, $db_pass, $db_prefix);
if ($drupaldb) {
$commentcount = $drupaldb->get_value("SELECT count( c.cid ) FROM {$db_prefix}comments AS c INNER JOIN {$db_prefix}node AS n ON (n.nid = c.nid) WHERE n.type IN ('{$entry_type}', '{$page_type}')");
$min = $commentindex * DRUPAL_IMPORT_BATCH + 1;
$max = min(($commentindex + 1) * DRUPAL_IMPORT_BATCH, $commentcount);
echo "<p>Importing comments {$min}-{$max} of {$commentcount}.</p>";
$postinfo = DB::table('postinfo');
$post_info = DB::get_results("SELECT post_id, value FROM {$postinfo} WHERE name= 'drupal_nid';");
foreach ($post_info as $info) {
$post_map[$info->value] = $info->post_id;
}
if ($import_comments) {
$comments = $drupaldb->get_results("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tc.nid as drupal_post_nid,\n\t\t\t\t\t\tc.comment as content,\n\t\t\t\t\t\tc.name,\n\t\t\t\t\t\tc.mail as email,\n\t\t\t\t\t\tc.homepage as url,\n\t\t\t\t\t\tINET_ATON( c.hostname ) as ip,\n\t\t\t\t\t\tc.status,\n\t\t\t\t\t\tFROM_UNIXTIME( c.timestamp ) as date\n\t\t\t\t\tFROM {$db_prefix}comments AS c\n\t\t\t\t\tINNER JOIN {$db_prefix}node AS n on ( n.nid = c.nid )\n\t\t\t\t\tLIMIT {$min}, " . DRUPAL_IMPORT_BATCH, array(), 'Comment');
} else {
$comments = array();
}
foreach ($comments as $comment) {
$comment->type = Comment::COMMENT;
$comment->status = $comment->status == '0' ? 1 : 0;
$comment->content = MultiByte::convert_encoding($comment->content);
$comment->name = MultiByte::convert_encoding($comment->name);
$carray = $comment->to_array();
if ($carray['ip'] == '') {
$carray['ip'] = 0;
}
if (!isset($post_map[$carray['drupal_post_nid']])) {
Utils::debug($carray);
} else {
$carray['post_id'] = $post_map[$carray['drupal_post_nid']];
unset($carray['drupal_post_nid']);
$c = new Comment($carray);
//Utils::debug( $c );
try {
$c->insert();
} catch (Exception $e) {
EventLog::log($e->getMessage(), 'err', null, null, print_r(array($c, $e), 1));
$errors = Options::get('import_errors');
$errors[] = $e->getMessage();
Options::set('import_errors', $errors);
}
}
}
if ($max < $commentcount) {
$ajax_url = URL::get('auth_ajax', array('context' => 'drupal_import_comments'));
$commentindex++;
echo <<<DRUPAL_IMPORT_AJAX1
\t\t\t\t\t<script type="text/javascript">
\t\t\t\t\t\$( '#import_progress' ).load(
\t\t\t\t\t\t"{$ajax_url}",
\t\t\t\t\t\t{
\t\t\t\t\t\t\tdb_host: "{$db_host}",
\t\t\t\t\t\t\tdb_name: "{$db_name}",
\t\t\t\t\t\t\tdb_user: "{$db_user}",
\t\t\t\t\t\t\tdb_pass: "{$db_pass}",
\t\t\t\t\t\t\tdb_prefix: "{$db_prefix}",
\t\t\t\t\t\t\timport_comments: "{$import_comments}",
\t\t\t\t\t\t\tentry_type: "{$entry_type}",
\t\t\t\t\t\t\tpage_type: "{$page_type}",
\t\t\t\t\t\t\ttag_vocab: "{$tag_vocab}",
\t\t\t\t\t\t\tcommentindex: {$commentindex}
\t\t\t\t\t\t}
\t\t\t\t\t );
\t\t\t\t</script>
DRUPAL_IMPORT_AJAX1;
} else {
EventLog::log('Import complete from "' . $db_name . '"');
echo '<p>' . _t('Import is complete.') . '</p>';
$errors = Options::get('import_errors');
if (count($errors) > 0) {
echo '<p>' . _t('There were errors during import:') . '</p>';
echo '<ul>';
foreach ($errors as $error) {
echo '<li>' . $error . '</li>';
}
echo '</ul>';
}
}
} else {
EventLog::log(sprintf(_t('Failed to import from "%s"'), $db_name), 'crit');
echo '<p>' . _t('Failed to connect using the given database connection details.') . '</p>';
}
}
示例8: theme_route_download_addon
public function theme_route_download_addon($theme, $url_args)
{
$addon = Post::get(array('slug' => $url_args['slug']));
if (!$addon) {
return;
// Don't let people pass weird stuff into here
}
$version = $url_args['version'];
$terms = $this->vocabulary->get_object_terms('addon', $addon->id);
foreach ($terms as $term) {
if ($version == $this->version_slugify($term)) {
if (!isset($term->info->url) || !isset($term->info->hash)) {
Utils::debug($term);
return;
// We must have a download url and a hash to get
}
// zip file of the requested version is located in /user/files/addon_downloads/{$addonslug}/{$versionslug}/{$hash}/{$addonslug}_{$versionslug}.zip
$versiondir = '/files/addon_downloads/' . $addon->slug . '/' . $version . '/';
$dir = $versiondir . $term->info->hash . '/';
$zipfile = Site::get_dir('user') . $dir . $addon->slug . '_' . $version . '.zip';
$zipurl = Site::get_url('user') . $dir . $addon->slug . '_' . $version . '.zip';
if (!is_file($zipfile) || isset($url_args['refresh']) && $url_args['refresh'] == 'refresh') {
// File does not yet exist, prepare directories and create it
if (is_writable(Site::get_dir('user') . '/files/')) {
if (!is_dir(Site::get_dir('user') . $versiondir)) {
mkdir(Site::get_dir('user') . $versiondir, 0755, true);
}
$tmp_dir = sys_get_temp_dir() . '/' . $addon->slug;
// Cleanup: Remove copies from older commits
exec('rm -rf ' . Site::get_dir('user') . $versiondir . '*');
exec('rm -rf ' . $tmp_dir);
exec('rm -rf ' . $zipfile);
if (!is_dir(Site::get_dir('user') . $dir)) {
mkdir(Site::get_dir('user') . $dir, 0755, true);
}
Plugins::act('addon_download', $term->info->source, $addon, $term, $tmp_dir);
if (count(scandir($tmp_dir)) > 2) {
exec('cd ' . $tmp_dir . ' && zip -9 -r ' . $zipfile . ' *');
}
}
}
if (is_file($zipfile)) {
// Everything worked fine - or the file already existed
Utils::redirect($zipurl);
}
}
}
}
示例9: action_upgrade
public function action_upgrade($oldversion)
{
Utils::debug('upgrade ' . $oldversion);
die;
}
示例10: action_handler_display_snippets
public function action_handler_display_snippets($handler_vars)
{
Utils::debug($handler_vars);
exit;
}
示例11: dbg
public function dbg($var, $tipo = 2)
{
return Utils::debug($var, $tipo);
}
示例12: do_stupid_things_in_global_scope
function do_stupid_things_in_global_scope()
{
/**
* Test for the RemoteRequest class.
*/
include '../htdocs/system/classes/remoterequest.php';
include '../htdocs/system/classes/curlrequestprocessor.php';
include '../htdocs/system/classes/socketrequestprocessor.php';
include '../htdocs/system/classes/utils.php';
include '../htdocs/system/classes/error.php';
error_reporting(E_ALL | E_STRICT);
function bs($v)
{
return $v ? 'TRUE' : 'FALSE';
}
$tests_failed = array();
$tests = array('GET http://test.habariproject.org/' => array("\$res"), 'GET http://test.habariproject.org/get' => array("\$res_get"), 'POST http://test.habariproject.org/post' => array("\$res_post"));
print "<h1>Running tests</h1>\n";
$processors = array(new CURLRequestProcessor(), new SocketRequestProcessor());
foreach ($processors as $processor) {
$rr = new RemoteRequest('http://test.habariproject.org/');
$rr->__set_processor($processor);
$res = $rr->execute();
if ($res === TRUE) {
$results[] = array(get_class($processor), $rr->get_response_headers(), substr($rr->get_response_body(), 0));
} else {
$results[] = array(get_class($processor), $res);
}
$rr = new RemoteRequest('http://test.habariproject.org/get');
$rr->__set_processor($processor);
$rr->set_params(array('query' => 'var', 'another' => 'variable'));
$res_get = $rr->execute();
if ($res_get === TRUE) {
$results[] = array(get_class($processor), $rr->get_response_headers(), substr($rr->get_response_body(), 0));
} else {
$results[] = array(get_class($processor), $res_get);
}
$rr = new RemoteRequest('http://test.habariproject.org/post', 'POST');
$rr->__set_processor($processor);
$rr->set_body('If you can read this, the test was successful.');
$res_post = $rr->execute();
if ($res_post === TRUE) {
$results[] = array(get_class($processor), $rr->get_response_headers(), substr($rr->get_response_body(), 0));
} else {
$results[] = array(get_class($processor), $res_post);
}
foreach ($tests as $name => $group) {
print "<h2>{$name}</h2>\n";
foreach ($group as $test) {
$result = eval('return (' . $test . ');');
printf("<p><strong>%s</strong> == ( %s )</p>\n", bs($result), var_export($test, TRUE));
Utils::debug(array_shift($results));
if (!$result) {
$tests_failed[$name][] = $test;
}
}
}
}
if (count($tests_failed)) {
print "<h1>Failed tests</h1>\n";
foreach ($tests_failed as $name => $tests) {
print "<h2>{$name}</h2>\n";
foreach ($tests as $test) {
print "<p>{$test}</p>\n";
}
}
} else {
print "<h1>All tests successful</h1>\n";
}
}
示例13: action_plugin_act_display_column
public function action_plugin_act_display_column($handler)
{
Utils::debug(Posts::get(array('content_type' => Post::type('section'), 'nolimit' => TRUE, 'status' => Post::status('published'), 'orderby' => 'title ASC', 'fetch_fn' => 'get_perms')));
// Utils::debug($handler->handler_vars);
}
示例14: array
<?php
require_once 'config/config.conf.php';
try {
$articles = Db::selectAll('SELECT * FROM posts LIMIT 5');
echo Utils::debug($articles);
echo '<hr>';
$article = Db::selectOne('SELECT * FROM posts WHERE id = :id', array(':id' => 23));
echo Utils::debug($article);
} catch (Exception $e) {
echo $e->getMessage();
}
示例15: setslug
/**
* Generate a new slug for the post.
*
* @return string The slug
*/
private function setslug()
{
// determine the base value from:
// - the new slug
if (isset($this->newfields['slug']) && $this->newfields['slug'] != '') {
$value = $this->newfields['slug'];
} elseif (isset($this->newfields['slug']) && $this->newfields['slug'] == '') {
if ($this->fields['status'] == Post::status('draft') || $this->fields['status'] != Post::status('draft') && $this->newfields['status'] != Post::status('draft')) {
if (isset($this->newfields['title']) && $this->newfields['title'] != '') {
$value = $this->newfields['title'];
} else {
$value = $this->fields['title'];
}
}
} elseif ($this->fields['slug'] != '') {
$value = $this->fields['slug'];
} elseif (isset($this->newfields['title']) && $this->newfields['title'] != '') {
$value = $this->newfields['title'];
} elseif ($this->fields['title'] != '') {
$value = $this->fields['title'];
} else {
$value = 'Post';
}
// make sure our slug is unique
$slug = Plugins::filter('post_setslug', $value);
$slug = Utils::slugify($slug);
$postfix = '';
$postfixcount = 0;
do {
if (!($slugcount = DB::get_row('SELECT COUNT(slug) AS ct FROM {posts} WHERE slug = ?;', array($slug . $postfix)))) {
Utils::debug(DB::get_errors());
exit;
}
if ($slugcount->ct != 0) {
$postfix = "-" . ++$postfixcount;
}
} while ($slugcount->ct != 0);
return $this->newfields['slug'] = $slug . $postfix;
}