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 static function getInstance() { if (empty(self::$instance)) { self::$instance = new Database_Styles(); } return self::$instance; }
public function setUp() { $this->tearDown(); $database_styles = Database_Styles::getInstance(); $database_styles->createStandardSheet(); $this->check = new Checks_Usfm("phpunit"); $this->check->initialize(); }
public function recreate() { $database_styles = Database_Styles::getInstance(); $stylesheets = $database_styles->getSheets(); foreach ($stylesheets as $stylesheet) { $path = $this->get_location($stylesheet, false); $this->create($stylesheet, $path, false, false); $path = $this->get_location($stylesheet, true); $this->create($stylesheet, $path, true, false); } }
public function generate() { $this->css[] = '.superscript { font-size: x-small; vertical-align: super; }'; if ($this->exports) { $this->add_exports_styles(); } if ($this->editor) { $this->add_editor_styles(); } $database_styles = Database_Styles::getInstance(); $markers = $database_styles->getMarkers($this->stylesheet); foreach ($markers as $marker) { $style = $database_styles->getMarkerData($this->stylesheet, $marker); $this->evaluate($style); } }
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 function tearDown() { $database_styles = Database_Styles::getInstance(); $database_styles->deleteSheet("phpunit"); }
(at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ require_once "../bootstrap/bootstrap.php"; page_access_level(Filter_Roles::MANAGER_LEVEL); Assets_Page::header(Locale_Translate::_("Styles")); $view = new Assets_View(__FILE__); $database_styles = Database_Styles::getInstance(); $session_logic = Session_Logic::getInstance(); $username = $session_logic->currentUser(); $userlevel = $session_logic->currentLevel(); @($delete = $_GET['delete']); if ($delete != "") { @($confirm = $_GET['confirm']); if ($confirm != "") { $write = $database_styles->hasWriteAccess($username, $delete); if ($userlevel >= Filter_Roles::ADMIN_LEVEL) { $write = true; } if ($write) { $database_styles->deleteSheet($delete); $database_styles->revokeWriteAccess("", $delete); Assets_Page::success(Locale_Translate::_("The stylesheet has been deleted"));
/** * 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 testBasicFormattedNote() { $styles_logic = Styles_Logic::getInstance(); $database_styles = Database_Styles::getInstance(); $add = $database_styles->getMarkerData("Standard", "add"); $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->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𐌰 Addnormal . EOD; $this->assertEquals($standard, trim($odt)); }
public function testAddStyle() { $database_styles = Database_Styles::getInstance(); $database_styles->createSheet("phpunit"); // Get markers. $markers = $database_styles->getMarkers("phpunit"); $this->assertNotContains("zhq", $markers); // Add marker. $database_styles->addMarker("phpunit", "zhq"); $markers = $database_styles->getMarkers("phpunit"); $this->assertContains("zhq", $markers); }
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 function getStylesheet() { $sheet = $this->getValue("stylesheet", "Standard"); // If the stylesheet does not exist, take the first one available instead. $database_styles = Database_Styles::getInstance(); $sheets = $database_styles->getSheets(); if (!in_array($sheet, $sheets)) { $sheet = $sheets[0]; $this->setStylesheet($sheet); } return $sheet; }
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; }