Class PHP_Crossword

Description
Variable Summary
mixed $cols
mixed $grid
mixed $max_tries
mixed $max_words
mixed $rows
mixed $word_pool
mixed $_debug
mixed $_full_tries
mixed $_items
mixed $_match_line
mixed $_tries
Method Summary
PHP_Crossword PHP_Crossword ([int $rows = 15], [int $cols = 15])
int countWords ()
boolean existsWord (string $word)
boolean generate ()
boolean generateFromWords (string $words_list)
string getHTML ([array $params = array()])
string getQuestion (string $word)
array getWords ()
string getXML ()
void insertWord (string $word, string $question)
void reset ()
void setDebug ([boolean $debug = TRUE])
void setMaxFullTries (int $max_full_tries)
void setMaxTries (int $max_tries)
void setMaxWords (int $max_words)
void __autoGenerate ()
void &__calcStartCell ( &$cell,  &$start,  &$end, int $axis, string $word,  &$pos, object $cell, object $start, object $end, int $pos)
array __getItems ()
string __getMatchLine ( &$cell,  &$start,  &$end, int $axis, object $cell, object $start, object $end)
string __getMatchMin (string $str)
string __getMatchRegexp (string $str)
string __getRandomWord (int $max_length)
string __getWord ( &$cell,  &$start,  &$end, int $axis, object $cell, object $start, object $end)
array __getWordWithStart ( &$cell, int $axis, object $cell)
result __loadWords (string $match, int $len_min, int $len_max)
void __pickWord ( &$rs, string $regexp, array $rs)
string __wordItem2XML (object $item, string $ident)
Variables
mixed $cols = 15 (line 44)
mixed $grid (line 45)
mixed $max_full_tries = 10 (line 47)
mixed $max_tries = 50 (line 49)
mixed $max_words = 15 (line 48)
mixed $rows = 15 (line 43)
mixed $word_pool = NULL (line 57)
mixed $_debug = FALSE (line 54)
mixed $_full_tries = 0 (line 52)
mixed $_items (line 55)
mixed $_match_line (line 51)
mixed $_tries = 0 (line 53)
Methods
Constructor PHP_Crossword (line 64)

Constructor

PHP_Crossword PHP_Crossword ([int $rows = 15], [int $cols = 15])
  • int $rows
  • int $cols
countWords (line 635)

Get number of words

int countWords ()
existsWord (line 546)

Check if the word already exists in the database

boolean existsWord (string $word)
  • string $word
generate (line 110)

Generate crossword

  • return: TRUE - if succeeded, FALSE - if unable to get required number of words
boolean generate ()
generateFromWords (line 646)

Generate crossword from provided words list

  • return: TRUE on success
boolean generateFromWords (string $words_list)
  • string $words_list
getHTML (line 167)

Get crossword HTML (useful for generator debugging)

  • return: HTML
string getHTML ([array $params = array()])
  • array $params: params
getQuestion (line 211)

Get question for the word

string getQuestion (string $word)
  • string $word
getWords (line 176)

Get crossword items

array getWords ()
getXML (line 572)

Get generated crossword XML

  • return: XML
string getXML ()
insertWord (line 557)

Insert word into database

void insertWord (string $word, string $question)
  • string $word
  • string $question: (ignored - we make questions by shuffling the characters)
reset (line 150)

Reset grid

void reset ()
setDebug (line 74)

Enable / disable debugging

void setDebug ([boolean $debug = TRUE])
  • boolean $debug
setMaxFullTries (line 92)

Set maximum number of tries to generate full crossword

void setMaxFullTries (int $max_full_tries)
  • int $max_full_tries
setMaxTries (line 101)

Set max tries to pick the words

void setMaxTries (int $max_tries)
  • int $max_tries
setMaxWords (line 83)

Set number of words the crossword shoud have

void setMaxWords (int $max_words)
  • int $max_words
__autoGenerate (line 221)

Try to generate crossword automatically

(until we get enough word or reach number of maximum tries

  • private:
void __autoGenerate ()
__calcStartCell (line 311)

Calculate starting cell for the word

  • private:
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
__getItems (line 186)

Get crossword items array

  • private:
array __getItems ()
__getMatchLine (line 398)

Generate word matching line

  • return: matching line
  • private:
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
__getMatchMin (line 432)

Get minimum match string

  • private:
string __getMatchMin (string $str)
  • string $str: match string
__getMatchRegexp (line 445)

Get REGEXP for the match string

  • private:
string __getMatchRegexp (string $str)
  • string $str: match string
__getRandomWord (line 527)

Get random word

  • return: word
  • private:
string __getRandomWord (int $max_length)
  • int $max_length: maximum word length
__getWord (line 356)

Try to get the word

  • return: word
  • private:
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
__getWordWithStart (line 274)

Try to pick the word crossing the cell

  • return: Array of 2 items - word and start cell object
  • private:
array __getWordWithStart ( &$cell, int $axis, object $cell)
  • object $cell: Cell object to cross
  • int $axis
  • &$cell
__initialiseWords (line 472)

Load words from ocPortal

void __initialiseWords ()
__loadWords (line 507)

Load words for the match

  • return: SQL result
  • private:
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
__pickWord (line 375)

Pick the word from the resultset

  • private:
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
__placeFirstWord (line 459)

Place first word to the cell

  • private:
void __placeFirstWord ()
__wordItem2XML (line 612)

Get XML of the word item

  • return: XML
  • private:
string __wordItem2XML (object $item, string $ident)
  • object $item: word item
  • string $ident

Documentation generated on Sun, 02 Jan 2011 23:22:08 +0000 by phpDocumentor 1.4.3