Beispiel #1
0
 public function setAllowedChildren($allowed)
 {
     if (is_array($allowed)) {
         $this->allowed_children = array();
         foreach ($allowed as $tag_name) {
             $tag_name = SpeedyBBC::strtolower($tag_name);
             if ($tag_name == '[text]' || preg_match('~^([a-z0-9_-])+$~i', $tag_name) > 0) {
                 $this->allowed_children[] = $tag_name;
             }
         }
         // Did anything even get added?
         if (count($this->allowed_children) == 0) {
             $this->allowed_children = null;
         }
         // Now disable the disallowed children option.
         $this->setDisallowedChildren(false);
     } else {
         $this->allowed_children = null;
     }
 }
Beispiel #2
0
 public function attribute($name)
 {
     if ($this->tagType() != 'attribute') {
         return null;
     }
     // Get the array of the attributes, we will call on the attributes
     // method, which will parse them out if need be.
     $attributes = $this->attributes();
     // Now return the attribute value, if any.
     return array_key_exists(SpeedyBBC::strtolower($name), $attributes) ? $attributes[SpeedyBBC::strtolower($name)] : false;
 }
Beispiel #3
0
		.pass { color: green; font-weight: bold; }
		.fail { color: red; font-weight: bold; }
		.border-bottom { padding-bottom: 15px; border-bottom: 1px solid black; }

		p { margin-top: 5px; }
		code { display: block; margin: 10px 5px; background: #F0F0F0; overflow: auto; padding: 5px; }
	</style>
</head>
<body>
	<div id="test-cases">
		<h1>BBCode Testing</h1>
		<p>The following are the results of the BBCode test cases. <a href="#results">Jump to results</a>.</p>';
@set_time_limit(5);
require 'speedybbc-redux.class.php';
$bbc = new SpeedyBBC();
$start_time = microtime(true);
$total_tests = 0;
$total_passed = 0;
foreach ($test_cases as $test) {
    if (!is_array($test)) {
        echo '
			<h2>Category: ', $test, '</h2>';
    } else {
        echo '
			<h3>', $test['name'], '</h3>
			<p>Input:</p>
			<code style="white-space: pre-line;">', htmlspecialchars($test['bbc'], ENT_QUOTES), '</code>

			<p>Expected output:</p>
			<code>