示例#1
0
 public function testFormatDescriptionKnownTerms()
 {
     // Note: We must terms here, that we know will exist in the environment
     $input = "f9823hf92hrf Begriff ";
     $output = "f9823hf92hrf <span class=\"termLink\" data-term=\"Begriff\">Begriff</span> ";
     $this->assertEquals($output, Format::formatDescription($input));
 }
示例#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;
 }