private function evaluate($style) { // Get the relevant styles information included. $styles_logic = Styles_Logic::getInstance(); switch ($style['type']) { case StyleTypeIdentifier: break; case StyleTypeNotUsedComment: break; case StyleTypeNotUsedRunningHeader: break; case StyleTypeStartsParagraph: switch ($style['subtype']) { case ParagraphSubtypeMainTitle: case ParagraphSubtypeSubTitle: case ParagraphSubtypeSectionHeading: $this->add($style, true, true); break; case ParagraphSubtypeNormalParagraph: $this->add($style, true, false); break; } break; case StyleTypeInlineText: $this->add($style, false, false); break; case StyleTypeChapterNumber: $this->add($style, true, false); break; case StyleTypeVerseNumber: $this->add($style, false, false); break; case StyleTypeFootEndNote: switch ($style['subtype']) { case FootEndNoteSubtypeFootnote: case FootEndNoteSubtypeEndnote: $this->add($style, true, false); break; case FootEndNoteSubtypeStandardContent: case FootEndNoteSubtypeContent: case FootEndNoteSubtypeContentWithEndmarker: case FootEndNoteSubtypeParagraph: $this->add($style, false, false); break; } break; case StyleTypeCrossreference: switch ($style['subtype']) { case CrossreferenceSubtypeCrossreference: $this->add($style, true, false); break; case CrossreferenceSubtypeStandardContent: case CrossreferenceSubtypeContent: case CrossreferenceSubtypeContentWithEndmarker: $this->add($style, false, false); break; } break; } }
public function __construct($bible) { $database_config_bible = Database_Config_Bible::getInstance(); $database_styles = Database_Styles::getInstance(); $stylesheet = $database_config_bible->getExportStylesheet($bible); $this->markersStylesheet = $database_styles->getMarkers($stylesheet); $styles_logic = Styles_Logic::getInstance(); foreach ($this->markersStylesheet as $marker) { $style = $database_styles->getMarkerData($stylesheet, $marker); $requiredEndmarker = false; $styleType = $style['type']; $styleSubtype = $style['subtype']; if ($styleType == StyleTypeFootEndNote) { if ($styleSubtype == FootEndNoteSubtypeFootnote || $styleSubtype == FootEndNoteSubtypeEndnote) { $requiredEndmarker = true; } } if ($styleType == StyleTypeCrossreference) { if ($styleSubtype == CrossreferenceSubtypeCrossreference) { $requiredEndmarker = true; } } if ($styleType == StyleTypeInlineText) { $requiredEndmarker = true; } if ($styleType == StyleTypeWordlistElement) { $requiredEndmarker = true; } if ($requiredEndmarker) { $this->markersRequiringEndmarkers[] = $marker; } } }
public function stylesheet($stylesheet) { $this->styles = array(); $styles_logic = Styles_Logic::getInstance(); $database_styles = Database_Styles::getInstance(); $markers = $database_styles->getMarkers($stylesheet); // Load the style information into the object. foreach ($markers as $marker) { $style = $database_styles->getMarkerData($stylesheet, $marker); $this->styles[$marker] = $style; if ($style['type'] == StyleTypeFootEndNote) { if ($style['subtype'] == FootEndNoteSubtypeStandardContent) { $this->standardContentMarkerFootEndNote = $style['marker']; } } if ($style['type'] == StyleTypeCrossreference) { if ($style['subtype'] == CrossreferenceSubtypeStandardContent) { $this->standardContentMarkerCrossReference = $style['marker']; } } } }
public static function getInstance() { if (empty(self::$instance)) { self::$instance = new Styles_Logic(); } return self::$instance; }
/** * This function gets the styles from the database, * and stores them in the object for quicker access. */ private function getStyles($stylesheet) { $this->styles = array(); // Get the relevant styles information included. $styles_logic = Styles_Logic::getInstance(); if ($this->odf_text_standard) { $this->odf_text_standard->createPageBreakStyle(); } if ($this->odf_text_text_only) { $this->odf_text_text_only->createPageBreakStyle(); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->createPageBreakStyle(); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->createSuperscriptStyle(); } $database_styles = Database_Styles::getInstance(); $markers = $database_styles->getMarkers($stylesheet); foreach ($markers as $marker) { $style = $database_styles->getMarkerData($stylesheet, $marker); $this->styles[$marker] = $style; if ($style['type'] == StyleTypeFootEndNote) { if ($style['subtype'] == FootEndNoteSubtypeStandardContent) { $this->standardContentMarkerFootEndNote = $style['marker']; } } if ($style['type'] == StyleTypeCrossreference) { if ($style['subtype'] == CrossreferenceSubtypeStandardContent) { $this->standardContentMarkerCrossReference = $style['marker']; } } } }
public static function getAction($style) { $database_config_user = Database_Config_User::getInstance(); $database_styles = Database_Styles::getInstance(); $styles_logic = Styles_Logic::getInstance(); $stylesheet = $database_config_user->getStylesheet(); $data = $database_styles->getMarkerData($stylesheet, $style); @($type = $data["type"]); @($subtype = $data["subtype"]); switch ($type) { case StyleTypeIdentifier: case StyleTypeNotUsedComment: case StyleTypeNotUsedRunningHeader: return self::mono(); case StyleTypeStartsParagraph: return self::paragraph(); case StyleTypeInlineText: return self::character(); case StyleTypeChapterNumber: return self::paragraph(); case StyleTypeVerseNumber: return self::character(); case StyleTypeFootEndNote: switch ($subtype) { case FootEndNoteSubtypeFootnote: case FootEndNoteSubtypeEndnote: return self::note(); case FootEndNoteSubtypeContent: case FootEndNoteSubtypeContentWithEndmarker: return self::character(); case FootEndNoteSubtypeStandardContent: case FootEndNoteSubtypeParagraph: return self::paragraph(); default: return self::unknown(); } break; case StyleTypeCrossreference: switch ($subtype) { case CrossreferenceSubtypeCrossreference: return self::note(); case CrossreferenceSubtypeContent: case CrossreferenceSubtypeContentWithEndmarker: return self::character(); case CrossreferenceSubtypeStandardContent: return self::paragraph(); default: return self::unknown(); } break; case StyleTypePeripheral: return self::mono(); case StyleTypePicture: return self::mono(); case StyleTypePageBreak: return self::unknown(); case StyleTypeTableElement: switch ($subtype) { case TableElementSubtypeRow: case TableElementSubtypeHeading: case TableElementSubtypeCell: default: return self::mono(); } break; case StyleTypeWordlistElement: return self::character(); default: return self::unknown(); } }
public function testEmbeddedFormattedNote() { $styles_logic = Styles_Logic::getInstance(); $add = array("marker" => "add", "italic" => ooitOn, "bold" => NULL, "underline" => NULL, "smallcaps" => NULL, "superscript" => false, "color" => "000000"); $nd = array("marker" => "nd", "italic" => NULL, "bold" => NULL, "underline" => NULL, "smallcaps" => ooitOn, "superscript" => false, "color" => "000000"); $odf_text = new Odf_Text("phpunit"); $odf_text->newParagraph(); $odf_text->addText("text"); $odf_text->addNote("𐌰", "f"); $odf_text->openTextStyle($add, true, false); $odf_text->addNoteText("add"); $odf_text->openTextStyle($nd, true, true); $odf_text->addNoteText("nd"); $odf_text->closeTextStyle(true, false); $odf_text->addNoteText("normal"); $odf_text->addText("."); $odf_text->save("/tmp/OdfTextTest.odt"); $odt = shell_exec("odt2txt /tmp/OdfTextTest.odt"); $standard = <<<'EOD' text𐌰 addndnormal . EOD; $this->assertEquals($standard, trim($odt)); }
$dialog_list->run(); die; } if (isset($_GET['userint2'])) { $userint2 = $_GET['userint2']; if ($write) { $database_styles->updateUserint2($sheet, $style, $userint2); } } $view->view->userint2 = $styles_logic->noteRestartNumberingText($userint2); break; case UserInt2EndnotePosition: $view->view->userint2_endnoteposition = true; if (isset($_GET['endnoteposition'])) { $dialog_list = new Dialog_List(array("sheet", "style"), Locale_Translate::_("Would you like to change the position where to dump the endnotes?"), "", ""); $styles_logic = Styles_Logic::getInstance(); for ($i = EndNotePositionAfterBook; $i <= EndNotePositionAtMarker; $i++) { $dialog_list->add_row($styles_logic->endNotePositionText($i), "&userint2={$i}"); } $dialog_list->run(); die; } if (isset($_GET['userint2'])) { $userint2 = $_GET['userint2']; if ($write) { $database_styles->updateUserint2($sheet, $style, $userint2); } } $view->view->userint2 = $styles_logic->endNotePositionText($userint2); break; }
public function stylesheet($stylesheet) { $this->styles = array(); $this->noteOpeners = array(); $this->characterStyles = array(); $styles_logic = Styles_Logic::getInstance(); $database_styles = Database_Styles::getInstance(); $markers = $database_styles->getMarkers($stylesheet); // Load the style information into the object. foreach ($markers as $marker) { $style = $database_styles->getMarkerData($stylesheet, $marker); $this->styles[$marker] = $style; // Get markers with should not have endmarkers. $suppress = false; $type = $style['type']; $subtype = $style['subtype']; if ($type == StyleTypeVerseNumber) { $suppress = true; } if ($type == StyleTypeFootEndNote) { $suppress = true; if ($subtype == FootEndNoteSubtypeFootnote) { $this->noteOpeners[] = $marker; } if ($subtype == FootEndNoteSubtypeEndnote) { $this->noteOpeners[] = $marker; } if ($subtype == FootEndNoteSubtypeContentWithEndmarker) { $suppress = false; } if ($subtype == FootEndNoteSubtypeParagraph) { $suppress = false; } } if ($type == StyleTypeCrossreference) { $suppress = true; if ($subtype == CrossreferenceSubtypeCrossreference) { $this->noteOpeners[] = $marker; } if ($subtype == CrossreferenceSubtypeContentWithEndmarker) { $suppress = false; } } if ($type == StyleTypeTableElement) { $suppress = true; } if ($suppress) { $this->suppressEndMarkers[] = $marker; } } }
public static function import($input, $stylesheet) { $result = array(); $book_number = 0; $chapter_number = 0; $chapter_data = ""; $input = Filter_Usfm::oneString($input); $markers_and_text = Filter_Usfm::getMarkersAndText($input); $retrieve_book_number_on_next_iteration = false; $retrieve_chapter_number_on_next_iteration = false; foreach ($markers_and_text as $marker_or_text) { if ($retrieve_book_number_on_next_iteration) { $database_books = Database_Books::getInstance(); $book_number = $database_books->getIdFromUsfm(substr($marker_or_text, 0, 3)); $chapter_number = 0; $retrieve_book_number_on_next_iteration = false; } if ($retrieve_chapter_number_on_next_iteration) { $retrieve_chapter_number_on_next_iteration = false; $chapter_number = Filter_Numeric::integer_in_string($marker_or_text); if ($chapter_number == "") { $chapter_number = 0; } } $marker = Filter_Usfm::getMarker($marker_or_text); if ($marker != "") { // USFM marker found. if ($marker == "id") { $retrieve_book_number_on_next_iteration = true; $store_chapter_data = true; } if ($marker == "c") { $retrieve_chapter_number_on_next_iteration = true; $store_chapter_data = true; } if ($store_chapter_data) { $chapter_data = trim($chapter_data); if ($chapter_data != "") { $result[] = array($book_number, $chapter_number, $chapter_data); } $chapter_number = 0; $chapter_data = ""; $store_chapter_data = false; } $database_styles = Database_Styles::getInstance(); $marker_data = $database_styles->getMarkerData($stylesheet, $marker); $type = $marker_data['type']; $subtype = $marker_data['subtype']; $styles_logic = Styles_Logic::getInstance(); if ($styles_logic->startsNewLineInUsfm($type, $subtype)) { $chapter_data .= "\n"; } } $chapter_data .= $marker_or_text; } $chapter_data = trim($chapter_data); if ($chapter_data != "") { $result[] = array($book_number, $chapter_number, $chapter_data); } return $result; }