Ejemplo n.º 1
0
// Security: Page only runs from the cli SAPI.
Filter_Cli::assert();
$database_logs = Database_Logs::getInstance();
$database_versifications = Database_Versifications::getInstance();
$database_books = Database_Books::getInstance();
$database_offlineresources = Database_OfflineResources::getInstance();
$database_resources = Database_Resources::getInstance();
$resource = Filter_Cli::argument(@$argv, 1);
$book = Filter_Cli::argument(@$argv, 2);
$bookName = $database_books->getEnglishFromId($book);
$database_logs->log("{$resource} {$bookName}: Download has started", Filter_Roles::MANAGER_LEVEL);
$versification = $database_resources->getVersification($resource);
$chapters = $database_versifications->getChapters($versification, $book, true);
foreach ($chapters as $chapter) {
    $message = "{$resource}: {$bookName} chapter {$chapter}";
    $verses = $database_versifications->getVerses($versification, $book, $chapter);
    foreach ($verses as $verse) {
        $message .= "; verse {$verse}: ";
        if ($database_offlineresources->exists($resource, $book, $chapter, $verse)) {
            $message .= "exists";
        } else {
            $html = Resource_Logic::getExternal($resource, $book, $chapter, $verse, false);
            $database_offlineresources->store($resource, $book, $chapter, $verse, $html);
            $size = strlen($html);
            $message .= "size {$size}";
        }
    }
    $message .= "; done";
    $database_logs->log($message, Filter_Roles::MANAGER_LEVEL);
}
$database_logs->log(Locale_Translate::_("Completed") . " {$resource} {$bookName}", Filter_Roles::MANAGER_LEVEL);
Ejemplo n.º 2
0
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::CONSULTANT_LEVEL);
@($resource = $_GET['resource']);
@($book = $_GET['book']);
@($chapter = $_GET['chapter']);
@($verse = $_GET['verse']);
if ($resource == "") {
    die;
}
if ($book == "") {
    die;
}
if ($chapter == "") {
    die;
}
if ($verse == "") {
    die;
}
// In JavaScript the resource identifier starts at 1 instead of at 0.
$resource--;
$database_config_user = Database_Config_User::getInstance();
$resources = $database_config_user->getActiveResources();
$resource = $resources[$resource];
$html = Resource_Logic::getHtml($resource, $book, $chapter, $verse);
echo $html;
Ejemplo n.º 3
0
 private function verseText($resource, $book, $chapter, $verse)
 {
     $text = Resource_Logic::getText($resource, $book, $chapter, $verse);
     return $text;
 }
Ejemplo n.º 4
0
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::TRANSLATOR_LEVEL);
$header = new Assets_Header(Locale_Translate::_("Consistency"));
$header->run();
$database_config_user = Database_Config_User::getInstance();
$database_bibles = Database_Bibles::getInstance();
$database_usfmresources = Database_UsfmResources::getInstance();
$ipc_focus = Ipc_Focus::getInstance();
@($add = $_GET['add']);
if (isset($add)) {
    if ($add == "") {
        $dialog_list = new Dialog_List2(Locale_Translate::_("Would you like to add a Resource?"));
        $resources = Resource_Logic::getNames();
        foreach ($resources as $resource) {
            $dialog_list->add_row($resource, "&add={$resource}");
        }
        $dialog_list->run();
    } else {
        $resources = $database_config_user->getConsistencyResources();
        $resources[] = $add;
        $resources = array_unique($resources, SORT_STRING);
        $database_config_user->setConsistencyResources($resources);
    }
}
@($remove = $_GET['remove']);
if (isset($remove)) {
    $resources = $database_config_user->getConsistencyResources();
    $resources = array_diff($resources, array($remove));
Ejemplo n.º 5
0
$view->view->code = $code;
$database_books = Database_Books::getInstance();
$books = $database_books->getIDs();
$booknames = array();
foreach ($books as $id) {
    $booknames[] = $database_books->getEnglishFromId($id);
}
$view->view->books = $books;
$view->view->booknames = $booknames;
if (!isset($book)) {
    $book = 1;
}
if (!isset($chapter)) {
    $chapter = 1;
}
if (!isset($verse)) {
    $verse = 1;
}
$view->view->book = $book;
$view->view->chapter = $chapter;
$view->view->verse = $verse;
$output = Resource_Logic::getExternal($name, $book, $chapter, $verse, false);
$view->view->output = $output;
$file = $database_resources->getFile($name);
$file = basename($file);
$view->view->file = $file;
$metafile = $database_resources->getMetaFile($name);
$metafile = basename($metafile);
$view->view->metafile = $metafile;
$view->render("edit.php");
Assets_Page::footer();
Ejemplo n.º 6
0
$database_config_user = Database_Config_User::getInstance();
@($add = $_GET['add']);
if (isset($add)) {
    $resources = $database_config_user->getActiveResources();
    $resources[] = $add;
    $database_config_user->setActiveResources($resources);
}
@($remove = $_GET['remove']);
if (isset($remove)) {
    $resources = $database_config_user->getActiveResources();
    $key = array_search($remove, $resources);
    unset($resources[$key]);
    $database_config_user->setActiveResources($resources);
}
@($resources = $_POST['resources']);
if (isset($resources)) {
    $resources = explode(",", $resources);
    $database_config_user->setActiveResources($resources);
}
$header = new Assets_Header(Locale_Translate::_("Resources"));
$header->jQueryUIOn("sortable");
$header->run();
$view = new Assets_View(__FILE__);
$active_resources = $database_config_user->getActiveResources();
$view->view->actives = $active_resources;
// The selectable resources are the available ones minus the active ones.
$available_resources = Resource_Logic::getNames();
$selectable_resources = array_diff($available_resources, $active_resources);
$view->view->selectables = $selectable_resources;
$view->render("organize.php");
Assets_Page::footer();
Ejemplo n.º 7
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;
 }