Пример #1
0
 public static function regenerateAllWordLetters()
 {
     SqlDeleteRows('delete from word_letter', array());
     $words = SqlFetchRows("select * from word", array());
     SqlEchoOn();
     foreach ($words as $thisWord) {
         Learn::generateWordLetters($thisWord);
     }
 }
Пример #2
0
 function pageGenerateWordLetters()
 {
     Learn::regenerateAllWordLetters();
 }
Пример #3
0
<?php

/**
 * 
 * @authors Your Name (you@example.org)
 * @date    2016-10-13 15:42:18
 * @version $Id$
 */
class Learn
{
    function __construct()
    {
    }
    function testStatic()
    {
        static $a = 0;
        echo $a;
        ++$a;
    }
}
$learn = new Learn();
echo "ref testStatic ont times";
$learn->testStatic();
echo "<br/>";
echo "ref testStatic two times";
$learn->testStatic();
echo "<br/>";
Пример #4
0
 /**
  * Return a path for special shorthand in links.
  *
  * New link shorthand should be defined here, following the pattern
  * currently used for tutorials.
  *
  * A hook for this can be installed by withCallbacks().
  */
 protected function urlCallback($path)
 {
     $m = [];
     if (preg_match('/^tutorials?\\/([0-9]+)$/', $path, $m)) {
         if ($t = \LearnTutorialSaurus::getById($m[1])) {
             return \Learn::externalLink('tutorials')->id($t->url_path);
         }
     }
     // we didn't find anything
     return null;
 }
Пример #5
0
 public function getWords()
 {
     $words = array();
     for ($row = 1; $row <= self::size; $row++) {
         $word = '';
         for ($col = 1; $col <= self::size; $col++) {
             $letter = $this->cells[$row][$col]->getLetter();
             if ($letter) {
                 $word .= $letter;
             } else {
                 if ($word) {
                     $words[$word] = 1;
                     $word = '';
                 }
             }
         }
         if ($word) {
             $words[$word] = 1;
             $word = '';
         }
     }
     for ($col = 1; $col <= self::size; $col++) {
         $word = '';
         for ($row = 1; $row <= self::size; $row++) {
             $letter = $this->cells[$row][$col]->getLetter();
             if ($letter) {
                 $word .= $letter;
             } else {
                 if ($word) {
                     $words[$word] = 1;
                     $word = '';
                 }
             }
         }
         if ($word) {
             $words[$word] = 1;
             $word = '';
         }
     }
     // SqlEchoOn();
     foreach ($words as $thisWord => $thing) {
         SqlBeginTransaction();
         $word = strtoupper($thisWord);
         $len = strlen($word);
         if ($len < 2) {
             continue;
         }
         $id = SqlFetchCell("select id from word where word = :word", array('word' => $word));
         if (!$id) {
             echo "inserting word: {$word}<br>";
             SqlInsertRow("insert into word (word, len) values (:wordwrap, :len)", array('word' => $word, 'len' => $len));
             Learn::generateWordLetters($word);
         }
         SqlCommitTransaction();
     }
 }