Skip to content

Commit

Permalink
Just avoiding generation of php undefined index, offset or variable n…
Browse files Browse the repository at this point in the history
…otices

git-svn-id: https://svn.php.net/repository/pear/packages/Text_Wiki/trunk@305056 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Rodrigo Sampaio Primo committed Nov 3, 2010
1 parent 61de383 commit 08f4ffc
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Text/Wiki.php
Expand Up @@ -664,7 +664,7 @@ function getRenderConf($format, $rule, $key = null)

function setFormatConf($format, $arg1, $arg2 = null)
{
if (! is_array($this->formatConf[$format])) {
if (! isset($this->formatConf[$format]) || ! is_array($this->formatConf[$format])) {
$this->formatConf[$format] = array();
}

Expand Down Expand Up @@ -1278,14 +1278,14 @@ function addToken($rule, $options = array(), $id_only = false)

function setToken($id, $rule, $options = array())
{
$oldRule = $this->tokens[$id][0];
$oldRule = isset($this->tokens[$id]) ? $this->tokens[$id][0] : null;
// reset the token
$this->tokens[$id] = array(
0 => $rule,
1 => $options
);
if ($rule != $oldRule) {
if (!($this->_countRulesTokens[$oldRule]--)) {
if (isset($oldRule) && !($this->_countRulesTokens[$oldRule]--)) {
unset($this->_countRulesTokens[$oldRule]);
}
if (!isset($this->_countRulesTokens[$rule])) {
Expand Down
2 changes: 1 addition & 1 deletion Text/Wiki/Render/Tiki/Code.php
Expand Up @@ -18,7 +18,7 @@ class Text_Wiki_Render_Tiki_Code extends Text_Wiki_Render {
function token($options)
{
$ret = '{CODE(';
if ($options['attr']['type']) {
if (isset($options['attr']) && $options['attr']['type']) {
$ret .= 'colors=>'.$options['attr']['type'];
}
return $ret.")}\n".$options['text']."\n{CODE}";
Expand Down
2 changes: 1 addition & 1 deletion Text/Wiki/Render/Tiki/Colortext.php
Expand Up @@ -36,7 +36,7 @@ class Text_Wiki_Render_Tiki_Colortext extends Text_Wiki_Render {

function token($options)
{
if (!in_array($options['color'], $this->colors)) {
if (isset($options['color']) && !in_array($options['color'], $this->colors)) {
$options['color'] = '#' . $options['color'];
}

Expand Down
2 changes: 1 addition & 1 deletion Text/Wiki/Render/Tiki/Image.php
Expand Up @@ -30,7 +30,7 @@ function token($options)
$img .= $this->conf['prefix'];
$img .= $options['src'] . '"';

if (is_array($options['attr'])) {
if (isset($options['attr']) && is_array($options['attr'])) {
foreach ($options['attr'] as $var => $val) {
$img .= ' '.$var.'="'.$val.'"';
}
Expand Down
2 changes: 1 addition & 1 deletion Text/Wiki/Render/Tiki/Table.php
Expand Up @@ -53,7 +53,7 @@ function token($options)
break;

case 'cell_end':
if ($options['span'] > 1) {
if (isset($options['span']) && $options['span'] > 1) {
$output = str_pad('', ($options['span'] - 1) * 3, ' | ');
} else {
$output = '';
Expand Down
8 changes: 4 additions & 4 deletions Text/Wiki/Render/Tiki/Url.php
Expand Up @@ -18,18 +18,18 @@ class Text_Wiki_Render_Tiki_Url extends Text_Wiki_Render {

function token($options)
{
if ($options['type'] == 'start') {
if (! strlen($options['text']) || $options['href'] == $options['text']) {
if (isset($options['type']) && $options['type'] == 'start') {
if ((! isset($options['text']) || ! strlen($options['text'])) || $options['href'] == $options['text']) {
return '['.$options['href'];
} else {
return '['.$options['href'].'|';
}
}
else if ($options['type'] == 'end') {
else if (isset($options['type']) && $options['type'] == 'end') {
return ']';
}
else {
if (! strlen($options['text']) || $options['href'] == $options['text']) {
if ((! isset($options['text']) || ! strlen($options['text'])) || $options['href'] == $options['text']) {
return '['.$options['href'].']';
} else {
return '['.$options['href'].'|'.$options['text'].']';
Expand Down
6 changes: 3 additions & 3 deletions Text/Wiki/Render/Tiki/Wikilink.php
Expand Up @@ -20,15 +20,15 @@ function token($options)
if (isset($options['type'])) {
if ($options['type'] == 'start') {
return '(('.$options['page'].
(strlen($options['anchor']) ? '#'.$options['anchor'] : '').
(isset($options['anchor']) && strlen($options['anchor']) ? '#'.$options['anchor'] : '').
(strlen($options['text']) /*&& $options['page'] != $options['text']*/ ? '|' : '');
} else {
return '))';
}
} else {
return '(('.$options['page'].
(strlen($options['anchor']) ? '#'.$options['anchor'] : '').
(strlen($options['text']) && $options['page'] != $options['text'] ? '|' . $options['text'] : '').
(isset($options['anchor']) && strlen($options['anchor']) ? '#'.$options['anchor'] : '').
(isset($options['text']) && strlen($options['text']) && $options['page'] != $options['text'] ? '|' . $options['text'] : '').
'))';
}
}
Expand Down

0 comments on commit 08f4ffc

Please sign in to comment.