idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
55,700
protected function removeNestedPlaceholders ( $ originalContent ) { return preg_replace_callback ( '/' . Constants :: PLACEHOLDER_PATTERN . '/' , function ( $ match ) { return $ this -> pull ( $ match [ 0 ] ) ; } , $ originalContent ) ; }
Remove nested placeholders so no nested placholders remain in the original contents .
55,701
public static function newResources ( $ credentials ) { if ( ( ! isset ( $ credentials [ self :: USERNAME ] ) ) || ( ! isset ( $ credentials [ self :: PASSWORD ] ) ) ) { throw new Exception ( 'Invalid credentials' ) ; } $ restClient = new Client ( $ credentials [ self :: USERNAME ] , $ credentials [ self :: PASSWORD ] ) ; return new Resources ( $ restClient ) ; }
Creates a new Resources object
55,702
public static function options ( ) { if ( self :: $ options === null ) { self :: $ options = [ self :: WHITESPACES => new Option ( self :: WHITESPACES , 'Remove redundant whitespaces' , true ) , self :: COMMENTS => new Option ( self :: COMMENTS , 'Remove comments' , true ) , self :: BOOLEAN_ATTRIBUTES => new Option ( self :: BOOLEAN_ATTRIBUTES , 'Collapse boolean attributes from checked="checked" to checked' , true ) , self :: ATTRIBUTE_QUOTES => new Option ( self :: ATTRIBUTE_QUOTES , 'Remove quotes around html attributes' , false ) , self :: OPTIONAL_ELEMENTS => new Option ( self :: OPTIONAL_ELEMENTS , 'Remove optional elements which can be implied by the browser' , false ) , self :: REMOVE_DEFAULTS => new Option ( self :: REMOVE_DEFAULTS , 'Remove defaults such as from <script type=text/javascript>' , false ) , self :: EMPTY_ATTRIBUTES => new Option ( self :: EMPTY_ATTRIBUTES , 'Remove empty attributes. HTML boolean attributes are skipped' , false ) , ] ; } return self :: $ options ; }
Get all the options available for this minifier .
55,703
private function isBooleanAttribute ( $ attribute ) { return array_search ( trim ( $ attribute ) , $ this -> repository -> getAttributes ( ) ) || Html :: isDataAttribute ( $ attribute ) ; }
Check if an attribute is a boolean attribute .
55,704
protected function minifyAttribute ( $ match ) { if ( Str :: contains ( $ match [ 2 ] , $ this -> prohibitedChars ) ) { return $ match [ 0 ] ; } elseif ( preg_match ( '/' . Constants :: PLACEHOLDER_PATTERN . '/is' , $ match [ 2 ] ) ) { return $ match [ 0 ] ; } return '=' . $ match [ 2 ] ; }
Minify the attribute quotes if allowed .
55,705
protected function functionHasReturnStatement ( PHP_CodeSniffer_File $ phpcsFile , $ stackPtr , $ continueSearch = null ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ sFunctionToken = $ tokens [ $ stackPtr ] ; $ returnStatement = false ; if ( isset ( $ sFunctionToken [ 'scope_closer' ] ) and isset ( $ sFunctionToken [ 'scope_opener' ] ) ) { $ startSearch = $ continueSearch !== null ? $ continueSearch : $ sFunctionToken [ 'scope_opener' ] ; $ returnStatement = $ phpcsFile -> findNext ( T_RETURN , $ startSearch , $ sFunctionToken [ 'scope_closer' ] ) || $ phpcsFile -> findNext ( T_YIELD , $ startSearch , $ sFunctionToken [ 'scope_closer' ] ) ; } if ( $ returnStatement !== false ) { if ( $ phpcsFile -> hasCondition ( $ returnStatement , T_CLOSURE ) ) { return $ this -> functionHasReturnStatement ( $ phpcsFile , $ stackPtr , $ returnStatement + 1 ) ; } else { return true ; } } return false ; }
Search if Function has a Return Statement
55,706
protected function isInterface ( PHP_CodeSniffer_File $ phpcsFile ) { $ checkFile = "" . $ phpcsFile -> getFilename ( ) ; if ( isset ( $ this -> isFileInterface [ $ checkFile ] ) ) { return ( bool ) $ this -> isFileInterface [ $ checkFile ] ; } $ interface = $ phpcsFile -> findNext ( T_INTERFACE , 0 ) ; return $ this -> isFileInterface [ $ checkFile ] = ( bool ) ( empty ( $ interface ) == false ) ; }
Test if this a PHP Interface File
55,707
protected function removeElement ( $ element , $ contents ) { $ newContents = preg_replace ( '@' . $ element -> regex . '@xi' , '' , $ contents ) ; if ( $ newContents !== $ contents && isset ( $ element -> elements ) ) { foreach ( $ element -> elements as $ element ) { $ newContents = $ this -> removeElement ( $ element , $ newContents ) ; } } return $ newContents ; }
Remove an optional element .
55,708
public function process ( MinifyContext $ context ) { $ contents = preg_replace_callback ( '/' . Constants :: $ htmlEventNamePrefix . Constants :: ATTRIBUTE_NAME_REGEX . ' # Match an on{attribute} \s*=\s* # Match equals sign with optional whitespaces around it ["\']? # Match an optional quote \s*javascript: # Match the text "javascript:" which should be removed /xis' , function ( $ match ) { return str_replace ( 'javascript:' , '' , $ match [ 0 ] ) ; } , $ context -> getContents ( ) ) ; return $ context -> setContents ( $ contents ) ; }
Minify javascript prefixes on html event attributes .
55,709
public function process ( $ context ) { $ contents = $ context -> getContents ( ) ; $ contents = $ this -> whitespaceBetweenInlineElements ( $ contents , $ context -> getPlaceholderContainer ( ) ) ; $ contents = $ this -> whitespaceInInlineElements ( $ contents , $ context -> getPlaceholderContainer ( ) ) ; $ contents = $ this -> replaceElementContents ( $ contents , $ context -> getPlaceholderContainer ( ) ) ; return $ context -> setContents ( $ contents ) ; }
Replace critical content with a temporary placeholder .
55,710
protected function whitespaceBetweenInlineElements ( $ contents , PlaceholderContainer $ placeholderContainer ) { $ elementsRegex = $ this -> getInlineElementsRegex ( ) ; return preg_replace_callback ( '/ ( <(' . $ elementsRegex . ') # Match the start tag and capture it (?:(?!<\/\2>).*) # Match everything without the end tag <\/\2> # Match the captured elements end tag ) \s+ # Match minimal 1 whitespace between the elements <(' . $ elementsRegex . ') # Match the start of the next inline element /xi' , function ( $ match ) use ( $ placeholderContainer ) { $ placeholder = $ placeholderContainer -> createPlaceholder ( ' ' ) ; return $ match [ 1 ] . $ placeholder . '<' . $ match [ 3 ] ; } , $ contents ) ; }
Whitespaces between inline html elements must be replaced with a placeholder because a browser is showing that whitespace .
55,711
protected function whitespaceInInlineElements ( $ contents , PlaceholderContainer $ placeholderContainer ) { $ elementsRegex = $ this -> getInlineElementsRegex ( ) ; return preg_replace_callback ( '/ ( <(' . $ elementsRegex . ') # Match an inline element (?:(?!<\/\2>).*) # Match everything except its end tag <\/\2> # Match the end tag \s+ ) <(' . $ elementsRegex . ') # Match starting tag /xis' , function ( $ match ) use ( $ placeholderContainer ) { return $ this -> replaceWhitespacesInInlineElements ( $ match [ 1 ] , $ placeholderContainer ) . '<' . $ match [ 3 ] ; } , $ contents ) ; }
Whitespaces in an inline element have a function so we replace it .
55,712
private function replaceWhitespacesInInlineElements ( $ element , PlaceholderContainer $ placeholderContainer ) { return preg_replace_callback ( '/>\s/' , function ( $ match ) use ( $ placeholderContainer ) { return '>' . $ placeholderContainer -> createPlaceholder ( ' ' ) ; } , $ element ) ; }
Replace the whitespaces in inline elements with a placeholder .
55,713
public function getAttributes ( ) { if ( self :: $ attributes === null ) { self :: $ attributes = $ this -> loadJson ( $ this -> resource ( 'HtmlBooleanAttributes.json' ) ) -> attributes ; } return self :: $ attributes ; }
Get the html boolean attributes .
55,714
public function handle ( ) { if ( ( bool ) GeneralUtility :: _GP ( 'juSecure' ) ) { $ this -> forwardJumpUrlSecureFileData ( $ this -> url ) ; } else { $ this -> redirectToJumpUrl ( $ this -> url ) ; } }
Custom processing of the current URL .
55,715
protected function redirectToJumpUrl ( $ jumpUrl ) { $ this -> validateIfJumpUrlRedirectIsAllowed ( $ jumpUrl ) ; $ pageTSconfig = $ this -> getTypoScriptFrontendController ( ) -> getPagesTSconfig ( ) ; if ( is_array ( $ pageTSconfig [ 'TSFE.' ] ) ) { $ pageTSconfig = $ pageTSconfig [ 'TSFE.' ] ; } else { $ pageTSconfig = [ ] ; } $ jumpUrl = str_replace ( '%23' , '#' , $ jumpUrl ) ; $ jumpUrl = $ this -> addParametersToTransferSession ( $ jumpUrl , $ pageTSconfig ) ; $ statusCode = $ this -> getRedirectStatusCode ( $ pageTSconfig ) ; $ this -> redirect ( $ jumpUrl , $ statusCode ) ; }
Redirects the user to the given jump URL if all submitted values are valid
55,716
protected function forwardJumpUrlSecureFileData ( $ jumpUrl ) { $ locationData = ( string ) GeneralUtility :: _GP ( 'locationData' ) ; $ mimeType = ( string ) GeneralUtility :: _GP ( 'mimeType' ) ; $ juHash = ( string ) GeneralUtility :: _GP ( 'juHash' ) ; if ( $ juHash !== JumpUrlUtility :: calculateHashSecure ( $ jumpUrl , $ locationData , $ mimeType ) ) { throw new \ Exception ( 'The calculated Jump URL secure hash ("juHash") did not match the submitted "juHash" query parameter.' , 1294585196 ) ; } if ( ! $ this -> isLocationDataValid ( $ locationData ) ) { throw new \ Exception ( 'The calculated secure location data "' . $ locationData . '" is not accessible.' , 1294585195 ) ; } $ jumpUrl = rawurldecode ( $ jumpUrl ) ; if ( version_compare ( TYPO3_version , '8.0' , '<' ) ) { $ absoluteFileName = GeneralUtility :: getFileAbsFileName ( GeneralUtility :: resolveBackPath ( $ jumpUrl ) , false ) ; } else { $ absoluteFileName = GeneralUtility :: getFileAbsFileName ( GeneralUtility :: resolveBackPath ( $ jumpUrl ) ) ; } if ( ! GeneralUtility :: isAllowedAbsPath ( $ absoluteFileName ) || ! GeneralUtility :: verifyFilenameAgainstDenyPattern ( $ absoluteFileName ) || GeneralUtility :: isFirstPartOfStr ( $ absoluteFileName , ( PATH_site . 'typo3conf' ) ) ) { throw new \ Exception ( 'The requested file was not allowed to be accessed through Jump URL. The path or file is not allowed.' , 1294585194 ) ; } try { $ resourceFactory = $ this -> getResourceFactory ( ) ; $ file = $ resourceFactory -> retrieveFileOrFolderObject ( $ absoluteFileName ) ; $ this -> readFileAndExit ( $ file , $ mimeType ) ; } catch ( \ Exception $ e ) { throw new \ Exception ( 'The requested file "' . $ jumpUrl . '" for Jump URL was not found..' , 1294585193 ) ; } }
If the submitted hash is correct and the user has access to the related content element the contents of the submitted file will be output to the user .
55,717
protected function isLocationDataValid ( $ locationData ) { $ isValidLocationData = false ; list ( $ pageUid , $ table , $ recordUid ) = explode ( ':' , $ locationData ) ; $ pageRepository = $ this -> getTypoScriptFrontendController ( ) -> sys_page ; $ timeTracker = $ this -> getTimeTracker ( ) ; if ( empty ( $ table ) || $ pageRepository -> checkRecord ( $ table , $ recordUid , true ) ) { if ( ! empty ( $ pageRepository -> getPage ( $ pageUid ) ) ) { $ isValidLocationData = true ; } else { $ timeTracker -> setTSlogMessage ( 'LocationData Error: The page pointed to by location data "' . $ locationData . '" was not accessible.' , 2 ) ; } } else { $ timeTracker -> setTSlogMessage ( 'LocationData Error: Location data "' . $ locationData . '" record pointed to was not accessible.' , 2 ) ; } return $ isValidLocationData ; }
Checks if the given location data is valid and the connected record is accessible by the current user .
55,718
protected function readFileAndExit ( $ file , $ mimeType ) { $ file -> getStorage ( ) -> dumpFileContents ( $ file , true , null , $ mimeType ) ; exit ; }
Calls the PHP readfile function and exits .
55,719
protected function addParametersToTransferSession ( $ jumpUrl , $ pageTSconfig ) { if ( ! empty ( $ pageTSconfig [ 'jumpUrl_transferSession' ] ) ) { $ uParts = parse_url ( $ jumpUrl ) ; $ params = '&FE_SESSION_KEY=' . rawurlencode ( $ this -> getTypoScriptFrontendController ( ) -> fe_user -> id . '-' . md5 ( $ this -> getTypoScriptFrontendController ( ) -> fe_user -> id . '/' . $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'SYS' ] [ 'encryptionKey' ] ) ) ; $ jumpUrl .= ( $ uParts [ 'query' ] ? '' : '?' ) . $ params ; } return $ jumpUrl ; }
Modified the URL to go to by adding the session key information to it but only if TSFE . jumpUrl_transferSession = 1 is set via pageTSconfig .
55,720
public function process ( MinifyContext $ context ) { Collection :: make ( $ this -> redundantAttributes ) -> each ( function ( $ attributes , $ element ) use ( & $ context ) { Collection :: make ( $ attributes ) -> each ( function ( $ value , $ attribute ) use ( $ element , & $ context ) { $ contents = preg_replace_callback ( '/ ' . $ element . ' # Match the given element ((?!\s*' . $ attribute . '\s*=).)* # Match everything except the given attribute ( \s*' . $ attribute . '\s* # Match the attribute =\s* # Match the equals sign (["\']?) # Match the opening quotes \s*' . $ value . '\s* # Match the value \3? # Match the captured opening quotes again \s* ) /xis' , function ( $ match ) { return $ this -> removeAttribute ( $ match [ 0 ] , $ match [ 2 ] ) ; } , $ context -> getContents ( ) ) ; $ context -> setContents ( $ contents ) ; } ) ; } ) ; return $ context ; }
Minify redundant attributes which are not needed by the browser .
55,721
protected function removeAttribute ( $ element , $ attribute ) { $ replacement = Html :: hasSurroundingAttributes ( $ attribute ) ? ' ' : '' ; return str_replace ( $ attribute , $ replacement , $ element ) ; }
Remove the attribute from the element .
55,722
public function createReferencePoint ( $ inputSize , $ keyname = null ) { if ( $ keyname === null ) { $ keyname = 'Step: ' . ( count ( $ this -> referencePoints ) + 1 ) ; } if ( ! array_key_exists ( $ keyname , $ this -> referencePoints ) ) { $ this -> referencePoints [ $ keyname ] = new ReferencePoint ( $ keyname , $ inputSize ) ; } else { $ this -> referencePoints [ $ keyname ] -> addBytes ( $ inputSize ) ; } return $ this -> referencePoints ; }
Add a step and measure the input size .
55,723
public function getTotalSavedBytes ( ) { $ initialStep = array_first ( $ this -> referencePoints ) ; $ lastStep = array_last ( $ this -> referencePoints ) ; return $ initialStep -> getBytes ( ) - $ lastStep -> getBytes ( ) ; }
Get the total saved bytes in bytes .
55,724
public function actionRun ( ) { $ this -> importScheduleFile ( ) ; $ events = $ this -> schedule -> dueEvents ( Yii :: $ app ) ; foreach ( $ events as $ event ) { $ this -> stdout ( 'Running scheduled command: ' . $ event -> getSummaryForDisplay ( ) . "\n" ) ; $ event -> run ( Yii :: $ app ) ; } if ( count ( $ events ) === 0 ) { $ this -> stdout ( "No scheduled commands are ready to run.\n" ) ; } }
Run scheduled commands
55,725
public function actionList ( ) { $ this -> importScheduleFile ( ) ; $ climate = new CLImate ( ) ; $ data = [ ] ; $ row = 0 ; foreach ( $ this -> schedule -> getEvents ( ) as $ event ) { $ data [ ] = [ '#' => ++ $ row , 'Task' => $ event -> getSummaryForDisplay ( ) , 'Expression' => $ event -> getExpression ( ) , 'Command to Run' => is_a ( $ event , CallbackEvent :: class ) ? $ event -> getSummaryForDisplay ( ) : $ event -> command , 'Next run at' => $ this -> getNextRunDate ( $ event ) , ] ; } $ climate -> table ( $ data ) ; }
Render list of registered tasks
55,726
protected function importScheduleFile ( ) { $ scheduleFile = Yii :: getAlias ( $ this -> scheduleFile ) ; if ( ! file_exists ( $ scheduleFile ) ) { throw new InvalidConfigException ( "Can not load schedule file {$this->scheduleFile}" ) ; } $ schedule = $ this -> schedule ; call_user_func ( function ( ) use ( $ schedule , $ scheduleFile ) { include $ scheduleFile ; } ) ; }
Import schedule file
55,727
public function setImage ( \ Imagick $ image ) { $ this -> originalImage = $ image ; $ this -> setBaseDimensions ( $ this -> originalImage -> getImageWidth ( ) , $ this -> originalImage -> getImageHeight ( ) ) ; return $ this ; }
Sets the object Image to be croped
55,728
protected function getSafeResizeOffset ( \ Imagick $ image , $ targetWidth , $ targetHeight ) { $ source = $ image -> getImageGeometry ( ) ; if ( 0 == $ targetHeight || ( $ source [ 'width' ] / $ source [ 'height' ] ) < ( $ targetWidth / $ targetHeight ) ) { $ scale = $ source [ 'width' ] / $ targetWidth ; } else { $ scale = $ source [ 'height' ] / $ targetHeight ; } return array ( 'width' => ( int ) ( $ source [ 'width' ] / $ scale ) , 'height' => ( int ) ( $ source [ 'height' ] / $ scale ) ) ; }
Returns width and height for resizing the image keeping the aspect ratio and allow the image to be larger than either the width or height
55,729
protected function autoOrient ( ) { switch ( $ this -> originalImage -> getImageOrientation ( ) ) { case \ Imagick :: ORIENTATION_BOTTOMRIGHT : $ this -> originalImage -> rotateimage ( '#000' , 180 ) ; break ; case \ Imagick :: ORIENTATION_RIGHTTOP : $ this -> originalImage -> rotateimage ( '#000' , 90 ) ; break ; case \ Imagick :: ORIENTATION_LEFTBOTTOM : $ this -> originalImage -> rotateimage ( '#000' , - 90 ) ; break ; } $ this -> originalImage -> setImageOrientation ( \ Imagick :: ORIENTATION_TOPLEFT ) ; }
Applies EXIF orientation metadata to pixel data and removes the EXIF rotation
55,730
public function getData ( ) { $ data = array ( ) ; $ contentClassAttribute = $ this -> ContentObjectAttribute -> contentClassAttribute ( ) ; $ keywordFieldName = parent :: generateAttributeFieldName ( $ contentClassAttribute , 'lckeyword' ) ; $ textFieldName = parent :: generateAttributeFieldName ( $ contentClassAttribute , 'text' ) ; $ tagIDsFieldName = parent :: generateSubattributeFieldName ( $ contentClassAttribute , 'tag_ids' , 'sint' ) ; $ data [ $ keywordFieldName ] = '' ; $ data [ $ textFieldName ] = '' ; $ data [ $ tagIDsFieldName ] = array ( ) ; if ( ! $ this -> ContentObjectAttribute -> hasContent ( ) ) return $ data ; $ objectAttributeContent = $ this -> ContentObjectAttribute -> content ( ) ; if ( ! $ objectAttributeContent instanceof eZTags ) return $ data ; $ tagIDs = array ( ) ; $ keywords = array ( ) ; $ this -> indexSynonyms = eZINI :: instance ( 'eztags.ini' ) -> variable ( 'SearchSettings' , 'IndexSynonyms' ) === 'enabled' ; $ indexParentTags = eZINI :: instance ( 'eztags.ini' ) -> variable ( 'SearchSettings' , 'IndexParentTags' ) === 'enabled' ; $ includeSynonyms = eZINI :: instance ( 'eztags.ini' ) -> variable ( 'SearchSettings' , 'IncludeSynonyms' ) === 'enabled' ; $ tags = $ objectAttributeContent -> attribute ( 'tags' ) ; if ( is_array ( $ tags ) ) { foreach ( $ tags as $ tag ) { if ( $ tag instanceof eZTagsObject ) { $ this -> processTag ( $ tag , $ tagIDs , $ keywords , $ indexParentTags , $ includeSynonyms ) ; } } } if ( ! empty ( $ tagIDs ) ) { $ data [ $ keywordFieldName ] = implode ( ', ' , $ keywords ) ; $ data [ $ textFieldName ] = implode ( ' ' , $ keywords ) ; $ data [ $ tagIDsFieldName ] = $ tagIDs ; } $ data [ 'ezf_df_tag_ids' ] = $ tagIDs ; $ data [ 'ezf_df_tags' ] = $ keywords ; return $ data ; }
Returns the data from content object attribute which is sent to Solr backend
55,731
static public function getFieldNameList ( eZContentClassAttribute $ classAttribute , $ exclusiveTypeFilter = array ( ) ) { $ fieldsList = array ( ) ; if ( empty ( $ exclusiveTypeFilter ) || ! in_array ( 'lckeyword' , $ exclusiveTypeFilter ) ) $ fieldsList [ ] = parent :: generateAttributeFieldName ( $ classAttribute , 'lckeyword' ) ; if ( empty ( $ exclusiveTypeFilter ) || ! in_array ( 'text' , $ exclusiveTypeFilter ) ) $ fieldsList [ ] = parent :: generateAttributeFieldName ( $ classAttribute , 'text' ) ; if ( empty ( $ exclusiveTypeFilter ) || ! in_array ( 'sint' , $ exclusiveTypeFilter ) ) $ fieldsList [ ] = parent :: generateSubattributeFieldName ( $ classAttribute , 'tag_ids' , 'sint' ) ; return $ fieldsList ; }
Returns the list of field names this handler sends to Solr backend
55,732
private function processTag ( eZTagsObject $ tag , array & $ tagIDs , array & $ keywords , $ indexParentTags = false , $ includeSynonyms = false ) { if ( ! $ this -> indexSynonyms && $ tag -> isSynonym ( ) ) $ tag = $ tag -> getMainTag ( ) ; $ keyword = $ tag -> getKeyword ( $ this -> ContentObjectAttribute -> attribute ( 'language_code' ) ) ; if ( ! $ keyword ) { $ mainLanguage = eZContentLanguage :: fetch ( $ tag -> attribute ( 'main_language_id' ) ) ; if ( $ mainLanguage instanceof eZContentLanguage ) $ keyword = $ tag -> getKeyword ( $ mainLanguage -> attribute ( 'locale' ) ) ; } if ( $ keyword ) { $ tagIDs [ ] = ( int ) $ tag -> attribute ( 'id' ) ; $ keywords [ ] = $ keyword ; } if ( $ indexParentTags ) { $ parentTags = $ tag -> getPath ( true ) ; foreach ( $ parentTags as $ parentTag ) { if ( $ parentTag instanceof eZTagsObject ) { $ this -> processTag ( $ parentTag , $ tagIDs , $ keywords ) ; } } } if ( $ this -> indexSynonyms && $ includeSynonyms ) { foreach ( $ tag -> getSynonyms ( ) as $ synonym ) { if ( $ synonym instanceof eZTagsObject ) { $ this -> processTag ( $ synonym , $ tagIDs , $ keywords ) ; } } } }
Extracts data to be indexed from the tag
55,733
private static function isBinaryOperator ( TokenInterface $ token ) : bool { return in_array ( $ token -> getType ( ) , [ TokenInterface :: TYPE_OPERATOR_ASSIGNMENT , TokenInterface :: TYPE_OPERATOR_COPY , TokenInterface :: TYPE_OPERATOR_MODIFY , TokenInterface :: TYPE_OPERATOR_REFERENCE , ] ) ; }
Tests whether a token is a binary operator
55,734
private static function isWhitespaceOfLength ( TokenInterface $ token , int $ length ) : bool { return static :: isWhitespace ( $ token ) && strlen ( trim ( $ token -> getValue ( ) , "\n" ) ) == $ length ; }
Tests whether a token is a whitespace of a given length
55,735
public function countIssues ( ) : int { $ count = 0 ; foreach ( $ this -> files as $ file ) { $ count += count ( $ file -> getIssues ( ) ) ; } return $ count ; }
Returns the number of issues for the entire report .
55,736
public function countIssuesBySeverity ( string $ severity ) : int { $ count = 0 ; foreach ( $ this -> files as $ file ) { $ count += count ( $ file -> getIssuesBySeverity ( $ severity ) ) ; } return $ count ; }
Returns the number of issues with a given severity for the entire report
55,737
public function onResponse ( FilterResponseEvent $ event ) { $ response = $ event -> getResponse ( ) ; $ node = $ this -> getObject ( $ response , 'node' ) ; if ( $ node === FALSE ) { return ; } $ links = array_merge ( $ this -> generateEntityReferenceLinks ( $ node ) , $ this -> generateRelatedMediaLinks ( $ node ) , $ this -> generateRestLinks ( $ node ) ) ; if ( empty ( $ links ) ) { return ; } $ response -> headers -> set ( 'Link' , $ links , FALSE ) ; }
Adds node - specific link headers to appropriate responses .
55,738
protected function generateRelatedMediaLinks ( NodeInterface $ node ) { $ links = [ ] ; foreach ( $ this -> utils -> getMedia ( $ node ) as $ media ) { $ url = $ media -> url ( 'canonical' , [ 'absolute' => TRUE ] ) ; foreach ( $ media -> referencedEntities ( ) as $ term ) { if ( $ term -> getEntityTypeId ( ) == 'taxonomy_term' && $ term -> hasField ( 'field_external_uri' ) ) { $ field = $ term -> get ( 'field_external_uri' ) ; if ( ! $ field -> isEmpty ( ) ) { $ link = $ field -> first ( ) -> getValue ( ) ; $ uri = $ link [ 'uri' ] ; if ( strpos ( $ uri , 'http://pcdm.org/use#' ) === 0 ) { $ title = $ term -> label ( ) ; $ links [ ] = "<$url>; rel=\"related\"; title=\"$title\"" ; } } } } } return $ links ; }
Generates link headers for media associated with a node .
55,739
public function getParentNode ( MediaInterface $ media ) { if ( ! $ media -> hasField ( self :: MEDIA_OF_FIELD ) ) { return NULL ; } $ field = $ media -> get ( self :: MEDIA_OF_FIELD ) ; if ( $ field -> isEmpty ( ) ) { return NULL ; } $ parent = $ field -> first ( ) -> get ( 'entity' ) -> getTarget ( ) ; if ( ! is_null ( $ parent ) ) { return $ parent -> getValue ( ) ; } return NULL ; }
Gets nodes that a media belongs to .
55,740
public function getMedia ( NodeInterface $ node ) { if ( ! $ this -> entityTypeManager -> getStorage ( 'field_storage_config' ) -> load ( 'media.' . self :: MEDIA_OF_FIELD ) ) { return [ ] ; } $ mids = $ this -> entityQuery -> get ( 'media' ) -> condition ( self :: MEDIA_OF_FIELD , $ node -> id ( ) ) -> execute ( ) ; if ( empty ( $ mids ) ) { return [ ] ; } return $ this -> entityTypeManager -> getStorage ( 'media' ) -> loadMultiple ( $ mids ) ; }
Gets media that belong to a node .
55,741
public function getMediaWithTerm ( NodeInterface $ node , TermInterface $ term ) { $ mids = $ this -> getMediaReferencingNodeAndTerm ( $ node , $ term ) ; if ( empty ( $ mids ) ) { return NULL ; } return $ this -> entityTypeManager -> getStorage ( 'media' ) -> load ( reset ( $ mids ) ) ; }
Gets media that belong to a node with the specified term .
55,742
public function getReferencingMedia ( $ fid ) { $ fields = $ this -> getReferencingFields ( 'media' , 'file' ) ; $ conditions = array_map ( function ( $ field ) { return ltrim ( $ field , 'media.' ) . '.target_id' ; } , $ fields ) ; $ query = $ this -> entityQuery -> get ( 'media' , 'OR' ) ; foreach ( $ conditions as $ condition ) { $ query -> condition ( $ condition , $ fid ) ; } return $ this -> entityTypeManager -> getStorage ( 'media' ) -> loadMultiple ( $ query -> execute ( ) ) ; }
Gets Media that reference a File .
55,743
public function executeNodeReactions ( $ reaction_type , NodeInterface $ node ) { $ provider = new NodeContextProvider ( $ node ) ; $ provided = $ provider -> getRuntimeContexts ( [ ] ) ; $ this -> contextManager -> evaluateContexts ( $ provided ) ; foreach ( $ this -> contextManager -> getActiveReactions ( $ reaction_type ) as $ reaction ) { $ reaction -> execute ( $ node ) ; } }
Executes context reactions for a Node .
55,744
public function executeMediaReactions ( $ reaction_type , MediaInterface $ media ) { $ provider = new MediaContextProvider ( $ media ) ; $ provided = $ provider -> getRuntimeContexts ( [ ] ) ; $ this -> contextManager -> evaluateContexts ( $ provided ) ; foreach ( $ this -> contextManager -> getActiveReactions ( $ reaction_type ) as $ reaction ) { $ reaction -> execute ( $ media ) ; } }
Executes context reactions for a Media .
55,745
public function executeDerivativeReactions ( $ reaction_type , NodeInterface $ node , MediaInterface $ media ) { $ provider = new MediaContextProvider ( $ media ) ; $ provided = $ provider -> getRuntimeContexts ( [ ] ) ; $ this -> contextManager -> evaluateContexts ( $ provided ) ; foreach ( $ this -> contextManager -> getActiveReactions ( $ reaction_type ) as $ reaction ) { $ reaction -> execute ( $ node ) ; } }
Executes derivative reactions for a Media and Node .
55,746
public function haveFieldsChanged ( ContentEntityInterface $ entity , ContentEntityInterface $ original ) { $ field_definitions = $ this -> entityFieldManager -> getFieldDefinitions ( $ entity -> getEntityTypeId ( ) , $ entity -> bundle ( ) ) ; $ ignore_list = [ 'vid' => 1 , 'changed' => 1 , 'path' => 1 ] ; $ field_definitions = array_diff_key ( $ field_definitions , $ ignore_list ) ; foreach ( $ field_definitions as $ field_name => $ field_definition ) { $ langcodes = array_keys ( $ entity -> getTranslationLanguages ( ) ) ; if ( $ langcodes !== array_keys ( $ original -> getTranslationLanguages ( ) ) ) { return TRUE ; } foreach ( $ langcodes as $ langcode ) { $ items = $ entity -> getTranslation ( $ langcode ) -> get ( $ field_name ) -> filterEmptyItems ( ) ; $ original_items = $ original -> getTranslation ( $ langcode ) -> get ( $ field_name ) -> filterEmptyItems ( ) ; if ( ! $ items -> equals ( $ original_items ) ) { return TRUE ; } } } return FALSE ; }
Evaluates if fields have changed between two instances of a ContentEntity .
55,747
public function getFilesystemSchemes ( ) { $ schemes = [ 'public' ] ; if ( ! empty ( Settings :: get ( 'file_private_path' ) ) ) { $ schemes [ ] = 'private' ; } return array_merge ( $ schemes , $ this -> flysystemFactory -> getSchemes ( ) ) ; }
Returns a list of all available filesystem schemes .
55,748
private function getEntityQueryOrCondition ( QueryInterface $ query , array $ fields , $ value ) { $ condition = $ query -> orConditionGroup ( ) ; foreach ( $ fields as $ field ) { $ condition -> condition ( $ field , $ value ) ; } return $ condition ; }
Make an OR condition for an array of fields and a value .
55,749
public function addQuery ( Search $ query , $ modeManualAction = null ) { if ( $ modeManualAction && $ this -> data [ 'mode' ] != 'manual' ) { throw new \ InvalidArgumentException ( 'Query mode must be set to "manual" before using a batchAction for queries.' ) ; } $ queryArray = json_decode ( $ query -> getData ( ) , true ) ; if ( $ modeManualAction ) { $ queryArray [ 'batchAction' ] = $ modeManualAction ; } $ template = $ query -> getTemplate ( ) ; if ( ! empty ( $ template ) ) { $ queryArray [ 'template' ] = $ template ; $ suffix = 'Template' ; } else { $ suffix = '' ; } $ type = get_class ( $ query ) ; switch ( $ type ) { case 'OpenSearchServer\Search\Field\Search' : $ queryArray [ 'type' ] = 'SearchField' . $ suffix ; break ; case 'OpenSearchServer\Search\Pattern\Search' : $ queryArray [ 'type' ] = 'SearchPattern' . $ suffix ; break ; } $ this -> data [ 'queries' ] [ ] = $ queryArray ; }
Add one query to the batch
55,750
static public function fetchTag ( $ tagID , $ language = false ) { if ( $ language ) { if ( ! is_array ( $ language ) ) $ language = array ( $ language ) ; eZContentLanguage :: setPrioritizedLanguages ( $ language ) ; } $ result = false ; if ( is_numeric ( $ tagID ) ) { $ result = eZTagsObject :: fetch ( $ tagID ) ; } else if ( is_array ( $ tagID ) && ! empty ( $ tagID ) ) { $ result = eZTagsObject :: fetchList ( array ( 'id' => array ( $ tagID ) ) ) ; } if ( $ language ) eZContentLanguage :: clearPrioritizedLanguages ( ) ; if ( $ result instanceof eZTagsObject || ( is_array ( $ result ) && ! empty ( $ result ) ) ) return array ( 'result' => $ result ) ; return array ( 'result' => false ) ; }
Fetches eZTagsObject object for the provided tag ID
55,751
static public function fetchTagsByKeyword ( $ keyword , $ language = false ) { if ( $ language ) { if ( ! is_array ( $ language ) ) $ language = array ( $ language ) ; eZContentLanguage :: setPrioritizedLanguages ( $ language ) ; } if ( strpos ( $ keyword , '*' ) !== false ) { $ keyword = preg_replace ( array ( '#%#m' , '#(?<!\\\\)\\*#m' , '#(?<!\\\\)\\\\\\*#m' , '#\\\\\\\\#m' ) , array ( '\\%' , '%' , '*' , '\\\\' ) , $ keyword ) ; $ keyword = array ( 'like' , $ keyword ) ; } $ result = eZTagsObject :: fetchByKeyword ( $ keyword ) ; if ( $ language ) eZContentLanguage :: clearPrioritizedLanguages ( ) ; if ( is_array ( $ result ) && ! empty ( $ result ) ) return array ( 'result' => $ result ) ; return array ( 'result' => false ) ; }
Fetches all tags named with provided keyword
55,752
static public function fetchTagByRemoteID ( $ remoteID , $ language = false ) { if ( $ language ) { if ( ! is_array ( $ language ) ) $ language = array ( $ language ) ; eZContentLanguage :: setPrioritizedLanguages ( $ language ) ; } $ result = eZTagsObject :: fetchByRemoteID ( $ remoteID ) ; if ( $ language ) eZContentLanguage :: clearPrioritizedLanguages ( ) ; if ( $ result instanceof eZTagsObject ) return array ( 'result' => $ result ) ; return array ( 'result' => false ) ; }
Fetches tag identified with provided remote ID
55,753
static public function fetchTagByUrl ( $ url , $ language = false ) { if ( $ language ) { if ( ! is_array ( $ language ) ) $ language = array ( $ language ) ; eZContentLanguage :: setPrioritizedLanguages ( $ language ) ; } $ result = eZTagsObject :: fetchByUrl ( $ url ) ; if ( $ language ) eZContentLanguage :: clearPrioritizedLanguages ( ) ; if ( $ result instanceof eZTagsObject ) return array ( 'result' => $ result ) ; return array ( 'result' => false ) ; }
Fetches tag identified with provided URL
55,754
public function getBodyAttribute ( $ value ) { $ value = str_replace ( ':)' , '<div class="smiley smile"></div>' , $ value ) ; $ value = str_replace ( ':-)' , '<div class="smiley smile"></div>' , $ value ) ; $ value = str_replace ( '(angry)' , '<div class="smiley angry"></div>' , $ value ) ; $ value = str_replace ( ':(' , '<div class="smiley sad"></div>' , $ value ) ; $ value = str_replace ( ':-(' , '<div class="smiley sad"></div>' , $ value ) ; $ value = str_replace ( ':o' , '<div class="smiley surprised"></div>' , $ value ) ; $ value = str_replace ( ':-o' , '<div class="smiley surprised"></div>' , $ value ) ; $ value = str_replace ( ':s' , '<div class="smiley confused"></div>' , $ value ) ; $ value = str_replace ( ':-s' , '<div class="smiley confused"></div>' , $ value ) ; $ value = str_replace ( ':D' , '<div class="smiley laugh"></div>' , $ value ) ; $ value = str_replace ( ':-D' , '<div class="smiley laugh"></div>' , $ value ) ; $ value = str_replace ( ';)' , '<div class="smiley wink"></div>' , $ value ) ; $ value = str_replace ( ';-)' , '<div class="smiley wink"></div>' , $ value ) ; $ value = str_replace ( ':|' , '<div class="smiley speechless"></div>' , $ value ) ; $ value = str_replace ( ':-|' , '<div class="smiley speechless"></div>' , $ value ) ; return $ value ; }
mutator for message body that replaces smiley codes with smiley images
55,755
public function verify ( Payload $ payload ) { $ response = $ this -> service -> call ( $ payload ) ; $ string = $ response -> getBody ( ) ; $ pattern = sprintf ( '/(%s|%s)/' , self :: IPN_VERIFIED , self :: IPN_INVALID ) ; if ( ! preg_match ( $ pattern , $ string ) ) { throw new UnexpectedValueException ( sprintf ( 'Unexpected verification status encountered: %s' , $ string ) ) ; } return $ response ; }
Send HTTP Request to PayPal & verfify payload .
55,756
public function createLogger ( string $ outputFormat , OutputInterface $ reportOutput , OutputInterface $ consoleOutput ) : LinterLoggerInterface { $ errorOutput = ( $ consoleOutput instanceof ConsoleOutputInterface ) ? $ consoleOutput -> getErrorOutput ( ) : $ consoleOutput ; switch ( $ outputFormat ) { case 'checkstyle' : case 'xml' : return new CompactConsoleLogger ( new CheckstyleReportPrinter ( $ reportOutput ) , $ errorOutput ) ; case 'txt' : case 'text' : return new VerboseConsoleLogger ( new ConsoleReportPrinter ( $ reportOutput ) , $ consoleOutput ) ; case 'compact' : return new CompactConsoleLogger ( new ConsoleReportPrinter ( $ reportOutput ) , $ consoleOutput ) ; default : throw new \ InvalidArgumentException ( 'Invalid report printer "' . $ outputFormat . '"!' ) ; } }
Builds a suitable logger for logging lint progress and results .
55,757
public function addDocument ( $ document ) { if ( is_array ( $ document ) ) { $ this -> addDocumentArray ( $ document ) ; } elseif ( $ document instanceof Document ) { $ this -> addDocumentObject ( $ document ) ; } }
Add a document in list of documents to push to index
55,758
public function loadConfiguration ( array $ possibleConfigurationFiles = [ ] , LinterConfiguration $ configuration = null ) : LinterConfiguration { $ configs = [ $ this -> loader -> load ( 'typoscript-lint.dist.yml' ) ] ; foreach ( $ possibleConfigurationFiles as $ configurationFile ) { $ loadedConfig = $ this -> loader -> load ( $ configurationFile ) ; if ( isset ( $ loadedConfig [ "extends" ] ) || isset ( $ loadedConfig [ "rulesDirectory" ] ) || isset ( $ loadedConfig [ "rules" ] ) ) { continue ; } $ configs [ ] = $ loadedConfig ; } $ configuration = $ configuration ?? new LinterConfiguration ( ) ; $ processedConfiguration = $ this -> processor -> processConfiguration ( $ configuration , $ configs ) ; $ configuration -> setConfiguration ( $ processedConfiguration ) ; return $ configuration ; }
Loads the linter configuration .
55,759
static public function fetchByTagID ( $ tagID ) { $ objects = parent :: fetchObjectList ( self :: definition ( ) , null , array ( 'keyword_id' => $ tagID ) ) ; if ( is_array ( $ objects ) ) return $ objects ; return array ( ) ; }
Fetches the array of eZTagsAttributeLinkObject objects based on provided tag ID
55,760
static public function fetchByObjectAttributeAndKeywordID ( $ objectAttributeID , $ objectAttributeVersion , $ objectID , $ keywordID ) { $ objects = parent :: fetchObjectList ( self :: definition ( ) , null , array ( 'objectattribute_id' => $ objectAttributeID , 'objectattribute_version' => $ objectAttributeVersion , 'object_id' => $ objectID , 'keyword_id' => $ keywordID ) ) ; if ( is_array ( $ objects ) && ! empty ( $ objects ) ) return $ objects [ 0 ] ; return false ; }
Fetches the eZTagsAttributeLinkObject object based on provided content object params and keyword ID
55,761
static public function removeByAttribute ( $ objectAttributeID , $ objectAttributeVersion = null ) { if ( ! is_numeric ( $ objectAttributeID ) ) return ; $ conditions = array ( 'objectattribute_id' => ( int ) $ objectAttributeID ) ; if ( is_numeric ( $ objectAttributeVersion ) ) $ conditions [ 'objectattribute_version' ] = ( int ) $ objectAttributeVersion ; parent :: removeObject ( self :: definition ( ) , $ conditions ) ; }
Removes the objects from persistence which are related to content object attribute defined by attribute ID and attribute version
55,762
public function writeReport ( Report $ report ) : void { $ count = 0 ; $ this -> output -> writeln ( '' ) ; $ this -> output -> writeln ( '<comment>CHECKSTYLE REPORT</comment>' ) ; $ styleMap = [ Issue :: SEVERITY_ERROR => 'error' , Issue :: SEVERITY_WARNING => 'comment' , Issue :: SEVERITY_INFO => 'info' , ] ; foreach ( $ report -> getFiles ( ) as $ file ) { $ this -> output -> writeln ( "=> <comment>{$file->getFilename()}</comment>." ) ; foreach ( $ file -> getIssues ( ) as $ issue ) { $ count ++ ; $ style = $ styleMap [ $ issue -> getSeverity ( ) ] ; $ this -> output -> writeln ( sprintf ( '<comment>%4d <%s>%s</%s></comment>' , $ issue -> getLine ( ) ?? 0 , $ style , $ issue -> getMessage ( ) , $ style ) ) ; } } $ summary = [ ] ; foreach ( $ styleMap as $ severity => $ style ) { $ severityCount = $ report -> countIssuesBySeverity ( $ severity ) ; if ( $ severityCount > 0 ) { $ summary [ ] = "<comment>$severityCount</comment> {$severity}s" ; } } $ this -> output -> writeln ( "" ) ; $ this -> output -> writeln ( '<comment>SUMMARY</comment>' ) ; $ this -> output -> write ( "<info><comment>$count</comment> issues in total.</info>" ) ; if ( $ count > 0 ) { $ this -> output -> writeln ( " (" . implode ( ', ' , $ summary ) . ")" ) ; } }
Writes a report in human - readable table form .
55,763
public function getVersion ( ) { $ current = dirname ( __FILE__ ) ; while ( $ current !== '/' ) { if ( file_exists ( $ current . '/composer.lock' ) ) { $ contents = file_get_contents ( $ current . '/composer.lock' ) ; if ( $ contents === false ) { continue ; } $ data = json_decode ( $ contents ) ; $ packages = array_values ( array_filter ( $ data -> packages , function ( $ package ) { return $ package -> name === "helmich/typo3-typoscript-lint" ; } ) ) ; if ( count ( $ packages ) > 0 ) { return $ packages [ 0 ] -> version ; } } $ current = dirname ( $ current ) ; } return parent :: getVersion ( ) ; }
Gets the currently installed version number .
55,764
protected function getCenterOffset ( \ Imagick $ image , $ targetWidth , $ targetHeight ) { $ size = $ image -> getImageGeometry ( ) ; $ originalWidth = $ size [ 'width' ] ; $ originalHeight = $ size [ 'height' ] ; $ goalX = ( int ) ( ( $ originalWidth - $ targetWidth ) / 2 ) ; $ goalY = ( int ) ( ( $ originalHeight - $ targetHeight ) / 2 ) ; return array ( 'x' => $ goalX , 'y' => $ goalY ) ; }
Get the cropping offset for the image based on the center of the image
55,765
public function initializeClassAttribute ( $ classAttribute ) { if ( $ classAttribute -> attribute ( self :: SUBTREE_LIMIT_FIELD ) === null ) $ classAttribute -> setAttribute ( self :: SUBTREE_LIMIT_FIELD , 0 ) ; if ( $ classAttribute -> attribute ( self :: HIDE_ROOT_TAG_FIELD ) === null ) $ classAttribute -> setAttribute ( self :: HIDE_ROOT_TAG_FIELD , 0 ) ; if ( $ classAttribute -> attribute ( self :: MAX_TAGS_FIELD ) === null ) $ classAttribute -> setAttribute ( self :: MAX_TAGS_FIELD , 0 ) ; if ( $ classAttribute -> attribute ( self :: EDIT_VIEW_FIELD ) === null ) $ classAttribute -> setAttribute ( self :: EDIT_VIEW_FIELD , self :: EDIT_VIEW_DEFAULT_VALUE ) ; $ classAttribute -> store ( ) ; }
Initializes the content class attribute
55,766
public function initializeObjectAttribute ( $ contentObjectAttribute , $ currentVersion , $ originalContentObjectAttribute ) { if ( $ currentVersion != false ) { $ eZTags = eZTags :: createFromAttribute ( $ originalContentObjectAttribute , $ contentObjectAttribute -> attribute ( 'language_code' ) ) ; $ eZTags -> store ( $ contentObjectAttribute ) ; } }
Initializes content object attribute based on another attribute
55,767
private function validateObjectAttribute ( $ contentObjectAttribute , $ idString , $ keywordString , $ parentString , $ localeString ) { $ classAttribute = $ contentObjectAttribute -> contentClassAttribute ( ) ; if ( strlen ( $ keywordString ) == 0 && strlen ( $ parentString ) == 0 && strlen ( $ idString ) == 0 && strlen ( $ localeString ) == 0 ) { if ( $ contentObjectAttribute -> validateIsRequired ( ) ) { $ contentObjectAttribute -> setValidationError ( ezpI18n :: tr ( 'extension/eztags/datatypes' , 'At least one tag is required to be added.' ) ) ; return eZInputValidator :: STATE_INVALID ; } } else if ( strlen ( $ keywordString ) == 0 || strlen ( $ parentString ) == 0 || strlen ( $ idString ) == 0 || strlen ( $ localeString ) == 0 ) { $ contentObjectAttribute -> setValidationError ( ezpI18n :: tr ( 'extension/eztags/datatypes' , 'Attribute contains invalid data.' ) ) ; return eZInputValidator :: STATE_INVALID ; } else { $ idArray = explode ( '|#' , $ idString ) ; $ keywordArray = explode ( '|#' , $ keywordString ) ; $ parentArray = explode ( '|#' , $ parentString ) ; $ localeArray = explode ( '|#' , $ localeString ) ; if ( count ( $ keywordArray ) != count ( $ idArray ) || count ( $ parentArray ) != count ( $ idArray ) || count ( $ localeArray ) != count ( $ idArray ) ) { $ contentObjectAttribute -> setValidationError ( ezpI18n :: tr ( 'extension/eztags/datatypes' , 'Attribute contains invalid data.' ) ) ; return eZInputValidator :: STATE_INVALID ; } $ maxTags = ( int ) $ classAttribute -> attribute ( self :: MAX_TAGS_FIELD ) ; if ( $ maxTags > 0 && ( count ( $ idArray ) > $ maxTags || count ( $ keywordArray ) > $ maxTags || count ( $ parentArray ) > $ maxTags || count ( $ localeArray ) > $ maxTags ) ) { $ contentObjectAttribute -> setValidationError ( ezpI18n :: tr ( 'extension/eztags/datatypes' , 'Up to %1 tags are allowed to be added.' , null , array ( '%1' => $ maxTags ) ) ) ; return eZInputValidator :: STATE_INVALID ; } } return eZInputValidator :: STATE_ACCEPTED ; }
Validates the data structure and returns true if it is valid for this datatype
55,768
public function validateObjectAttributeHTTPInput ( $ http , $ base , $ contentObjectAttribute ) { $ contentObjectAttributeID = $ contentObjectAttribute -> attribute ( 'id' ) ; $ keywordString = trim ( $ http -> postVariable ( $ base . '_eztags_data_text_' . $ contentObjectAttributeID , '' ) ) ; $ parentString = trim ( $ http -> postVariable ( $ base . '_eztags_data_text2_' . $ contentObjectAttributeID , '' ) ) ; $ idString = trim ( $ http -> postVariable ( $ base . '_eztags_data_text3_' . $ contentObjectAttributeID , '' ) ) ; $ localeString = trim ( $ http -> postVariable ( $ base . '_eztags_data_text4_' . $ contentObjectAttributeID , '' ) ) ; return $ this -> validateObjectAttribute ( $ contentObjectAttribute , $ idString , $ keywordString , $ parentString , $ localeString ) ; }
Validates the input and returns true if the input was valid for this datatype
55,769
public function storeObjectAttribute ( $ attribute ) { $ eZTags = $ attribute -> content ( ) ; if ( $ eZTags instanceof eZTags ) $ eZTags -> store ( $ attribute ) ; }
Stores the object attribute
55,770
public function validateClassAttributeHTTPInput ( $ http , $ base , $ attribute ) { $ classAttributeID = $ attribute -> attribute ( 'id' ) ; $ maxTags = trim ( $ http -> postVariable ( $ base . self :: MAX_TAGS_VARIABLE . $ classAttributeID , '' ) ) ; if ( ( ! is_numeric ( $ maxTags ) && ! empty ( $ maxTags ) ) || ( int ) $ maxTags < 0 ) return eZInputValidator :: STATE_INVALID ; $ subTreeLimit = ( int ) $ http -> postVariable ( $ base . self :: SUBTREE_LIMIT_VARIABLE . $ classAttributeID , - 1 ) ; if ( $ subTreeLimit < 0 ) return eZInputValidator :: STATE_INVALID ; if ( $ subTreeLimit > 0 ) { $ tag = eZTagsObject :: fetchWithMainTranslation ( $ subTreeLimit ) ; if ( ! $ tag instanceof eZTagsObject || $ tag -> attribute ( 'main_tag_id' ) > 0 ) return eZInputValidator :: STATE_INVALID ; } return eZInputValidator :: STATE_ACCEPTED ; }
Validates class attribute HTTP input
55,771
public function fetchClassAttributeHTTPInput ( $ http , $ base , $ attribute ) { $ classAttributeID = $ attribute -> attribute ( 'id' ) ; $ subTreeLimit = ( int ) $ http -> postVariable ( $ base . self :: SUBTREE_LIMIT_VARIABLE . $ classAttributeID , - 1 ) ; $ maxTags = ( int ) trim ( $ http -> postVariable ( $ base . self :: MAX_TAGS_VARIABLE . $ classAttributeID , - 1 ) ) ; if ( $ subTreeLimit < 0 || $ maxTags < 0 ) return false ; $ hideRootTag = ( int ) $ http -> hasPostVariable ( $ base . self :: HIDE_ROOT_TAG_VARIABLE . $ classAttributeID ) ; $ editView = trim ( $ http -> postVariable ( $ base . self :: EDIT_VIEW_VARIABLE . $ classAttributeID , self :: EDIT_VIEW_DEFAULT_VALUE ) ) ; $ eZTagsIni = eZINI :: instance ( 'eztags.ini' ) ; $ availableEditViews = $ eZTagsIni -> variable ( 'EditSettings' , 'AvailableViews' ) ; if ( ! in_array ( $ editView , array_keys ( $ availableEditViews ) ) ) return false ; $ attribute -> setAttribute ( self :: SUBTREE_LIMIT_FIELD , $ subTreeLimit ) ; $ attribute -> setAttribute ( self :: HIDE_ROOT_TAG_FIELD , $ hideRootTag ) ; $ attribute -> setAttribute ( self :: MAX_TAGS_FIELD , $ maxTags ) ; $ attribute -> setAttribute ( self :: EDIT_VIEW_FIELD , $ editView ) ; return true ; }
Fetches class attribute HTTP input and stores it
55,772
public function unserializeContentClassAttribute ( $ classAttribute , $ attributeNode , $ attributeParametersNode ) { $ subTreeLimit = 0 ; $ domNodes = $ attributeParametersNode -> getElementsByTagName ( 'subtree-limit' ) ; if ( $ domNodes -> length > 0 ) $ subTreeLimit = ( int ) $ domNodes -> item ( 0 ) -> textContent ; $ maxTags = 0 ; $ domNodes = $ attributeParametersNode -> getElementsByTagName ( 'max-tags' ) ; if ( $ domNodes -> length > 0 ) $ maxTags = ( int ) $ domNodes -> item ( 0 ) -> textContent ; $ hideRootTag = 0 ; $ domNodes = $ attributeParametersNode -> getElementsByTagName ( 'hide-root-tag' ) ; if ( $ domNodes -> length > 0 && $ domNodes -> item ( 0 ) -> textContent === 'true' ) $ hideRootTag = 1 ; $ editView = self :: EDIT_VIEW_DEFAULT_VALUE ; $ domNodes = $ attributeParametersNode -> getElementsByTagName ( 'edit-view' ) ; if ( $ domNodes -> length > 0 ) { $ domNodeContent = trim ( $ domNodes -> item ( 0 ) -> textContent ) ; if ( ! empty ( $ domNodeContent ) ) { $ editView = $ domNodeContent ; } } $ classAttribute -> setAttribute ( self :: SUBTREE_LIMIT_FIELD , $ subTreeLimit ) ; $ classAttribute -> setAttribute ( self :: MAX_TAGS_FIELD , $ maxTags ) ; $ classAttribute -> setAttribute ( self :: HIDE_ROOT_TAG_FIELD , $ hideRootTag ) ; $ classAttribute -> setAttribute ( self :: EDIT_VIEW_FIELD , $ editView ) ; }
Extracts values from the attribute parameters and sets it in the class attribute .
55,773
public function serializeContentClassAttribute ( $ classAttribute , $ attributeNode , $ attributeParametersNode ) { $ dom = $ attributeParametersNode -> ownerDocument ; $ subTreeLimit = ( string ) $ classAttribute -> attribute ( self :: SUBTREE_LIMIT_FIELD ) ; $ domNode = $ dom -> createElement ( 'subtree-limit' ) ; $ domNode -> appendChild ( $ dom -> createTextNode ( $ subTreeLimit ) ) ; $ attributeParametersNode -> appendChild ( $ domNode ) ; $ maxTags = ( string ) $ classAttribute -> attribute ( self :: MAX_TAGS_FIELD ) ; $ domNode = $ dom -> createElement ( 'max-tags' ) ; $ domNode -> appendChild ( $ dom -> createTextNode ( $ maxTags ) ) ; $ attributeParametersNode -> appendChild ( $ domNode ) ; $ hideRootTag = ( ( int ) $ classAttribute -> attribute ( self :: HIDE_ROOT_TAG_FIELD ) ) > 0 ? 'true' : 'false' ; $ domNode = $ dom -> createElement ( 'hide-root-tag' ) ; $ domNode -> appendChild ( $ dom -> createTextNode ( $ hideRootTag ) ) ; $ attributeParametersNode -> appendChild ( $ domNode ) ; $ editView = ( string ) $ classAttribute -> attribute ( self :: EDIT_VIEW_FIELD ) ; $ domNode = $ dom -> createElement ( 'edit-view' ) ; $ domNode -> appendChild ( $ dom -> createTextNode ( $ editView ) ) ; $ attributeParametersNode -> appendChild ( $ domNode ) ; }
Adds the necessary DOM structure to the attribute parameters
55,774
public function metaData ( $ attribute ) { $ eZTags = $ attribute -> content ( ) ; if ( ! $ eZTags instanceof eZTags ) return '' ; $ indexSynonyms = eZINI :: instance ( 'eztags.ini' ) -> variable ( 'SearchSettings' , 'IndexSynonyms' ) === 'enabled' ; $ keywords = array ( ) ; $ tags = $ eZTags -> attribute ( 'tags' ) ; foreach ( $ tags as $ tag ) { if ( ! $ indexSynonyms && $ tag -> isSynonym ( ) ) $ tag = $ tag -> getMainTag ( ) ; if ( $ tag instanceof eZTagsObject ) { $ keyword = $ tag -> getKeyword ( $ attribute -> attribute ( 'language_code' ) ) ; if ( ! $ keyword ) { $ mainLanguage = eZContentLanguage :: fetch ( $ tag -> attribute ( 'main_language_id' ) ) ; if ( $ mainLanguage instanceof eZContentLanguage ) $ keyword = $ tag -> getKeyword ( $ mainLanguage -> attribute ( 'locale' ) ) ; } if ( $ keyword ) $ keywords [ ] = $ keyword ; } } return implode ( ', ' , array_unique ( $ keywords ) ) ; }
Returns the meta data used for storing search indices
55,775
public function hasObjectAttributeContent ( $ contentObjectAttribute ) { $ eZTags = $ contentObjectAttribute -> content ( ) ; if ( ! $ eZTags instanceof eZTags ) return false ; $ tagsCount = $ eZTags -> attribute ( 'tags_count' ) ; return $ tagsCount > 0 ; }
Returns true if content object attribute has content
55,776
public function toString ( $ contentObjectAttribute ) { $ eZTags = $ contentObjectAttribute -> content ( ) ; if ( ! $ eZTags instanceof eZTags ) return '' ; $ returnArray = array ( ) ; $ returnArray [ ] = $ eZTags -> attribute ( 'id_string' ) ; $ returnArray [ ] = $ eZTags -> attribute ( 'keyword_string' ) ; $ returnArray [ ] = $ eZTags -> attribute ( 'parent_string' ) ; $ returnArray [ ] = $ eZTags -> attribute ( 'locale_string' ) ; return implode ( '|#' , $ returnArray ) ; }
Returns string representation of a content object attribute
55,777
public function serializeContentObjectAttribute ( $ package , $ objectAttribute ) { $ node = $ this -> createContentObjectAttributeDOMNode ( $ objectAttribute ) ; $ eZTags = $ objectAttribute -> content ( ) ; if ( ! $ eZTags instanceof eZTags ) return $ node ; $ dom = $ node -> ownerDocument ; $ idStringNode = $ dom -> createElement ( 'id-string' ) ; $ idStringNode -> appendChild ( $ dom -> createTextNode ( $ eZTags -> attribute ( 'id_string' ) ) ) ; $ node -> appendChild ( $ idStringNode ) ; $ keywordStringNode = $ dom -> createElement ( 'keyword-string' ) ; $ keywordStringNode -> appendChild ( $ dom -> createTextNode ( $ eZTags -> attribute ( 'keyword_string' ) ) ) ; $ node -> appendChild ( $ keywordStringNode ) ; $ parentStringNode = $ dom -> createElement ( 'parent-string' ) ; $ parentStringNode -> appendChild ( $ dom -> createTextNode ( $ eZTags -> attribute ( 'parent_string' ) ) ) ; $ node -> appendChild ( $ parentStringNode ) ; $ localeStringNode = $ dom -> createElement ( 'locale-string' ) ; $ localeStringNode -> appendChild ( $ dom -> createTextNode ( $ eZTags -> attribute ( 'locale_string' ) ) ) ; $ node -> appendChild ( $ localeStringNode ) ; return $ node ; }
Serializes the content object attribute
55,778
public function unserializeContentObjectAttribute ( $ package , $ objectAttribute , $ attributeNode ) { $ idString = $ attributeNode -> getElementsByTagName ( 'id-string' ) -> item ( 0 ) -> textContent ; $ keywordString = $ attributeNode -> getElementsByTagName ( 'keyword-string' ) -> item ( 0 ) -> textContent ; $ parentString = $ attributeNode -> getElementsByTagName ( 'parent-string' ) -> item ( 0 ) -> textContent ; $ localeString = $ attributeNode -> getElementsByTagName ( 'locale-string' ) -> item ( 0 ) -> textContent ; $ validationResult = $ this -> validateObjectAttribute ( $ objectAttribute , $ idString , $ keywordString , $ parentString , $ localeString ) ; if ( $ validationResult == eZInputValidator :: STATE_ACCEPTED ) { $ eZTags = eZTags :: createFromStrings ( $ objectAttribute , $ idString , $ keywordString , $ parentString , $ localeString ) ; $ objectAttribute -> setContent ( $ eZTags ) ; } }
Unserializes the content object attribute from provided DOM node
55,779
private function isEmptyLine ( array $ tokensInLine ) : bool { if ( count ( $ tokensInLine ) > 1 ) { return false ; } $ firstToken = $ tokensInLine [ 0 ] ; return $ firstToken -> getType ( ) === TokenInterface :: TYPE_WHITESPACE && $ firstToken -> getValue ( ) === "\n" ; }
Checks if a stream of tokens is an empty line .
55,780
private function reduceIndentationLevel ( int $ indentationLevel , array $ tokensInLine ) : int { $ raisingIndentation = [ TokenInterface :: TYPE_BRACE_CLOSE , ] ; if ( $ this -> indentConditions ) { $ raisingIndentation [ ] = TokenInterface :: TYPE_CONDITION_END ; } foreach ( $ tokensInLine as $ token ) { if ( in_array ( $ token -> getType ( ) , $ raisingIndentation ) ) { if ( $ token -> getType ( ) === TokenInterface :: TYPE_CONDITION_END ) { $ this -> insideCondition = false ; } return $ indentationLevel - 1 ; } } return $ indentationLevel ; }
Check whether indentation should be reduced by one level for current line .
55,781
private function raiseIndentationLevel ( int $ indentationLevel , array $ tokensInLine ) : int { $ raisingIndentation = [ TokenInterface :: TYPE_BRACE_OPEN , ] ; if ( $ this -> indentConditions && $ this -> insideCondition === false ) { $ raisingIndentation [ ] = TokenInterface :: TYPE_CONDITION ; } foreach ( $ tokensInLine as $ token ) { if ( in_array ( $ token -> getType ( ) , $ raisingIndentation ) ) { if ( $ token -> getType ( ) === TokenInterface :: TYPE_CONDITION ) { $ this -> insideCondition = true ; } return $ indentationLevel + 1 ; } } return $ indentationLevel ; }
Check whether indentation should be raised by one level for current line .
55,782
public function field ( $ fieldName , $ fieldValue = '' , $ fieldBoost = null ) { if ( empty ( $ fieldName ) ) { throw new \ InvalidArgumentException ( 'Please provide a fieldname' ) ; } $ field = array ( 'name' => $ fieldName , 'value' => $ fieldValue ) ; if ( ! empty ( $ fieldBoost ) ) { $ field [ 'boost' ] = $ fieldBoost ; } $ this -> fields [ ] = $ field ; return $ this ; }
Add a field entry for this document
55,783
private function buildUrl ( $ request ) { return $ this -> options [ 'url' ] . $ request -> getUrlPrefix ( ) . $ request -> getPath ( ) . '?' . $ this -> getUrlPartParameters ( $ request ) ; }
Build final URL to call
55,784
public function submitFile ( RequestFile $ requestOSS , array $ options = array ( ) ) { $ request = curl_init ( $ this -> buildUrl ( $ requestOSS ) ) ; ( $ requestOSS -> getMethod ( ) == 'PUT' ) ? curl_setopt ( $ request , CURLOPT_CUSTOMREQUEST , 'PUT' ) : curl_setopt ( $ request , CURLOPT_POST , true ) ; $ args [ 'file' ] = new \ CurlFile ( $ requestOSS -> getFilePath ( ) ) ; curl_setopt ( $ request , CURLOPT_POSTFIELDS , $ args ) ; curl_setopt ( $ request , CURLOPT_RETURNTRANSFER , true ) ; $ content = curl_exec ( $ request ) ; $ errmsg = curl_error ( $ request ) ; $ headers = curl_getinfo ( $ request ) ; $ httpCode = curl_getinfo ( $ request , CURLINFO_HTTP_CODE ) ; $ newHeader = 'HTTP ' . $ httpCode . ' ' ; $ newHeader .= ( $ errmsg ) ? $ errmsg : '-' ; array_unshift ( $ headers , $ newHeader ) ; $ response = new BuzzResponse ( ) ; $ response -> setContent ( $ content ) ; $ response -> setHeaders ( $ headers ) ; $ response -> getStatusCode ( ) ; curl_close ( $ request ) ; return new \ OpenSearchServer \ Response \ Response ( $ response , $ requestOSS ) ; }
Submit a PUT or POST request to the API sending a file using CURL directly .
55,785
static public function createFromStrings ( eZContentObjectAttribute $ attribute , $ idString , $ keywordString , $ parentString , $ localeString ) { $ idArray = explode ( '|#' , $ idString ) ; $ keywordArray = explode ( '|#' , $ keywordString ) ; $ parentArray = explode ( '|#' , $ parentString ) ; $ localeArray = explode ( '|#' , $ localeString ) ; $ wordArray = array ( ) ; foreach ( array_keys ( $ idArray ) as $ key ) { $ wordArray [ ] = trim ( $ idArray [ $ key ] ) . "|#" . trim ( $ keywordArray [ $ key ] ) . "|#" . trim ( $ parentArray [ $ key ] ) . "|#" . trim ( $ localeArray [ $ key ] ) ; } $ idArray = array ( ) ; $ keywordArray = array ( ) ; $ parentArray = array ( ) ; $ localeArray = array ( ) ; $ db = eZDB :: instance ( ) ; $ wordArray = array_unique ( $ wordArray ) ; foreach ( $ wordArray as $ wordKey ) { $ word = explode ( '|#' , $ wordKey ) ; if ( $ word [ 0 ] != '' ) { $ idArray [ ] = ( int ) $ word [ 0 ] ; $ keywordArray [ ] = trim ( $ word [ 1 ] ) ; $ parentArray [ ] = ( int ) $ word [ 2 ] ; $ localeArray [ ] = trim ( $ word [ 3 ] ) ; } } return new self ( $ attribute , $ idArray , $ keywordArray , $ parentArray , $ localeArray ) ; }
Initializes the tags
55,786
private function getPermissionArray ( ) { $ permissionArray = array ( 'can_add' => false , 'subtree_limit' => $ this -> Attribute -> contentClassAttribute ( ) -> attribute ( eZTagsType :: SUBTREE_LIMIT_FIELD ) , 'allowed_locations' => array ( ) , 'allowed_locations_tags' => false ) ; $ userLimitations = eZTagsTemplateFunctions :: getSimplifiedUserAccess ( 'tags' , 'add' ) ; if ( $ userLimitations [ 'accessWord' ] == 'no' ) return $ permissionArray ; $ userLimitations = isset ( $ userLimitations [ 'simplifiedLimitations' ] [ 'Tag' ] ) ? $ userLimitations [ 'simplifiedLimitations' ] [ 'Tag' ] : array ( ) ; $ limitTag = eZTagsObject :: fetchWithMainTranslation ( $ permissionArray [ 'subtree_limit' ] ) ; if ( empty ( $ userLimitations ) ) { if ( $ permissionArray [ 'subtree_limit' ] == 0 || $ limitTag instanceof eZTagsObject ) { $ permissionArray [ 'allowed_locations' ] = array ( $ permissionArray [ 'subtree_limit' ] ) ; if ( $ limitTag instanceof eZTagsObject ) $ permissionArray [ 'allowed_locations_tags' ] = array ( $ limitTag ) ; } } else if ( $ permissionArray [ 'subtree_limit' ] == 0 ) { $ permissionArray [ 'allowed_locations_tags' ] = array ( ) ; $ userLimitations = eZTagsObject :: fetchList ( array ( 'id' => array ( $ userLimitations ) ) , null , null , true ) ; if ( is_array ( $ userLimitations ) && ! empty ( $ userLimitations ) ) { foreach ( $ userLimitations as $ limitation ) { $ permissionArray [ 'allowed_locations' ] [ ] = $ limitation -> attribute ( 'id' ) ; $ permissionArray [ 'allowed_locations_tags' ] [ ] = $ limitation ; } } } else if ( $ limitTag instanceof eZTagsObject ) { $ userLimitations = eZTagsObject :: fetchList ( array ( 'id' => array ( $ userLimitations ) ) , null , null , true ) ; if ( is_array ( $ userLimitations ) && ! empty ( $ userLimitations ) ) { $ pathString = $ limitTag -> attribute ( 'path_string' ) ; foreach ( $ userLimitations as $ limitation ) { if ( strpos ( $ pathString , '/' . $ limitation -> attribute ( 'id' ) . '/' ) !== false ) { $ permissionArray [ 'allowed_locations' ] = array ( $ permissionArray [ 'subtree_limit' ] ) ; $ permissionArray [ 'allowed_locations_tags' ] = array ( $ limitTag ) ; break ; } } } } if ( ! empty ( $ permissionArray [ 'allowed_locations' ] ) ) $ permissionArray [ 'can_add' ] = true ; return $ permissionArray ; }
Returns the array with permission info for linking tags to current content object attribute
55,787
static private function canSave ( $ pathString , array $ allowedLocations ) { foreach ( $ allowedLocations as $ location ) { if ( $ location == 0 || strpos ( $ pathString , '/' . $ location . '/' ) !== false ) return true ; } return false ; }
Checks if tags can be saved below tag with provided path string taking into account allowed locations for tag placement
55,788
static private function createAndLinkTag ( eZContentObjectAttribute $ attribute , $ parentID , $ parentPathString , $ parentDepth , $ keyword , $ locale , $ priority ) { $ languageID = eZContentLanguage :: idByLocale ( $ locale ) ; if ( $ languageID === false ) return ; $ ini = eZINI :: instance ( 'eztags.ini' ) ; $ alwaysAvailable = $ ini -> variable ( 'GeneralSettings' , 'DefaultAlwaysAvailable' ) ; $ alwaysAvailable = $ alwaysAvailable === 'true' ? 1 : 0 ; $ tagObject = new eZTagsObject ( array ( 'parent_id' => $ parentID , 'main_tag_id' => 0 , 'depth' => $ parentDepth + 1 , 'path_string' => $ parentPathString , 'main_language_id' => $ languageID , 'language_mask' => $ languageID + $ alwaysAvailable ) , $ locale ) ; $ tagObject -> store ( ) ; $ tagKeywordObject = new eZTagsKeyword ( array ( 'keyword_id' => $ tagObject -> attribute ( 'id' ) , 'language_id' => $ languageID + $ alwaysAvailable , 'keyword' => $ keyword , 'locale' => $ locale , 'status' => eZTagsKeyword :: STATUS_PUBLISHED ) ) ; $ tagKeywordObject -> store ( ) ; $ tagObject -> setAttribute ( 'path_string' , $ tagObject -> attribute ( 'path_string' ) . $ tagObject -> attribute ( 'id' ) . '/' ) ; $ tagObject -> store ( ) ; $ tagObject -> updateModified ( ) ; $ linkObject = new eZTagsAttributeLinkObject ( array ( 'keyword_id' => $ tagObject -> attribute ( 'id' ) , 'objectattribute_id' => $ attribute -> attribute ( 'id' ) , 'objectattribute_version' => $ attribute -> attribute ( 'version' ) , 'object_id' => $ attribute -> attribute ( 'contentobject_id' ) , 'priority' => $ priority ) ) ; $ linkObject -> store ( ) ; if ( class_exists ( 'ezpEvent' , false ) ) { ezpEvent :: getInstance ( ) -> filter ( 'tag/add' , array ( 'tag' => $ tagObject , 'parentTag' => $ tagObject -> getParent ( true ) ) ) ; } }
Creates a new tag and links it to provided content object attribute
55,789
static private function linkTag ( eZContentObjectAttribute $ attribute , eZTagsObject $ tagObject , $ keyword , $ locale , $ priority ) { $ languageID = eZContentLanguage :: idByLocale ( $ locale ) ; if ( $ languageID === false ) return ; if ( $ locale == $ attribute -> attribute ( 'language_code' ) ) { if ( ! $ tagObject -> hasTranslation ( $ locale ) ) { $ tagKeywordObject = new eZTagsKeyword ( array ( 'keyword_id' => $ tagObject -> attribute ( 'id' ) , 'language_id' => $ languageID , 'keyword' => $ keyword , 'locale' => $ locale , 'status' => eZTagsKeyword :: STATUS_PUBLISHED ) ) ; $ tagKeywordObject -> store ( ) ; $ tagObject -> updateLanguageMask ( ) ; } } $ linkObject = new eZTagsAttributeLinkObject ( array ( 'keyword_id' => $ tagObject -> attribute ( 'id' ) , 'objectattribute_id' => $ attribute -> attribute ( 'id' ) , 'objectattribute_version' => $ attribute -> attribute ( 'version' ) , 'object_id' => $ attribute -> attribute ( 'contentobject_id' ) , 'priority' => $ priority ) ) ; $ linkObject -> store ( ) ; }
Links the content object attribute and tag
55,790
public function tags ( ) { if ( ! is_array ( $ this -> IDArray ) || empty ( $ this -> IDArray ) ) return array ( ) ; $ tags = array ( ) ; foreach ( eZTagsObject :: fetchList ( array ( 'id' => array ( $ this -> IDArray ) ) ) as $ item ) { $ tags [ array_search ( $ item -> attribute ( 'id' ) , $ this -> IDArray ) ] = $ item ; } ksort ( $ tags ) ; return $ tags ; }
Returns tags within this instance
55,791
public function tagsCount ( ) { if ( ! is_array ( $ this -> IDArray ) || empty ( $ this -> IDArray ) ) return 0 ; return eZTagsObject :: fetchListCount ( array ( 'id' => array ( $ this -> IDArray ) ) ) ; }
Returns the count of tags within this instance
55,792
public function metaKeywordString ( ) { $ tagKeywords = array_map ( function ( $ tag ) { return $ tag -> attribute ( 'keyword' ) ; } , $ this -> tags ( ) ) ; return ! empty ( $ tagKeywords ) ? implode ( ', ' , $ tagKeywords ) : '' ; }
Returns the keywords as a string
55,793
protected function _fixVersionTables ( Event $ event ) { if ( ! preg_match ( '/Versions$/' , $ event -> subject -> viewVars [ 'name' ] ) ) { return ; } unset ( $ event -> subject -> viewVars [ 'rulesChecker' ] [ 'version_id' ] ) ; foreach ( $ event -> subject -> viewVars [ 'associations' ] [ 'belongsTo' ] as $ i => $ association ) { if ( $ association [ 'alias' ] === 'Versions' && $ association [ 'foreignKey' ] === 'version_id' ) { unset ( $ event -> subject -> viewVars [ 'associations' ] [ 'belongsTo' ] [ $ i ] ) ; } } }
Removes unnecessary associations
55,794
protected function _checkAssociation ( Event $ event , $ tableSuffix ) { $ subject = $ event -> subject ; $ connection = ConnectionManager :: get ( $ subject -> viewVars [ 'connection' ] ) ; $ schema = $ connection -> getSchemaCollection ( ) ; $ versionTable = sprintf ( '%s_%s' , Hash :: get ( $ event -> subject -> viewVars , 'table' ) , $ tableSuffix ) ; if ( ! in_array ( $ versionTable , $ schema -> listTables ( ) ) ) { return false ; } $ event -> subject -> viewVars [ 'behaviors' ] [ 'Josegonzalez/Version.Version' ] = [ sprintf ( "'versionTable' => '%s'" , $ versionTable ) , ] ; $ event -> subject -> viewVars [ 'associations' ] [ 'belongsTo' ] = $ this -> _modifyBelongsTo ( $ event ) ; $ event -> subject -> viewVars [ 'rulesChecker' ] = $ this -> _modifyRulesChecker ( $ event ) ; return true ; }
Attaches the behavior and modifies associations as necessary
55,795
protected function _modifyBelongsTo ( Event $ event ) { $ belongsTo = $ event -> subject -> viewVars [ 'associations' ] [ 'belongsTo' ] ; foreach ( $ belongsTo as $ i => $ association ) { if ( $ association [ 'alias' ] !== 'Versions' || $ association [ 'foreignKey' ] !== 'version_id' ) { continue ; } unset ( $ belongsTo [ $ i ] ) ; } return $ belongsTo ; }
Removes unnecessary belongsTo associations
55,796
protected function _modifyRulesChecker ( Event $ event ) { $ rulesChecker = $ event -> subject -> viewVars [ 'rulesChecker' ] ; foreach ( $ rulesChecker as $ key => $ config ) { if ( Hash :: get ( $ config , 'extra' ) !== 'Versions' || $ key !== 'version_id' ) { continue ; } unset ( $ rulesChecker [ $ key ] ) ; } return $ rulesChecker ; }
Removes unnecessary rulesChecker entries
55,797
public function writeReport ( Report $ report ) : void { $ xml = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ root = $ xml -> createElement ( 'checkstyle' ) ; $ root -> setAttribute ( 'version' , APP_NAME . '-' . APP_VERSION ) ; foreach ( $ report -> getFiles ( ) as $ file ) { $ xmlFile = $ xml -> createElement ( 'file' ) ; $ xmlFile -> setAttribute ( 'name' , $ file -> getFilename ( ) ) ; foreach ( $ file -> getIssues ( ) as $ issue ) { $ xmlWarning = $ xml -> createElement ( 'error' ) ; $ xmlWarning -> setAttribute ( 'line' , "" . $ issue -> getLine ( ) ) ; $ xmlWarning -> setAttribute ( 'severity' , $ issue -> getSeverity ( ) ) ; $ xmlWarning -> setAttribute ( 'message' , $ issue -> getMessage ( ) ) ; $ xmlWarning -> setAttribute ( 'source' , $ issue -> getSource ( ) ) ; if ( $ issue -> getColumn ( ) !== null ) { $ xmlWarning -> setAttribute ( 'column' , "" . $ issue -> getColumn ( ) ) ; } $ xmlFile -> appendChild ( $ xmlWarning ) ; } $ root -> appendChild ( $ xmlFile ) ; } $ xml -> appendChild ( $ root ) ; $ xml -> formatOutput = true ; $ this -> output -> write ( $ xml -> saveXML ( ) ) ; }
Writes a report in checkstyle XML format .
55,798
public function sort ( $ field , $ direction = self :: SORT_DESC ) { if ( empty ( $ this -> data [ 'sorts' ] ) ) { $ this -> data [ 'sorts' ] = array ( ) ; } $ this -> data [ 'sorts' ] [ ] = array ( 'field' => $ field , 'direction' => $ direction ) ; return $ this ; }
Add one level of sorting
55,799
public function facet ( $ field , $ min = 0 , $ multi = false , $ postCollapsing = false ) { if ( empty ( $ this -> data [ 'facets' ] ) ) { $ this -> data [ 'facets' ] = array ( ) ; } $ this -> data [ 'facets' ] [ ] = array ( 'field' => $ field , 'minCount' => $ min , 'multivalued' => $ multi , 'postCollapsing' => $ postCollapsing ) ; return $ this ; }
Add a facet to search results