/** * Description... * * @return void **/ public function address() { if ($this->citySearchName() == qh($this->address)) { return qh($this->address); } return $this->citySearchName() . ' ' . qh($this->address); }
/** * Returns an HTML report of the difference between the expected * and actual line. * * @param $expectedLine string the correct line * @param $actualLine string the submitted line * @return string HTML showing correct words in green and incorrect words in red */ protected function diffLines($expectedLine, $actualLine) { list($expectedLabel, $expectedWords) = $expectedLine ? explode(':', $expectedLine, 2) : array('', ''); list($actualLabel, $actualWords) = explode(':', $actualLine, 2); preg_match_all('![\\s,]*([^\\s,]+)!', $actualWords, $actualMatches); preg_match_all('![\\s,]*([^\\s,]+)!', $expectedWords, $expectedMatches); $diff = $actualLabel . ':'; $n = max(count($expectedMatches[1]), count($actualMatches[1])); for ($i = 0; $i < $n; $i++) { if ($i >= count($expectedMatches[1])) { $diff .= ' <span class="incorrect">' . qh($actualMatches[1][$i]) . ' <span class="hint">()</span></span>'; } elseif ($i >= count($actualMatches[1])) { $diff .= ' <span class="incorrect"><span class="hint">(' . qh($expectedMatches[1][$i]) . ')</span></span>'; } elseif (strcasecmp(preg_replace('![^a-z]!i', '', $expectedMatches[1][$i]), preg_replace('![^a-z]!i', '', $actualMatches[1][$i])) !== 0) { $diff .= ' <span class="incorrect">' . qh($actualMatches[1][$i]) . ' <span class="hint">(' . qh($expectedMatches[1][$i]) . ')</span></span>'; } else { $diff .= ' <span class="correct">' . qh($actualMatches[1][$i]) . '</span>'; } } return $diff; }
<?php if (!isNull($object)) { ?> <?php echo qh($object->name); } else { ?> <?php if ($system_value) { ?> <?php echo L('shop.unknown_city') . $system_value; ?> <?php } else { ?> <?php echo L('shop.allrussia'); ?> <?php } }
public static function externalLinks($text) { $rLink = '/^(.*?)(\\[(http[^\\s]*)\\s*([^\\]]*)\\])(.*?)$/'; while (preg_match($rLink, $text, $m)) { $lhs = $m[1]; $link = $m[3]; $title = $m[4]; $rhs = $m[5]; $text = $lhs . '<a target="_blank" nofollow href="' . qh($link, false) . '" title="' . qh($title, false) . '">' . qh($title, false) . '</a>' . $rhs; } return $text; }
<?php require_once './app/views/shared/_header.php'; ?> <h1><?php echo qh($this->table->getName()); ?> </h1> <p>We have finished marking your submission. Words in green are correct; words in red are incorrect (with the correct word shown in parentheses). <a href="index.php?controller=table&action=new&table=<?php echo urlencode($this->table->getName()); ?> ">Try again?</a></p> <pre> <?php echo $this->diff; ?> </pre> <?php require_once './app/views/shared/_footer.php';
public function testQh_HtmlEncodesAmpersands() { $this->assertIdentical('A & W', qh('A & W')); }
/** * Description... * * @return void **/ public function address() { return qh($this->address); }
<?php require_once './app/views/shared/_header.php'; ?> <h1><?php echo qh($this->table->getName()); ?> </h1> <p>Here are the answers for the <cite><?php echo qh($this->table->getName()); ?> </cite> table. <a href="index.php?controller=table&action=new&table=<?php echo urlencode($this->table->getName()); ?> ">Ready to try it?</a></p> <pre> <?php echo qh($this->table->getText()); ?> </pre> <?php require_once './app/views/shared/_footer.php';
echo urlencode(TableLoader::NOUNS); ?> &demo=1">demo</a>. <?php } ?> </p> <form action="index.php?controller=table&action=create&table=<?php echo urlencode($this->table->getName()); ?> " method="post"> <input type="submit" class="submit" value="Submit" /> <textarea id="text" name="text"><?php echo qh($this->text); ?> </textarea> <input type="submit" class="submit" value="Submit" /> </form> <?php if (!$this->demoing) { ?> <textarea id="answers" style="display:none"><?php echo qh($this->answers); ?> </textarea> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script src="public/javascripts/shared/util.js"></script> <script src="public/javascripts/table/new.js"></script> <?php } require_once './app/views/shared/_footer.php';