Example #1
0
     $xml = new DOMDocument('1.0', 'utf-8');
     $xml->formatOutput = true;
     $xml->preserveWhiteSpace = false;
     $xml->load('../config.xml') or die("Couldn't load config.xml for theme");
     //Get item Element
     $element = $xml->getElementsByTagName('Configuration')->item(0) or die("Couldn't find Configuration node for changing theme ");
     //Load child elements
     $NameofActivity = $element->getElementsByTagName('ThemeName')->item(0) or die("Couldn't load ThemeName");
     //Replacing the value
     $NameofActivity->nodeValue = $_POST['theme'];
     $xml->save("../config.xml") or die("Couldn't change the theme");
     echo "Theme has been changed successfully!";
 } elseif (!empty($_POST['beforeimageupload'])) {
 } elseif (!empty($_POST['updateWords'])) {
     //	addWord
     addWord($_POST['word'], $_POST['category'], $_POST['tags'], '4pics1');
     //	getLastWordDetails
     $mslno = getLastWordDetails();
     //	updateFolderName
     updateWordFolder($_POST['loc'], $mslno);
     echo "Your word has been added to database successfully !";
 } elseif (!empty($_FILES)) {
     //	$mime_type=check_mime_content_type($_FILES["activity-file"]["name"]);
     //	echo $mime_type;
     if (is_zip_file($_FILES["activity-file"]["name"]) && zipIsValid($_FILES["activity-file"]["tmp_name"])) {
         //		echo "VALID";
         //		pr($_FILES);
         //		echo $mime_type;
         $zip = new ZipArchive();
         $filedetail = pathinfo($_FILES["activity-file"]["name"]);
         if ($zip->open($_FILES["activity-file"]["tmp_name"]) === TRUE) {
Example #2
0
<?php

require_once 'config.php';
$session->requireLoggedIn();
if (!empty($_POST['word']) && !empty($_POST['lang']) && is_numeric($_POST['lang']) && !empty($_POST['pron'])) {
    $wordId = addWord($_POST['lang'], $_POST['word'], $_POST['pron']);
    if (is_numeric($wordId)) {
        header('Location: word.php?id=' . $wordId);
        die;
    }
}
require 'design_head.php';
?>

<h2>Add new word</h2>

<form method="post" action="">
    Word: <input type="text" name="word"/><br/>
    Pronunciation: <input type="text" name="pron"/><br/>
    Language: <?php 
echo xhtmlSelectCategory(CATEGORY_LANGUAGE, 0, 'lang');
?>
    <input type="submit" class="button" value="Add"/>
</form>

<?php 
require 'design_foot.php';
if (isset($wordId)) {
    JS_Alert('FAILED TO ADD WORD!! word already exists');
}
Example #3
0
function fillBoard()
{
    //fill board with list by calling addWord() for each word
    //or return false if failed
    global $word;
    $direction = array("N", "S", "E", "W");
    $itWorked = TRUE;
    $counter = 0;
    $keepGoing = TRUE;
    while ($keepGoing) {
        $dir = rand(0, 3);
        $result = addWord($word[$counter], $direction[$dir]);
        if ($result == FALSE) {
            //print "failed to place $word[$counter]";
            $keepGoing = FALSE;
            $itWorked = FALSE;
        }
        // end if
        $counter++;
        if ($counter >= count($word)) {
            $keepGoing = FALSE;
        }
        // end if
    }
    // end while
    return $itWorked;
}
// Create and configure a link to the pspell module.
$pspell_config = pspell_config_create("en");
pspell_config_mode($pspell_config, PSPELL_FAST);
if ($usePersonalDict) {
    pspell_config_personal($pspell_config, $path_to_personal_dictionary);
}
$pspell_link = pspell_new_config($pspell_config);
switch ($_POST['action']) {
    case 'spellcheck':
        spellCheck($_POST['spellText']);
        break;
    case 'suggest':
        getSuggestions($_POST['suggestionText']);
        break;
    case 'addToDictionary':
        addWord($_POST['wordToAdd']);
        break;
    default:
        echo "Unknown Action";
        break;
}
/*************************************************************
 * showSuggestions($word, $id)
 *
 * The showSuggestions function creates the list of up to 10
 * suggestions to return for the given misspelled word.
 *
 * $word - The misspelled word that was clicked on
 * $id - The id of the span containing the misspelled word.
 *
 *************************************************************/
Example #5
0
/**
 * Takes a body of text and saves as many observations as possible about the text
 *
 * @param $langId id of the language of the text
 * @param $text the text to analyze
 * @return nothing
 */
function analyzeText($langId, $text)
{
    if (!is_numeric($langId) || !$text) {
        return false;
    }
    $sentences = parseText($text);
    for ($i = 0; $i < count($sentences); $i++) {
        //Split up the sentences in array of words separated by space
        $words = explode(' ', $sentences[$i]);
        for ($j = 0; $j < count($words); $j++) {
            if (notWord($words[$j])) {
                echo '<div class="critical">Skipped invalid word <b>' . $words[$j] . '</b></div>';
                continue;
            }
            if (unsureWord($words[$j])) {
                //FIXME: checkbox & submit to add the rest of the words
                echo '<div style="background-color:#FD9534">Not sure if this is a word, skipping <b></b>' . $words[$j] . '</b></div>';
                continue;
            }
            $wordId = addWord($langId, $words[$j]);
            if ($wordId) {
                echo '<div class="okay"><b>' . $words[$j] . '</b> added to database</div>';
            } else {
                $wordId = getWordId($langId, $words[$j]);
            }
            if ($wordId) {
                //save observations
                if ($j == 0) {
                    //word can occur in the beginning of sentence
                    learnWordRelation(WORDRELATION_STARTSENTENCE, $wordId);
                }
                if ($j == count($words)) {
                    //word can occur at end of sentences
                    echo 'END OF SENTENCE<br/>';
                    learnWordRelation(WORDRELATION_ENDSENTENCE, $wordId);
                }
                if (count($words) == 1) {
                    //word can be full sentence by itself
                    echo 'FULL SENTENCE WORD<br/>';
                    learnWordRelation(WORDRELATION_ALONEINSENTENCE, $wordId);
                }
                if ($j > 0) {
                    //word can occur after $words[$j - 1]
                    $otherId = getWordId($langId, $words[$j - 1]);
                    learnWordRelation(WORDRELATION_COMESAFTER, $wordId, $otherId);
                }
                if ($j < count($words) - 1) {
                    //word can occur before $words[$j + 1]
                    $otherId = getWordId($langId, $words[$j + 1]);
                    learnWordRelation(WORDRELATION_COMESBEFORE, $wordId, $otherId);
                }
            }
        }
    }
}