Source of file KeywordInsertionItem.php
Size: 2,005 Bytes - Last Modified: 2018-06-12T11:20:28+00:00
/var/www/docs.ssmods.com/process/src/code/KeywordInsertionItem.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 | <?php /** * Class provides a simple keyword element, only contains the keyword as * key of a keyword insertion request. * You can extend this Element with your own data and fields. */ class KeywordInsertionItem extends DataObject { /** * @var array */ private static $db = array( 'Keyword' => 'Varchar(200)', 'Value' => 'Varchar(200)', ); /** * @var array */ private static $has_one = array( 'KeywordInsertionPage' => 'KeywordInsertionPage', ); /** * @var string */ static $singular_name = 'Wildcard Element'; /** * @var string */ static $plural_name = 'Wildcard Element'; /** * Returns the fieldset for cms backend * * @return \FieldList */ public function getCMSFields() { $fields = new FieldList( $rootTab = new TabSet('Root', $tabMain = new Tab('Main') ) ); $fields->addFieldsToTab( 'Root.Main', array( new TextField( 'Keyword', _t('KeywordInsertionPage.KEYWORD_LABEL', 'Keyword') ), new TextField( 'Value', _t('KeywordInsertionPage.VALUE_LABEL', 'Value') ) ) ); return $fields; } /** * Method returns all values based on a specific keyword * * @return array */ public function allKeywordValues() { $aAllKeywordValues = array(); $aAllKeywords = self::allKeywords(); foreach($aAllKeywords as $sKeyword) { $aAllKeywordValues[$sKeyword] = $this->{$sKeyword}; } return $aAllKeywordValues; } /** * Return keywords for wildcard insertion. * * @return array */ public static function allKeywords() { return array( 'Value', ); } } |