Skip to content

Commit

Permalink
возвращен пробел в список пробельных символов, код приведен в большее…
Browse files Browse the repository at this point in the history
… соответствие стандартам кодирования Zend
  • Loading branch information
Gemorroj committed Apr 8, 2012
1 parent 27979e1 commit 0e8f799
Show file tree
Hide file tree
Showing 37 changed files with 1,848 additions and 1,626 deletions.
33 changes: 21 additions & 12 deletions Xbb/Tags/A.php
Expand Up @@ -22,13 +22,18 @@
******************************************************************************/

// Класс для тегов [a], [anchor] и [url]
class Xbb_Tags_A extends bbcode {
class Xbb_Tags_A extends bbcode
{
public $behaviour = 'a';
function get_html($tree = null) {

public function get_html($tree = null)
{
$this -> autolinks = false;
$text = '';
foreach ($this -> tree as $val) {
if ('text' == $val['type']) { $text .= $val['str']; }
if ('text' === $val['type']) {
$text .= $val['str'];
}
}
$href = '';
if (isset($this -> attrib['url'])) {
Expand All @@ -40,15 +45,17 @@ function get_html($tree = null) {
if (! $href && isset($this -> attrib['href'])) {
$href = $this -> attrib['href'];
}
if (! $href && ! isset($this -> attrib['anchor'])) { $href = $text; }
$href = $this -> checkUrl($href);
if (! $href && ! isset($this -> attrib['anchor'])) {
$href = $text;
}
$href = $this -> _checkUrl($href);
$attr = 'class="bb"';
if ($href) {
$attr .= ' href="'.$href.'"';
$attr .= ' href="' . $href . '"';
}
if (isset($this -> attrib['title'])) {
$title = $this -> attrib['title'];
$attr .= ' title="'.htmlspecialchars($title).'"';
$attr .= ' title="' . htmlspecialchars($title) . '"';
}
$id = '';
if (isset($this -> attrib['id'])) {
Expand All @@ -62,14 +69,16 @@ function get_html($tree = null) {
if (! $id) { $id = $text; }
}
if ($id) {
if ($id{0} < 'A' || $id{0} > 'z') { $id = 'bb'.$id; }
$attr .= ' id="'.htmlspecialchars($id).'"';
if ($id{0} < 'A' || $id{0} > 'z') {
$id = 'bb' . $id;
}
$attr .= ' id="' . htmlspecialchars($id) . '"';
}
if (isset($this -> attrib['target'])) {
$target = $this -> attrib['target'];
$attr .= ' target="'.htmlspecialchars($target).'"';
$attr .= ' target="' . htmlspecialchars($target) . '"';
}
return '<a '.$attr.'>'.parent::get_html($this -> tree).'</a>';

return '<a ' . $attr . '>' . parent::get_html($this -> tree) . '</a>';
}
}
?>
12 changes: 7 additions & 5 deletions Xbb/Tags/Abbr.php
Expand Up @@ -22,14 +22,16 @@
******************************************************************************/

// Класс для тега [abbr]
class Xbb_Tags_Abbr extends bbcode {
class Xbb_Tags_Abbr extends bbcode
{
public $behaviour = 'span';
function get_html($tree = null) {

public function get_html($tree = null)
{
$attrib = 'class="bb"';
if ($this -> attrib['abbr']) {
$attrib .= ' title="'.htmlspecialchars($this -> attrib['abbr']).'"';
$attrib .= ' title="' . htmlspecialchars($this -> attrib['abbr']) . '"';
}
return '<abbr '.$attrib.'>'.parent::get_html($this -> tree).'</abbr>';
return '<abbr ' . $attrib . '>' . parent::get_html($this -> tree) . '</abbr>';
}
}
?>
17 changes: 10 additions & 7 deletions Xbb/Tags/Acronym.php
Expand Up @@ -22,16 +22,19 @@
******************************************************************************/

// Класс для тега [acronym]
class Xbb_Tags_Acronym extends bbcode {
class Xbb_Tags_Acronym extends bbcode
{
public $behaviour = 'span';
function get_html($tree = null) {

public function get_html($tree = null)
{
$attrib = 'class="bb"';
if ($this -> attrib['acronym']) {
$attrib .= ' title="'.htmlspecialchars($this -> attrib['acronym'])
.'"';
$attrib .= ' title="' . htmlspecialchars($this -> attrib['acronym'])
. '"';
}
return '<acronym '.$attrib.'>'.parent::get_html($this -> tree)
.'</acronym>';

return '<acronym ' . $attrib . '>' . parent::get_html($this -> tree)
. '</acronym>';
}
}
?>
12 changes: 7 additions & 5 deletions Xbb/Tags/Address.php
Expand Up @@ -22,11 +22,13 @@
******************************************************************************/

// Класс для тега [address]
class Xbb_Tags_Address extends bbcode {
class Xbb_Tags_Address extends bbcode
{
public $rbr = 1;
function get_html($tree = null) {
return '<address class="bb">'.parent::get_html($this -> tree)
.'</address>';

public function get_html($tree = null)
{
return '<address class="bb">' . parent::get_html($this -> tree)
. '</address>';
}
}
?>
12 changes: 8 additions & 4 deletions Xbb/Tags/Align.php
Expand Up @@ -22,9 +22,12 @@
******************************************************************************/

// Класс для тегов [align], [center], [justify], [left] и [right]
class Xbb_Tags_Align extends bbcode {
class Xbb_Tags_Align extends bbcode
{
public $rbr = 1;
function get_html($tree = null) {

public function get_html($tree = null)
{
$align = '';
if (isset($this -> attrib['justify'])) { $align = 'justify'; }
if (isset($this -> attrib['left'])) { $align = 'left'; }
Expand All @@ -46,8 +49,9 @@ function get_html($tree = null) {
break;
}
}
return '<div class="bb" align="'.$align.'">'
.parent::get_html($this -> tree).'</div>';

return '<div class="bb" align="' . $align . '">'
. parent::get_html($this -> tree) . '</div>';
}
}
?>
17 changes: 11 additions & 6 deletions Xbb/Tags/Bbcode.php
Expand Up @@ -22,20 +22,25 @@
******************************************************************************/

// Класс для тега [bbcode]
class Xbb_Tags_Bbcode extends bbcode {
public $behaviour = 'code';
function get_html($tree = null) {
class Xbb_Tags_Bbcode extends bbcode
{
public $behaviour = 'code';

public function get_html($tree = null)
{
$str = '';
foreach ($this -> tree as $item) {
if ('item' == $item['type']) { continue; }
if ('item' === $item['type']) {
continue;
}
$str .= $item['str'];
}
$bb = new bbcode();
$bb -> tags = $this -> tags;
$bb -> mnemonics = $this -> mnemonics;
$bb -> autolinks = $this -> autolinks;
$bb -> parse($str);
return '<code class="bb_code">'.$bb -> highlight().'</code>';

return '<code class="bb_code">' . $bb -> highlight() . '</code>';
}
}
?>
9 changes: 6 additions & 3 deletions Xbb/Tags/Bdo.php
Expand Up @@ -22,9 +22,12 @@
******************************************************************************/

// Класс для тега [bdo]
class Xbb_Tags_Bdo extends bbcode {
class Xbb_Tags_Bdo extends bbcode
{
public $behaviour = 'span';
function get_html($tree = null) {

public function get_html($tree = null)
{
$dir = '';
switch (strtolower($this->attrib['bdo'])) {
case 'ltr':
Expand All @@ -42,7 +45,7 @@ function get_html($tree = null) {
if (isset($this->attrib['lang'])) {
$attr .= ' lang="' . htmlspecialchars($this->attrib['lang']) . '"';
}

return '<bdo ' . $attr . '>' . parent::get_html() . '</bdo>';
}
}
?>
8 changes: 5 additions & 3 deletions Xbb/Tags/Br.php
Expand Up @@ -22,11 +22,13 @@
******************************************************************************/

// Класс для тега [br]
class Xbb_Tags_Br extends bbcode {
class Xbb_Tags_Br extends bbcode
{
public $is_close = true;
public $behaviour = 'span';
function get_html($tree = null) {

public function get_html($tree = null)
{
return '<br class="bb" />' . "\n";
}
}
?>
12 changes: 7 additions & 5 deletions Xbb/Tags/Caption.php
Expand Up @@ -22,11 +22,13 @@
******************************************************************************/

// Класс для тега [caption]
class Xbb_Tags_Caption extends bbcode {
class Xbb_Tags_Caption extends bbcode
{
public $behaviour = 'caption';
function get_html($tree = null) {
return '<caption class="bb">'.parent::get_html($this -> tree)
.'</caption>';

public function get_html($tree = null)
{
return '<caption class="bb">' . parent::get_html($this -> tree)
. '</caption>';
}
}
?>
24 changes: 16 additions & 8 deletions Xbb/Tags/Code.php
Expand Up @@ -22,7 +22,8 @@
******************************************************************************/

/* Класс для тегов подсветки синтаксиса и для тегов [code] и [pre] */
class Xbb_Tags_Code extends bbcode {
class Xbb_Tags_Code extends bbcode
{
/* Число разрывов строк, которые должны быть игнорированы перед тегом */
public $lbr = 0;
/* Число разрывов строк, которые должны быть игнорированы после тега */
Expand All @@ -44,18 +45,22 @@ class Xbb_Tags_Code extends bbcode {
);
/* Объект GeSHi */
private $_geshi;

/* Конструктор класса */
function Xbb_Tags_Code() {
public function __construct()
{
$geshi_path = realpath(
dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR
. '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'geshi.php'
);
@include_once $geshi_path;
@$this->_geshi = new GeSHi('', 'text');
$this->_geshi = new GeSHi('', 'text');
$this->_geshi->set_header_type(GESHI_HEADER_NONE);
}

/* Описываем конвертацию в HTML */
function get_html($tree = null) {
public function get_html($tree = null)
{
// Находим язык подсветки
switch ($this->tag) {
case 'code':
Expand All @@ -66,16 +71,19 @@ function get_html($tree = null) {
break;
default:
$language = $this->tag;
break;
}
if (! $language) { $language = 'text'; }
if (isset($this->lang_synonym[$language])) {
$language = $this->lang_synonym[$language];
}
@$this->_geshi->set_language($language);
$this->_geshi->set_language($language);
// Находим подсвечиваемый код
$source = '';
foreach ($this->tree as $item) {
if ('item' == $item['type']) { continue; }
if ('item' === $item['type']) {
continue;
}
$source .= $item['str'];
}
$this->_geshi->set_source($source);
Expand Down Expand Up @@ -109,16 +117,16 @@ function get_html($tree = null) {
$result = htmlspecialchars($this->attrib['title'], ENT_NOQUOTES);
}
// Получаем подсвеченный код
$result = '<div class="bb_code"><div class="bb_code_header">' .$result
$result = '<div class="bb_code"><div class="bb_code_header">' . $result
. '</div>' . $this->_geshi->parse_code();
// Формируем подпись под кодом
if (isset($this->attrib['footer'])) {
$content = htmlspecialchars($this->attrib['footer'], ENT_NOQUOTES);
$content = '<div class="bb_code_footer">' . $content . '</div>';
$result .= $content;
}

// Возвращаем результат
return $result . '</div>';
}
}
?>
12 changes: 7 additions & 5 deletions Xbb/Tags/Color.php
Expand Up @@ -22,12 +22,14 @@
******************************************************************************/

// Класс для тега [color]
class Xbb_Tags_Color extends bbcode {
class Xbb_Tags_Color extends bbcode
{
public $behaviour = 'span';
function get_html($tree = null) {

public function get_html($tree = null)
{
$color = htmlspecialchars($this -> attrib['color']);
return '<font color="'.$color.'">'.parent::get_html($this -> tree)
.'</font>';
return '<font color="' . $color . '">' . parent::get_html($this -> tree)
. '</font>';
}
}
?>

0 comments on commit 0e8f799

Please sign in to comment.