Commit 055455d8 by Qiang Xue

updated error handler and requirement checker links.

parent 0b29c960
...@@ -32,27 +32,27 @@ $requirements = array( ...@@ -32,27 +32,27 @@ $requirements = array(
'name' => 'PDO extension', 'name' => 'PDO extension',
'mandatory' => true, 'mandatory' => true,
'condition' => extension_loaded('pdo'), 'condition' => extension_loaded('pdo'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All DB-related classes',
), ),
array( array(
'name' => 'PDO SQLite extension', 'name' => 'PDO SQLite extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('pdo_sqlite'), 'condition' => extension_loaded('pdo_sqlite'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All DB-related classes',
'memo' => 'Required for SQLite database.', 'memo' => 'Required for SQLite database.',
), ),
array( array(
'name' => 'PDO MySQL extension', 'name' => 'PDO MySQL extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('pdo_mysql'), 'condition' => extension_loaded('pdo_mysql'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All DB-related classes',
'memo' => 'Required for MySQL database.', 'memo' => 'Required for MySQL database.',
), ),
array( array(
'name' => 'PDO PostgreSQL extension', 'name' => 'PDO PostgreSQL extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('pdo_pgsql'), 'condition' => extension_loaded('pdo_pgsql'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All DB-related classes',
'memo' => 'Required for PostgreSQL database.', 'memo' => 'Required for PostgreSQL database.',
), ),
// Cache : // Cache :
...@@ -60,21 +60,21 @@ $requirements = array( ...@@ -60,21 +60,21 @@ $requirements = array(
'name' => 'Memcache extension', 'name' => 'Memcache extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>', 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html">MemCache</a>',
'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc/api/CMemCache#useMemcached-detail">CMemCache::useMemcached</a> to <code>true</code>.' : '' 'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html#$useMemcached-detail">MemCache::useMemcached</a> to <code>true</code>.' : ''
), ),
array( array(
'name' => 'APC extension', 'name' => 'APC extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('apc'), 'condition' => extension_loaded('apc'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>', 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>',
), ),
// Additional PHP extensions : // Additional PHP extensions :
array( array(
'name' => 'Mcrypt extension', 'name' => 'Mcrypt extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('mcrypt'), 'condition' => extension_loaded('mcrypt'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>', 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-helpers-security.html">Security Helper</a>',
'memo' => 'Required by encrypt and decrypt methods.' 'memo' => 'Required by encrypt and decrypt methods.'
), ),
// PHP ini : // PHP ini :
...@@ -102,7 +102,7 @@ $requirements = array( ...@@ -102,7 +102,7 @@ $requirements = array(
'phpSmtp' => array( 'phpSmtp' => array(
'name' => 'PHP mail SMTP', 'name' => 'PHP mail SMTP',
'mandatory' => false, 'mandatory' => false,
'condition' => strlen(ini_get('SMTP'))>0, 'condition' => strlen(ini_get('SMTP')) > 0,
'by' => 'Email sending', 'by' => 'Email sending',
'memo' => 'PHP mail SMTP server required', 'memo' => 'PHP mail SMTP server required',
), ),
......
...@@ -32,27 +32,27 @@ $requirements = array( ...@@ -32,27 +32,27 @@ $requirements = array(
'name' => 'PDO extension', 'name' => 'PDO extension',
'mandatory' => true, 'mandatory' => true,
'condition' => extension_loaded('pdo'), 'condition' => extension_loaded('pdo'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All DB-related classes',
), ),
array( array(
'name' => 'PDO SQLite extension', 'name' => 'PDO SQLite extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('pdo_sqlite'), 'condition' => extension_loaded('pdo_sqlite'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All DB-related classes',
'memo' => 'Required for SQLite database.', 'memo' => 'Required for SQLite database.',
), ),
array( array(
'name' => 'PDO MySQL extension', 'name' => 'PDO MySQL extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('pdo_mysql'), 'condition' => extension_loaded('pdo_mysql'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All DB-related classes',
'memo' => 'Required for MySQL database.', 'memo' => 'Required for MySQL database.',
), ),
array( array(
'name' => 'PDO PostgreSQL extension', 'name' => 'PDO PostgreSQL extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('pdo_pgsql'), 'condition' => extension_loaded('pdo_pgsql'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All DB-related classes',
'memo' => 'Required for PostgreSQL database.', 'memo' => 'Required for PostgreSQL database.',
), ),
// Cache : // Cache :
...@@ -60,21 +60,21 @@ $requirements = array( ...@@ -60,21 +60,21 @@ $requirements = array(
'name' => 'Memcache extension', 'name' => 'Memcache extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>', 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html">MemCache</a>',
'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc/api/CMemCache#useMemcached-detail">CMemCache::useMemcached</a> to <code>true</code>.' : '' 'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html#$useMemcached-detail">MemCache::useMemcached</a> to <code>true</code>.' : ''
), ),
array( array(
'name' => 'APC extension', 'name' => 'APC extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('apc'), 'condition' => extension_loaded('apc'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>', 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>',
), ),
// Additional PHP extensions : // Additional PHP extensions :
array( array(
'name' => 'Mcrypt extension', 'name' => 'Mcrypt extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('mcrypt'), 'condition' => extension_loaded('mcrypt'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>', 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-helpers-security.html">Security Helper</a>',
'memo' => 'Required by encrypt and decrypt methods.' 'memo' => 'Required by encrypt and decrypt methods.'
), ),
// PHP ini : // PHP ini :
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<?php if ($method !== null): ?> <?php if ($method !== null): ?>
<span class="call"> <span class="call">
<?php if ($file !== null) echo '&ndash;' ?> <?php if ($file !== null) echo '&ndash;' ?>
<?php if ($class !== null) echo $handler->addTypeLinks($class) . '::'; ?><?= $handler->addTypeLinks($method . '()') ?> <?= $class !== null ? $handler->addTypeLinks("$class::$method()") : $method . '()' ?>
</span> </span>
<?php endif; ?> <?php endif; ?>
<span class="at"><?php if ($line !== null) echo 'at line'; ?></span> <span class="at"><?php if ($line !== null) echo 'at line'; ?></span>
......
...@@ -152,22 +152,24 @@ class ErrorHandler extends \yii\base\ErrorHandler ...@@ -152,22 +152,24 @@ class ErrorHandler extends \yii\base\ErrorHandler
*/ */
public function addTypeLinks($code) public function addTypeLinks($code)
{ {
$html = ''; if (strpos($code, 'yii\\') !== 0) {
if (strpos($code, '\\') !== false) { return $this->htmlEncode($code);
// namespaced class }
foreach (explode('\\', $code) as $part) {
$html .= '<a href="http://yiiframework.com/doc/api/2.0/' . $this->htmlEncode($part) . '" target="_blank">' . $this->htmlEncode($part) . '</a>\\'; if (($pos = strpos($code, '::')) !== false) {
} $class = substr($code, 0, $pos);
$html = rtrim($html, '\\'); $method = substr($code, $pos + 2);
} elseif (strpos($code, '()') !== false) { } else {
// method/function call $class = $code;
$html = preg_replace_callback('/^(.*)\(\)$/', function ($matches) { }
return '<a href="http://yiiframework.com/doc/api/2.0/' . $this->htmlEncode($matches[1]) . '" target="_blank">' .
$this->htmlEncode($matches[1]) . '</a>()'; $page = $this->htmlEncode(strtolower(str_replace('\\', '-', $class)));
}, $code); $url = "http://www.yiiframework.com/doc-2.0/$page.html";
if (isset($method)) {
$url .= "#$method-detail";
} }
return $html; return '<a href="' . $url . '" target="_blank">' . $this->htmlEncode($code) . '</a>';
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment