idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
59,000
|
public function matchUrl ( $ url ) { $ url = '/' . ltrim ( $ url , '/' ) ; $ url = $ this -> sanitizeUrl ( $ url ) ; if ( $ url && $ route = $ this -> matchUrlDirectly ( $ url ) ) { return $ route ; } if ( $ url && $ route = $ this -> matchUrlWithParameters ( $ url ) ) { return $ route ; } return null ; }
|
Try to find a match in all available routes .
|
59,001
|
protected function matchUrlDirectly ( $ url ) { foreach ( $ this -> routes as $ route ) { if ( $ route -> matchDirectly ( $ url ) ) { return $ route ; } } return null ; }
|
Loop through routes and try to match directly .
|
59,002
|
protected function matchUrlWithParameters ( $ url ) { foreach ( $ this -> routes as $ route ) { if ( $ route -> matchWithParameters ( $ url ) ) { return $ route ; } } return null ; }
|
Loop through routes and try to match with parameters .
|
59,003
|
public function setMailSender ( \ Parable \ Mail \ Sender \ SenderInterface $ mailSender ) { $ this -> mailSender = $ mailSender ; return $ this ; }
|
Set the mail sender implementation to use .
|
59,004
|
public function setFrom ( $ email , $ name = null ) { if ( ! filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { throw new \ Parable \ Mail \ Exception ( "Email provided is invalid: {$email}" ) ; } $ this -> addresses [ 'from' ] = [ [ 'email' => $ email , 'name' => $ name , ] ] ; return $ this ; }
|
Set the from address .
|
59,005
|
public function getAddressesForType ( $ type ) { if ( ! isset ( $ this -> addresses [ $ type ] ) ) { throw new \ Parable \ Mail \ Exception ( 'Only to, cc, bcc addresses are allowed.' ) ; } $ addresses = [ ] ; foreach ( $ this -> addresses [ $ type ] as $ address ) { if ( ! empty ( $ address [ 'name' ] ) ) { $ addresses [ ] = $ address [ 'name' ] . ' <' . $ address [ 'email' ] . '>' ; } else { $ addresses [ ] = $ address [ 'email' ] ; } } return implode ( ', ' , $ addresses ) ; }
|
Return all addresses for type .
|
59,006
|
public function resetMailData ( ) { $ this -> subject = null ; $ this -> body = null ; $ this -> headers = [ ] ; return $ this ; }
|
Reset just the subject body headers
|
59,007
|
public function setAction ( $ action ) { if ( ! in_array ( $ action , $ this -> acceptedValues ) ) { $ acceptedValuesString = implode ( ', ' , $ this -> acceptedValues ) ; throw new \ Parable \ ORM \ Exception ( "Invalid action set, only {$acceptedValuesString} are allowed." ) ; } $ this -> action = $ action ; return $ this ; }
|
Set the type of query we re going to do .
|
59,008
|
public function where ( \ Parable \ ORM \ Query \ ConditionSet $ set ) { $ this -> where [ ] = $ set ; return $ this ; }
|
Add a where condition set .
|
59,009
|
public function having ( \ Parable \ ORM \ Query \ ConditionSet $ set ) { $ this -> having [ ] = $ set ; return $ this ; }
|
Add a having condition set .
|
59,010
|
protected function join ( $ type , $ joinTableName , $ key , $ comparator , $ value = null , $ shouldCompareFields = true , $ tableName = null ) { if ( ! $ tableName ) { $ tableName = $ this -> getTableName ( ) ; } $ condition = new \ Parable \ ORM \ Query \ Condition ( ) ; $ condition -> setQuery ( $ this ) -> setTableName ( $ tableName ) -> setJoinTableName ( $ joinTableName ) -> setKey ( $ key ) -> setComparator ( $ comparator ) -> setValue ( $ value ) -> setShouldCompareFields ( $ shouldCompareFields ) ; $ this -> joins [ $ type ] [ ] = $ condition ; return $ this ; }
|
Add a join to the query .
|
59,011
|
public function innerJoin ( $ joinTableName , $ key , $ comparator , $ value = null , $ shouldCompareFields = true , $ tableName = null ) { return $ this -> join ( self :: JOIN_INNER , $ joinTableName , $ key , $ comparator , $ value , $ shouldCompareFields , $ tableName ) ; }
|
Add an inner join to the query .
|
59,012
|
public function leftJoin ( $ joinTableName , $ key , $ comparator , $ value = null , $ shouldCompareFields = true , $ tableName = null ) { return $ this -> join ( self :: JOIN_LEFT , $ joinTableName , $ key , $ comparator , $ value , $ shouldCompareFields , $ tableName ) ; }
|
Add a left join to the query .
|
59,013
|
public function fullJoin ( $ joinTableName , $ key , $ comparator , $ value = null , $ shouldCompareFields = true , $ tableName = null ) { return $ this -> join ( self :: JOIN_FULL , $ joinTableName , $ key , $ comparator , $ value , $ shouldCompareFields , $ tableName ) ; }
|
Add a full join to the query .
|
59,014
|
public function orderBy ( $ key , $ direction = self :: ORDER_ASC , $ tableName = null ) { if ( ! $ tableName ) { $ tableName = $ this -> getTableName ( ) ; } $ this -> orderBy [ ] = [ 'key' => $ key , 'direction' => $ direction , 'tableName' => $ tableName ] ; return $ this ; }
|
Sets the order for select queries .
|
59,015
|
public function groupBy ( $ key , $ tableName = null ) { if ( ! $ tableName ) { $ tableName = $ this -> getTableName ( ) ; } $ this -> groupBy [ ] = [ 'key' => $ key , 'tableName' => $ tableName ] ; return $ this ; }
|
Sets the group by for select queries .
|
59,016
|
protected function buildSelect ( ) { $ selects = [ ] ; foreach ( $ this -> select as $ select ) { $ shouldBeQuoted = true ; foreach ( $ this -> nonQuoteStrings as $ nonQuoteString ) { if ( strpos ( strtolower ( $ select ) , $ nonQuoteString ) !== false ) { $ shouldBeQuoted = false ; break ; } } if ( $ shouldBeQuoted ) { $ selects [ ] = $ this -> getQuotedTableName ( ) . '.' . $ this -> quoteIdentifier ( $ select ) ; } else { $ selects [ ] = $ select ; } } return 'SELECT ' . implode ( ', ' , $ selects ) ; }
|
Build and return the select string .
|
59,017
|
protected function buildJoins ( ) { $ builtJoins = [ ] ; foreach ( $ this -> joins as $ type => $ joins ) { if ( count ( $ joins ) > 0 ) { foreach ( $ joins as $ join ) { if ( $ type === self :: JOIN_INNER ) { $ builtJoins [ ] = 'INNER JOIN' ; } elseif ( $ type === self :: JOIN_LEFT ) { $ builtJoins [ ] = 'LEFT JOIN' ; } elseif ( $ type === self :: JOIN_RIGHT ) { $ builtJoins [ ] = 'RIGHT JOIN' ; } elseif ( $ type === self :: JOIN_FULL ) { $ builtJoins [ ] = 'FULL JOIN' ; } $ builtJoins [ ] = $ this -> quoteIdentifier ( $ join -> getJoinTableName ( ) ) . ' ON' ; $ conditionSet = new Query \ Condition \ AndSet ( $ this , [ $ join ] ) ; $ builtJoins [ ] = $ conditionSet -> buildWithoutParentheses ( ) ; } } } return implode ( ' ' , $ builtJoins ) ; }
|
Build and return the join strings .
|
59,018
|
protected function buildWheres ( ) { if ( count ( $ this -> where ) === 0 ) { return '' ; } $ conditionSet = new Query \ Condition \ AndSet ( $ this , $ this -> where ) ; return "WHERE {$conditionSet->buildWithoutParentheses()}" ; }
|
Build and return the where string .
|
59,019
|
protected function buildHaving ( ) { if ( count ( $ this -> having ) === 0 ) { return '' ; } $ conditionSet = new Query \ Condition \ AndSet ( $ this , $ this -> having ) ; return "HAVING {$conditionSet->buildWithoutParentheses()}" ; }
|
Build and return the having string .
|
59,020
|
protected function buildOrderBy ( ) { if ( count ( $ this -> orderBy ) === 0 ) { return '' ; } $ orders = [ ] ; foreach ( $ this -> orderBy as $ orderBy ) { $ key = $ this -> quoteIdentifier ( $ orderBy [ 'tableName' ] ) . '.' . $ this -> quoteIdentifier ( $ orderBy [ 'key' ] ) ; $ orders [ ] = $ key . ' ' . $ orderBy [ 'direction' ] ; } return 'ORDER BY ' . implode ( ', ' , $ orders ) ; }
|
Build and return the order by string .
|
59,021
|
protected function buildGroupBy ( ) { if ( count ( $ this -> groupBy ) === 0 ) { return '' ; } $ groups = [ ] ; foreach ( $ this -> groupBy as $ groupBy ) { $ groupBy = $ this -> quoteIdentifier ( $ groupBy [ 'tableName' ] ) . '.' . $ this -> quoteIdentifier ( $ groupBy [ 'key' ] ) ; $ groups [ ] = $ groupBy ; } return 'GROUP BY ' . implode ( ', ' , $ groups ) ; }
|
Build and return the group by string .
|
59,022
|
public function getAll ( ) { $ query = $ this -> createQuery ( ) ; $ result = $ this -> database -> query ( $ query ) ; $ entities = [ ] ; if ( $ result ) { $ result = $ result -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; $ entities = $ this -> handleResult ( $ result ) ; } if ( $ this -> returnOne && is_array ( $ entities ) ) { return current ( $ entities ) ; } return $ entities ; }
|
Returns all rows for this model type .
|
59,023
|
public function getByCondition ( $ key , $ comparator , $ value = null ) { $ query = $ this -> createQuery ( ) ; $ conditionSet = $ query -> buildAndSet ( [ $ key , $ comparator , $ value ] ) ; return $ this -> getByConditionSet ( $ conditionSet ) ; }
|
Returns all rows matching specific condition parameters given .
|
59,024
|
public function getByConditionSets ( array $ conditionSets ) { $ query = $ this -> createQuery ( ) ; $ query -> whereMany ( $ conditionSets ) ; $ result = $ this -> database -> query ( $ query ) ; $ entities = [ ] ; if ( $ result ) { $ result = $ result -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; $ entities = $ this -> handleResult ( $ result ) ; } if ( $ this -> returnOne && is_array ( $ entities ) ) { return current ( $ entities ) ; } return $ entities ; }
|
Returns all rows matching all conditions passed .
|
59,025
|
public function setModel ( \ Parable \ ORM \ Model $ model ) { $ this -> model = $ model -> reset ( ) ; return $ this ; }
|
Set a model on the repository . Reset it so there s no unwanted values stored on it .
|
59,026
|
protected function handleResult ( array $ result ) { if ( $ this -> onlyCount && isset ( $ result [ 0 ] ) && is_array ( $ result [ 0 ] ) ) { return ( int ) current ( $ result [ 0 ] ) ; } $ entities = [ ] ; foreach ( $ result as $ row ) { $ model = clone $ this -> getModel ( ) ; $ model -> populate ( $ row ) ; $ entities [ ] = $ model ; } return $ entities ; }
|
Handle the result of one of the get functions . This attempts to create a new model with the values returned properly set .
|
59,027
|
public function reset ( ) { $ this -> orderBy = [ ] ; $ this -> limitOffset = [ ] ; $ this -> setOnlyCount ( false ) ; $ this -> returnAll ( ) ; }
|
Resets everything but the query and model class to their default values .
|
59,028
|
public function initialize ( ) { if ( $ this -> checkAuthentication ( ) ) { $ data = $ this -> getAuthenticationData ( ) ; if ( ! isset ( $ data [ 'user_id' ] ) ) { return false ; } $ user = $ this -> toolkit -> getRepository ( $ this -> userClassName ) -> getById ( $ data [ 'user_id' ] ) ; if ( ! $ user ) { $ this -> setAuthenticated ( false ) ; $ this -> setAuthenticationData ( [ ] ) ; return false ; } $ this -> setUser ( $ user ) ; return true ; } return false ; }
|
Initialize the authentication picking up on session data if possible .
|
59,029
|
protected function checkAuthentication ( ) { $ authSession = $ this -> readFromSession ( ) ; if ( $ authSession ) { if ( isset ( $ authSession [ 'authenticated' ] ) ) { $ this -> setAuthenticated ( $ authSession [ 'authenticated' ] ) ; } else { $ this -> setAuthenticated ( false ) ; } if ( isset ( $ authSession [ 'data' ] ) ) { $ this -> setAuthenticationData ( $ authSession [ 'data' ] ) ; } else { $ this -> setAuthenticationData ( [ ] ) ; } return true ; } return false ; }
|
Checks whether there s an auth session active at this point .
|
59,030
|
public function setUserClassName ( $ className ) { try { \ Parable \ DI \ Container :: create ( $ className ) ; } catch ( \ Exception $ e ) { throw new \ Parable \ Framework \ Exception ( "Class '{$className}' could not be instantiated." ) ; } $ this -> userClassName = $ className ; return $ this ; }
|
Set the class name to use for the user .
|
59,031
|
public function setUser ( $ user ) { if ( ! ( $ user instanceof $ this -> userClassName ) ) { throw new \ Parable \ Framework \ Exception ( "Invalid object provided, type {$this->userClassName} required." ) ; } $ this -> user = $ user ; return $ this ; }
|
Set the user and check whether it s of the right type .
|
59,032
|
public function authenticate ( $ passwordProvided , $ passwordHash ) { if ( password_verify ( $ passwordProvided , $ passwordHash ) ) { $ this -> setAuthenticated ( true ) ; if ( $ this -> getUser ( ) && property_exists ( $ this -> getUser ( ) , $ this -> getUserIdProperty ( ) ) ) { $ userId = $ this -> getUser ( ) -> { $ this -> getUserIdProperty ( ) } ; $ this -> setAuthenticationData ( [ 'user_id' => $ userId ] ) ; } $ this -> writeToSession ( [ 'authenticated' => true , 'data' => $ this -> getAuthenticationData ( ) , ] ) ; } else { $ this -> revokeAuthentication ( ) ; } return $ this -> isAuthenticated ( ) ; }
|
Check whether the provided password matches the password hash .
|
59,033
|
protected function isJsonString ( $ data ) { if ( ! is_string ( $ data ) && ! is_null ( $ data ) ) { return false ; } json_decode ( $ data , true ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { return false ; } return true ; }
|
Attempt to check whether the provided string is json or not .
|
59,034
|
public function loadTemplate ( $ path ) { $ path = $ this -> path -> getDir ( $ path ) ; if ( ! file_exists ( $ path ) ) { throw new \ Parable \ Framework \ Exception ( "Email template '{$path}' does not exist." ) ; } $ content = $ this -> view -> partial ( $ path ) ; $ this -> setBody ( trim ( $ content ) ) ; return $ this ; }
|
Load template for this mail . Returns the interpreted output as string .
|
59,035
|
public function setupEntities ( ) { if ( $ this -> registeredEntities -> Count ( ) > 0 ) { return ; } if ( Config :: inst ( ) -> get ( 'DocumentationManifest' , 'automatic_registration' ) ) { $ this -> populateEntitiesFromInstall ( ) ; } $ registered = Config :: inst ( ) -> get ( 'DocumentationManifest' , 'register_entities' ) ; foreach ( $ registered as $ details ) { $ required = array ( 'Path' , 'Title' ) ; foreach ( $ required as $ require ) { if ( ! isset ( $ details [ $ require ] ) ) { throw new Exception ( "$require is a required key in DocumentationManifest.register_entities" ) ; } } $ path = $ this -> getRealPath ( $ details [ 'Path' ] ) ; $ key = ( isset ( $ details [ 'Key' ] ) ) ? $ details [ 'Key' ] : $ details [ 'Title' ] ; if ( ! $ path || ! is_dir ( $ path ) ) { trigger_error ( $ details [ 'Path' ] . ' is not a valid documentation directory' , E_USER_WARNING ) ; continue ; } $ version = ( isset ( $ details [ 'Version' ] ) ) ? $ details [ 'Version' ] : '' ; $ versionTitle = isset ( $ details [ 'VersionTitle' ] ) ? $ details [ 'VersionTitle' ] : $ version ; $ archived = ! empty ( $ details [ 'Archived' ] ) ; $ branch = ( isset ( $ details [ 'Branch' ] ) ) ? $ details [ 'Branch' ] : '' ; $ langs = scandir ( $ path ) ; if ( $ langs ) { $ possible = i18n :: get_common_languages ( true ) ; foreach ( $ langs as $ k => $ lang ) { if ( isset ( $ possible [ $ lang ] ) ) { $ entity = Injector :: inst ( ) -> create ( 'DocumentationEntity' , $ key ) ; $ entity -> setPath ( DocumentationHelper :: normalizePath ( Controller :: join_links ( $ path , $ lang , '/' ) ) ) ; $ entity -> setTitle ( $ details [ 'Title' ] ) ; $ entity -> setLanguage ( $ lang ) ; $ entity -> setVersion ( $ version ) ; $ entity -> setVersionTitle ( $ versionTitle ) ; $ entity -> setBranch ( $ branch ) ; $ entity -> setIsArchived ( $ archived ) ; if ( isset ( $ details [ 'Stable' ] ) ) { $ entity -> setIsStable ( $ details [ 'Stable' ] ) ; } if ( isset ( $ details [ 'DefaultEntity' ] ) ) { $ entity -> setIsDefaultEntity ( $ details [ 'DefaultEntity' ] ) ; if ( $ entity -> getIsDefaultEntity ( ) ) { $ this -> has_default_entity = true ; } } $ this -> registeredEntities -> push ( $ entity ) ; } } } } }
|
Sets up the top level entities .
|
59,036
|
public function populateEntitiesFromInstall ( ) { if ( $ this -> automaticallyPopulated ) { return ; } foreach ( scandir ( BASE_PATH ) as $ key => $ entity ) { if ( $ key == "themes" ) { continue ; } $ dir = DocumentationHelper :: normalizePath ( Controller :: join_links ( BASE_PATH , $ entity ) ) ; if ( is_dir ( $ dir ) ) { $ docs = Controller :: join_links ( $ dir , 'docs' ) ; if ( is_dir ( $ docs ) ) { $ entities [ ] = array ( 'Path' => $ docs , 'Title' => DocumentationHelper :: clean_page_name ( $ entity ) , 'Version' => 'master' , 'Branch' => 'master' , 'Stable' => true ) ; } } } Config :: inst ( ) -> update ( 'DocumentationManifest' , 'register_entities' , $ entities ) ; $ this -> automaticallyPopulated = true ; }
|
Scans the current installation and picks up all the SilverStripe modules that contain a docs folder .
|
59,037
|
public function getPage ( $ url ) { $ pages = $ this -> getPages ( ) ; $ url = $ this -> normalizeUrl ( $ url ) ; if ( ! isset ( $ pages [ $ url ] ) ) { return null ; } $ record = $ pages [ $ url ] ; foreach ( $ this -> getEntities ( ) as $ entity ) { if ( strpos ( $ record [ 'filepath' ] , $ entity -> getPath ( ) ) !== false ) { $ page = Injector :: inst ( ) -> create ( $ record [ 'type' ] , $ entity , $ record [ 'basename' ] , $ record [ 'filepath' ] ) ; return $ page ; } } }
|
Returns a particular page for the requested URL .
|
59,038
|
public function getRedirect ( $ url ) { $ pages = $ this -> getRedirects ( ) ; $ url = $ this -> normalizeUrl ( $ url ) ; if ( isset ( $ pages [ $ url ] ) ) { return $ pages [ $ url ] ; } }
|
Get any redirect for the given url
|
59,039
|
protected function stripLinkBase ( $ link ) { $ link = preg_replace ( '/^' . preg_quote ( Director :: baseURL ( ) , '/' ) . '/' , '' , $ link ) ; if ( $ linkBase = Config :: inst ( ) -> get ( 'DocumentationViewer' , 'link_base' ) ) { $ link = preg_replace ( '/^' . preg_quote ( $ linkBase , '/' ) . '\/?/' , '' , $ link ) ; } return $ link ; }
|
Remove the link_base from the start of a link
|
59,040
|
protected function buildUrl ( $ url ) { return Controller :: join_links ( Director :: baseURL ( ) , Config :: inst ( ) -> get ( 'DocumentationViewer' , 'link_base' ) , $ url , '/' ) ; }
|
Create a clean domain - relative URL form a docuetn URL
|
59,041
|
public function getNextPage ( $ filepath , $ entityBase ) { $ grabNext = false ; $ fallback = null ; foreach ( $ this -> getPages ( ) as $ url => $ page ) { if ( $ grabNext && strpos ( $ page [ 'filepath' ] , $ entityBase ) !== false ) { return new ArrayData ( array ( 'Link' => $ this -> buildUrl ( $ url ) , 'Title' => $ page [ 'title' ] ) ) ; } if ( $ filepath == $ page [ 'filepath' ] ) { $ grabNext = true ; } elseif ( ! $ fallback && strpos ( $ page [ 'filepath' ] , $ filepath ) !== false ) { $ fallback = new ArrayData ( array ( 'Link' => $ this -> buildUrl ( $ url ) , 'Title' => $ page [ 'title' ] , 'Fallback' => true ) ) ; } } if ( ! $ grabNext ) { return $ fallback ; } return null ; }
|
Determine the next page from the given page .
|
59,042
|
public function getPreviousPage ( $ filepath , $ entityPath ) { $ previousUrl = $ previousPage = null ; foreach ( $ this -> getPages ( ) as $ url => $ page ) { if ( $ filepath == $ page [ 'filepath' ] ) { if ( $ previousUrl ) { return new ArrayData ( array ( 'Link' => $ this -> buildUrl ( $ previousUrl ) , 'Title' => $ previousPage [ 'title' ] ) ) ; } } if ( strpos ( $ page [ 'filepath' ] , $ entityPath ) !== false ) { $ previousUrl = $ url ; $ previousPage = $ page ; } } return null ; }
|
Determine the previous page from the given page .
|
59,043
|
public function getChildrenFor ( $ entityPath , $ recordPath = null ) { if ( ! $ recordPath ) { $ recordPath = $ entityPath ; } $ output = new ArrayList ( ) ; $ entityPath = $ this -> normalizeUrl ( $ entityPath ) ; $ recordPath = $ this -> normalizeUrl ( $ recordPath ) ; $ recordParts = explode ( '/' , trim ( $ recordPath , '/' ) ) ; $ currentRecordPath = end ( $ recordParts ) ; $ depth = substr_count ( $ entityPath , '/' ) ; foreach ( $ this -> getPages ( ) as $ url => $ page ) { $ pagePath = $ this -> normalizeUrl ( $ page [ 'filepath' ] ) ; if ( strpos ( $ pagePath , $ entityPath ) === false ) { continue ; } if ( substr_count ( $ pagePath , '/' ) == ( $ depth + 1 ) ) { $ pagePathParts = explode ( '/' , trim ( $ pagePath , '/' ) ) ; $ currentPagePath = end ( $ pagePathParts ) ; if ( $ currentPagePath == $ currentRecordPath ) { $ mode = 'current' ; } elseif ( strpos ( $ recordPath , $ pagePath ) !== false ) { $ mode = 'section' ; } else { $ mode = 'link' ; } $ children = new ArrayList ( ) ; if ( $ mode == 'section' || $ mode == 'current' ) { $ children = $ this -> getChildrenFor ( $ pagePath , $ recordPath ) ; } $ output -> push ( new ArrayData ( array ( 'Link' => $ this -> buildUrl ( $ url ) , 'Title' => $ page [ 'title' ] , 'LinkingMode' => $ mode , 'Summary' => $ page [ 'summary' ] , 'Children' => $ children ) ) ) ; } } return $ output ; }
|
Return the children of the provided record path .
|
59,044
|
public function getAllVersions ( ) { $ versions = array ( ) ; foreach ( $ this -> getEntities ( ) as $ entity ) { if ( $ entity -> getVersion ( ) ) { $ versions [ $ entity -> getVersion ( ) ] = $ entity -> getVersion ( ) ; } else { $ versions [ '0.0' ] = _t ( 'DocumentationManifest.MASTER' , 'Master' ) ; } } asort ( $ versions ) ; return $ versions ; }
|
Returns a sorted array of all the unique versions registered
|
59,045
|
public static function fromInteger ( int $ vat = null ) : Tax { $ mapping = [ 0 => self :: VAT0 , 10 => self :: VAT110 , 18 => self :: VAT118 , ] ; if ( null === $ vat ) { return new self ( self :: NONE ) ; } if ( ! isset ( $ mapping [ $ vat ] ) ) { throw VatException :: becauseUnknownVatValue ( $ vat ) ; } return new self ( $ mapping [ $ vat ] ) ; }
|
Get tax by integer value .
|
59,046
|
public static function clean_page_name ( $ name ) { $ name = self :: trim_extension_off ( $ name ) ; $ name = self :: trim_sort_number ( $ name ) ; $ name = str_replace ( array ( '-' , '_' ) , ' ' , $ name ) ; return ucfirst ( trim ( $ name ) ) ; }
|
String helper for cleaning a file name to a readable version .
|
59,047
|
public static function clean_page_url ( $ name ) { $ name = str_replace ( array ( ' ' ) , '_' , $ name ) ; $ name = self :: trim_extension_off ( $ name ) ; $ name = self :: trim_sort_number ( $ name ) ; if ( preg_match ( '/^[\/]?index[\/]?/' , $ name ) ) { return '' ; } return strtolower ( $ name ) ; }
|
String helper for cleaning a file name to a URL safe version .
|
59,048
|
public static function trim_extension_off ( $ name ) { if ( strrpos ( $ name , '.' ) !== false ) { return substr ( $ name , 0 , strrpos ( $ name , '.' ) ) ; } return $ name ; }
|
Helper function to strip the extension off and return the name without the extension .
|
59,049
|
public static function relativePath ( $ path ) { $ base = self :: normalizePath ( Director :: baseFolder ( ) ) ; return substr ( $ path , strlen ( $ base ) ) ; }
|
Helper function to make normalized paths relative
|
59,050
|
private static function _getPrefix ( $ word ) { $ questionMarkPosition = strpos ( $ word , '?' ) ; $ astrericPosition = strpos ( $ word , '*' ) ; if ( $ questionMarkPosition !== false ) { if ( $ astrericPosition !== false ) { return substr ( $ word , 0 , min ( $ questionMarkPosition , $ astrericPosition ) ) ; } return substr ( $ word , 0 , $ questionMarkPosition ) ; } else if ( $ astrericPosition !== false ) { return substr ( $ word , 0 , $ astrericPosition ) ; } return $ word ; }
|
Get terms prefix
|
59,051
|
private function _translateInput ( $ char ) { if ( strpos ( self :: QUERY_WHITE_SPACE_CHARS , $ char ) !== false ) { return self :: IN_WHITE_SPACE ; } else if ( strpos ( self :: QUERY_SYNT_CHARS , $ char ) !== false ) { return self :: IN_SYNT_CHAR ; } else if ( strpos ( self :: QUERY_MUTABLE_CHARS , $ char ) !== false ) { return self :: IN_MUTABLE_CHAR ; } else if ( strpos ( self :: QUERY_LEXEMEMODIFIER_CHARS , $ char ) !== false ) { return self :: IN_LEXEME_MODIFIER ; } else if ( strpos ( self :: QUERY_ASCIIDIGITS_CHARS , $ char ) !== false ) { return self :: IN_ASCII_DIGIT ; } else if ( $ char === '"' ) { return self :: IN_QUOTE ; } else if ( $ char === '.' ) { return self :: IN_DECIMAL_POINT ; } else if ( $ char === '\\' ) { return self :: IN_ESCAPE_CHAR ; } else { return self :: IN_CHAR ; } }
|
Translate input char to an input symbol of state machine
|
59,052
|
public function tokenize ( $ inputString , $ encoding ) { $ this -> reset ( ) ; $ this -> _lexemes = array ( ) ; $ this -> _queryString = array ( ) ; if ( PHP_OS == 'AIX' && $ encoding == '' ) { $ encoding = 'ISO8859-1' ; } $ strLength = iconv_strlen ( $ inputString , $ encoding ) ; $ inputString .= ' ' ; for ( $ count = 0 ; $ count < $ strLength ; $ count ++ ) { $ this -> _queryString [ $ count ] = iconv_substr ( $ inputString , $ count , 1 , $ encoding ) ; } for ( $ this -> _queryStringPosition = 0 ; $ this -> _queryStringPosition < count ( $ this -> _queryString ) ; $ this -> _queryStringPosition ++ ) { $ this -> process ( $ this -> _translateInput ( $ this -> _queryString [ $ this -> _queryStringPosition ] ) ) ; } $ this -> process ( self :: IN_WHITE_SPACE ) ; if ( $ this -> getState ( ) != self :: ST_WHITE_SPACE ) { include_once 'Zend/Search/Lucene/Search/QueryParserException.php' ; throw new Zend_Search_Lucene_Search_QueryParserException ( 'Unexpected end of query' ) ; } $ this -> _queryString = null ; return $ this -> _lexemes ; }
|
This method is used to tokenize query string into lexemes
|
59,053
|
public function addQuerySyntaxLexeme ( ) { $ lexeme = $ this -> _queryString [ $ this -> _queryStringPosition ] ; if ( strpos ( self :: QUERY_DOUBLECHARLEXEME_CHARS , $ lexeme ) !== false ) { $ this -> _queryStringPosition ++ ; if ( $ this -> _queryStringPosition == count ( $ this -> _queryString ) || $ this -> _queryString [ $ this -> _queryStringPosition ] != $ lexeme ) { include_once 'Zend/Search/Lucene/Search/QueryParserException.php' ; throw new Zend_Search_Lucene_Search_QueryParserException ( 'Two chars lexeme expected. ' . $ this -> _positionMsg ( ) ) ; } $ lexeme .= $ lexeme ; } $ token = new Zend_Search_Lucene_Search_QueryToken ( Zend_Search_Lucene_Search_QueryToken :: TC_SYNTAX_ELEMENT , $ lexeme , $ this -> _queryStringPosition ) ; if ( $ token -> type == Zend_Search_Lucene_Search_QueryToken :: TT_FIELD_INDICATOR ) { $ token = array_pop ( $ this -> _lexemes ) ; if ( $ token === null || $ token -> type != Zend_Search_Lucene_Search_QueryToken :: TT_WORD ) { include_once 'Zend/Search/Lucene/Search/QueryParserException.php' ; throw new Zend_Search_Lucene_Search_QueryParserException ( 'Field mark \':\' must follow field name. ' . $ this -> _positionMsg ( ) ) ; } $ token -> type = Zend_Search_Lucene_Search_QueryToken :: TT_FIELD ; } $ this -> _lexemes [ ] = $ token ; }
|
Add query syntax lexeme
|
59,054
|
public function addLexemeModifier ( ) { $ this -> _lexemes [ ] = new Zend_Search_Lucene_Search_QueryToken ( Zend_Search_Lucene_Search_QueryToken :: TC_SYNTAX_ELEMENT , $ this -> _queryString [ $ this -> _queryStringPosition ] , $ this -> _queryStringPosition ) ; }
|
Add lexeme modifier
|
59,055
|
public function addQuotedLexeme ( ) { $ this -> _lexemes [ ] = new Zend_Search_Lucene_Search_QueryToken ( Zend_Search_Lucene_Search_QueryToken :: TC_PHRASE , $ this -> _currentLexeme , $ this -> _queryStringPosition ) ; $ this -> _currentLexeme = '' ; }
|
Add quoted lexeme
|
59,056
|
public function addNumberLexeme ( ) { $ this -> _lexemes [ ] = new Zend_Search_Lucene_Search_QueryToken ( Zend_Search_Lucene_Search_QueryToken :: TC_NUMBER , $ this -> _currentLexeme , $ this -> _queryStringPosition - 1 ) ; $ this -> _currentLexeme = '' ; }
|
Add number lexeme
|
59,057
|
protected function executeQuery ( $ url , array $ data = array ( ) , array $ extra_result_data = array ( ) ) { $ headers = array ( sprintf ( 'Authorization: Bearer %s' , $ this -> accessToken ) , 'Content-Type: application/json' , 'Accept: application/json' ) ; $ content = $ this -> getAdapter ( ) -> getContent ( $ url , 'POST' , $ headers , json_encode ( $ data ) ) ; if ( null === $ content ) { return array_merge ( $ this -> getDefaults ( ) , $ extra_result_data ) ; } return $ this -> parseResults ( $ content , $ extra_result_data ) ; }
|
Issues the actual HTTP query .
|
59,058
|
public static function getPrefix ( $ str , $ length ) { $ prefixBytes = 0 ; $ prefixChars = 0 ; while ( $ prefixBytes < strlen ( $ str ) && $ prefixChars < $ length ) { $ charBytes = 1 ; if ( ( ord ( $ str [ $ prefixBytes ] ) & 0xC0 ) == 0xC0 ) { $ charBytes ++ ; if ( ord ( $ str [ $ prefixBytes ] ) & 0x20 ) { $ charBytes ++ ; if ( ord ( $ str [ $ prefixBytes ] ) & 0x10 ) { $ charBytes ++ ; } } } if ( $ prefixBytes + $ charBytes > strlen ( $ str ) ) { break ; } $ prefixChars ++ ; $ prefixBytes += $ charBytes ; } return substr ( $ str , 0 , $ prefixBytes ) ; }
|
Get term prefix
|
59,059
|
public static function getLength ( $ str ) { $ bytes = 0 ; $ chars = 0 ; while ( $ bytes < strlen ( $ str ) ) { $ charBytes = 1 ; if ( ( ord ( $ str [ $ bytes ] ) & 0xC0 ) == 0xC0 ) { $ charBytes ++ ; if ( ord ( $ str [ $ bytes ] ) & 0x20 ) { $ charBytes ++ ; if ( ord ( $ str [ $ bytes ] ) & 0x10 ) { $ charBytes ++ ; } } } if ( $ bytes + $ charBytes > strlen ( $ str ) ) { break ; } $ chars ++ ; $ bytes += $ charBytes ; } return $ chars ; }
|
Get UTF - 8 string length
|
59,060
|
protected function isPureArray ( array $ array ) { $ i = 0 ; foreach ( $ array as $ k => $ v ) { if ( $ k !== $ i ) { return false ; } $ i ++ ; } return true ; }
|
Checks wether the provided array has string keys and if it s not sparse .
|
59,061
|
public function termDocsFilter ( Zend_Search_Lucene_Index_Term $ term , $ docsFilter = null ) { return $ this -> _index -> termDocsFilter ( $ term , $ docsFilter ) ; }
|
Returns documents filter for all documents containing term .
|
59,062
|
public function run ( $ request ) { $ this -> start ( ) ; $ registered = Config :: inst ( ) -> get ( 'DocumentationManifest' , 'register_entities' ) ; foreach ( $ registered as $ details ) { $ required = array ( 'Path' , 'Title' ) ; foreach ( $ required as $ require ) { if ( ! isset ( $ details [ $ require ] ) ) { $ this -> showError ( "$require is a required key in DocumentationManifest.register_entities" ) ; } } $ path = $ this -> getRealPath ( $ details [ 'Path' ] ) ; if ( ! $ path || ! is_dir ( $ path ) ) { $ this -> showError ( $ details [ 'Path' ] . ' is not a valid documentation directory' ) ; } } $ this -> end ( ) ; }
|
Validate all source files
|
59,063
|
public function addTerm ( Zend_Search_Lucene_Index_Term $ term , $ position = null ) { if ( ( count ( $ this -> _terms ) != 0 ) && ( end ( $ this -> _terms ) -> field != $ term -> field ) ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'All phrase terms must be in the same field: ' . $ term -> field . ':' . $ term -> text ) ; } $ this -> _terms [ ] = $ term ; if ( $ position !== null ) { $ this -> _offsets [ ] = $ position ; } else if ( count ( $ this -> _offsets ) != 0 ) { $ this -> _offsets [ ] = end ( $ this -> _offsets ) + 1 ; } else { $ this -> _offsets [ ] = 0 ; } }
|
Adds a term to the end of the query phrase . The relative position of the term is specified explicitly or the one immediately after the last term added .
|
59,064
|
public static function add ( $ map = array ( ) ) { if ( ArrayLib :: is_associative ( $ map ) ) { self :: $ mapping = array_merge ( self :: $ mapping , $ map ) ; } else { user_error ( "DocumentationPermalinks::add() requires an associative array" , E_USER_ERROR ) ; } }
|
Add a mapping of nice short permalinks to a full long path
|
59,065
|
public static function map ( $ url ) { return ( isset ( self :: $ mapping [ $ url ] ) ) ? self :: $ mapping [ $ url ] : false ; }
|
Return the location for a given short value .
|
59,066
|
public function getSearchedEntities ( ) { $ entities = array ( ) ; if ( ! empty ( $ _REQUEST [ 'Entities' ] ) ) { if ( is_array ( $ _REQUEST [ 'Entities' ] ) ) { $ entities = Convert :: raw2att ( $ _REQUEST [ 'Entities' ] ) ; } else { $ entities = explode ( ',' , Convert :: raw2att ( $ _REQUEST [ 'Entities' ] ) ) ; $ entities = array_combine ( $ entities , $ entities ) ; } } return $ entities ; }
|
Return an array of folders and titles
|
59,067
|
public function getSearchedVersions ( ) { $ versions = array ( ) ; if ( ! empty ( $ _REQUEST [ 'Versions' ] ) ) { if ( is_array ( $ _REQUEST [ 'Versions' ] ) ) { $ versions = Convert :: raw2att ( $ _REQUEST [ 'Versions' ] ) ; $ versions = array_combine ( $ versions , $ versions ) ; } else { $ version = Convert :: raw2att ( $ _REQUEST [ 'Versions' ] ) ; $ versions [ $ version ] = $ version ; } } return $ versions ; }
|
Return an array of versions that we re allowed to return
|
59,068
|
public function getSearchQuery ( ) { if ( isset ( $ _REQUEST [ 'Search' ] ) ) { return DBField :: create_field ( 'HTMLText' , $ _REQUEST [ 'Search' ] ) ; } elseif ( isset ( $ _REQUEST [ 'q' ] ) ) { return DBField :: create_field ( 'HTMLText' , $ _REQUEST [ 'q' ] ) ; } }
|
Return the current search query .
|
59,069
|
public function getSearchResults ( ) { $ query = $ this -> getSearchQuery ( ) ; $ search = new DocumentationSearch ( ) ; $ search -> setQuery ( $ query ) ; $ search -> setVersions ( $ this -> getSearchedVersions ( ) ) ; $ search -> setModules ( $ this -> getSearchedEntities ( ) ) ; $ search -> setOutputController ( $ this -> owner ) ; return $ search -> renderResults ( ) ; }
|
Past straight to results display and encode the query .
|
59,070
|
protected function registerCustomBindings ( ) : void { $ repositoryFactory = $ this -> app -> make ( IRepositoryFactory :: class ) ; foreach ( config ( 'laravel_repositories.bindings' ) as $ className => $ repository ) { $ repositoryFactory -> register ( $ className , $ repository ) ; } }
|
Register custom repositories implementations .
|
59,071
|
static public function getLocalClass ( $ remoteClass ) { $ localClass = false ; $ cb = false ; $ localClass = ( isset ( self :: $ maps [ $ remoteClass ] ) ) ? self :: $ maps [ $ remoteClass ] : false ; if ( ! $ localClass && is_callable ( self :: $ onGetLocalClass ) ) { $ cb = true ; $ localClass = call_user_func ( self :: $ onGetLocalClass , $ remoteClass ) ; } if ( ! $ localClass ) return false ; if ( ! is_string ( $ localClass ) && $ cb ) { throw new Exception ( 'Classname received from onGetLocalClass should be a string or return false. ' . gettype ( $ localClass ) . ' was returned' ) ; } if ( ! class_exists ( $ localClass ) ) { throw new Exception ( 'Class ' . $ localClass . ' is not defined' ) ; } return $ localClass ; }
|
Get the local classname for a remote class
|
59,072
|
static public function getRemoteClass ( $ localClass ) { $ remoteClass = false ; $ cb = false ; $ remoteClass = array_search ( $ localClass , self :: $ maps ) ; if ( ! $ remoteClass && is_callable ( self :: $ onGetRemoteClass ) ) { $ cb = true ; $ remoteClass = call_user_func ( self :: $ onGetRemoteClass , $ localClass ) ; } if ( ! $ remoteClass ) return false ; if ( ! is_string ( $ remoteClass ) && $ cb ) { throw new Exception ( 'Classname received from onGetRemoteClass should be a string or return false. ' . gettype ( $ remoteClass ) . ' was returned' ) ; } return $ remoteClass ; }
|
Get the remote classname for a local class
|
59,073
|
public function highlight ( $ words ) { $ color = $ this -> _highlightColors [ $ this -> _currentColorIndex ] ; $ this -> _currentColorIndex = ( $ this -> _currentColorIndex + 1 ) % count ( $ this -> _highlightColors ) ; $ this -> _doc -> highlight ( $ words , $ color ) ; }
|
Highlight specified words
|
59,074
|
public function tokenize ( $ data , $ encoding = '' ) { $ this -> setInput ( $ data , $ encoding ) ; $ tokenList = array ( ) ; while ( ( $ nextToken = $ this -> nextToken ( ) ) !== null ) { $ tokenList [ ] = $ nextToken ; } return $ tokenList ; }
|
Tokenize text to a terms Returns array of Zend_Search_Lucene_Analysis_Token objects
|
59,075
|
public function setInput ( $ data , $ encoding = '' ) { $ this -> _input = $ data ; $ this -> _encoding = $ encoding ; $ this -> reset ( ) ; }
|
Tokenization stream API Set input
|
59,076
|
public function addState ( $ state ) { $ this -> _states [ $ state ] = $ state ; if ( $ this -> _currentState === null ) { $ this -> _currentState = $ state ; } }
|
Add state to the state machine
|
59,077
|
public function setState ( $ state ) { if ( ! isset ( $ this -> _states [ $ state ] ) ) { include_once 'Zend/Search/Exception.php' ; throw new Zend_Search_Exception ( 'State \'' . $ state . '\' is not on of the possible FSM states.' ) ; } $ this -> _currentState = $ state ; }
|
Set FSM state . No any action is invoked
|
59,078
|
public function addRules ( $ rules ) { foreach ( $ rules as $ rule ) { $ this -> addrule ( $ rule [ 0 ] , $ rule [ 1 ] , $ rule [ 2 ] , isset ( $ rule [ 3 ] ) ? $ rule [ 3 ] : null ) ; } }
|
Add transition rules
|
59,079
|
public function addRule ( $ sourceState , $ input , $ targetState , $ inputAction = null ) { if ( ! isset ( $ this -> _states [ $ sourceState ] ) ) { include_once 'Zend/Search/Exception.php' ; throw new Zend_Search_Exception ( 'Undefined source state (' . $ sourceState . ').' ) ; } if ( ! isset ( $ this -> _states [ $ targetState ] ) ) { include_once 'Zend/Search/Exception.php' ; throw new Zend_Search_Exception ( 'Undefined target state (' . $ targetState . ').' ) ; } if ( ! isset ( $ this -> _inputAphabet [ $ input ] ) ) { include_once 'Zend/Search/Exception.php' ; throw new Zend_Search_Exception ( 'Undefined input symbol (' . $ input . ').' ) ; } if ( ! isset ( $ this -> _rules [ $ sourceState ] ) ) { $ this -> _rules [ $ sourceState ] = array ( ) ; } if ( isset ( $ this -> _rules [ $ sourceState ] [ $ input ] ) ) { include_once 'Zend/Search/Exception.php' ; throw new Zend_Search_Exception ( 'Rule for {state,input} pair (' . $ sourceState . ', ' . $ input . ') is already defined.' ) ; } $ this -> _rules [ $ sourceState ] [ $ input ] = $ targetState ; if ( $ inputAction !== null ) { $ this -> addInputAction ( $ sourceState , $ input , $ inputAction ) ; } }
|
Add symbol to the input alphabet
|
59,080
|
public function process ( $ input ) { if ( ! isset ( $ this -> _rules [ $ this -> _currentState ] ) ) { include_once 'Zend/Search/Exception.php' ; throw new Zend_Search_Exception ( 'There is no any rule for current state (' . $ this -> _currentState . ').' ) ; } if ( ! isset ( $ this -> _rules [ $ this -> _currentState ] [ $ input ] ) ) { include_once 'Zend/Search/Exception.php' ; throw new Zend_Search_Exception ( 'There is no any rule for {current state, input} pair (' . $ this -> _currentState . ', ' . $ input . ').' ) ; } $ sourceState = $ this -> _currentState ; $ targetState = $ this -> _rules [ $ this -> _currentState ] [ $ input ] ; if ( $ sourceState != $ targetState && isset ( $ this -> _exitActions [ $ sourceState ] ) ) { foreach ( $ this -> _exitActions [ $ sourceState ] as $ action ) { $ action -> doAction ( ) ; } } if ( isset ( $ this -> _inputActions [ $ sourceState ] ) && isset ( $ this -> _inputActions [ $ sourceState ] [ $ input ] ) ) { foreach ( $ this -> _inputActions [ $ sourceState ] [ $ input ] as $ action ) { $ action -> doAction ( ) ; } } $ this -> _currentState = $ targetState ; if ( isset ( $ this -> _transitionActions [ $ sourceState ] ) && isset ( $ this -> _transitionActions [ $ sourceState ] [ $ targetState ] ) ) { foreach ( $ this -> _transitionActions [ $ sourceState ] [ $ targetState ] as $ action ) { $ action -> doAction ( ) ; } } if ( $ sourceState != $ targetState && isset ( $ this -> _entryActions [ $ targetState ] ) ) { foreach ( $ this -> _entryActions [ $ targetState ] as $ action ) { $ action -> doAction ( ) ; } } }
|
Process an input
|
59,081
|
public function getToken ( string $ login , string $ pass ) : GetTokenResponse { $ response = $ this -> request ( 'GET' , 'getToken' , [ 'login' => $ login , 'pass' => $ pass , ] ) ; return $ this -> converter -> getResponseObject ( GetTokenResponse :: class , $ response ) ; }
|
Get auth token .
|
59,082
|
public function createStoredFieldsFiles ( ) { $ this -> _fdxFile = $ this -> _directory -> createFile ( $ this -> _name . '.fdx' ) ; $ this -> _fdtFile = $ this -> _directory -> createFile ( $ this -> _name . '.fdt' ) ; $ this -> _files [ ] = $ this -> _name . '.fdx' ; $ this -> _files [ ] = $ this -> _name . '.fdt' ; }
|
Create stored fields files and open them for write
|
59,083
|
public function close ( ) { if ( $ this -> _docCount == 0 ) { return null ; } $ this -> _dumpFNM ( ) ; $ this -> _generateCFS ( ) ; include_once 'Zend/Search/Lucene/Index/SegmentInfo.php' ; return new Zend_Search_Lucene_Index_SegmentInfo ( $ this -> _directory , $ this -> _name , $ this -> _docCount , - 1 , null , true , true ) ; }
|
Close segment write it to disk and return segment info
|
59,084
|
public function close ( ) { if ( $ this -> _fileHandle !== null ) { @ fclose ( $ this -> _fileHandle ) ; $ this -> _fileHandle = null ; } }
|
Close File object
|
59,085
|
public function size ( ) { $ position = ftell ( $ this -> _fileHandle ) ; fseek ( $ this -> _fileHandle , 0 , SEEK_END ) ; $ size = ftell ( $ this -> _fileHandle ) ; fseek ( $ this -> _fileHandle , $ position ) ; return $ size ; }
|
Get the size of the already opened file
|
59,086
|
protected function notAllowed ( Request $ request ) { if ( $ request -> ajax ( ) ) { return response ( 'Unauthorized.' , 401 ) ; } else { $ action = $ this -> config -> get ( 'zendacl.action' , 'redirect' ) ; if ( $ action == 'redirect' ) { $ url = $ this -> config -> get ( 'zendacl.redirect' , 'auth/login' ) ; return redirect ( $ url ) ; } elseif ( $ action == 'route' ) { $ route = $ this -> config -> get ( 'zendacl.redirect' ) ; return redirect ( ) -> route ( $ route ) ; } elseif ( $ action == 'view' ) { $ view = $ this -> config -> get ( 'zendacl.view' , 'zendacl::unauthorized' ) ; return view ( $ view ) ; } } }
|
Processes not allowed response
|
59,087
|
public function init ( ) { parent :: init ( ) ; if ( empty ( $ this -> htmlOptions [ 'id' ] ) ) { $ this -> htmlOptions [ 'id' ] = $ this -> id ; } if ( $ this -> useHtmlData ) { if ( isset ( $ this -> options [ 'data' ] ) ) { $ this -> items = ( array ) $ this -> options [ 'data' ] ; unset ( $ this -> options [ 'data' ] ) ; } if ( isset ( $ this -> options [ 'spinner' ] ) ) { $ this -> spinner = ( array ) $ this -> options [ 'spinner' ] ; unset ( $ this -> options [ 'spinner' ] ) ; } foreach ( $ this -> options as $ option => $ value ) { $ this -> htmlOptions [ 'data-' . $ option ] = $ value ; } $ this -> options = [ ] ; } $ this -> htmlOptions [ 'data-auto' ] = 'false' ; if ( ! empty ( $ this -> items ) ) { $ this -> options [ 'data' ] = $ this -> items ; } if ( ! empty ( $ this -> spinner ) ) { $ this -> options [ 'spinner' ] = $ this -> spinner ; } echo Html :: beginTag ( $ this -> tagName , $ this -> htmlOptions ) . "\n" ; }
|
Initializes the widget . This renders the open tag .
|
59,088
|
protected function build ( string $ modelClass ) : IRepository { $ repositoryClass = $ this -> registeredRepositories [ $ modelClass ] ?? Repository :: class ; $ parameters = [ ] ; if ( $ repositoryClass === Repository :: class || is_subclass_of ( $ repositoryClass , Repository :: class ) ) { $ parameters = [ 'modelClass' => $ modelClass ] ; } return $ this -> container -> make ( $ repositoryClass , $ parameters ) ; }
|
Build repository by model class from registered instances or creates default .
|
59,089
|
public function getStatus ( $ messageId ) { if ( null === $ this -> username || null === $ this -> password || null === $ this -> accountRef ) { throw new Exception \ InvalidCredentialsException ( 'No API credentials provided' ) ; } $ params = $ this -> getParameters ( array ( 'messageID' => $ messageId , ) ) ; return $ this -> executeQuery ( self :: SMS_STATUS_URL , $ params ) ; }
|
Retrieves the status of a message
|
59,090
|
public static function getDefaultSearchField ( ) { if ( count ( $ this -> _indices ) == 0 ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices list is empty' ) ; } $ defaultSearchField = reset ( $ this -> _indices ) -> getDefaultSearchField ( ) ; foreach ( $ this -> _indices as $ index ) { if ( $ index -> getDefaultSearchField ( ) !== $ defaultSearchField ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices have different default search field.' ) ; } } return $ defaultSearchField ; }
|
Get default search field .
|
59,091
|
public static function getResultSetLimit ( ) { if ( count ( $ this -> _indices ) == 0 ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices list is empty' ) ; } $ defaultResultSetLimit = reset ( $ this -> _indices ) -> getResultSetLimit ( ) ; foreach ( $ this -> _indices as $ index ) { if ( $ index -> getResultSetLimit ( ) !== $ defaultResultSetLimit ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices have different default search field.' ) ; } } return $ defaultResultSetLimit ; }
|
Set result set limit .
|
59,092
|
public function getMaxBufferedDocs ( ) { if ( count ( $ this -> _indices ) == 0 ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices list is empty' ) ; } $ maxBufferedDocs = reset ( $ this -> _indices ) -> getMaxBufferedDocs ( ) ; foreach ( $ this -> _indices as $ index ) { if ( $ index -> getMaxBufferedDocs ( ) !== $ maxBufferedDocs ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices have different default search field.' ) ; } } return $ maxBufferedDocs ; }
|
Retrieve index maxBufferedDocs option
|
59,093
|
public function getMaxMergeDocs ( ) { if ( count ( $ this -> _indices ) == 0 ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices list is empty' ) ; } $ maxMergeDocs = reset ( $ this -> _indices ) -> getMaxMergeDocs ( ) ; foreach ( $ this -> _indices as $ index ) { if ( $ index -> getMaxMergeDocs ( ) !== $ maxMergeDocs ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices have different default search field.' ) ; } } return $ maxMergeDocs ; }
|
Retrieve index maxMergeDocs option
|
59,094
|
public function getMergeFactor ( ) { if ( count ( $ this -> _indices ) == 0 ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices list is empty' ) ; } $ mergeFactor = reset ( $ this -> _indices ) -> getMergeFactor ( ) ; foreach ( $ this -> _indices as $ index ) { if ( $ index -> getMergeFactor ( ) !== $ mergeFactor ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices have different default search field.' ) ; } } return $ mergeFactor ; }
|
Retrieve index mergeFactor option
|
59,095
|
public function getSimilarity ( ) { if ( count ( $ this -> _indices ) == 0 ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices list is empty' ) ; } $ similarity = reset ( $ this -> _indices ) -> getSimilarity ( ) ; foreach ( $ this -> _indices as $ index ) { if ( $ index -> getSimilarity ( ) !== $ similarity ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( 'Indices have different similarity.' ) ; } } return $ similarity ; }
|
Retrive similarity used by index reader
|
59,096
|
public function setDocumentDistributorCallback ( $ callback ) { if ( $ callback !== null && ! is_callable ( $ callback ) ) { include_once 'Zend/Search/Lucene/Exception.php' ; throw new Zend_Search_Lucene_Exception ( '$callback parameter must be a valid callback.' ) ; } $ this -> _documentDistributorCallBack = $ callback ; }
|
Set callback for choosing target index .
|
59,097
|
public static function getTypes ( ) { return array ( self :: TT_WORD , self :: TT_PHRASE , self :: TT_FIELD , self :: TT_FIELD_INDICATOR , self :: TT_REQUIRED , self :: TT_PROHIBITED , self :: TT_FUZZY_PROX_MARK , self :: TT_BOOSTING_MARK , self :: TT_RANGE_INCL_START , self :: TT_RANGE_INCL_END , self :: TT_RANGE_EXCL_START , self :: TT_RANGE_EXCL_END , self :: TT_SUBQUERY_START , self :: TT_SUBQUERY_END , self :: TT_AND_LEXEME , self :: TT_OR_LEXEME , self :: TT_NOT_LEXEME , self :: TT_TO_LEXEME , self :: TT_NUMBER ) ; }
|
Returns all possible lexeme types . It s used for syntax analyzer state machine initialization
|
59,098
|
public static function loadDocxFile ( $ fileName , $ storeContent = false ) { if ( ! is_readable ( $ fileName ) ) { include_once 'Zend/Search/Lucene/Document/Exception.php' ; throw new Zend_Search_Lucene_Document_Exception ( 'Provided file \'' . $ fileName . '\' is not readable.' ) ; } return new Zend_Search_Lucene_Document_Docx ( $ fileName , $ storeContent ) ; }
|
Load Docx document from a file
|
59,099
|
private function executeQuery ( $ url , array $ data = array ( ) , array $ extra_result_data = array ( ) ) { $ request = array ( 'outboundSMSMessageRequest' => array ( 'address' => array ( sprintf ( 'tel:%s' , $ data [ 'to' ] ) ) , 'senderAddress' => sprintf ( 'tel:%s' , $ data [ 'from' ] ) , 'outboundSMSTextMessage' => array ( 'message' => $ data [ 'text' ] ) , ) , ) ; $ content = $ this -> getAdapter ( ) -> getContent ( $ url , 'POST' , $ this -> getHeaders ( ) , json_encode ( $ request ) ) ; if ( null == $ content ) { $ results = $ this -> getDefaults ( ) ; } if ( is_string ( $ content ) ) { $ content = json_decode ( $ content , true ) ; $ results [ 'id' ] = $ content [ 'outboundSMSMessageRequest' ] [ 'clientCorrelator' ] ; switch ( $ content [ 'outboundSMSMessageRequest' ] [ 'deliveryInfoList' ] [ 'deliveryInfo' ] [ 0 ] [ 'deliveryStatus' ] ) { case 'DeliveredToNetwork' : $ results [ 'status' ] = ResultInterface :: STATUS_SENT ; break ; case 'DeliveryImpossible' : $ results [ 'status' ] = ResultInterface :: STATUS_FAILED ; break ; } } return array_merge ( $ results , $ extra_result_data ) ; }
|
do the query
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.