Example #1
0
 public function testCleanTerm()
 {
     $this->assertEquals("foo-bar", Format::cleanTerm("foo bar"));
     $this->assertEquals("foobar", Format::cleanTerm("foo\t\r\nbar"));
 }
Example #2
0
 /**
  * Is called when a definition is loaded via AJAX call, for example from an
  * existing definition page. We load the definition data and return it
  * formated as a card, that is supposed be inserted into a card area.
  *
  * NOTE: Because this is an AJAX action, we do not return from this call and
  * exit script execution with "exit".
  *
  * @param array $args The AJAX call's arguments as key -> value pairs
  */
 public function ajaxAction($args)
 {
     $term = Format::cleanTerm(urldecode(reset($args)));
     try {
         $definition = \Glossary\Definition\DefinitionFactory::getInstance()->fromTerm($term);
         echo "<div class=\"definitionCard main\">\n                    <span class=\"definitionTerm\">" . $definition->getTerm() . "</span>\n\n                    <br/>\n\n                    <span class=\"definitionDescription\">" . Format::formatDescription($definition->getDescription()) . "</span>\n                </div>";
     } catch (\Exception $e) {
         echo "<div class=\"errors\">\n                <span class=\"error\">Suchbegriff nicht gefunden</span>\n                </div>";
     }
     exit;
 }