Ejemplo n.º 1
0
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new Database_UsfmResources();
     }
     return self::$instance;
 }
Ejemplo n.º 2
0
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(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);
$database_usfmresources = Database_UsfmResources::getInstance();
@($delete = $_GET['delete']);
if (isset($delete)) {
    if (Access_Bible::write($delete)) {
        $database_usfmresources->deleteResource($delete);
    } else {
        Assets_Page::error(Locale_Translate::_("You do not have write access to this resource"));
    }
}
@($convert = $_GET['convert']);
if (isset($convert)) {
    if (Access_Bible::write($convert)) {
        Tasks_Logic::queue(Tasks_Logic::PHP, array(__DIR__ . "/convert2bible.php", $convert));
        Filter_Url::redirect("../journal/index.php");
        die;
    } else {
Ejemplo n.º 3
0
 public function testDeleteBook()
 {
     $database_usfmresources = Database_UsfmResources::getInstance();
     $database_usfmresources->storeChapter("bibledit", 2, 3, "usfm");
     $books = $database_usfmresources->getBooks("bibledit");
     $this->assertEquals(array(2), $books);
     $database_usfmresources->deleteBook("bibledit", 2);
     $books = $database_usfmresources->getBooks("bibledit");
     $this->assertEmpty($books);
 }
Ejemplo n.º 4
0
 public static function usfm_resource_chapter_checksum($name, $book, $chapter)
 {
     $database_usfmresources = Database_UsfmResources::getInstance();
     $checksum = $database_usfmresources->getSize($name, $book, $chapter);
     return $checksum;
 }
Ejemplo n.º 5
0
 public static function getText($resource, $book, $chapter, $verse)
 {
     $database_bibles = Database_Bibles::getInstance();
     $database_resources = Database_Resources::getInstance();
     $database_usfmresources = Database_UsfmResources::getInstance();
     $database_offlineresources = Database_OfflineResources::getInstance();
     $bibles = $database_bibles->getBibles();
     $usfms = $database_usfmresources->getResources();
     $externals = $database_resources->getNames();
     $isBible = in_array($resource, $bibles);
     $isUsfm = in_array($resource, $usfms);
     if ($isBible || $isUsfm) {
         if ($isBible) {
             $chapter_usfm = $database_bibles->getChapter($resource, $book, $chapter);
         }
         if ($isUsfm) {
             $chapter_usfm = $database_usfmresources->getUsfm($resource, $book, $chapter);
         }
         $verse_usfm = Filter_Usfm::getVerseText($chapter_usfm, $verse);
         $database_config_user = Database_Config_User::getInstance();
         $stylesheet = $database_config_user->getStylesheet();
         $filter_text = new Filter_Text($resource);
         $filter_text->text_text = new Text_Text();
         $filter_text->addUsfmCode($verse_usfm);
         $filter_text->run($stylesheet);
         $text = $filter_text->text_text->get();
     } else {
         if (in_array($resource, $externals)) {
             // Use offline copy if it exists, else fetch it online.
             if ($database_offlineresources->exists($resource, $book, $chapter, $verse)) {
                 $text = $database_offlineresources->get($resource, $book, $chapter, $verse);
             } else {
                 $text = Resource_Logic::getExternal($resource, $book, $chapter, $verse, true);
             }
             $text = Filter_Html::html2text($text);
         } else {
             $text = "";
         }
     }
     return $text;
 }