Example #1
0
function make_trans($i, $wid, $trans, $word, $lang)
{
    global $tbpref;
    $trans = trim($trans);
    $widset = is_numeric($wid);
    if ($widset) {
        $alltrans = get_first_value("select WoTranslation as value from " . $tbpref . "words where WoID = " . $wid);
        $transarr = preg_split('/[' . get_sepas() . ']/u', $alltrans);
        $r = "";
        $set = false;
        foreach ($transarr as $t) {
            $tt = trim($t);
            if ($tt == '*' || $tt == '') {
                continue;
            }
            if (!$set && $tt == $trans) {
                $set = true;
                $r .= '<span class="nowrap"><input class="impr-ann-radio" checked="checked" type="radio" name="rg' . $i . '" value="' . tohtml($tt) . '" />&nbsp;' . tohtml($tt) . '</span> <br /> ';
            } else {
                $r .= '<span class="nowrap"><input class="impr-ann-radio" type="radio" name="rg' . $i . '" value="' . tohtml($tt) . '" />&nbsp;' . tohtml($tt) . '</span>  <br />  ';
            }
        }
        if (!$set) {
            $r .= '<span class="nowrap"><input class="impr-ann-radio" checked="checked" type="radio" name="rg' . $i . '" value="" />&nbsp;<input class="impr-ann-text" type="text" name="tx' . $i . '" id="tx' . $i . '" value="' . tohtml($trans) . '" maxlength="50" size="40" />';
        } else {
            $r .= '<span class="nowrap"><input class="impr-ann-radio" type="radio" name="rg' . $i . '" value="" />&nbsp;<input class="impr-ann-text" type="text" name="tx' . $i . '" id="tx' . $i . '" value="" maxlength="50" size="40" />';
        }
    } else {
        $r = '<span class="nowrap"><input checked="checked" type="radio" name="rg' . $i . '" value="" />&nbsp;<input class="impr-ann-text" type="text" name="tx' . $i . '" id="tx' . $i . '" value="' . tohtml($trans) . '" maxlength="50" size="40" />';
    }
    $r .= ' &nbsp;<img class="click" src="icn/eraser.png" title="Erase Text Field" alt="Erase Text Field" onclick="$(\'#tx' . $i . '\').val(\'\').trigger(\'change\');" />';
    $r .= ' &nbsp;<img class="click" src="icn/star.png" title="* (Set to Term)" alt="* (Set to Term)" onclick="$(\'#tx' . $i . '\').val(\'*\').trigger(\'change\');" />';
    if ($widset) {
        $r .= ' &nbsp;<img class="click" src="icn/plus-button.png" title="Save another translation to existent term" alt="Save another translation to existent term" onclick="addTermTranslation(' . $wid . ', \'#tx' . $i . '\',\'\',' . $lang . ');" />';
    } else {
        $r .= ' &nbsp;<img class="click" src="icn/plus-button.png" title="Save translation to new term" alt="Save translation to new term" onclick="addTermTranslation(0, \'#tx' . $i . '\',' . prepare_textdata_js($word) . ',' . $lang . ');" />';
    }
    $r .= '</span>';
    return $r;
}
Example #2
0
function Segmenter(array $t_args, array $input, array $output, array $given_states)
{
    $resType = ['fragment', 'multi'];
    $system_headers = ['array', 'vector', 'memory', 'cinttypes', 'unordered_map'];
    $user_headers = ['HashFunctions.h'];
    $lib_headers = [];
    $preferFragment = get_default($t_args, 'inner.prefer.fragment', false);
    $wantedRes = $preferFragment ? ['fragment', 'multi'] : ['multi', 'fragment'];
    $nInputs = \count($input);
    grokit_assert($nInputs > 1, 'Segmenter: Not enough inputs specified!');
    $keyName = array_keys($input)[0];
    $keyType = array_get_index($input, 0);
    $innerInputs = array_slice($input, 1, $nInputs - 1, true);
    $gla = get_first_key($t_args, ['gla', 'GLA', 0]);
    grokit_assert(is_gla($gla), 'Segmenter: [gla] argument must be a valid GLA');
    $gla = $gla->apply($innerInputs, $output, $given_states);
    $n_passes = get_default($t_args, 'passes', 1);
    grokit_assert(is_int($n_passes), 'Segmenter: [passes] argument must be an integer');
    grokit_assert($n_passes > 0, 'Segmenter: [passes] argument must be > 0');
    $libraries = $gla->libraries();
    $innerRes = get_first_value($gla->result_type(), $wantedRes);
    $innerInputs = $gla->input();
    $innerOutput = $gla->output();
    $input = array_merge([$keyName => $keyType], $innerInputs);
    $output = $innerOutput;
    $segments = get_default($t_args, 'segments', 64);
    $constState = lookupResource('BASE::SegmenterState', ['gla' => $gla, 'passes' => $n_passes, 'segments' => $segments]);
    $className = generate_name('Segmenter_');
    $savedArgs = [];
    $cArgs = [];
    $innerCArgs = [];
    if ($gla->configurable()) {
        $savedArgs['json_init'] = 'Json::Value';
        $cArgs['json_init'] = 'Json::Value';
        $innerCArgs[] = 'json_init';
    }
    $cArgs['const_state'] = $constState;
    if ($gla->has_state()) {
        $innerCArgs[] = 'constState.inner_cstate';
    }
    $cstStr = \count($innerCArgs) > 0 ? '(' . implode(',', $innerCArgs) . ')' : '';
    grokit_assert(!$gla->iterable(), 'Segementer does not support iterable GLAs');
    $iterable = $n_passes > 1;
    ?>

class <?php 
    echo $className;
    ?>
 {
private:

    using ConstantState = <?php 
    echo $constState;
    ?>
;
    using SplitState = ConstantState::SplitState;

    static constexpr const size_t NUM_STATES = SplitState::NUM_STATES;

    using InnerGLA = <?php 
    echo $gla;
    ?>
;
    using InnerGLAPtr = std::unique_ptr<InnerGLA>;
    using GLA_Array = std::array<InnerGLAPtr, NUM_STATES>;

public:
    using size_type = std::size_t;

<?php 
    if ($innerRes == 'fragment') {
        ?>
    class Iterator {
    private:
        InnerGLA * gla;
        int fragmentNum;

        InnerGLA::Iterator * innerIter;

    public:
        Iterator( InnerGLA * _gla, int _fragmentNum, int _innerFrag ) :
            gla(_gla), fragmentNum(_fragmentNum),
            innerIter(nullptr)
        {
            innerIter = gla->Finalize(_innerFrag);
        }

        ~Iterator(void) {
            if( innerIter != nullptr ) {
                delete innerIter;
                innerIter = nullptr;
            }
        }

        bool GetNextResult( <?php 
        echo typed_ref_args($gla->output());
        ?>
 ) {
            return innerIter->GetNextResult(<?php 
        echo args($gla->output());
        ?>
);
        }

        int FragmentNumber() {
            return fragmentNum;
        }
    };
<?php 
    } else {
        // if inner result type is fragment
        ?>
    class Iterator {
    private:
        InnerGLA * gla;
        int fragmentNum;

    public:
        Iterator( InnerGLA * _gla, int fragNo ) : gla(_gla), fragmentNum(fragNo) {
            gla->Finalize();
        }

        ~Iterator(void) { }

        bool GetNextResult( <?php 
        echo typed_ref_args($gla->output());
        ?>
 ) {
            return gla->GetNextResult(<?php 
        echo args($gla->output());
        ?>
);
        }

        int FragmentNumber() {
            return fragmentNum;
        }
    };
<?php 
    }
    // if inner result type is multi
    ?>

private:

    const ConstantState & constState;
    GLA_Array localState;

    // Iteration state for multi result type
    int numFrags;
    int multiFragNo;
    Iterator * multiIter;

<?php 
    if ($innerRes == 'fragment') {
        ?>
    using frag_info = std::pair<int, int>;
    using frag_map_t = std::unordered_map<int, frag_info>;
    frag_map_t fragMap;
<?php 
    }
    ?>


<?php 
    foreach ($savedArgs as $name => $type) {
        ?>
    const <?php 
        echo $type;
        ?>
 <?php 
        echo $name;
        ?>
;
<?php 
    }
    // foreach saved arg
    ?>

public:

    // Constructor
    <?php 
    echo $className;
    ?>
( <?php 
    echo const_typed_ref_args($cArgs);
    ?>
 ) :
        constState(const_state)
        , localState()
        , numFrags(0)
        , multiFragNo(0)
        , multiIter(nullptr)
<?php 
    if ($innerRes == 'fragment') {
        ?>
        , fragMap()
<?php 
    }
    foreach ($savedArgs as $name => $type) {
        ?>
        , <?php 
        echo $name;
        ?>
(<?php 
        echo $name;
        ?>
)
<?php 
    }
    // foreach constructor arg to save
    ?>
    {
        for( auto & elem : localState ) {
            elem.reset(new InnerGLA<?php 
    echo $cstStr;
    ?>
);
        }
    }

    void AddItem( <?php 
    echo const_typed_ref_args($input);
    ?>
 ) {
        uint64_t hashVal = CongruentHash(Hash(<?php 
    echo $keyName;
    ?>
), H_b + 1);
        uint64_t passNum = (hashVal / NUM_STATES) % ConstantState::N_PASSES;
        uint64_t segNum = hashVal % NUM_STATES;

<?php 
    if ($n_passes > 1) {
        ?>
        if( passNum != constState.pass ) {
            return;
        }
<?php 
    }
    // more than 1 pass
    ?>
        localState[segNum]->AddItem(<?php 
    echo args($innerInputs);
    ?>
);
    }

    void ChunkBoundary(void) {
        // Merge local states into the global state

        SplitState & globalStates = constState.segments;

        int theseAreOk[NUM_STATES];
        for( int i = 0; NUM_STATES > i; i++ ) {
            theseAreOk[i] = 1;
        }

        int segsLeft = NUM_STATES;

        while( segsLeft > 0 ) {
            InnerGLA * checkedOut = nullptr;
            int whichOne = globalStates.CheckOutOne( theseAreOk, checkedOut );

            if( checkedOut == NULL ) {
                checkedOut = new InnerGLA<?php 
    echo $cstStr;
    ?>
;
            }

            checkedOut->AddState( *(localState[whichOne]) );

            globalStates.CheckIn( whichOne, checkedOut );

            theseAreOk[whichOne] = 0;
            segsLeft--;
        }

        // Re-initialize the local states
        for( auto & elem : localState ) {
<?php 
    if ($gla->is('resettable')) {
        ?>
            elem->Reset();
<?php 
    } else {
        // if resettable
        ?>
            elem.reset(new InnerGLA<?php 
        echo $cstStr;
        ?>
);
<?php 
    }
    // if not resettable
    ?>
        }
    }

    void AddState( <?php 
    echo $className;
    ?>
 & o ) {
        // Do nothing
    }

    void Finalize() {
        SplitState & globalStates = constState.segments;

        if( multiIter != nullptr)
            delete multiIter;

        multiFragNo = 0;
<?php 
    if ($innerRes == 'fragment') {
        ?>
        frag_info fInfo = fragMap[multiFragNo];
        multiIter = new Iterator(globalStates.Peek(fInfo.first), multiFragNo,
            fInfo.second);
<?php 
    } else {
        ?>
        multiIter = new Iterator(globalStates.Peek(multiFragNo), multiFragNo);
<?php 
    }
    ?>
    }

    bool GetNextResult(<?php 
    echo typed_ref_args($output);
    ?>
) {
        bool gotResult = false;
        SplitState & globalStates = constState.segments;

        while( (multiFragNo < numFrags && multiIter != nullptr) && !gotResult ) {
            gotResult = multiIter->GetNextResult(<?php 
    echo args($output);
    ?>
);

            if( !gotResult ) {
                multiFragNo++;
                delete multiIter;

                if( numFrags > multiFragNo ) {
<?php 
    if ($innerRes == 'fragment') {
        ?>
                    frag_info fInfo = fragMap[multiFragNo];
                    multiIter = new Iterator(globalStates.Peek(fInfo.first), multiFragNo,
                        fInfo.second);
<?php 
    } else {
        ?>
                    multiIter = new Iterator(globalStates.Peek(multiFragNo), multiFragNo);
<?php 
    }
    ?>
                } else {
                    multiIter = nullptr;
                }
            }
        }

        return gotResult;
    }

    int GetNumFragments(void) {
<?php 
    if ($innerRes == 'fragment') {
        ?>
        SplitState & globalStates = constState.segments;
        numFrags = 0;

        for (int i = 0; i < NUM_STATES; i++) {
            int curFrags = globalStates.Peek(i)->GetNumFragments();

            for (int curFrag = 0; curFrag < curFrags; curFrag++) {
                fragMap[numFrags] = frag_info(i, curFrag);

                numFrags++;
            }
        }
<?php 
    } else {
        ?>
        numFrags = NUM_STATES;
<?php 
    }
    ?>
        return numFrags;
    }

    Iterator * Finalize( int fragment ) {
        SplitState & globalStates = constState.segments;

<?php 
    if ($innerRes == 'fragment') {
        ?>
        frag_info info = fragMap[fragment];
        return new Iterator(globalStates.Peek(info.first), fragment, info.second);
<?php 
    } else {
        ?>
        return new Iterator(globalStates.Peek(fragment), fragment);
<?php 
    }
    ?>
    }

    bool GetNextResult( Iterator * it, <?php 
    echo typed_ref_args($output);
    ?>
 ) {
        bool ret = it->GetNextResult(<?php 
    echo args($output);
    ?>
);

        return ret;
    }

<?php 
    if ($iterable) {
        ?>
    bool ShouldIterate( ConstantState & modible ) {
        modible.pass++;

        return modible.pass < ConstantState::N_PASSES;
    }

    void PostFinalize() {
        constState.segments.Reset();
    }
<?php 
    }
    // iterable
    ?>

<?php 
    if ($gla->is('finite container')) {
        ?>
    size_type size() {
        SplitState & globalStates = constState.segments;
        size_type s = 0;
        for( int i = 0; NUM_STATES > i; i++ ) {
            InnerGLA * ptr = globalStates.Peek(i);
            s += ptr->size();
        }

        return s;
    }

    size_type size(int frag) {
        SplitState & globalStates = constState.segments;
        return globalStates.Peek(frag)->size();
    }
<?php 
    }
    // if the gla is a container
    ?>
};

typedef <?php 
    echo $className;
    ?>
::Iterator <?php 
    echo $className;
    ?>
_Iterator;

<?php 
    return ['kind' => 'GLA', 'name' => $className, 'system_headers' => $system_headers, 'user_headers' => $user_headers, 'lib_headers' => $lib_headers, 'libraries' => $libraries, 'input' => $input, 'output' => $output, 'result_type' => $resType, 'generated_state' => $constState, 'required_states' => $gla->req_states(), 'chunk_boundary' => true, 'configurable' => $gla->configurable(), 'iterable' => $iterable, 'post_finalize' => $iterable, 'intermediates' => true];
}
Example #3
0
In case this is not legally possible, any entity is granted the
right to use this work for any purpose, without any conditions, 
unless such conditions are required by law.

Developed by J. Pierre in 2011.
***************************************************************/
/**************************************************************
Call: insert_word_wellknown.php?tid=[textid]&ord=[textpos]
Ignore single word (new term with status 99)
***************************************************************/
include "connect.inc.php";
include "settings.inc.php";
include "utilities.inc.php";
$word = get_first_value("select TiText as value from textitems where TiWordCount = 1 and TiTxID = " . $_REQUEST['tid'] . " and TiOrder = " . $_REQUEST['ord']);
$wordlc = mb_strtolower($word, 'UTF-8');
$langid = get_first_value("select TxLgID as value from texts where TxID = " . $_REQUEST['tid']);
pagestart("Term: " . $word, false);
$m1 = runsql('insert into words (WoLgID, WoText, WoTextLC, WoStatus, WoStatusChanged,' . make_score_random_insert_update('iv') . ') values( ' . $langid . ', ' . convert_string_to_sqlsyntax($word) . ', ' . convert_string_to_sqlsyntax($wordlc) . ', 99, NOW(), ' . make_score_random_insert_update('id') . ')', 'Term added');
$wid = get_last_key();
echo "<p>OK, you know this term well!</p>";
$hex = strToClassName($wordlc);
?>
<script type="text/javascript">
//<![CDATA[
var context = window.parent.frames['l'].document;
var contexth = window.parent.frames['h'].document;
var title = make_tooltip(<?php 
echo prepare_textdata_js($word);
?>
,'*','','99');
$('.TERM<?php 
Example #4
0
<th class="th1 clickable">Tag Text</th>
<th class="th1 clickable">Tag Comment</th>
<th class="th1 clickable">Terms With Tag</th>
</tr>

<?php 
        $sql = 'select TgID, TgText, TgComment from tags where (1=1) ' . $wh_query . ' order by ' . $sorts[$currentsort - 1] . ' ' . $limit;
        if ($debug) {
            echo $sql;
        }
        $res = mysql_query($sql);
        if ($res == FALSE) {
            die("Invalid Query: {$sql}");
        }
        while ($record = mysql_fetch_assoc($res)) {
            $c = get_first_value('select count(*) as value from wordtags where WtTgID=' . $record['TgID']);
            echo '<tr>';
            echo '<td class="td1 center"><a name="rec' . $record['TgID'] . '"><input name="marked[]" type="checkbox" class="markcheck" value="' . $record['TgID'] . '" ' . checkTest($record['TgID'], 'marked') . ' /></a></td>';
            echo '<td class="td1 center" nowrap="nowrap">&nbsp;<a href="' . $_SERVER['PHP_SELF'] . '?chg=' . $record['TgID'] . '"><img src="icn/document--pencil.png" title="Edit" alt="Edit" /></a>&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?del=' . $record['TgID'] . '"><img src="icn/minus-button.png" title="Delete" alt="Delete" /></a>&nbsp;</td>';
            echo '<td class="td1 center">' . tohtml($record['TgText']) . '</td>';
            echo '<td class="td1 center">' . tohtml($record['TgComment']) . '</td>';
            echo '<td class="td1 center">' . ($c > 0 ? '<a href="edit_words.php?page=1&amp;query=&amp;text=&amp;status=&amp;filterlang=&amp;status=&amp;tag12=0&amp;tag2=&amp;tag1=' . $record['TgID'] . '">' . $c . '</a>' : '0') . '</td>';
            echo '</tr>';
        }
        mysql_free_result($res);
        ?>
</table>
</form>

<?php 
        if ($pages > 1) {
Example #5
0
     $g = '';
 }
 $w = limitlength($w, 250);
 $wl = limitlength(mb_strtolower($w, 'UTF-8'), 250);
 $t = limitlength($t, 500);
 $r = limitlength($r, 100);
 $s = limitlength($s, 1000);
 $g = explode(",", trim(str_replace(" ", ",", $g)));
 $g = array_filter($g, "notempty");
 array_walk($g, 'limit20');
 $protokoll .= '<tr><td class="td1 right">' . ($i + 1) . '</td><td class="td1">' . tohtml($w) . '</td><td class="td1">' . tohtml($t) . '</td><td class="td1">' . tohtml($r) . '</td><td class="td1">' . tohtml($s) . '</td><td class="td1">' . implode(", ", $g) . '</td>';
 if ($w != '') {
     if ($t == '') {
         $t = '*';
     }
     $excnt = get_first_value('select count(*) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoTextLC=' . convert_string_to_sqlsyntax($wl));
     if ($excnt > 0) {
         // exists
         if ($overwrite) {
             // update
             $msg1 = runsql('delete from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoTextLC=' . convert_string_to_sqlsyntax($wl), "Exists, deleted");
             runsql("DELETE " . $tbpref . "wordtags FROM (" . $tbpref . "wordtags LEFT JOIN " . $tbpref . "words on WtWoID = WoID) WHERE WoID IS NULL", '');
             $msg2 = runsql('insert into ' . $tbpref . 'words (WoLgID, WoTextLC, WoText, WoStatus, WoTranslation, WoRomanization, WoSentence, WoStatusChanged,' . make_score_random_insert_update('iv') . ') values ( ' . $lang . ', ' . convert_string_to_sqlsyntax($wl) . ', ' . convert_string_to_sqlsyntax($w) . ', ' . $status . ', ' . convert_string_to_sqlsyntax($t) . ', ' . convert_string_to_sqlsyntax($r) . ', ' . convert_string_to_sqlsyntax($s) . ', NOW(), ' . make_score_random_insert_update('id') . ')', "Imported");
             $wid = get_last_key();
             array_walk($g, 'savetag', $wid);
             $sqlct++;
             $protokoll .= '<td class="td1">' . tohtml($msg1 . ' / ' . $msg2) . ' (' . $sqlct . ')</td></tr>';
         } else {
             // no overwrite
             $protokoll .= '<td class="td1"><span class="red2">EXISTS, NOT IMPORTED</span></td></tr>';
         }
Example #6
0
File: index.php Project: Fips11/lwt
// ********* WORDPRESS LOGOUT *********
?>

	<br /><br /></li>
<li><a href="info.htm">Help/Information</a></li>
<li><a href="mobile.php">Mobile LWT (Experimental)</a></li>
</ul>

<p class="smallgray graydotted">&nbsp;</p>
<table><tr><td class="width50px"><a target="_blank" href="http://unlicense.org/"><img alt="Public Domain" title="Public Domain" src="img/public_domain.png" /></a></td><td><p class="smallgray"><a href="http://lwt.sourceforge.net/" target="_blank">"Learning with Texts" (LWT)</a> is free and unencumbered software released<br />into the <b>PUBLIC DOMAIN</b>. <a href="http://unlicense.org/" target="_blank">More information and detailed Unlicense ...</a><br />

<?php 
flush();
// optimizedb();
$p = convert_string_to_sqlsyntax_nonull($tbpref);
$mb = get_first_value("SELECT round(sum(data_length+index_length)/1024/1024,1) as value FROM information_schema.TABLES where table_schema = " . convert_string_to_sqlsyntax($dbname) . " and table_name in (" . "CONCAT(" . $p . ",'archivedtexts')," . "CONCAT(" . $p . ",'archtexttags')," . "CONCAT(" . $p . ",'languages')," . "CONCAT(" . $p . ",'sentences')," . "CONCAT(" . $p . ",'settings')," . "CONCAT(" . $p . ",'tags')," . "CONCAT(" . $p . ",'tags2')," . "CONCAT(" . $p . ",'textitems')," . "CONCAT(" . $p . ",'texts')," . "CONCAT(" . $p . ",'texttags')," . "CONCAT(" . $p . ",'words')," . "CONCAT(" . $p . ",'wordtags'))");
if (!isset($mb)) {
    $mb = '0.0';
}
?>

This is <b>LWT <?php 
echo get_version();
?>
</b><br />Database: <b><?php 
echo $dbname;
?>
</b> on <b><?php 
echo $server;
?>
</b> / <?php 
Example #7
0
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE SOFTWARE.

For more information, please refer to [http://unlicense.org/].
***************************************************************/
/**************************************************************
Call: all_words_wellknown.php?text=[textid]
Setting all unknown words to Well Known (99)
***************************************************************/
require_once 'settings.inc.php';
require_once 'connect.inc.php';
require_once 'dbutils.inc.php';
require_once 'utilities.inc.php';
$langid = get_first_value("select TxLgID as value from " . $tbpref . "texts where TxID = " . $_REQUEST['text']);
pagestart("Setting all blue words to Well-known", false);
$sql = 'select distinct TiText, TiTextLC from (' . $tbpref . 'textitems left join ' . $tbpref . 'words on (TiTextLC = WoTextLC) and (TiLgID = WoLgID)) where TiIsNotWord = 0 and WoID is null and TiWordCount = 1 and TiTxID = ' . $_REQUEST['text'] . ' order by TiOrder';
$res = do_mysql_query($sql);
$count = 0;
$javascript = "var title='';";
while ($record = mysql_fetch_assoc($res)) {
    $term = $record['TiText'];
    $termlc = $record['TiTextLC'];
    $count1 = 0 + runsql('insert into ' . $tbpref . 'words (WoLgID, WoText, WoTextLC, WoStatus, WoStatusChanged,' . make_score_random_insert_update('iv') . ') values( ' . $langid . ', ' . convert_string_to_sqlsyntax($term) . ', ' . convert_string_to_sqlsyntax($termlc) . ', 99 , NOW(), ' . make_score_random_insert_update('id') . ')', '');
    $wid = get_last_key();
    if ($count1 > 0) {
        $javascript .= "title = make_tooltip(" . prepare_textdata_js($term) . ",'*','','99');";
    }
    $javascript .= "\$('.TERM" . strToClassName($termlc) . "', context).removeClass('status0').addClass('status99 word" . $wid . "').attr('data_status','99').attr('data_wid','" . $wid . "').attr('title',title);";
    $count += $count1;
Example #8
0
unless such conditions are required by law.

Developed by J. Pierre in 2011.
***************************************************************/
/**************************************************************
Call: delete_mword.php?wid=[wordid]&tid=[textid]
Delete an expression 
***************************************************************/
include "connect.inc.php";
include "settings.inc.php";
include "utilities.inc.php";
$showAll = getSetting('showallwords');
$showAll = $showAll == '' ? 1 : ((int) $showAll != 0 ? 1 : 0);
$tid = $_REQUEST['tid'];
$wid = $_REQUEST['wid'];
$word = get_first_value("select WoText as value from words where WoID = " . $wid);
pagestart("Term: " . $word, false);
$m1 = runsql('delete from words where WoID = ' . $wid, '');
adjust_autoincr('words', 'WoID');
echo "<p>OK, term deleted (" . $m1 . ").</p>";
?>
<script type="text/javascript">
//<![CDATA[
var context = window.parent.frames['l'].document;
var contexth = window.parent.frames['h'].document;
$('.word<?php 
echo $wid;
?>
', context).removeClass('status1 status2 status3 status4 status5 status98 status99 word<?php 
echo $wid;
?>
function get_annotation_link($textid)
{
    global $tbpref;
    if (get_first_value('select length(TxAnnotatedText) as value from ' . $tbpref . 'texts where TxID=' . $textid) > 0) {
        return ' &nbsp;<a href="print_impr_text.php?text=' . $textid . '" target="_top"><img src="icn/tick.png" title="Annotated Text" alt="Annotated Text" /></a>';
    } else {
        return '';
    }
}
Example #10
0
<th class="th1 sorttable_numeric clickable">Terms</th>
</tr>

<?php 
        $sql = 'select LgID, LgName from languages order by LgName';
        if ($debug) {
            echo $sql;
        }
        $res = mysql_query($sql);
        if ($res == FALSE) {
            die("Invalid Query: {$sql}");
        }
        while ($record = mysql_fetch_assoc($res)) {
            $textcount = get_first_value('select count(TxID) as value from texts where TxLgID=' . $record['LgID']);
            $archtextcount = get_first_value('select count(AtID) as value from archivedtexts where AtLgID=' . $record['LgID']);
            $wordcount = get_first_value('select count(WoID) as value from words where WoLgID=' . $record['LgID']);
            echo '<tr>';
            if ($current == $record['LgID']) {
                $tdth = 'th';
                echo '<th class="th1"><img src="icn/exclamation-red.png" title="Current Language" alt="Current Language" /></th>';
            } else {
                $tdth = 'td';
                echo '<td class="td1 center"><a href="save_setting_redirect.php?k=currentlanguage&amp;v=' . $record['LgID'] . '&amp;u=edit_languages.php"><img src="icn/tick-button.png" title="Set as Current Language" alt="Set as Current Language" /></a></td>';
            }
            echo '<' . $tdth . ' class="' . $tdth . '1 center"><a href="do_test.php?lang=' . $record['LgID'] . '"><img src="icn/question-balloon.png" title="Test" alt="Test" /></a></' . $tdth . '>';
            echo '<' . $tdth . ' class="' . $tdth . '1 center" nowrap="nowrap">&nbsp;<a href="' . $_SERVER['PHP_SELF'] . '?chg=' . $record['LgID'] . '"><img src="icn/document--pencil.png" title="Edit" alt="Edit" /></a>';
            if ($textcount == 0 && $archtextcount == 0 && $wordcount == 0) {
                echo '&nbsp; <span class="click" onclick="if (confirm (\'Are you sure?\')) location.href=\'' . $_SERVER['PHP_SELF'] . '?del=' . $record['LgID'] . '\';"><img src="icn/minus-button.png" title="Delete" alt="Delete" /></span>';
            } else {
                echo '&nbsp; <img src="icn/placeholder.png" title="Delete not possible" alt="Delete not possible" />';
            }
Example #11
0
 $kt = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99) and cast(WoStatusChanged as date) = curdate()');
 $cy = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoCreated as date) = subdate(curdate(), \'1 day\')');
 $ay = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoStatusChanged as date) = subdate(curdate(), \'1 day\')');
 $ky = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99) and cast(WoStatusChanged as date) = subdate(curdate(), \'1 day\')');
 $cw = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoCreated as date) between subdate(curdate(), \'6 day\') and curdate()');
 $aw = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'6 day\') and curdate()');
 $kw = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'6 day\') and curdate()');
 $cm = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoCreated as date) between subdate(curdate(), \'29 day\') and curdate()');
 $am = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'29 day\') and curdate()');
 $km = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'29 day\') and curdate()');
 $ca = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoCreated as date) between subdate(curdate(), \'364 day\') and curdate()');
 $aa = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'364 day\') and curdate()');
 $ka = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'364 day\') and curdate()');
 $call = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99)');
 $aall = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99)');
 $kall = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99)');
 $sumct += $ct;
 $sumat += $at;
 $sumkt += $kt;
 $sumcy += $cy;
 $sumay += $ay;
 $sumky += $ky;
 $sumcw += $cw;
 $sumaw += $aw;
 $sumkw += $kw;
 $sumcm += $cm;
 $sumam += $am;
 $sumkm += $km;
 $sumca += $ca;
 $sumaa += $aa;
 $sumka += $ka;
Example #12
0
        pageend();
        exit;
    }
    ?>
	
<p>OK: <?php 
    echo tohtml($message);
    ?>
</p>

<?php 
    $lang = get_first_value('select WoLgID as value from ' . $tbpref . 'words where WoID = ' . $wid);
    if (!isset($lang)) {
        my_die('Cannot retrieve language in edit_tword.php');
    }
    $regexword = get_first_value('select LgRegexpWordCharacters as value from ' . $tbpref . 'languages where LgID = ' . $lang);
    if (!isset($regexword)) {
        my_die('Cannot retrieve language data in edit_tword.php');
    }
    $sent = tohtml(repl_tab_nl($_REQUEST["WoSentence"]));
    $sent1 = str_replace("{", ' <b>[', str_replace("}", ']</b> ', mask_term_in_sentence($sent, $regexword)));
    ?>

<script type="text/javascript">
//<![CDATA[
var context = window.parent.frames['l'].document;
var woid = <?php 
    echo prepare_textdata_js($wid);
    ?>
;
if(window.parent.frames['l'].location.href.indexOf('do_test_table') !== -1) {
Example #13
0
This applies worldwide.
In case this is not legally possible, any entity is granted the
right to use this work for any purpose, without any conditions, 
unless such conditions are required by law.

Developed by J.P. in 2011, 2012.
***************************************************************/
/**************************************************************
Call: do_text.php?start=[textid]
Start Reading a text (frameset)
***************************************************************/
include "connect.inc.php";
include "settings.inc.php";
include "utilities.inc.php";
if (isset($_REQUEST['start'])) {
    $audio = get_first_value('select TxAudioURI as value from texts where TxID = ' . $_REQUEST['start']);
    framesetheader('Read');
    ?>
<frameset cols="<?php 
    echo tohtml(getSettingWithDefault('set-text-l-framewidth-percent'));
    ?>
%,*">
	<frameset rows="<?php 
    echo isset($audio) ? getSettingWithDefault('set-text-h-frameheight-with-audio') : getSettingWithDefault('set-text-h-frameheight-no-audio');
    ?>
,*">
		<frame src="do_text_header.php?text=<?php 
    echo $_REQUEST['start'];
    ?>
" scrolling="no" name="h" />			
		<frame src="do_text_text.php?text=<?php 
Example #14
0
);"><img src="icn/sticky-notes-stack.png" title="Show Sentences" alt="Show Sentences" /> Show Sentences</span></div>	
		<?php 
    } else {
        $sql = 'select WoTranslation, WoSentence, WoRomanization, WoStatus from words where WoID = ' . $wid;
        $res = mysql_query($sql);
        if ($res == FALSE) {
            die("Invalid Query: {$sql}");
        }
        if ($record = mysql_fetch_assoc($res)) {
            $status = $record['WoStatus'];
            if ($status >= 98) {
                $status = 1;
            }
            $sentence = repl_tab_nl($record['WoSentence']);
            if ($sentence == '') {
                $seid = get_first_value("select TiSeID as value from textitems where TiTxID = " . $_REQUEST['tid'] . " and TiOrder = " . $_REQUEST['ord']);
                $sent = getSentence($seid, $termlc, (int) getSettingWithDefault('set-term-sentence-count'));
                $sentence = repl_tab_nl($sent[1]);
            }
            $transl = repl_tab_nl($record['WoTranslation']);
            if ($transl == '*') {
                $transl = '';
            }
            ?>
		
			<form name="editword" class="validate" action="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
" method="post">
			<input type="hidden" name="WoID" value="<?php 
            echo $wid;
Example #15
0
function Multiplexer(array $t_args, array $inputs, array $outputs)
{
    $className = generate_name('Multiplexer');
    if (\count($inputs) == 0) {
        grokit_assert(array_key_exists('input', $t_args), 'No inputs specified for Multiplexer');
        $inputs = $t_args['input'];
        foreach ($t_args['inputs'] as $name => &$type) {
            if (is_identifier($type)) {
                $type = lookupType(strval($type));
            }
            grokit_assert(is_datatype($type), 'Only types may be specified as inputs to Multiplexer.');
        }
        $inputs = ensure_valid_names($inputs, 'multi_input');
    }
    $glas = get_first_key($t_args, ['glas', 0]);
    grokit_assert(\count($glas) > 0, 'No GLAs specified for Multiplexer.');
    $myGLAs = [];
    $glaInputs = [];
    $glaOutputs = [];
    $resultType = 'multi';
    $usedOutputs = [];
    $libraries = [];
    $glaGenStates = [];
    $glaReqStates = [];
    $configurable = false;
    $constArgs = [];
    $genStates = [];
    $reqStates = [];
    $iterable = null;
    foreach ($glas as $name => $glaInfo) {
        grokit_assert(is_array($glaInfo), 'Template argument \'glas\' must be an array');
        grokit_assert(array_key_exists('gla', $glaInfo), 'No GLA given for glas[' . $name . ']');
        grokit_assert(array_key_exists('inputs', $glaInfo), 'No inputs given for glas[' . $name . ']');
        grokit_assert(array_key_exists('outputs', $glaInfo), 'No outputs given for glas[' . $name . ']');
        $gla = $glaInfo['gla'];
        $glaInAtts = $glaInfo['inputs'];
        $glaOutAtts = $glaInfo['outputs'];
        grokit_assert(is_gla($gla), 'Non-GLA given for glas[' . $name . '][gla]');
        grokit_assert(is_array($glaInAtts), 'Non-array given for inputs for gla ' . $name);
        grokit_assert(is_array($glaOutAtts), 'Non-array given for outputs for gla ' . $name);
        $glaInAtts = array_map('strval', $glaInAtts);
        $glaOutAtts = array_map('strval', $glaOutAtts);
        $glaName = "innerGLA_" . $name;
        $glaInputs[$glaName] = [];
        $glaOutputs[$glaName] = [];
        foreach ($glaInAtts as $att) {
            grokit_assert(array_key_exists($att, $inputs), 'Input ' . $att . ' for GLA ' . $name . ' not found in inputs');
            $glaInputs[$glaName][$att] = $inputs[$att];
        }
        foreach ($glaOutAtts as $att) {
            grokit_assert(array_key_exists($att, $outputs), 'Output ' . $att . ' for GLA ' . $name . ' not found in outputs');
            grokit_assert(!in_array($att, $usedOutputs), 'Output ' . $att . ' used by multiple GLAs');
            $usedOutputs[] = $att;
            $glaOutputs[$glaName][$att] = $outputs[$att];
        }
        //fwrite(STDERR, "Inputs for GLA " . $glaName . ": " . print_r($glaInputs[$glaName], true) . PHP_EOL );
        //fwrite(STDERR, "Outputs for GLA " . $glaName . ": " . print_r($glaOutputs[$glaName], true) . PHP_EOL );
        $gla = $gla->apply($glaInputs[$glaName], $glaOutputs[$glaName]);
        $myGLAs[$glaName] = $gla;
        $glaRez[$glaName] = get_first_value($gla->result_type(), ['multi', 'single', 'state']);
        $libraries = array_merge($libraries, $gla->libraries());
        if ($glaRez[$glaName] == 'state') {
            grokit_assert(\count($glaOutputs[$glaName]) == 1, "GLA {$glaName} is produced as state, and thus must have exactly 1 output.");
            $stateType = lookupType('base::STATE', ['type' => $gla]);
            $glaOutputs[$glaName] = array_combine(array_keys($glaOutputs[$glaName]), [$stateType]);
        } else {
            grokit_assert(\count($glaOutputs[$glaName]) == \count($gla->output()), 'GLA ' . $glaName . ' produces different number of outputs than expected');
            $glaOutputs[$glaName] = array_combine(array_keys($glaOutputs[$glaName]), $gla->output());
        }
        // Set types for our output
        foreach ($glaOutputs[$glaName] as $attName => $type) {
            $outputs[$attName] = $type;
        }
        if (is_null($iterable)) {
            $iterable = $gla->iterable();
        } else {
            grokit_assert($iterable == $gla->iterable(), 'Multiplexer does not support mixing iterable and non-iterable GLAs');
        }
        $glaReqStates[$glaName] = $gla->req_states();
        foreach ($gla->req_states() as $rstate) {
            $reqStates[] = $rstate;
        }
        $glaGenStates[$glaName] = $gla->state();
        // TODO: Support constant states
        grokit_assert(!$gla->has_state(), 'Multiplexer currently does not support constant states.');
    }
    $libraries = array_unique($libraries);
    $extra = ['glas' => $myGLAs];
    ?>

class <?php 
    echo $className;
    ?>
 {
<?php 
    foreach ($myGLAs as $name => $type) {
        ?>
    <?php 
        echo $type;
        ?>
 <?php 
        echo $name;
        ?>
;
<?php 
    }
    // foreach inner gla
    ?>

    class Iterator {

        bool _gotResultsOnce;
        bool _valid;

<?php 
    foreach ($myGLAs as $name => $type) {
        ?>
        <?php 
        echo $type;
        ?>
 * it_<?php 
        echo $name;
        ?>
;
<?php 
    }
    // foreach inner gla
    ?>

    public:
        Iterator(void) : _gotResultsOnce(false), _valid(false),
            <?php 
    echo array_template('it_{key}(nullptr)', ', ', $myGLAs);
    ?>

        { }

        Iterator(<?php 
    echo typed_ref_args($myGLAs);
    ?>
) : _gotResultsOnce(false), _valid(true),
            <?php 
    echo array_template('it_{key}(&{key})', ', ', $myGLAs);
    ?>

        {
<?php 
    foreach ($myGLAs as $name => $type) {
        if ($glaRez[$name] == 'multi') {
            ?>
            <?php 
            echo $name;
            ?>
.Finalize();
<?php 
        }
        // if inner GLA is multi
    }
    // foreach inner gla
    ?>
        }

        Iterator( const Iterator & other) = default;

        ~Iterator() { }

        bool GetNextResult( <?php 
    echo typed_ref_args($outputs);
    ?>
 ) {
            FATALIF(!_valid, "Tried to get results from an invalid iterator.");

            bool ret = !_gotResultsOnce;
            _gotResultsOnce = true;

<?php 
    foreach ($myGLAs as $name => $type) {
        if ($glaRez[$name] == 'multi') {
            ?>
            ret |= it_<?php 
            echo $name;
            ?>
->GetNextResult(<?php 
            echo args($glaOutputs[$name]);
            ?>
);
<?php 
        }
        // if inner GLA is multi
    }
    // foreach inner gla
    ?>

            if( ret ) {
<?php 
    foreach ($myGLAs as $name => $type) {
        if ($glaRez[$name] == 'single') {
            ?>
                it_<?php 
            echo $name;
            ?>
->GetResult(<?php 
            echo args($glaOutputs[$name]);
            ?>
);
<?php 
        } else {
            if ($glaRez[$name] == 'state') {
                $stateVar = array_keys($glaOutputs[$name])[0];
                $stateType = $glaOutputs[$name][$stateVar];
                ?>
                <?php 
                echo $stateVar;
                ?>
 = <?php 
                echo $stateType;
                ?>
(it_<?php 
                echo $name;
                ?>
);
<?php 
            }
        }
        // if inner GLA is state
    }
    // foreach inner gla
    ?>
            }

            return ret;
        }
    };

    Iterator multiIterator;

public:
    <?php 
    echo $className;
    ?>
() { }
    ~<?php 
    echo $className;
    ?>
() { }

    void AddItem(<?php 
    echo const_typed_ref_args($inputs);
    ?>
) {
        // Call AddItem individually on each GLA.
<?php 
    foreach ($myGLAs as $gName => $gType) {
        ?>
        <?php 
        echo $gName;
        ?>
.AddItem(<?php 
        echo args($glaInputs[$gName]);
        ?>
);
<?php 
    }
    // foreach inner gla
    ?>
    }

    void AddState( <?php 
    echo $className;
    ?>
 & other ) {
        // Call AddState individually on each GLA.
<?php 
    foreach ($myGLAs as $gName => $gType) {
        ?>
        <?php 
        echo $gName;
        ?>
.AddState(other.<?php 
        echo $gName;
        ?>
);
<?php 
    }
    // foreach inner gla
    ?>
    }

    void Finalize() {
        multiIterator = Iterator(<?php 
    echo args($myGLAs);
    ?>
);
    }

    bool GetNextResult(<?php 
    echo typed_ref_args($outputs);
    ?>
) {
        return multiIterator.GetNextResult(<?php 
    echo args($outputs);
    ?>
);
    }

    void GetResult(<?php 
    echo typed_ref_args($outputs);
    ?>
) {
        Finalize();
        GetNextResult(<?php 
    echo args($outputs);
    ?>
);
    }

<?php 
    foreach (array_keys($myGLAs) as $index => $name) {
        ?>
    const <?php 
        echo $myGLAs[$name];
        ?>
& GetGLA<?php 
        echo $index;
        ?>
() const {
      return <?php 
        echo $name;
        ?>
;
    }
<?php 
    }
    ?>
};

<?php 
    return array('kind' => 'GLA', 'name' => $className, 'input' => $inputs, 'output' => $outputs, 'result_type' => $resultType, 'libraries' => $libraries, 'configurable' => $configurable, 'extra' => $extra);
}
Example #16
0
<li><a href="upload_words.php">Import Terms</a></li>
<li><a href="backup_restore.php">Backup/Restore LWT Database</a>
	<br /><br /></li>
<li><a href="settings.php">Settings/Preferences</a>
	<br /><br /></li>
<li><a href="info.htm">Help/Information</a></li>
<li><a href="mobile.php">Mobile LWT (Experimental)</a></li>
</ul>

<p class="smallgray graydotted">&nbsp;</p>
<table><tr><td class="width50px"><a target="_blank" href="http://en.wikipedia.org/wiki/Public_domain_software"><img alt="Public Domain" src="img/public_domain.png" /></a></td><td><p class="smallgray"><a href="http://lwt.sourceforge.net/" target="_blank">"Learning with Texts" (LWT)</a> is released into the Public Domain. This applies worldwide.<br />In case this is not legally possible, any entity is granted the right to use this work for any purpose,<br />without any conditions, unless such conditions are required by law.<br />

<?php 
flush();
optimizedb();
$mb = get_first_value("SELECT round(sum(data_length+index_length)/1024/1024,1) as value FROM information_schema.TABLES where table_schema = " . convert_string_to_sqlsyntax($dbname) . " GROUP BY table_schema");
?>

This is <b>LWT <?php 
echo get_version();
?>
</b> / Database: <b><?php 
echo $dbname;
?>
</b> on <b><?php 
echo $server;
?>
</b> / DB-Size: <b><?php 
echo $mb;
?>
 MB</b></p></td></tr></table>
Example #17
0
            if (trim($record["SeText"]) != '¶') {
                echo '<li><a href="mobile.php?action=4&amp;lang=' . $lang . '&amp;text=' . $text . '&amp;sent=' . $record["SeID"] . '">' . tohtml($record["SeText"]) . '</a></li>';
            }
        }
        ?>
		
		</ul>

		<?php 
        mysql_free_result($res);
    } elseif ($action == 4 || $action == 5) {
        $lang = $_REQUEST["lang"];
        $text = $_REQUEST["text"];
        $sent = $_REQUEST["sent"];
        $senttext = get_first_value('select SeText as value from sentences where SeID = ' . $sent);
        $nextsent = get_first_value('select SeID as value from sentences where SeTxID = ' . $text . ' and trim(SeText) != \'¶\' and SeID > ' . $sent . ' order by SeID limit 1');
        $sql = 'select TiWordCount as Code, TiText, TiOrder, TiIsNotWord, WoID, WoTranslation, WoRomanization, WoStatus from (textitems left join words on (TiTextLC = WoTextLC) and (TiLgID = WoLgID)) where TiSeID = ' . $sent . ' and (not (TiWordCount > 1 and WoID is null)) order by TiOrder asc, TiWordCount desc';
        $res = mysql_query($sql);
        if ($res == FALSE) {
            die("Invalid Query: {$sql}");
        }
        if ($action == 4) {
            ?>

		<ul id="<?php 
            echo $action . '-' . $sent;
            ?>
" title="<?php 
            echo tohtml($senttext);
            ?>
">
Example #18
0
        ?>
);"><img src="icn/sticky-notes-stack.png" title="Show Sentences" alt="Show Sentences" /> Show Sentences</span></div>	
		<?php 
    } else {
        $sql = 'select WoTranslation, WoSentence, WoRomanization, WoStatus from ' . $tbpref . 'words where WoID = ' . $wid;
        $res = do_mysql_query($sql);
        if ($record = mysql_fetch_assoc($res)) {
            $status = $record['WoStatus'];
            if ($fromAnn == '') {
                if ($status >= 98) {
                    $status = 1;
                }
            }
            $sentence = repl_tab_nl($record['WoSentence']);
            if ($sentence == '' && isset($_REQUEST['tid']) && isset($_REQUEST['ord'])) {
                $seid = get_first_value("select TiSeID as value from " . $tbpref . "textitems where TiTxID = " . $_REQUEST['tid'] . " and TiWordCount = 1 and TiOrder = " . $_REQUEST['ord']);
                $sent = getSentence($seid, $termlc, (int) getSettingWithDefault('set-term-sentence-count'));
                $sentence = repl_tab_nl($sent[1]);
            }
            $transl = repl_tab_nl($record['WoTranslation']);
            if ($transl == '*') {
                $transl = '';
            }
            ?>
		
			<form name="editword" class="validate" action="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
" method="post">
			<input type="hidden" name="WoLgID" id="langfield" value="<?php 
            echo $lang;
Example #19
0
        $stchange = 1;
    }
} else {
    $stchange = $stchange + 0;
    $status = $oldstatus + $stchange;
    if ($status < 1) {
        $status = 1;
    }
    if ($status > 5) {
        $status = 5;
    }
}
$word = get_first_value("select WoText as value from words where WoID = " . $wid);
pagestart("Term: " . $word, false);
$m1 = runsql('update words set WoStatus = ' . $status . ', WoStatusChanged = NOW(),' . make_score_random_insert_update('u') . ' where WoID = ' . $wid, 'Status changed');
$newscore = get_first_value('select greatest(0,round(WoTodayScore,0)) AS value from words where WoID = ' . $wid) + 0;
if ($oldstatus == $status) {
    echo '<p>Status ' . get_colored_status_msg($status) . ' not changed.</p>';
} else {
    echo '<p>Status changed from ' . get_colored_status_msg($oldstatus) . ' to ' . get_colored_status_msg($status) . '.</p>';
}
echo "<p>Old score was " . $oldscore . ", new score is now " . $newscore . ".</p>";
$totaltests = $_SESSION['testtotal'];
$wrong = $_SESSION['testwrong'];
$correct = $_SESSION['testcorrect'];
$notyettested = $totaltests - $correct - $wrong;
if ($notyettested > 0) {
    if ($stchange >= 0) {
        $_SESSION['testcorrect']++;
    } else {
        $_SESSION['testwrong']++;
Example #20
0
$ann = get_first_value("select TxAnnotatedText as value from " . $tbpref . "texts where TxID = " . $textid);
$ann_exists = strlen($ann) > 0;
if ($ann_exists) {
    $ann = recreate_save_ann($textid, $ann);
    $ann_exists = strlen($ann) > 0;
}
if ($textid == 0) {
    header("Location: edit_texts.php");
    exit;
}
if ($delmode) {
    // Delete
    if ($ann_exists) {
        $dummy = runsql('update ' . $tbpref . 'texts set ' . 'TxAnnotatedText = ' . convert_string_to_sqlsyntax("") . ' where TxID = ' . $textid, "");
    }
    $ann_exists = get_first_value("select length(TxAnnotatedText) as value from " . $tbpref . "texts where TxID = " . $textid) + 0 > 0;
    if (!$ann_exists) {
        header("Location: print_text.php?text=" . $textid);
        exit;
    }
}
$sql = 'select TxLgID, TxTitle, TxAudioURI, TxSourceURI from ' . $tbpref . 'texts where TxID = ' . $textid;
$res = do_mysql_query($sql);
$record = mysql_fetch_assoc($res);
$title = $record['TxTitle'];
$sourceURI = $record['TxSourceURI'];
$langid = $record['TxLgID'];
$audio = $record['TxAudioURI'];
if (!isset($audio)) {
    $audio = '';
}
Example #21
0
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE SOFTWARE.

For more information, please refer to [http://unlicense.org/].
***************************************************************/
/**************************************************************
Call: delete_word.php?wid=[wordid]&tid=[textid]
Delete a word
***************************************************************/
require_once 'settings.inc.php';
require_once 'connect.inc.php';
require_once 'dbutils.inc.php';
require_once 'utilities.inc.php';
$tid = $_REQUEST['tid'];
$wid = $_REQUEST['wid'];
$term = get_first_value("select WoText as value from " . $tbpref . "words where WoID = " . $wid);
pagestart("Term: " . $term, false);
$m1 = runsql('delete from ' . $tbpref . 'words where WoID = ' . $wid, '');
adjust_autoincr('words', 'WoID');
echo "<p>OK, term deleted, now unknown (" . $m1 . ").</p>";
?>
<script type="text/javascript">
//<![CDATA[
var context = window.parent.frames['l'].document;
var contexth = window.parent.frames['h'].document;
var title = make_tooltip(<?php 
echo prepare_textdata_js($term);
?>
,'','','');
$('.word<?php 
echo $wid;
Example #22
0
    if (file_exists($file)) {
        $handle = gzopen($file, "r");
        if ($handle === FALSE) {
            $message = "Error: File ' . {$file} . ' could not be opened";
        } else {
            // $handle OK
            $message = restore_file($handle, "Demo Database");
        }
        // $handle OK
    } else {
        $message = "Error: File ' . {$file} . ' does not exist";
    }
}
pagestart('Install LWT Demo Database', true);
echo error_message_with_hide($message, 1);
$langcnt = get_first_value('select count(*) as value from ' . $tbpref . 'languages');
if ($tbpref == '') {
    $prefinfo = "(Default Table Set)";
} else {
    $prefinfo = "(Table Set: <i>" . tohtml(substr($tbpref, 0, -1)) . "</i>)";
}
?>
<form enctype="multipart/form-data" action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" method="post" onsubmit="return confirm('Are you sure?');">
<table class="tab3" cellspacing="0" cellpadding="5">
<tr>
<th class="th1 center">Install Demo</th>
<td class="td1">
<p class="smallgray2">
Example #23
0
	function sql_upd_client($is_query=1) { // update record

		// ***********************************************************
		$this->add_field('login_upd', TIME, 'int');
		$this->add_field('contact_upd', TIME, 'int');
		$this->add_field('account_upd', TIME, 'int');
		$this->add_field('account_balance', get_balance($this->client_id));
		$this->add_field('account_hpsp', get_hpsp($this->client_id));
		$this->add_field('account_lcsp', get_lcsp($this->client_id));
		$this->add_field('account_trades', get_nof_rec('trades', 'trade_account='.$this->client_id.' AND trade_status>0'));
		$this->add_field('account_lastfnd', get_first_value('fund_valdate', 'funds', 'fund_account='.$this->client_id, 'DESC'));
		$this->add_field('account_lasttrd', get_first_value('trade_valdate', 'trades', 'trade_account='.$this->client_id, 'DESC'));
		$this->add_field('account_options', get_total_options($this->client_id));
		$this->add_field('bank_upd', TIME, 'int');
		
		// account_status
		if (($this->account_trades>1)&&($this->account_status>1)){
			$this->add_field('account_status', 9);
		}elseif (($this->account_trades==1)&&($this->account_status>1)){
			$this->add_field('account_status', 3);
		}elseif ($this->account_status>1){
			$this->add_field('account_status', 2);
		}elseif (($this->account_logged<(TIME-DAYS_TILL_EXPIRY))&&($this->account_status>1)){
			$this->add_field('account_status', 1);
		}
		
		$sql_login='******';
		foreach ($this->field_value as $key=>$val){
			if ('login'==substr($key, 0, 5)){
				$val=set_insql($val, $this->field_type[$key]);
				$sql_login.=$key.'='.$val.', ';
			}
		}
		$sql_login=substr($sql_login, 0, -2);
		$sql_login.=' WHERE login_id='.$this->login_id;
		
		$sql_contact='UPDATE contacts SET ';
		foreach ($this->field_value as $key=>$val){
			if ('contact'==substr($key, 0, 7)){
				$val=set_insql($val, $this->field_type[$key]);
				$sql_contact.=$key.'='.$val.', ';
			}
		}
		$sql_contact=substr($sql_contact, 0, -2);
		$sql_contact.=' WHERE contact_id='.$this->contact_id;
		
		$sql_account='UPDATE accounts SET ';
		foreach ($this->field_value as $key=>$val){
			if ('account'==substr($key, 0, 7)){
				$val=set_insql($val, $this->field_type[$key]);
				$sql_account.=$key.'='.$val.', ';
			}
		}
		$sql_account=substr($sql_account, 0, -2);
		$sql_account.=' WHERE account_id='.$this->account_id;
		
		$sql_bank='UPDATE banks SET ';
		foreach ($this->field_value as $key=>$val){
			if ('bank'==substr($key, 0, 4)){
				$val=set_insql($val, $this->field_type[$key]);
				$sql_bank.=$key.'='.$val.', ';
			}
		}
		$sql_bank=substr($sql_bank, 0, -2);
		$sql_bank.=' WHERE bank_id='.$this->bank_id;
		
		if ($is_query){ // process query 
			mysql_query($sql_login);
			mysql_query($sql_contact);
			mysql_query($sql_account);
			mysql_query($sql_bank);
		}else{
			echo $sql_login.'<br/>'.$sql_contact.'<br/>'.$sql_account.'<br/>'.$sql_bank;
		}
	}
Example #24
0
    $p = "lang=" . $langid;
    $title = "All Terms in " . get_first_value('select LgName as value from ' . $tbpref . 'languages where LgID = ' . $langid);
    $testsql = ' ' . $tbpref . 'words where WoLgID = ' . $langid . ' ';
}
if (isset($_REQUEST['text'])) {
    $textid = getreq('text');
    $p = "text=" . $textid;
    $title = get_first_value('select TxTitle as value from ' . $tbpref . 'texts where TxID = ' . $textid);
    saveSetting('currenttext', $_REQUEST['text']);
    $testsql = ' ' . $tbpref . 'words, ' . $tbpref . 'textitems where TiLgID = WoLgID and TiTextLC = WoTextLC and TiTxID = ' . $textid . ' ';
}
if ($p == '') {
    my_die("do_test_header.php called with wrong parameters");
}
$totalcountdue = get_first_value('SELECT count(distinct WoID) as value FROM ' . $testsql . ' AND WoStatus BETWEEN 1 AND 5 AND WoTranslation != \'\' AND WoTranslation != \'*\' AND WoTodayScore < 0');
$totalcount = get_first_value('SELECT count(distinct WoID) as value FROM ' . $testsql . ' AND WoStatus BETWEEN 1 AND 5 AND WoTranslation != \'\' AND WoTranslation != \'*\'');
pagestart_nobody(tohtml($title), $addcss = 'html, body {margin-bottom:0;}');
echo '<h4>';
echo '<a href="edit_texts.php" target="_top">';
echo_lwt_logo();
echo 'LWT';
echo '</a>&nbsp; | &nbsp;';
quickMenu();
if (substr($p, 0, 4) == 'text') {
    echo getPreviousAndNextTextLinks($textid, 'do_test.php?text=', FALSE, '&nbsp; | &nbsp;');
    echo '&nbsp; | &nbsp;<a href="do_text.php?start=' . $textid . '" target="_top"><img src="icn/book-open-bookmark.png" title="Read" alt="Read" /></a> &nbsp;<a href="print_text.php?text=' . $textid . '" target="_top"><img src="icn/printer.png" title="Print" alt="Print" /></a>' . get_annotation_link($textid);
}
echo '</h4><table><tr><td><h3>TEST&nbsp;▶</h3></td><td class="width99pc"><h3>' . tohtml($title) . ' (Due: ' . $totalcountdue . ' of ' . $totalcount . ')</h3></td></tr><tr><td colspan="2">';
$_SESSION['teststart'] = time() + 2;
$_SESSION['testcorrect'] = 0;
$_SESSION['testwrong'] = 0;
Example #25
0
<th class="th1 clickable">Texts<br />With Tag</th>
<th class="th1 clickable">Arch.Texts<br />With Tag</th>
</tr>

<?php 
        $sql = 'select T2ID, T2Text, T2Comment from tags2 where (1=1) ' . $wh_query . ' order by ' . $sorts[$currentsort - 1] . ' ' . $limit;
        if ($debug) {
            echo $sql;
        }
        $res = mysql_query($sql);
        if ($res == FALSE) {
            die("Invalid Query: {$sql}");
        }
        while ($record = mysql_fetch_assoc($res)) {
            $c = get_first_value('select count(*) as value from texttags where TtT2ID=' . $record['T2ID']);
            $ca = get_first_value('select count(*) as value from archtexttags where AgT2ID=' . $record['T2ID']);
            echo '<tr>';
            echo '<td class="td1 center"><a name="rec' . $record['T2ID'] . '"><input name="marked[]" type="checkbox" class="markcheck" value="' . $record['T2ID'] . '" ' . checkTest($record['T2ID'], 'marked') . ' /></a></td>';
            echo '<td class="td1 center" nowrap="nowrap">&nbsp;<a href="' . $_SERVER['PHP_SELF'] . '?chg=' . $record['T2ID'] . '"><img src="icn/document--pencil.png" title="Edit" alt="Edit" /></a>&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?del=' . $record['T2ID'] . '"><img src="icn/minus-button.png" title="Delete" alt="Delete" /></a>&nbsp;</td>';
            echo '<td class="td1 center">' . tohtml($record['T2Text']) . '</td>';
            echo '<td class="td1 center">' . tohtml($record['T2Comment']) . '</td>';
            echo '<td class="td1 center">' . ($c > 0 ? '<a href="edit_texts.php?page=1&amp;query=&amp;tag12=0&amp;tag2=&amp;tag1=' . $record['T2ID'] . '">' . $c . '</a>' : '0') . '</td>';
            echo '<td class="td1 center">' . ($ca > 0 ? '<a href="edit_archivedtexts.php?page=1&amp;query=&amp;tag12=0&amp;tag2=&amp;tag1=' . $record['T2ID'] . '">' . $ca . '</a>' : '0') . '</td>';
            echo '</tr>';
        }
        mysql_free_result($res);
        ?>
</table>
</form>

<?php 
Example #26
0
For more information, please refer to [http://unlicense.org/].
***************************************************************/
/**************************************************************
Call: display_impr_text.php?text=[textid]
Display an improved annotated text (frame set)
***************************************************************/
require_once 'settings.inc.php';
require_once 'connect.inc.php';
require_once 'dbutils.inc.php';
require_once 'utilities.inc.php';
require_once 'php-mobile-detect/Mobile_Detect.php';
$detect = new Mobile_Detect();
$mobileDisplayMode = getSettingWithDefault('set-mobile-display-mode') + 0;
$mobile = $mobileDisplayMode == 0 && $detect->isMobile() || $mobileDisplayMode == 2;
if (isset($_REQUEST['text'])) {
    $audio = get_first_value('select TxAudioURI as value from ' . $tbpref . 'texts where TxID = ' . $_REQUEST['text']);
    framesetheader('Display');
    if ($mobile) {
        ?>

	<style type="text/css"> 
	body {
		background-color: #cccccc;
		margin: 0;
		overflow: hidden;
	}
	#frame-h, #frame-l {
		position:absolute; 
		overflow:scroll; 
		-webkit-overflow-scrolling: touch;
	}
Example #27
0
function GLAGenerate_Finalize($wpName, $queries, $attMap)
{
    ?>
#ifndef PER_QUERY_PROFILE
#define PER_QUERY_PROFILE
#endif

//+{"kind":"WPF", "name":"Finalize (Chunk)", "action":"start"}
extern "C"
int GLAFinalizeWorkFunc_<?php 
    echo $wpName;
    ?>
(WorkDescription &workDescription, ExecEngineData &result) {
    GLAFinalizeWD myWork;
    myWork.swap (workDescription);
    QueryExit whichOne = myWork.get_whichQueryExit();
    GLAState& glaState = myWork.get_glaState();
<?php 
    cgDeclareQueryIDs($queries);
    ?>

    // Set up the output chunk
    Chunk output;

    QueryIDSet queriesToRun = whichOne.query;
<?php 
    // Extract the state for the query
    foreach ($queries as $query => $info) {
        $gla = $info['gla'];
        ?>
    // Do query <?php 
        echo queryName($query);
        ?>
:
    <?php 
        echo $gla;
        ?>
 * state_<?php 
        echo queryName($query);
        ?>
 = NULL;
    if( whichOne.query == <?php 
        echo queryName($query);
        ?>
 ) {
        // Look for the state of query <?php 
        echo queryName($query);
        ?>
.
        GLAPtr state;
        state.swap(glaState);
        FATALIF( state.get_glaType() != <?php 
        echo $gla->cHash();
        ?>
,
            "Got GLA of unexpected type");
        state_<?php 
        echo queryName($query);
        ?>
 = (<?php 
        echo $gla;
        ?>
 *) state.get_glaPtr();
    }
<?php 
    }
    // foreach query
    ?>

    // Start columns for all possible outputs.
<?php 
    foreach ($queries as $query => $info) {
        $output = $info['output'];
        cgConstructColumns($output);
    }
    // foreach query
    ?>

    // This is the output bitstring
    MMappedStorage myStore;
    Column bitmapOut( myStore );
    BStringIterator myOutBStringIter( bitmapOut, queriesToRun );

    PROFILING2_START;
    int64_t numTuples = 0;

#ifdef PER_QUERY_PROFILE
<?php 
    foreach ($queries as $query => $info) {
        ?>
    int64_t numTuples_<?php 
        echo queryName($query);
        ?>
 = 0;
<?php 
    }
    // foreach query
    ?>
#endif // PER_QUERY_PROFILE

    // Extract results
<?php 
    foreach ($queries as $query => $info) {
        $gla = $info['gla'];
        $output = $info['output'];
        // If this is true, we return the GLA as a const state.
        // Otherwise, we pack the results into a chunk.
        $retState = $info['retState'];
        $stateName = 'state_' . queryName($query);
        ?>
    if( whichOne.query == <?php 
        echo queryName($query);
        ?>
 ) {
<?php 
        if ($retState) {
            ?>
        FATAL( "Called normal finalize for query that was supposed to be returned as a const state" );
<?php 
        } else {
            $resType = $gla->result_type();
            $resType = get_first_value($resType, ['fragment', 'multi', 'single', 'state']);
            if ($resType == 'single') {
                ?>
        <?php 
                echo $stateName;
                ?>
->GetResult(<?php 
                echo implode(', ', $output);
                ?>
);
        numTuples++;
#ifdef PER_QUERY_PROFILE
        numTuples_<?php 
                echo queryName($query);
                ?>
++;
#endif // PER_QUERY_PROFILE
        myOutBStringIter.Insert(<?php 
                echo queryName($query);
                ?>
);
        myOutBStringIter.Advance();
<?php 
                cgInsertAttributesList($output, '_Column_Out', 2);
            } elseif ($resType == 'multi') {
                ?>
        <?php 
                echo $stateName;
                ?>
->Finalize();
        while( <?php 
                echo $stateName;
                ?>
->GetNextResult(<?php 
                echo implode(', ', $output);
                ?>
) ) {
            numTuples++;
#ifdef PER_QUERY_PROFILE
            numTuples_<?php 
                echo queryName($query);
                ?>
++;
#endif // PER_QUERY_PROFILE
            myOutBStringIter.Insert(<?php 
                echo queryName($query);
                ?>
);
            myOutBStringIter.Advance();
<?php 
                cgInsertAttributesList($output, '_Column_Out', 3);
                ?>
        }
<?php 
            } elseif ($resType == 'fragment') {
                ?>
        int fragment = myWork.get_fragmentNo();
        <?php 
                echo $gla;
                ?>
_Iterator * iterator = <?php 
                echo $stateName;
                ?>
->Finalize(fragment);
        while( <?php 
                echo $stateName;
                ?>
->GetNextResult(iterator, <?php 
                echo implode(', ', $output);
                ?>
) ) {
            numTuples++;
#ifdef PER_QUERY_PROFILE
            numTuples_<?php 
                echo queryName($query);
                ?>
++;
#endif // PER_QUERY_PROFILE
            myOutBStringIter.Insert(<?php 
                echo queryName($query);
                ?>
);
            myOutBStringIter.Advance();
<?php 
                cgInsertAttributesList($output, '_Column_Out', 3);
                ?>
        }
        delete iterator;
<?php 
            } elseif ($resType == 'state') {
                reset($output);
                $att = current($output);
                // Output attribute
                if ($gla->finalize_as_state()) {
                    ?>
        <?php 
                    echo $stateName;
                    ?>
->FinalizeState();
<?php 
                }
                // if GLA finalized as state
                ?>
        <?php 
                echo $att;
                ?>
 = <?php 
                echo $att->type();
                ?>
( <?php 
                echo $stateName;
                ?>
 );
        numTuples++;
#ifdef PER_QUERY_PROFILE
        numTuples_<?php 
                echo queryName($query);
                ?>
++;
#endif // PER_QUERY_PROFILE
        myOutBStringIter.Insert(<?php 
                echo queryName($query);
                ?>
);
        myOutBStringIter.Advance();
<?php 
                cgInsertAttributesList($output, '_Column_Out', 2);
            } else {
                grokit_error('GLA ' . $gla . ' has no known result type: [' . implode(',', $resType) . ']');
            }
            // switch GLA result type
        }
        // else GLA produces into a chunk
        ?>
        myOutBStringIter.Done();
        output.SwapBitmap(myOutBStringIter);

        // Write columns
<?php 
        foreach ($output as $att) {
            ?>
        Column col_<?php 
            echo $att;
            ?>
;
        <?php 
            echo $att;
            ?>
_Column_Out.Done(col_<?php 
            echo $att;
            ?>
);
        output.SwapColumn( col_<?php 
            echo $att;
            ?>
, <?php 
            echo $att->slot();
            ?>
 );
<?php 
        }
        // foreach output attribute
        ?>
    }
<?php 
    }
    // foreach query
    ?>

    PROFILING2_END;

    PCounterList counterList;
    PCounter totalCnt("tpo", numTuples, "<?php 
    echo $wpName;
    ?>
");
    counterList.Append(totalCnt);

#ifdef PER_QUERY_PROFILE
<?php 
    foreach ($queries as $query => $info) {
        ?>
    {
        PCounter qCount("tpo <?php 
        echo queryName($query);
        ?>
", numTuples_<?php 
        echo queryName($query);
        ?>
, "<?php 
        echo $wpName;
        ?>
");
        counterList.Append(qCount);
    }
<?php 
    }
    // foreach query
    ?>
#endif // PER_QUERY_PROFILE

    PROFILING2_SET(counterList, "<?php 
    echo $wpName;
    ?>
");

    ChunkContainer tempResult(output);
    tempResult.swap(result);
    return WP_FINALIZE;
}
//+{"kind":"WPF", "name":"Finalize (Chunk)", "action":"end"}
<?php 
}
Example #28
0
    exit;
}
?>
<div id="body">
<?php 
$count = get_first_value('SELECT count(distinct WoID) as value FROM ' . $testsql . ' AND WoStatus BETWEEN 1 AND 5 AND WoTranslation != \'\' AND WoTranslation != \'*\' AND WoTodayScore < 0');
if ($debug) {
    echo 'DEBUG - COUNT TO TEST: ' . $count . '<br />';
}
$notyettested = $count;
if ($count <= 0) {
    $count2 = get_first_value('SELECT count(distinct WoID) as value FROM ' . $testsql . ' AND WoStatus BETWEEN 1 AND 5 AND WoTranslation != \'\' AND WoTranslation != \'*\' AND WoTomorrowScore < 0');
    echo '<p class="center"><img src="img/ok.png" alt="Done!" /><br /><br /><span class="red2">Nothing ' . ($totaltests ? 'more ' : '') . 'to test here!<br /><br />Tomorrow you\'ll find here ' . $count2 . ' test' . ($count2 == 1 ? '' : 's') . '!</span></p></div>';
    $count = 0;
} else {
    $lang = get_first_value('select WoLgID as value from ' . $testsql . ' limit 1');
    $sql = 'select LgName, LgDict1URI, LgDict2URI, LgGoogleTranslateURI, LgTextSize, LgRemoveSpaces, LgRegexpWordCharacters, LgRightToLeft from languages where LgID = ' . $lang;
    $res = mysql_query($sql);
    if ($res == FALSE) {
        die("Invalid query: {$sql}");
    }
    $record = mysql_fetch_assoc($res);
    $wb1 = isset($record['LgDict1URI']) ? $record['LgDict1URI'] : "";
    $wb2 = isset($record['LgDict2URI']) ? $record['LgDict2URI'] : "";
    $wb3 = isset($record['LgGoogleTranslateURI']) ? $record['LgGoogleTranslateURI'] : "";
    $textsize = $record['LgTextSize'];
    $removeSpaces = $record['LgRemoveSpaces'];
    $regexword = $record['LgRegexpWordCharacters'];
    $rtlScript = $record['LgRightToLeft'];
    $langname = $record['LgName'];
    mysql_free_result($res);
Example #29
0
		<input type="button" value="Cancel" onclick="location.href='edit_archivedtexts.php#rec<?php 
        echo $_REQUEST['chg'];
        ?>
';" /> 
		<input type="submit" name="op" value="Change" /></td>
		</tr>
		</table>
		</form>
		
		<?php 
    }
    mysql_free_result($res);
} else {
    echo error_message_with_hide($message, 0);
    $sql = 'select count(*) as value from (select AtID from (archivedtexts left JOIN archtexttags ON AtID = AgAtID) where (1=1) ' . $wh_lang . $wh_query . ' group by AtID ' . $wh_tag . ') as dummy';
    $recno = get_first_value($sql);
    if ($debug) {
        echo $sql . ' ===&gt; ' . $recno;
    }
    $maxperpage = getSettingWithDefault('set-archivedtexts-per-page');
    $pages = $recno == 0 ? 0 : intval(($recno - 1) / $maxperpage) + 1;
    if ($currentpage < 1) {
        $currentpage = 1;
    }
    if ($currentpage > $pages) {
        $currentpage = $pages;
    }
    $limit = 'LIMIT ' . ($currentpage - 1) * $maxperpage . ',' . $maxperpage;
    $sorts = array('AtTitle', 'AtID desc');
    $lsorts = count($sorts);
    if ($currentsort < 1) {
Example #30
0
function GroupBy(array $t_args, array $inputs, array $outputs, array $states)
{
    // Ensure we have valid inputs.
    if (\count($inputs) == 0) {
        // No inputs given, try to get them from template arguments.
        grokit_assert(array_key_exists('input', $t_args), 'No inputs given for GroupBy');
        $inputs = $t_args['input'];
        if (!is_array($inputs)) {
            $inputs = [$inputs];
        }
        foreach ($inputs as $name => &$type) {
            if (is_identifier($type)) {
                $type = lookupType(strval($type));
            }
            grokit_assert(is_datatype($type), 'Invalid type given for input ' . $name);
        }
    }
    grokit_assert(array_key_exists('group', $t_args), 'No groups specified for GroupBy');
    $gbyAttMap = $t_args['group'];
    grokit_assert(is_array($gbyAttMap), 'Invalid value given for groups, expected an expression name or list of expression names');
    $gbyAttMap = array_map('strval', $gbyAttMap);
    $gbyAttNames = array_keys($gbyAttMap);
    foreach ($gbyAttMap as $in => $out) {
        grokit_assert(array_key_exists($in, $inputs), 'Group ' . $in . ' not present in input');
        grokit_assert(array_key_exists($out, $outputs), 'Output Attribute ' . $out . ' for group ' . $in . ' not found in outputs');
    }
    $numGByAtts = \count($gbyAttNames);
    grokit_assert(array_key_exists('aggregate', $t_args), 'No aggregate specified for GroupBy');
    $innerGLA = $t_args['aggregate'];
    grokit_assert(is_gla($innerGLA), 'Non-GLA specified as aggregate for GroupBy');
    $debug = get_default($t_args, 'debug', 0);
    $init_size = get_default($t_args, 'init.size', 1024);
    $use_mct = get_default($t_args, 'use.mct', true);
    $keepHashes = get_default($t_args, 'mct.keep.hashes', false);
    grokit_assert(is_bool($keepHashes), 'GroupBy mct.keep.hashes argument must be boolean');
    // determine the result type
    $use_fragments = get_default($t_args, 'use.fragments', true);
    $resType = $use_fragments ? ['fragment', 'multi'] : ['multi'];
    $fragSize = get_default($t_args, 'fragment.size', 2000000);
    // Always support state
    $resType[] = 'state';
    // Class name randomly generated
    $className = generate_name("GroupBy");
    // instantiate the inner GLA. input/output is derived from the main input/output
    $gbyAtts = [];
    $gbyAttsOut = [];
    $glaInputAtts = [];
    $glaOutputAtts = [];
    foreach ($inputs as $name => $type) {
        if (in_array($name, $gbyAttNames)) {
            $gbyAtts[$name] = $type;
            $gbyAttsOut[$gbyAttMap[$name]] = $type;
            $outputs[$gbyAttMap[$name]] = $type;
        } else {
            $glaInputAtts[$name] = $type;
        }
    }
    foreach ($outputs as $name => $type) {
        if (!in_array($name, $gbyAttMap)) {
            $glaOutputAtts[$name] = $type;
        }
    }
    $innerGLA = $innerGLA->apply($glaInputAtts, $glaOutputAtts, $states);
    $libraries = $innerGLA->libraries();
    $innerRes = get_first_value($innerGLA->result_type(), ['multi', 'single', 'state']);
    if ($innerRes == 'state') {
        // If the result type is state, the only output is a state object
        // containing the GLA.
        $outputName = array_keys($glaOutputAtts)[0];
        $innerOutputs = [$outputName => lookupType('base::STATE', ['type' => $innerGLA])];
    } else {
        $innerOutputs = $innerGLA->output();
        grokit_assert(\count($innerOutputs) == \count($glaOutputAtts), 'Expected ' . \count($glaOutputAtts) . ' outputs fromm Inner GLA, got ' . \count($innerOutputs));
    }
    $constState = lookupResource('GroupByState', ['gla' => $innerGLA, 'groups' => $gbyAtts, 'debug' => $debug]);
    // constructor argumetns are inherited from inner GLA
    $configurable = $innerGLA->configurable();
    $reqStates = $innerGLA->req_states();
    // We need to specially create the constructor string because apparently
    // declaring Type Name(); is a function declaration instead of a variable
    // declaration for some reason.
    $constructorParts = [];
    if ($configurable) {
        $constructorParts[] = 'jsonInit';
    }
    if ($innerGLA->has_state()) {
        $constructorParts[] = 'innerState';
    }
    $constructorString = \count($constructorParts) > 0 ? '(' . implode(', ', $constructorParts) . ')' : '';
    // add the outputs we got from the gla
    foreach ($innerOutputs as $name => $type) {
        grokit_assert(array_key_exists($name, $outputs), 'Inner GLA\'s outputs refer to unknown attribute ' . $name);
        grokit_assert($type !== null, 'GroupBy Inner GLA left output ' . $name . ' with no type');
        $outputs[$name] = $type;
    }
    $iterable = $innerGLA->iterable();
    // need to keep track of system includes needed
    $extraHeaders = array();
    $allocatorText = "std::allocator<std::pair<const Key, {$innerGLA}> >";
    if ($use_mct) {
        $keepHashesText = $keepHashes ? 'true' : 'false';
        $extraHeaders[] = "mct/hash-map.hpp";
        $map = "mct::closed_hash_map<Key, {$innerGLA}, HashKey, std::equal_to<Key>, {$allocatorText}, {$keepHashesText}>";
        $mapType = 'mct::closed_hash_map';
    } else {
        $extraHeaders[] = "unordered_map";
        $map = "std::unordered_map<Key, {$innerGLA}, HashKey, std::equal_to<Key>, {$allocatorText}>";
        $mapType = 'std::unordered_map';
    }
    if ($debug > 0) {
        $extraHeaders[] = 'cstdio';
    }
    ?>


class <?php 
    echo $className;
    ?>
{
public:
    using ConstantState = <?php 
    echo $constState;
    ?>
;
<?php 
    if ($innerGLA->has_state()) {
        ?>
    using InnerState = ConstantState::InnerState;
<?php 
    }
    // if gla has state
    ?>
    using Key = ConstantState::Key;
    using HashKey = ConstantState::HashKey;
    using InnerGLA = <?php 
    echo $innerGLA;
    ?>
;

    typedef <?php 
    echo $map;
    ?>
 MapType;
    static const size_t INIT_SIZE = <?php 
    echo $init_size;
    ?>
;

public:
    class Iterator {
        MapType::iterator it; // current value
        MapType::iterator end; // last value in the fragment

    public:
        Iterator() { }

        Iterator(MapType::iterator _it, MapType::iterator _end):
            it(_it), end(_end)
        {
            if( it != end ) {

<?php 
    switch ($innerRes) {
        case 'multi':
            ?>
            it->second.Finalize();
<?php 
            break;
        case 'state':
            if ($innerGLA->finalize_as_state()) {
                ?>
            it->second.FinalizeState();
<?php 
            }
            // if we need to finalize as a state
            break;
    }
    // end switch inner restype
    ?>
            }
        }

        bool GetNextResult( <?php 
    echo typed_ref_args($outputs);
    ?>
 ) {
            bool gotResult = false;
            while( it != end && !gotResult ) {
                <?php 
    echo $innerGLA;
    ?>
 & gla = it->second;
<?php 
    foreach ($gbyAttMap as $in => $out) {
        ?>
                <?php 
        echo $out;
        ?>
 = it->first.<?php 
        echo $in;
        ?>
;
<?php 
    }
    // foreach grouping attribute
    ?>

<?php 
    switch ($innerRes) {
        case 'multi':
            ?>
                gotResult = gla.GetNextResult( <?php 
            echo args($innerOutputs);
            ?>
);
                if( !gotResult ) {
                    ++it;
                    if( it != end ) {
                        it->second.Finalize();
                    }
                }
<?php 
            break;
        case 'single':
            ?>
                gotResult = true;
                gla.GetResult(<?php 
            echo args($innerOutputs);
            ?>
);
                ++it;
<?php 
            break;
        case 'state':
            reset($innerOutputs);
            // Assuming that $innerOutputs contains a single value that is
            // the state type.
            $oName = key($innerOutputs);
            $oType = current($innerOutputs);
            ?>
                gotResult = true;
                <?php 
            echo $oName;
            ?>
 = <?php 
            echo $oType;
            ?>
( &gla );
                ++it;
<?php 
    }
    // switch inner result type
    ?>
            }

            return gotResult;
        }
    };

private:
    const ConstantState & constState;

<?php 
    if ($configurable) {
        ?>
    const Json::Value jsonInit;
<?php 
    }
    // if configurable
    ?>

    size_t count;

    MapType groupByMap;

    std::vector<MapType::iterator> theIterators;  // the iterators, only 2 elements if multi, many if fragment
    Iterator multiIterator;

public:

    <?php 
    echo $className;
    ?>
(<?php 
    if ($configurable) {
        ?>
const Json::Value & _jsonInit, <?php 
    }
    ?>
const ConstantState & _constState ) :
        constState(_constState)
<?php 
    if ($configurable) {
        ?>
        , jsonInit(_jsonInit)
<?php 
    }
    // if configurable
    ?>
        , count(0)
        , groupByMap( INIT_SIZE )
        , theIterators()
        , multiIterator()
    { }

    ~<?php 
    echo $className;
    ?>
() {}

    void Reset(void) {
        count = 0;
        groupByMap.clear();
        theIterators.clear();
    }

    void AddItem(<?php 
    echo array_template('const {val} & {key}', ', ', $inputs);
    ?>
) {
        count++;
        // check if _key is already in the map; if yes, add _value; else, add a new
        // entry (_key, _value)
        Key key(<?php 
    echo array_template('{key}', ', ', $gbyAtts);
    ?>
);

        MapType::iterator it = groupByMap.find(key);
        if (it == groupByMap.end()) { // group does not exist
            // create an empty GLA and insert
            // better to not add the item here so we do not have
            // to transport a large state

<?php 
    if ($innerGLA->has_state()) {
        ?>
            const InnerState & innerState = constState.getConstState(key);
<?php 
    }
    // if gla has state
    ?>
            InnerGLA gla<?php 
    echo $constructorString;
    ?>
;
            auto ret = groupByMap.insert(MapType::value_type(key, gla));
            it = ret.first; // reposition
        }
        it->second.AddItem(<?php 
    echo array_template('{key}', ', ', $glaInputAtts);
    ?>
);
    }

    void AddState(<?php 
    echo $className;
    ?>
& other) {
        count += other.count;
        // scan other hash and insert or update content in this one
        for (MapType::iterator it = other.groupByMap.begin(); it != other.groupByMap.end();
                ++it) {
            const Key& okey = it->first;
            <?php 
    echo $innerGLA;
    ?>
& ogla = it->second;

            MapType::iterator itt = groupByMap.find(okey);
            if (itt != groupByMap.end()) { // found the group
                <?php 
    echo $innerGLA;
    ?>
& gla = itt->second;
                gla.AddState(ogla);
            } else {
                // add the other group to this hash
                groupByMap.insert(MapType::value_type(okey, ogla));
            }
        }
    }

<?php 
    if ($iterable) {
        ?>
    bool ShouldIterate(ConstantState& modibleState) {
<?php 
        if ($debug > 0) {
            ?>
        fprintf(stderr, "<?php 
            echo $className;
            ?>
: ==== ShouldIterate ====\n");
<?php 
        }
        // if debugging enabled
        ?>
        bool shouldIterate = false;
        for( MapType::iterator it = groupByMap.begin(); it != groupByMap.end(); ++it ) {
            const Key & key = it->first;
            InnerGLA & gla = it->second;
<?php 
        if ($innerGLA->has_state()) {
            ?>
            InnerState & innerState = modibleState.getModibleState(key);
<?php 
        }
        // if gla has state
        ?>
            bool glaRet = gla.ShouldIterate(innerState);
            shouldIterate = shouldIterate || glaRet;
<?php 
        if ($debug > 0) {
            ?>
            fprintf(stderr, "<?php 
            echo $className;
            ?>
: Key(%s) shouldIterate(%s)\n",
                key.to_string().c_str(),
                glaRet ? "true" : "false");
<?php 
        }
        // if debugging enabled
        ?>
        }

        return shouldIterate;
    }
<?php 
    }
    // if iterable
    ?>

<?php 
    if (in_array('fragment', $resType)) {
        ?>

    int GetNumFragments(void){
        int size = groupByMap.size();
        int sizeFrag = <?php 
        echo $fragSize;
        ?>
;
        // setup the fragment boundaries
        // scan via iterator and count
        int frag=0;
        int pos=0;
        MapType::iterator it = groupByMap.begin();
        theIterators.clear();
        theIterators.push_back( it );
        // special case when size < num_fragments
        // >
        if (sizeFrag == 0){
            it = groupByMap.end();
            theIterators.push_back( it );
            return 1; // one fragment
        }

        while(it!=groupByMap.end()){
            while(it!=groupByMap.end() && pos<( frag + 1 )*sizeFrag){
//>
                ++it;
                pos++;
            }
            theIterators.push_back( it );
            frag++;
        }

<?php 
        if ($debug > 0) {
            ?>
        fprintf(stderr, "<?php 
            echo $className;
            ?>
: fragments(%d)\n", frag);
<?php 
        }
        ?>

        return frag;

    }

    Iterator* Finalize(int fragment){
        // Call finalize on all inner GLAs in this fragment.
        MapType::iterator iter = theIterators[fragment];
        MapType::iterator iterEnd = theIterators[fragment+1];

        Iterator* rez
            = new Iterator(theIterators[fragment], theIterators[fragment+1] );
        return rez;
    }

    bool GetNextResult(Iterator* it,  <?php 
        echo array_template('{val} & {key}', ', ', $outputs);
        ?>
) {
        return it->GetNextResult(<?php 
        echo args($outputs);
        ?>
);
    }
<?php 
    }
    // if using fragment interface
    ?>

    void Finalize() {
        multiIterator = Iterator( groupByMap.begin(), groupByMap.end() );

<?php 
    if ($debug >= 1) {
        ?>
        fprintf(stderr, "<?php 
        echo $className;
        ?>
: groups(%lu) tuples(%lu)\n", groupByMap.size(), count);
<?php 
    }
    ?>
    }

    bool GetNextResult(<?php 
    echo array_template('{val} & {key}', ', ', $outputs);
    ?>
) {
        return multiIterator.GetNextResult( <?php 
    echo args($outputs);
    ?>
 );
    }

    std::size_t size() const {
        return groupByMap.size();
    }

    const MapType& GetMap() const {
      return groupByMap;
    }

    bool Contains(<?php 
    echo const_typed_ref_args($gbyAtts);
    ?>
) const {
      Key key(<?php 
    echo args($gbyAtts);
    ?>
);
      return groupByMap.count(key) > 0;
    }

    const InnerGLA& Get(<?php 
    echo const_typed_ref_args($gbyAtts);
    ?>
) const {
      Key key(<?php 
    echo args($gbyAtts);
    ?>
);
      return groupByMap.at(key);
    }

    bool Contains(Key key) const {
      return groupByMap.count(key) > 0;
    }

    const InnerGLA& Get(Key key) const {
      return groupByMap.at(key);
    }
};

<?php 
    if (in_array('fragment', $resType)) {
        ?>
typedef <?php 
        echo $className;
        ?>
::Iterator <?php 
        echo $className;
        ?>
_Iterator;
<?php 
    }
    ?>

<?php 
    $sys_headers = array_merge(['iomanip', 'iostream', 'cstring'], $extraHeaders);
    return array('kind' => 'GLA', 'name' => $className, 'system_headers' => $sys_headers, 'user_headers' => array('HashFunctions.h'), 'input' => $inputs, 'output' => $outputs, 'result_type' => $resType, 'configurable' => $configurable, 'generated_state' => $constState, 'required_states' => $reqStates, 'iterable' => $iterable, 'properties' => ['resettable', 'finite container'], 'libraries' => $libraries, 'extra' => ['inner_gla' => $innerGLA]);
}