Ejemplo n.º 1
0
/*
Copyright (©) 2003-2014 Teus Benschop.

This program is free software; you can redistribute it and/or modify
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::TRANSLATOR_LEVEL);
$bible = $_GET['bible'];
$book = $_GET['book'];
$chapter = $_GET['chapter'];
$database_bibles = Database_Bibles::getInstance();
$usfm = $database_bibles->getChapter($bible, $book, $chapter);
$ipc_focus = Ipc_Focus::getInstance();
$verse = $ipc_focus->getVerse();
$startingOffset = Filter_Usfm::verseNumber2offset($usfm, $verse);
$endingOffset = Filter_Usfm::verseNumber2offset($usfm, $verse + 1) - 1;
$data = array('start' => $startingOffset, 'end' => $endingOffset);
echo json_encode($data);
Ejemplo n.º 2
0
    public function testVerseNumber2OffsetOne()
    {
        $usfm = <<<'EOD'
\p
\v 1 Verse 1.
\v 2 Verse 2.
\v 3 Verse 3.
EOD;
        $result = Filter_Usfm::verseNumber2offset($usfm, 1);
        $this->assertEquals(3, $result);
        $result = Filter_Usfm::verseNumber2offset($usfm, 2);
        $this->assertEquals(17, $result);
        $result = Filter_Usfm::verseNumber2offset($usfm, 3);
        $this->assertEquals(31, $result);
        $result = Filter_Usfm::verseNumber2offset($usfm, 4);
        $this->assertEquals(44, $result);
        $result = Filter_Usfm::verseNumber2offset($usfm, 5);
        $this->assertEquals(44, $result);
    }