Constructor
PHP_Crossword
PHP_Crossword
([int $rows = 15], [int $cols = 15])
Get number of words
int
countWords
()
Check if the word already exists in the database
boolean
existsWord
(string $word)
Generate crossword
boolean
generate
()
Generate crossword from provided words list
boolean
generateFromWords
(string $words_list)
Get crossword HTML (useful for generator debugging)
string
getHTML
([array $params = array()])
Get question for the word
string
getQuestion
(string $word)
Get crossword items
array
getWords
()
Get generated crossword XML
string
getXML
()
Insert word into database
void
insertWord
(string $word, string $question)
-
string
$word
-
string
$question: (ignored - we make questions by shuffling the characters)
Enable / disable debugging
void
setDebug
([boolean $debug = TRUE])
Set maximum number of tries to generate full crossword
void
setMaxFullTries
(int $max_full_tries)
Set max tries to pick the words
void
setMaxTries
(int $max_tries)
Set number of words the crossword shoud have
void
setMaxWords
(int $max_words)
Try to generate crossword automatically
(until we get enough word or reach number of maximum tries
void
__autoGenerate
()
Calculate starting cell for the word
void
&__calcStartCell
( &$cell, &$start, &$end, int $axis, string $word, &$pos, object $cell, object $start, object $end, int $pos)
-
object
$cell: crossing cell
-
object
$start: minimum starting cell
-
object
$end: maximum ending cell
-
int
$axis
-
string
$word
-
int
$pos: last position return object|FALSE starting cell object or FALSE ir can't find
-
&$cell
-
&$start
-
&$end
-
&$pos
Get crossword items array
array
__getItems
()
Generate word matching line
string
__getMatchLine
( &$cell, &$start, &$end, int $axis, object $cell, object $start, object $end)
-
object
$cell: crossing cell
-
object
$start: minimum starting cell
-
object
$end: maximum ending cell
-
int
$axis
-
&$cell
-
&$start
-
&$end
Get minimum match string
string
__getMatchMin
(string $str)
-
string
$str: match string
Get REGEXP for the match string
string
__getMatchRegexp
(string $str)
-
string
$str: match string
Get random word
string
__getRandomWord
(int $max_length)
-
int
$max_length: maximum word length
Try to get the word
string
__getWord
( &$cell, &$start, &$end, int $axis, object $cell, object $start, object $end)
-
object
$cell: crossing cell
-
object
$start: minimum starting cell
-
object
$end: maximum ending cell
-
int
$axis
-
&$cell
-
&$start
-
&$end
Try to pick the word crossing the cell
array
__getWordWithStart
( &$cell, int $axis, object $cell)
-
object
$cell: Cell object to cross
-
int
$axis
-
&$cell
Load words from ocPortal
void
__initialiseWords
()
Load words for the match
result
__loadWords
(string $match, int $len_min, int $len_max)
-
string
$match: regular expression match
-
int
$len_min: minimum length of the word
-
int
$len_max: maximum length of the word
Pick the word from the resultset
void
__pickWord
( &$rs, string $regexp, array $rs)
-
array
$rs
-
string
$regexp: Regexp to match return string|NULL word or NULL if couldn't find
-
&$rs
Place first word to the cell
void
__placeFirstWord
()
Get XML of the word item
string
__wordItem2XML
(object $item, string $ident)
-
object
$item: word item
-
string
$ident