0) { $str = ""; } else { $str = " "; } return $str; } function create_dictionary_iterator($offset, $count, $first_letter) { global $LOWER_CHARSET_ASCIIMAP; $it =& Node::create_iterator($offset, $count, null, false, "ORDER BY `name`, `meaning`"); $asciimap = $LOWER_CHARSET_ASCIIMAP[strtolower($first_letter)]; if (!is_array($asciimap)) // just one char $it->where .= " AND name LIKE '" . strtolower($first_letter) . "%'"; else { $it->where .= " AND (0"; foreach ($asciimap as $char) { $it->where .= " OR name LIKE '" . mb_strtolower($char) . "%'"; } $it->where .= ")"; } return $it; } function get_excluded_letters() { global $LOWER_CHARSET_ASCII; $excluded = array(); foreach ($LOWER_CHARSET_ASCII as $char) { $it = create_dictionary_iterator(0, null, $char); if ($it->count() <= 0) { $excluded[] = $char; } } return $excluded; } $offset = (isset($_GET['offset'])?$_GET['offset']:0); $first_letter = (isset($_GET['letter'])?$_GET['letter']:'a'); $count = $DEFAULT_ITERATOR_COUNT; $MAX_NAMES_PER_COLUMN = $DEFAULT_ITERATOR_COUNT / 3; // Create iterator $it =& create_dictionary_iterator($offset, $count, $first_letter); $links = array(); $i=0; $col=0; $entries = $it->all(); $letters = strtoupper($first_letter); if ($it->count() > 0) { // if ($offset == 0) // first page // $first_letter = "A"; // else // $first_letter = first_letter($entries[0]->get('name')); // if ($offset + $count >= $it->count()) // last page // $last_letter = "Z"; // else // $last_letter = first_letter($entries[count($entries)-1]->get('name')); // $letters = $first_letter . "-" . $last_letter; foreach ($entries as $entry) { if ($i>=$MAX_NAMES_PER_COLUMN) { $i=0; $col++; } $display = new Display($entry); $links[$col][] = $display->link(); $i++; } // Hack: Fill with whitespaces to ensure all pages have the same height while (count($links[0]) < $MAX_NAMES_PER_COLUMN) { $links[0][] = " "; } $left = array_to_list($links[0]); $center = array_to_list($links[1]); $right = array_to_list($links[2]); } else { $left = "No names starting with that letter."; $center = $right = ""; } ?> : DICTIONARY