* @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2005 Nigel McNie * @version 1.1.0 * */ /** * Implementation of KeywordGetterStrategy for the HTML language. * * @package scripts * @author Nigel McNie * @since 0.1.1 * @version 1.1.0 * @see KeywordGetterStrategy */ class htmlKeywordGetterStrategy extends KeywordGetterStrategy { /** * The file from which the attribute names will be raided * @var string * @access private */ var $_fileName = '/usr/share/doc/w3-recs/RECS/html4/index/attributes.html'; /** * Creates a new HTML Keyword Getter Strategy. Defines allowed * keyword groups for HTML. */ function htmlKeywordGetterStrategy () { $this->_language = 'HTML'; $this->_validKeywordGroups = array( 'attributes' ); } /** * Implementation of abstract method {@link KeywordGetterStrategy::getKeywords()} * to get keywords for HTML * * @param string The keyword group to get keywords for. If not a valid keyword * group an error is returned * @return array The keywords for HTML for the specified keyword group * @throws KeywordGetterError */ function getKeywords ($keyword_group) { // Check that keyword group listed is valid $group_valid = $this->keywordGroupIsValid($keyword_group); if (KeywordGetter::isError($group_valid)) { return $group_valid; } if (!is_readable($this->_fileName)) { return new KeywordGetterError(FILE_UNAVAILABLE, $this->_language, array('{FILENAME}' => $this->_fileName)); } $file_contents = implode('', file($this->_fileName)); $matches = array(); preg_match_all('#]+>\s*([a-z\-]+)#', $file_contents, $matches); $keywords = $matches[1]; return array_unique($keywords); } } ?>