Ejemplo n.º 1
0
 public function testGetClosingUsfm()
 {
     $this->assertEquals('\\wj*', Filter_Usfm::getClosingUsfm('wj'));
     $this->assertEquals('\\add*', Filter_Usfm::getClosingUsfm('add'));
     $this->assertEquals('\\add*', Filter_Usfm::getClosingUsfm('add', false));
     $this->assertEquals('\\+add*', Filter_Usfm::getClosingUsfm('add', true));
 }
Ejemplo n.º 2
0
 private function closeElementNode($node)
 {
     // The tag name of this element node.
     $tagName = $node->tagName;
     $class = $node->getAttribute('class');
     switch ($tagName) {
         case 'p':
             // While editing it happens that the p element does not have a class.
             // Use the 'p' class in such cases.
             if ($class == "") {
                 $class = "p";
             }
             if (in_array($class, $this->noteOpeners)) {
                 // Deal with note closers.
                 $this->currentLine .= Filter_Usfm::getClosingUsfm($class);
             } else {
                 // Normally a p element closes the USFM line.
                 $this->flushLine();
                 $this->mono = false;
                 // Clear active character styles clear active character styles.
                 $this->characterStyles = array();
             }
             break;
         case 'span':
             // Do nothing for monospace elements, because the USFM would be the text nodes only.
             if ($this->mono) {
                 break;
             }
             // Do nothing without a class.
             if ($class == "") {
                 break;
             }
             // Do nothing if no endmarkers are supposed to be produced.
             if (in_array($class, $this->suppressEndMarkers)) {
                 break;
             }
             // Add closing USFM, optionally closing embedded tags in reverse order.
             $classes = explode(" ", $class);
             $this->characterStyles = array_diff($this->characterStyles, $classes);
             $classes = array_reverse($classes);
             foreach ($classes as $offset => $class) {
                 $embedded = count($classes) > 1 && $offset == 0;
                 if (!empty($this->characterStyles)) {
                     $embedded = true;
                 }
                 $this->currentLine .= Filter_Usfm::getClosingUsfm($class, $embedded);
             }
             break;
         case 'a':
             // Do nothing for note citations in the text.
             break;
         default:
             break;
     }
 }
Ejemplo n.º 3
0
 private function outputAsIs($marker, $isOpeningMarker)
 {
     // Output the marker in monospace font.
     if ($isOpeningMarker) {
         // Add opening marker as it is.
         $this->newParagraph("mono");
         $this->addText(Filter_Usfm::getOpeningUsfm($marker));
     } else {
         // Add closing marker to existing paragraph.
         $this->addText(Filter_Usfm::getClosingUsfm($marker));
     }
 }
Ejemplo n.º 4
0
require_once "../bootstrap/bootstrap.php";
page_access_level(Filter_Roles::TRANSLATOR_LEVEL);
$database_config_user = Database_Config_User::getInstance();
$database_bibles = Database_Bibles::getInstance();
$ipc_focus = Ipc_Focus::getInstance();
$bible = $database_config_user->getTargetXrefBible();
$book = $ipc_focus->getBook();
$chapter = $ipc_focus->getChapter();
$usfm = $database_bibles->getChapter($bible, $book, $chapter);
if (isset($_GET['overwrite'])) {
    $usfm = Filter_Usfm::removeNotes($usfm, array("x"));
    Bible_Logic::storeChapter($bible, $book, $chapter, $usfm);
}
// Count the cross references in this chapter.
$xrefs = Filter_Usfm::extractNotes($usfm, array("x"));
// Count the number of xref openers / closers in this chapter.
$opener = Filter_Usfm::getOpeningUsfm("x");
str_replace($opener, "", $usfm, $openers);
$closer = Filter_Usfm::getClosingUsfm("x");
str_replace($closer, "", $usfm, $closers);
if (empty($xrefs)) {
    Filter_Url::redirect("insert.php");
    die;
}
$header = new Assets_Header(Locale_Translate::_("Cross references"));
$header->run();
$view = new Assets_View(__FILE__);
$view->view->count = count($xrefs);
$view->view->tags = $openers - $closers;
$view->render("clear.php");
Assets_Page::footer();