idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
42,900
public function scaled ( $ width , $ height , $ aspectRatioMode = AspectRatioMode :: IGNORE_ASPECT_RATIO ) { switch ( $ aspectRatioMode ) { case AspectRatioMode :: IGNORE_ASPECT_RATIO : break ; case AspectRatioMode :: KEEP_ASPECT_RATIO : $ height = ( $ width * $ this -> getHeight ( ) ) / $ this -> getWidth ( ) ; break ; case AspectRatioMode :: KEEP_ASPECT_RATIO_BY_EXPANDING : $ width = ( $ height * $ this -> getWidth ( ) ) / $ this -> getHeight ( ) ; break ; } $ newResource = imagecreatetruecolor ( $ width , $ height ) ; imagealphablending ( $ newResource , false ) ; imagesavealpha ( $ newResource , true ) ; imagecopyresampled ( $ newResource , $ this -> resource , 0 , 0 , 0 , 0 , $ width , $ height , $ this -> getWidth ( ) , $ this -> getHeight ( ) ) ; $ newImage = MImage :: fromResource ( $ newResource ) ; $ newImage -> type = $ this -> type ; return $ newImage ; }
Returns a copy of the image scaled to a rectangle with the given width and height according to the given aspectRatioMode and transformMode . If either the width or the height is zero or negative this function returns a null image .
42,901
public function valid ( $ x , $ y ) { return ( $ x > 0 && $ x < $ this -> getWidth ( ) && $ y > 0 && $ y < $ this -> getHeight ( ) ) ; }
Returns true if pos is a valid coordinate pair within the image ; otherwise returns false .
42,902
private function rollbackOpeningFile ( $ temp_file = null ) { flock ( $ this -> getFile ( ) , LOCK_UN ) ; fclose ( $ this -> getFile ( ) ) ; if ( is_resource ( $ temp_file ) ) { fclose ( $ temp_file ) ; unlink ( $ this -> getTempFilePath ( ) ) ; } }
Used only when failed to open temp file in OpenFile
42,903
private function classifierExists ( $ classifier ) { if ( strpos ( $ classifier , '/' ) !== false ) { $ classifierArray = array_map ( 'strtolower' , explode ( '/' , $ classifier ) ) ; $ testArray = array_change_key_case ( $ this -> classifiers ) ; foreach ( $ testArray as $ key => $ values ) { $ testArray [ $ key ] = array_map ( 'strtolower' , $ values ) ; } if ( ! array_key_exists ( $ classifierArray [ 0 ] , $ testArray ) ) { throw new \ Exception ( "Classifier namespace {$classifierArray[0]} does not exist in Classifiers list" ) ; } if ( ! in_array ( $ classifierArray [ 1 ] , $ testArray [ $ classifierArray [ 0 ] ] ) ) { throw new \ Exception ( "Classifier {$classifierArray[1]} does not exist in Classifiers list" ) ; } return array ( $ classifierArray [ 0 ] , $ classifierArray [ 1 ] ) ; } return false ; }
Verify if the requested classifier exists
42,904
public static function classes ( array $ list = null ) { if ( $ list === null ) { $ list = Kohana :: list_files ( 'classes' ) ; } $ namespaces = Kohana :: $ config -> load ( 'userguide.namespaces' ) ; Debug :: stop ( $ namespaces ) ; $ namespaces = \ Arr :: map ( function ( $ namespace ) { $ namespace = trim ( $ namespace , '/' ) ; $ namespace = trim ( $ namespace , '\\' ) ; return str_replace ( '/' , '\\' , $ namespace ) ; } , $ namespaces ) ; $ namespaces = Arr :: flatten ( $ namespaces ) ; $ namespaces = array_unique ( $ namespaces ) ; $ classes = array ( ) ; $ ext_length = strlen ( EXT ) ; foreach ( $ list as $ name => $ path ) { if ( is_array ( $ path ) ) { $ classes += Kodoc :: classes ( $ path ) ; } elseif ( substr ( $ name , - $ ext_length ) === EXT ) { $ class = substr ( $ name , 8 , - $ ext_length ) ; $ class = str_replace ( DIRECTORY_SEPARATOR , '_' , $ class ) ; $ ret = '' ; foreach ( $ namespaces as $ namespace ) { $ _namespace = str_replace ( '\\' , '_' , $ namespace ) ; if ( mb_strpos ( $ class , $ _namespace ) === 0 ) { $ class = '\\' . $ namespace . '\\' . str_replace ( $ _namespace . '_' , '' , $ class ) ; break ; } } $ classes [ $ class ] = $ class ; } } return $ classes ; }
Returns an array of all the classes available built by listing all files in the classes folder .
42,905
public function getIncluded ( ) { $ data = [ ] ; $ include_params = $ this -> getIncludeParams ( ) ; if ( ! $ include_params ) { return $ include_params ; } foreach ( $ include_params -> getData ( ) as $ key => $ params ) { $ method = 'include' . ucfirst ( $ key ) ; $ transformer = $ this -> getTransformer ( ) ; $ allowed = $ transformer -> getAllowedIncludes ( ) ; if ( in_array ( $ key , $ allowed ) && method_exists ( $ transformer , $ method ) ) { $ result = $ transformer -> $ method ( $ this -> getData ( ) , $ params ) ; $ data [ $ key ] = $ result ; } } return $ data ; }
Get the includes to be parsed
42,906
private function getColumns ( ) { $ columns = array ( ) ; $ vars = call_user_func ( 'get_object_vars' , $ this ) ; foreach ( $ vars as $ key => $ value ) { $ columns [ ] = array ( "name" => $ key ) ; } return $ columns ; }
Helper function returns an array describing the model columns
42,907
private function getAttributes ( ) { $ attributes = array ( ) ; foreach ( $ this -> _columns as $ column ) { $ attributes [ $ column [ "name" ] ] = $ this -> { $ column [ "name" ] } ; } return $ attributes ; }
Helper function returns the model attributes as an array
42,908
private static function createModel ( $ row ) { $ table_name = get_called_class ( ) ; $ model = new $ table_name ( ) ; $ model -> setExists ( true ) ; foreach ( $ row as $ key => $ value ) { if ( ! is_int ( $ key ) ) { $ model -> $ key = $ value ; $ model -> _snapshot [ $ key ] = $ value ; } } return $ model ; }
Helper function to create and initialize a model
42,909
public static function findFirst ( $ sub_sql = null , $ params = null ) { $ params [ "find_first" ] = true ; return self :: find ( $ sub_sql , $ params ) ; }
Returns only the first model
42,910
public function save ( ) { $ di = DI :: getDefault ( ) ; $ database = $ di -> getService ( "database" ) ; if ( $ this -> _exists_in_db ) { $ query = $ database -> buildQuery ( $ this -> _table_name , "update" , array ( "columns" => $ this -> _columns ) ) ; $ attributes = $ this -> getAttributes ( ) ; $ snapshot = array ( ) ; foreach ( $ this -> _snapshot as $ key => $ value ) { $ snapshot [ "snap_" . $ key ] = $ value ; } return $ query -> execute ( array_merge ( $ attributes , $ snapshot ) ) ; } else { $ query = $ database -> buildQuery ( $ this -> _table_name , "insert" , array ( "columns" => $ this -> _columns ) ) ; $ attributes = $ this -> getAttributes ( ) ; return $ query -> execute ( $ attributes ) ; } }
Inserts or updates the database table
42,911
public function setRenderersConfig ( array $ renderers ) { foreach ( $ renderers as $ name => $ class ) { $ renderer = new $ class ; if ( ! $ renderer instanceof RendererInterface ) { throw new GeneratorServiceException ( 'Configured class of renderer must implement' . ' Infotech\DocumentGenerator\Renderer\RendererInterface interface' ) ; } $ this -> registerRenderer ( $ name , $ renderer ) ; } }
Instantiate and registering document renderers
42,912
public function setDocumentTypesConfig ( array $ documentTypes ) { foreach ( $ documentTypes as $ name => $ class ) { $ documentType = new $ class ; if ( ! $ documentType instanceof AbstractDocumentType ) { throw new GeneratorServiceException ( 'Configured class of document type must be descendant of' . ' Infotech\DocumentGenerator\DocumentType\AbstractDocumentType class' ) ; } $ this -> registerDocumentType ( $ name , $ documentType ) ; } }
Instantiate and registering document types
42,913
public function filterByFixed ( $ fixed = null , $ comparison = null ) { if ( is_string ( $ fixed ) ) { $ fixed = in_array ( strtolower ( $ fixed ) , array ( 'false' , 'off' , '-' , 'no' , 'n' , '0' , '' ) ) ? false : true ; } return $ this -> addUsingAlias ( ObjectTableMap :: COL_FIXED , $ fixed , $ comparison ) ; }
Filter the query on the fixed column
42,914
public function filterBySportId ( $ sportId = null , $ comparison = null ) { if ( is_array ( $ sportId ) ) { $ useMinMax = false ; if ( isset ( $ sportId [ 'min' ] ) ) { $ this -> addUsingAlias ( ObjectTableMap :: COL_SPORT_ID , $ sportId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ sportId [ 'max' ] ) ) { $ this -> addUsingAlias ( ObjectTableMap :: COL_SPORT_ID , $ sportId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( ObjectTableMap :: COL_SPORT_ID , $ sportId , $ comparison ) ; }
Filter the query on the sport_id column
42,915
public function filterBySkillCount ( $ skillCount = null , $ comparison = null ) { if ( is_array ( $ skillCount ) ) { $ useMinMax = false ; if ( isset ( $ skillCount [ 'min' ] ) ) { $ this -> addUsingAlias ( ObjectTableMap :: COL_SKILL_COUNT , $ skillCount [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ skillCount [ 'max' ] ) ) { $ this -> addUsingAlias ( ObjectTableMap :: COL_SKILL_COUNT , $ skillCount [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( ObjectTableMap :: COL_SKILL_COUNT , $ skillCount , $ comparison ) ; }
Filter the query on the skill_count column
42,916
public function getParameters ( ) { $ params = array ( ) ; foreach ( $ this -> parameters as $ name => $ param ) { $ params [ $ name ] = htmlentities ( $ param , ENT_QUOTES , 'UTF-8' , false ) ; } return $ params ; }
Returns an array of parameters used with the query
42,917
private function resolveHeaders ( $ headersForResolve ) { $ headers = [ ] ; foreach ( $ headersForResolve as $ name => $ value ) { if ( strpos ( $ name , 'REDIRECT_' ) === 0 ) { $ name = substr ( $ name , 9 ) ; if ( array_key_exists ( $ name , $ headersForResolve ) ) { continue ; } } if ( substr ( $ name , 0 , 5 ) == 'HTTP_' || isset ( $ this -> specialHeaders [ $ name ] ) ) { $ headers [ $ name ] = $ value ; } } return $ headers ; }
Resolve headers from provided array
42,918
public function error ( $ message , $ code = null , $ data = null ) { if ( null === $ code && isset ( $ this -> errorCodes [ $ message ] ) ) { $ code = $ this -> errorCodes [ $ message ] ; } return $ this -> getResponse ( 'error' , ( object ) array ( 'code' => $ code , 'message' => $ message , 'data' => $ data , ) ) ; }
Send error result
42,919
public function generateRouteFromText ( $ text , $ withSlash = false ) { if ( $ withSlash ) { $ result = '' ; foreach ( explode ( '/' , $ text ) as $ value ) { if ( '' !== $ value = trim ( $ value ) ) { $ result .= '/' . Urlizer :: urlize ( $ value ) ; } } return $ result ? : '/' ; } return $ this -> normalizeRoute ( Urlizer :: urlize ( $ text ) ) ; }
Generate route from text .
42,920
public function generateUniqueRoute ( RouteInterface $ route , $ withSlash = false ) { $ originalRoutePattern = $ this -> generateRouteFromText ( $ route -> getRoutePattern ( ) , $ withSlash ) ; if ( $ originalRoutePattern ) { $ key = 0 ; $ routePattern = $ this -> normalizeRoute ( $ originalRoutePattern ) ; while ( $ this -> hasRoute ( $ routePattern , $ route -> getName ( ) ) ) { $ key ++ ; $ routePattern = $ originalRoutePattern . '-' . $ key ; } $ route -> setRoutePattern ( $ routePattern ) ; return $ route ; } return null ; }
Generate unique route .
42,921
private function hasRoute ( $ routePattern , $ routeName ) { if ( ! $ routeName ) { throw new RoutingRuntimeException ( 'Route name is empty!' ) ; } $ route = $ this -> routeManager -> findByRoutePattern ( $ routePattern ) ; return ( ( null !== $ route ) && ( $ routeName !== $ route -> getName ( ) ) ) ; }
Has route .
42,922
private static function createRgbArray ( array $ vals ) { foreach ( $ vals as $ r ) { foreach ( $ vals as $ g ) { foreach ( $ vals as $ b ) { $ colors [ ] = [ 'r' => $ r , 'g' => $ g , 'b' => $ b ] ; } } } return $ colors ; }
Creates rgb codes array
42,923
private static function createHexArray ( array $ vals ) { foreach ( $ vals as $ r ) { foreach ( $ vals as $ g ) { foreach ( $ vals as $ b ) { $ colors [ ] = self :: rgbToHex ( $ r , $ g , $ b ) ; } } } return $ colors ; }
Creates hex values array
42,924
public function setWww ( bool $ www = true ) { $ this -> www = $ www ; $ this -> invoke ( "www" , $ www ) ; return $ this ; }
Use or not WWW prefix for domain
42,925
public function getMultiple ( string $ section , $ keys , $ default = null ) { $ concatted = [ ] ; foreach ( $ keys as $ key ) { $ concatted [ ] = $ section . $ this -> sectionKeyDelimiter . $ key ; } return $ this -> cacheStore -> getMultiple ( $ concatted , $ default ) ; }
Retrieves multiple config items by their unique section + keys from cache .
42,926
public function setMultiple ( string $ section , $ values ) : bool { $ concatted = [ ] ; foreach ( $ values as $ key => $ value ) { $ concatted [ $ section . $ this -> sectionKeyDelimiter . $ key ] = $ value ; } return $ this -> cacheStore -> setMultiple ( $ concatted ) ; }
Persists a set of section + key = > value pairs ; in the cache not . ini file .
42,927
public function convert ( ) { if ( empty ( $ this -> record ) || $ this -> record === false || ! $ this -> record -> exists ( ) ) { return $ this -> httpError ( 404 , _t ( 'KapostAdmin.KAPOST_CONTENT_NOT_FOUND' , '_Incoming Kapost Content could not be found' ) ) ; } return $ this -> customise ( array ( 'Title' => _t ( 'KapostAdmin.CONVERT_OBJECT' , '_Convert Object' ) , 'Content' => null , 'Form' => $ this -> ConvertObjectForm ( ) , 'KapostObject' => $ this -> record ) ) -> renderWith ( 'KapostAdmin_ConvertDialog' ) ; }
Handles requests for the convert dialog
42,928
private function getDestinationClass ( ) { if ( empty ( $ this -> record ) || $ this -> record === false ) { return false ; } $ convertToClass = false ; if ( class_exists ( $ this -> record -> DestinationClass ) && is_subclass_of ( $ this -> record -> DestinationClass , 'SiteTree' ) ) { $ convertToClass = $ this -> record -> DestinationClass ; } else { $ parentClasses = array_reverse ( ClassInfo :: dataClassesFor ( $ this -> record -> ClassName ) ) ; unset ( $ parentClasses [ $ this -> record -> ClassName ] ) ; unset ( $ parentClasses [ 'KapostObject' ] ) ; if ( count ( $ parentClasses ) > 0 ) { foreach ( $ parentClasses as $ class ) { $ sng = singleton ( $ class ) ; if ( class_exists ( $ sng -> DestinationClass ) && is_subclass_of ( $ sng -> DestinationClass , 'SiteTree' ) ) { $ convertToClass = $ sng -> DestinationClass ; break ; } } if ( isset ( $ sng ) ) { unset ( $ sng ) ; } } } return $ convertToClass ; }
Gets the destination class for the record
42,929
private function cleanUpExpiredPreviews ( ) { $ expiredPreviews = KapostObject :: get ( ) -> filter ( 'IsKapostPreview' , true ) -> filter ( 'LastEdited:LessThan' , date ( 'Y-m-d H:i:s' , strtotime ( '-' . ( KapostService :: config ( ) -> preview_data_expiry ) . ' minutes' ) ) ) ; if ( $ expiredPreviews -> count ( ) > 0 ) { foreach ( $ expiredPreviews as $ kapostObj ) { $ kapostObj -> delete ( ) ; } } }
Cleans up expired Kapost previews after twice the token expiry
42,930
public function getPreviousRunDate ( $ currentTime = 'now' , $ nth = 0 , $ allowCurrentDate = false ) { return $ this -> getRunDate ( $ currentTime , $ nth , true , $ allowCurrentDate ) ; }
Get a previous run date relative to the current date or a specific date
42,931
protected function getRunDate ( $ currentTime = null , $ nth = 0 , $ invert = false , $ allowCurrentDate = false ) { if ( $ currentTime instanceof DateTime ) { $ currentDate = clone $ currentTime ; } elseif ( $ currentTime instanceof DateTimeImmutable ) { $ currentDate = DateTime :: createFromFormat ( 'U' , $ currentTime -> format ( 'U' ) ) ; $ currentDate -> setTimezone ( $ currentTime -> getTimezone ( ) ) ; } else { $ currentDate = new DateTime ( $ currentTime ? : 'now' ) ; $ currentDate -> setTimezone ( new DateTimeZone ( date_default_timezone_get ( ) ) ) ; } $ currentDate -> setTime ( $ currentDate -> format ( 'H' ) , $ currentDate -> format ( 'i' ) , 0 ) ; $ nextRun = clone $ currentDate ; $ nth = ( int ) $ nth ; $ parts = array ( ) ; $ fields = array ( ) ; foreach ( self :: $ order as $ position ) { $ part = $ this -> getExpression ( $ position ) ; if ( null === $ part || '*' === $ part ) { continue ; } $ parts [ $ position ] = $ part ; $ fields [ $ position ] = $ this -> fieldFactory -> getField ( $ position ) ; } for ( $ i = 0 ; $ i < $ this -> maxIterationCount ; $ i ++ ) { foreach ( $ parts as $ position => $ part ) { $ satisfied = false ; $ field = $ fields [ $ position ] ; if ( strpos ( $ part , ',' ) === false ) { $ satisfied = $ field -> isSatisfiedBy ( $ nextRun , $ part ) ; } else { foreach ( array_map ( 'trim' , explode ( ',' , $ part ) ) as $ listPart ) { if ( $ field -> isSatisfiedBy ( $ nextRun , $ listPart ) ) { $ satisfied = true ; break ; } } } if ( ! $ satisfied ) { $ field -> increment ( $ nextRun , $ invert , $ part ) ; continue 2 ; } } if ( ( ! $ allowCurrentDate && $ nextRun == $ currentDate ) || -- $ nth > - 1 ) { $ this -> fieldFactory -> getField ( 0 ) -> increment ( $ nextRun , $ invert , isset ( $ parts [ 0 ] ) ? $ parts [ 0 ] : null ) ; continue ; } return $ nextRun ; } throw new RuntimeException ( 'Impossible CRON expression' ) ; }
Get the next or previous run date of the expression relative to a date
42,932
public static function getV4 ( ) { return sprintf ( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0x0fff ) | 0x4000 , mt_rand ( 0 , 0x3fff ) | 0x8000 , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) ) ; }
Get a UUID v4 .
42,933
public function handle ( ) { foreach ( $ this -> loaders as $ loader ) { if ( $ language = call_user_func ( $ loader ) ) { if ( in_array ( $ language , $ this -> supportedLanguages ) ) { return $ language ; } $ special = strpos ( $ language , '-' ) !== false ; if ( $ special && $ this -> allowFallback && in_array ( substr ( $ language , 0 , 2 ) , $ this -> supportedLanguages ) ) { return substr ( $ language , 0 , 2 ) ; } if ( ! $ special && $ this -> allowAdvance ) { foreach ( $ this -> supportedLanguages as $ supportedLanguage ) { if ( $ language === substr ( $ supportedLanguage , 0 , 2 ) ) { return $ supportedLanguage ; } } } } } return false ; }
Run all loaders returns a language string or false .
42,934
protected function loadFromHttpHeader ( ) { foreach ( Yii :: $ app -> request -> getAcceptableLanguages ( ) as $ language ) { if ( in_array ( $ language , $ this -> supportedLanguages ) ) { return $ language ; } } return false ; }
Load language from HTTP header .
42,935
protected function loadFromCookie ( ) { if ( $ this -> cookieLanguageField && ( $ language = Yii :: $ app -> request -> cookies -> has ( $ this -> cookieLanguageField ) ) ) { return $ language ; } return false ; }
Load language from client cookie .
42,936
protected function loadFromQueryParam ( ) { if ( ! $ this -> queryParamField ) { return false ; } if ( Yii :: $ app -> state < WebApplication :: STATE_HANDLING_REQUEST ) { Yii :: $ app -> request -> resolve ( ) ; } if ( ( $ language = Yii :: $ app -> request -> get ( $ this -> queryParamField , false ) ) ) { return $ language ; } return false ; }
Load language from url query param .
42,937
protected function loadFromUri ( ) { if ( ! $ this -> uriPosition ) { return false ; } $ url = Yii :: $ app -> request -> getAbsoluteUrl ( ) ; $ parse = parse_url ( $ url ) ; if ( ! empty ( $ parse ) ) { $ path = explode ( '/' , trim ( $ parse [ 'path' ] ) , $ this -> uriPosition + 1 ) ; is_string ( $ path ) and $ path = [ $ path ] ; if ( isset ( $ parse [ $ this -> uriPosition - 1 ] ) ) { return $ parse [ 0 ] ; } } return false ; }
Load language from uri position .
42,938
protected static function getInfo ( ) { $ files = self :: getFiles ( ) ; foreach ( $ files as $ path ) { $ data = self :: convert ( self :: readFile ( $ path . '/vinala.json' ) , $ path ) ; $ data = $ data [ 'system' ] ; $ data [ 'path' ] = $ path ; if ( array_key_exists ( 'alias' , $ data ) ) { self :: $ infos [ $ data [ 'alias' ] ] = $ data ; } else { } } return self :: $ infos ; }
Get infos about plug - ins .
42,939
protected static function convert ( $ string , $ path ) { $ data = json_decode ( $ string , true ) ; if ( json_last_error ( ) == JSON_ERROR_SYNTAX ) { throw new InfoStructureException ( $ path ) ; } return $ data ; }
Convert JSON to PHP array .
42,940
protected static function getFiles ( ) { $ files = [ ] ; foreach ( glob ( Application :: $ root . 'plugins/*' ) as $ value ) { $ files [ ] = $ value ; } return $ files ; }
Get all info files path .
42,941
public static function setAlias ( $ alias ) { if ( self :: isConfigKeyExist ( $ alias , 'shortcuts' ) ) { $ shortcuts = self :: $ config [ $ alias ] [ 'shortcuts' ] ; foreach ( $ shortcuts as $ alias => $ target ) { $ target = Strings :: replace ( $ target , '/' , '\\' ) ; Alias :: set ( $ target , $ alias ) ; } } }
Set classes aliases .
42,942
public static function getCore ( $ alias , $ param ) { if ( self :: isInfoKeyExist ( $ alias , 'core' , $ param ) ) { return self :: $ infos [ $ alias ] [ 'core' ] [ $ param ] ; } else { return ; } }
Get core .
42,943
public function getFilters ( ) { return [ new \ Twig_SimpleFilter ( 'truncate' , function ( $ value , $ len = 75 , $ ter = '...' , $ preserve = false ) { return \ Slick \ Template \ Utils \ Text :: truncate ( $ value , $ len , $ ter , $ preserve ) ; } ) , new \ Twig_SimpleFilter ( 'wordwrap' , function ( $ value , $ length = 75 , $ break = "\n" , $ cut = false ) { return \ Slick \ Template \ Utils \ Text :: wordwrap ( $ value , $ length , $ break , $ cut ) ; } ) ] ; }
Returns a list of filters
42,944
public function setSatisfied ( $ bool = true ) { $ storage = $ this -> getStorage ( ) -> read ( ) ? : [ ] ; $ storage [ 'is_satisfied' ] = $ bool ; $ this -> getStorage ( ) -> write ( $ storage ) ; return $ this ; }
Set if this adapter is satisfied or not
42,945
function it_tokenize_templates ( ) { $ this -> tokenize ( new Cursor ( "TEXT <{ ... . keyword 'string' \"string\" 3.14 var null true false }> TEXT" ) ) -> shouldBeLike ( [ new Token ( Token :: TYPE_TEXT , 'TEXT ' , 1 ) , new Token ( Token :: TYPE_OPEN_TAG | Token :: TYPE_SYMBOL , '<{' , 1 ) , new Token ( Token :: TYPE_SYMBOL , '...' , 1 ) , new Token ( Token :: TYPE_SYMBOL , '.' , 1 ) , new Token ( Token :: TYPE_KEYWORD | Token :: TYPE_IDENTIFIER , 'keyword' , 1 ) , new Token ( Token :: TYPE_STRING | Token :: TYPE_SINGLE_QUOTED , 'string' , 1 ) , new Token ( Token :: TYPE_STRING | Token :: TYPE_DOUBLE_QUOTED , 'string' , 1 ) , new Token ( Token :: TYPE_NUMBER , '3.14' , 1 ) , new Token ( Token :: TYPE_IDENTIFIER , 'var' , 1 ) , new Token ( Token :: TYPE_CONSTANT , 'null' , 1 ) , new Token ( Token :: TYPE_CONSTANT , 'true' , 1 ) , new Token ( Token :: TYPE_CONSTANT , 'false' , 1 ) , new Token ( Token :: TYPE_CLOSE_TAG | Token :: TYPE_SYMBOL , '}>' , 1 ) , new Token ( Token :: TYPE_TEXT , ' TEXT' , 1 ) , new Token ( Token :: TYPE_EOF , null , 1 ) , ] ) ; }
It tokenize templates .
42,946
protected function optimizeUrls ( $ content , $ file ) { preg_match_all ( '/url\((.[^\)]*)\)/is' , $ content , $ matches , PREG_SET_ORDER ) ; foreach ( $ matches as $ match ) { $ uri = $ match [ 1 ] ; if ( strpos ( $ uri , '\'' ) === 0 || strpos ( $ uri , '"' ) === 0 ) { $ uri = substr ( $ uri , 1 , - 1 ) ; } if ( strpos ( $ uri , 'http' ) === 0 ) { continue ; } $ additionalData = $ this -> getAdditionalUriData ( $ uri ) ; $ uri = $ this -> removeAdditionalUriData ( $ uri ) ; $ path = dirname ( $ file ) ; $ fullFilePath = realpath ( $ path . '/' . $ uri ) ; $ fileInformation = pathinfo ( $ fullFilePath ) ; $ imageExtensions = array ( 'png' , 'jpg' , 'jpeg' , 'gif' ) ; if ( in_array ( $ fileInformation [ 'extension' ] , $ imageExtensions ) ) { $ fileContent = $ this -> fileBackend -> loadFromFile ( $ fullFilePath ) ; $ encodedContent = base64_encode ( $ fileContent ) ; $ urlData = 'data:image/gif;base64,' . $ encodedContent ; $ content = str_replace ( $ match [ 1 ] , '\'' . $ urlData . '\'' , $ content ) ; } else { $ type = AssetManager :: BINARY ; $ cachedFile = $ this -> assetCacheManager -> generateCachedFile ( $ type , $ fullFilePath ) ; $ url = $ this -> assetCacheManager -> getUrlToTheAssetLoader ( $ cachedFile [ 'file' ] ) ; if ( $ additionalData !== '' ) { $ url .= $ additionalData ; } $ content = str_replace ( $ match [ 1 ] , '\'' . $ url . '\'' , $ content ) ; } } return $ content ; }
Optimizes the urls in the css content .
42,947
protected function getAdditionalUriData ( $ uri ) { if ( strpos ( $ uri , '?' ) !== false ) { return substr ( $ uri , strpos ( $ uri , '?' ) ) ; } else if ( strpos ( $ uri , '#' ) !== false ) { return substr ( $ uri , strpos ( $ uri , '#' ) ) ; } return '' ; }
Returns the additional uri data of the given uri .
42,948
protected function removeAdditionalUriData ( $ uri ) { if ( strpos ( $ uri , '?' ) !== false ) { return substr ( $ uri , 0 , strpos ( $ uri , '?' ) ) ; } else if ( strpos ( $ uri , '#' ) !== false ) { return substr ( $ uri , 0 , strpos ( $ uri , '#' ) ) ; } return $ uri ; }
Returns the uri without any additional uri data .
42,949
public function createConversionHistory ( $ destinationID ) { $ obj = new KapostConversionHistory ( ) ; $ obj -> Title = $ this -> Title ; $ obj -> KapostChangeType = $ this -> KapostChangeType ; $ obj -> KapostRefID = $ this -> KapostRefID ; $ obj -> KapostAuthor = $ this -> KapostAuthor ; $ obj -> DestinationType = $ this -> DestinationClass ; $ obj -> DestinationID = $ destinationID ; $ obj -> ConverterName = Member :: currentUser ( ) -> Name ; $ obj -> write ( ) ; return $ obj ; }
Used for recording a conversion history record
42,950
public function renderPreview ( ) { $ previewFieldMap = array ( 'ClassName' => $ this -> DestinationClass , 'IsKapostPreview' => true , 'Children' => false , 'Menu' => false , 'MetaTags' => false , 'Breadcrumbs' => false , 'current_stage' => Versioned :: current_stage ( ) , 'SilverStripeNavigator' => false ) ; $ extensions = $ this -> extend ( 'updatePreviewFieldMap' ) ; $ extensions = array_filter ( $ extensions , function ( $ v ) { return ! is_null ( $ v ) && is_array ( $ v ) ; } ) ; if ( count ( $ extensions ) > 0 ) { foreach ( $ extensions as $ ext ) { $ previewFieldMap = array_merge ( $ previewFieldMap , $ ext ) ; } } $ ancestry = ClassInfo :: ancestry ( $ this -> DestinationClass ) ; while ( $ class = array_pop ( $ ancestry ) ) { if ( class_exists ( $ class . "_Controller" ) ) { break ; } } $ controller = ( $ class !== null ? "{$class}_Controller" : "ContentController" ) ; return $ controller :: create ( $ this ) -> customise ( $ previewFieldMap ) ; }
Handles rendering of the preview for this object
42,951
public static function findByName ( $ tags , string $ group = null , string $ locale = null ) : Collection { $ locale = $ locale ?? app ( ) -> getLocale ( ) ; return collect ( Taggable :: parseDelimitedTags ( $ tags ) ) -> map ( function ( string $ tag ) use ( $ group , $ locale ) { return ( $ exists = static :: firstByName ( $ tag , $ group , $ locale ) ) ? $ exists -> getKey ( ) : null ; } ) -> filter ( ) -> unique ( ) ; }
Find tag by name .
42,952
public static function firstByName ( string $ tag , string $ group = null , string $ locale = null ) { $ locale = $ locale ?? app ( ) -> getLocale ( ) ; return static :: query ( ) -> where ( "name->{$locale}" , $ tag ) -> when ( $ group , function ( Builder $ builder ) use ( $ group ) { return $ builder -> where ( 'group' , $ group ) ; } ) -> first ( ) ; }
Get first tag by name .
42,953
protected function findMatchingMethods ( \ ReflectionClass $ reflectedClass , MethodSelector $ selector ) { try { return $ this -> findMatchingMethodsImpl ( $ reflectedClass , $ selector ) ; } catch ( UnsupportedMatcher $ e ) { throw new UnableToBuild ( ) ; } }
Finds all methods matching the given selector .
42,954
protected function computeCredentialsName ( $ prefix = null ) { if ( ! $ prefix ) { $ paths = $ this -> get ( 'paths' ) ; if ( $ paths && isset ( $ paths [ 'default' ] ) ) { $ prefix = $ paths [ 'default' ] ; } } preg_match ( '/([http:\/\/|https:\/\/|ssh:\/\/])*(\w@)*([\w\.\-_]{1,}+)/' , $ prefix , $ prefix ) ; if ( count ( $ prefix ) ) return end ( $ prefix ) ; return basename ( $ this -> repository -> getDir ( ) ) ; }
Compute the repository credentials name
42,955
protected function rm ( $ configOption ) { if ( isset ( $ this -> configuration [ $ configOption ] ) ) unset ( $ this -> configuration [ $ configOption ] ) ; return $ this ; }
Remove a config option
42,956
protected function save ( ) { if ( $ fileConfig = @ fopen ( $ this -> repository -> getDir ( ) . $ this -> repository -> getFileConfig ( ) . "hgrc" , 'w+' ) ) { $ ret = fwrite ( $ fileConfig , $ this -> arr2ini ( $ this -> configuration ) ) ; fclose ( $ fileConfig ) ; return $ ret ; } return false ; }
Save the config to file
42,957
protected function registerTranslator ( ) { $ this -> getContainer ( ) -> share ( 'translator' , function ( ) { $ translator = new Translator ( 'en' ) ; $ translator -> addLoader ( 'php' , new PhpFileLoader ( ) ) ; return $ translator ; } ) ; }
Register the session manager instance .
42,958
private function removeUnrealizableInArray ( array & $ array ) { $ this -> removeReferenceItemInArray ( $ array ) ; foreach ( $ array as & $ value ) { if ( is_object ( $ value ) ) { $ value = $ this -> removeUnserializable ( $ value ) ; } if ( is_array ( $ value ) ) { $ this -> removeUnrealizableInArray ( $ value ) ; } if ( $ this -> isUnserializable ( $ value ) ) { $ value = null ; } } return $ array ; }
remove Unrealizable In Array
42,959
private function removeReferenceItemInArray ( array & $ room ) { $ roomCopy = $ room ; $ keys = array_keys ( $ room ) ; foreach ( $ keys as $ key ) { if ( is_array ( $ roomCopy [ $ key ] ) ) { $ roomCopy [ $ key ] [ '_test' ] = true ; if ( isset ( $ room [ $ key ] [ '_test' ] ) ) { unset ( $ room [ $ key ] ) ; } } } }
Remove reference item in array
42,960
public function setBundleInfo ( array $ bundleInfo ) { $ this -> kernel -> setDrupalBundles ( $ this -> getAutoloadedBundles ( $ bundleInfo ) ) ; $ this -> bundlesBooted = false ; }
Set bundle info
42,961
public function getContainer ( ) { $ this -> kernel -> boot ( ) ; if ( ! $ this -> bundlesBooted ) { foreach ( $ this -> kernel -> getBundles ( ) as $ bundle ) { $ bundle -> boot ( ) ; } $ this -> bundlesBooted = true ; } return $ this -> kernel -> getContainer ( ) ; }
Retrieves the container
42,962
public function flushCaches ( $ all = false ) { $ dir = $ this -> kernel -> getCacheDir ( ) ; if ( $ all ) { $ dir .= '/..' ; } $ fs = new Filesystem ( ) ; $ fs -> remove ( realpath ( $ dir ) ) ; }
Cleanup cache files
42,963
private function copyStringToFlag ( $ value ) : int { switch ( true ) { case 'true' === $ value : case true === $ value : case 'yes' === $ value : return CopyDictionaryJob :: COPY ; case 'no' === $ value : case 'false' === $ value : case false === $ value : return CopyDictionaryJob :: DO_NOT_COPY ; case 'if-empty' === $ value : return CopyDictionaryJob :: COPY_IF_EMPTY ; default : throw new \ InvalidArgumentException ( 'Invalid value for copy flag.' ) ; } }
Convert the passed value to a copy flag .
42,964
private function boolishToFlag ( $ value ) : bool { switch ( true ) { case 'true' === $ value : case true === $ value : case 'yes' === $ value : return true ; case 'no' === $ value : case 'false' === $ value : case false === $ value : return false ; default : throw new \ InvalidArgumentException ( 'Invalid value for remove-obsolete flag.' ) ; } }
Convert the passed value to a bool .
42,965
public function isLogined ( ) { $ session = $ this -> getSession ( ) ; $ cookie = $ this -> getCookie ( ) ; if ( $ cookie -> has ( self :: USER_SESSION ) ) { $ login = $ cookie -> get ( self :: USER_SESSION ) ; $ login = unserialize ( base64_decode ( $ login ) ) ; } elseif ( false !== $ session -> has ( self :: USER_SESSION ) ) { $ login = $ session -> get ( self :: USER_SESSION ) ; } else { return false ; } return $ this -> isSameIp ( $ login ) ; }
check is login usered
42,966
public function hasRole ( $ role = '' ) { $ session = $ this -> getSession ( ) ; $ cookie = $ this -> getCookie ( ) ; if ( $ cookie -> has ( self :: USER_SESSION ) ) { $ login = $ cookie -> get ( self :: USER_SESSION ) ; } elseif ( false !== $ session -> has ( self :: USER_SESSION ) ) { $ login = $ session -> get ( self :: USER_SESSION ) ; } else { return false ; } $ roleLogin = $ login [ 'role' ] ; if ( is_string ( $ role ) ) { return $ roleLogin === $ role ; } elseif ( is_array ( $ role ) ) { return array_search ( $ roleLogin , $ role ) ; } return false ; }
check the user role
42,967
public function viewFile ( ProcessBuilder $ processBuilder , $ filePath ) { $ proc = $ processBuilder -> setPrefix ( $ this -> _pagerCommand ) -> setArguments ( [ $ filePath ] ) -> getProcess ( ) ; $ proc -> setTty ( true ) -> run ( ) ; return $ proc ; }
View the given file using the symfony process builder to build the symfony process to execute .
42,968
public function viewData ( ProcessBuilder $ processBuilder , $ data ) { $ proc = $ processBuilder -> setPrefix ( $ this -> _pagerCommand ) -> setInput ( $ data ) -> getProcess ( ) ; $ proc -> setTty ( true ) -> run ( ) ; return $ proc ; }
View the given data using the symfony process builder to build the symfony process to execute .
42,969
public function pollFeed ( $ url ) { $ self = $ this ; $ eventEmitter = $ this -> getEventEmitter ( ) ; $ logger = $ this -> getLogger ( ) ; $ logger -> info ( 'Sending request for feed URL' , array ( 'url' => $ url ) ) ; $ request = new HttpRequest ( array ( 'url' => $ url , 'resolveCallback' => function ( $ data ) use ( $ url , $ self ) { $ self -> processFeed ( $ url , $ data ) ; } , 'rejectCallback' => function ( $ error ) use ( $ url , $ self ) { $ self -> processFailure ( $ url , $ error ) ; } ) ) ; $ eventEmitter -> emit ( 'http.request' , array ( $ request ) ) ; }
Polls an individual feed for new content to syndicate to channels or users .
42,970
public function processFeed ( $ url , $ data ) { $ logger = $ this -> getLogger ( ) ; $ logger -> info ( 'Processing feed' , array ( 'url' => $ url ) ) ; $ logger -> debug ( 'Received feed data' , array ( 'data' => $ data ) ) ; try { $ new = iterator_to_array ( FeedReader :: importString ( $ data ) ) ; $ old = isset ( $ this -> cache [ $ url ] ) ? $ this -> cache [ $ url ] : array ( ) ; $ diff = $ this -> getNewFeedItems ( $ new , $ old ) ; if ( $ old ) { $ this -> syndicateFeedItems ( $ diff ) ; } $ this -> cache [ $ url ] = $ new ; } catch ( \ Exception $ e ) { $ logger -> warning ( 'Failed to process feed' , array ( 'url' => $ url , 'data' => $ data , 'error' => $ e , ) ) ; } $ this -> queuePoll ( $ url ) ; }
Processes content from successfully polled feeds .
42,971
protected function getNewFeedItems ( array $ new , array $ old ) { $ map = array ( ) ; $ getKey = function ( $ item ) { return $ item -> getPermalink ( ) ; } ; $ logger = $ this -> getLogger ( ) ; foreach ( $ new as $ item ) { $ key = $ getKey ( $ item ) ; $ logger -> debug ( 'New: ' . $ key ) ; $ map [ $ key ] = $ item ; } foreach ( $ old as $ item ) { $ key = $ getKey ( $ item ) ; $ logger -> debug ( 'Old: ' . $ key ) ; unset ( $ map [ $ key ] ) ; } $ logger -> debug ( 'Diff: ' . implode ( ' ' , array_keys ( $ map ) ) ) ; return array_values ( $ map ) ; }
Locates new items in a feed given newer and older lists of items from the feed .
42,972
protected function syndicateFeedItems ( array $ items ) { $ messages = array ( ) ; foreach ( $ items as $ item ) { $ messages [ ] = $ this -> formatter -> format ( $ item ) ; } foreach ( $ this -> targets as $ connection => $ targets ) { $ this -> getEventQueue ( $ connection ) -> then ( function ( $ queue ) use ( $ targets , $ messages ) { foreach ( $ targets as $ target ) { foreach ( $ messages as $ message ) { $ queue -> ircPrivmsg ( $ target , $ message ) ; } } } ) ; } }
Syndicates a given list of feed items to all targets .
42,973
public function processFailure ( $ url , $ error ) { $ this -> getLogger ( ) -> warning ( 'Failed to poll feed' , array ( 'url' => $ url , 'error' => $ error , ) ) ; $ this -> queuePoll ( $ url ) ; }
Logs feed poll failures .
42,974
protected function queuePoll ( $ url ) { $ self = $ this ; $ this -> loop -> addTimer ( $ this -> interval , function ( ) use ( $ url , $ self ) { $ self -> pollFeed ( $ url ) ; } ) ; }
Sets up a callback to poll a specified feed .
42,975
protected function getEventQueueDeferred ( $ mask ) { if ( ! isset ( $ this -> queues [ $ mask ] ) ) { $ this -> queues [ $ mask ] = new Deferred ; } return $ this -> queues [ $ mask ] ; }
Creates a deferred for the event queue of a given connection .
42,976
public function setEventQueue ( Event $ event , Queue $ queue ) { $ mask = $ this -> getConnectionMask ( $ event -> getConnection ( ) ) ; $ this -> getEventQueueDeferred ( $ mask ) -> resolve ( $ queue ) ; }
Stores a reference to the event queue for the connection on which a USER event occurs .
42,977
protected function getUrls ( array $ config ) { if ( ! isset ( $ config [ 'urls' ] ) || ! is_array ( $ config [ 'urls' ] ) || array_filter ( $ config [ 'urls' ] , 'is_string' ) != $ config [ 'urls' ] ) { throw new \ DomainException ( 'urls must be a list of strings containing feed URLs' , self :: ERR_URLS_INVALID ) ; } return $ config [ 'urls' ] ; }
Extracts feed URLs from configuration .
42,978
protected function getTargets ( array $ config ) { if ( ! isset ( $ config [ 'targets' ] ) || ! is_array ( $ config [ 'targets' ] ) || array_filter ( $ config [ 'targets' ] , 'is_array' ) != $ config [ 'targets' ] ) { throw new \ DomainException ( 'targets must be an array of arrays' , self :: ERR_TARGETS_INVALID ) ; } return $ config [ 'targets' ] ; }
Extracts targets from configuration .
42,979
protected function getInterval ( array $ config ) { if ( isset ( $ config [ 'interval' ] ) ) { if ( ! is_int ( $ config [ 'interval' ] ) || $ config [ 'interval' ] <= 0 ) { throw new \ DomainException ( 'interval must reference a positive integer value' , self :: ERR_INTERVAL_INVALID ) ; } return $ config [ 'interval' ] ; } return 300 ; }
Extracts the interval on which to update feeds from configuration .
42,980
protected function getFormatter ( array $ config ) { if ( isset ( $ config [ 'formatter' ] ) ) { if ( ! $ config [ 'formatter' ] instanceof FormatterInterface ) { throw new \ DomainException ( 'formatter must implement ' . __NAMESPACE__ . '\FormatterInterface' , self :: ERR_FORMATTER_INVALID ) ; } return $ config [ 'formatter' ] ; } return new DefaultFormatter ; }
Extracts the feed item formatter from configuration .
42,981
public static function loadConfigFiles ( ) { if ( self :: isTenant ( ) ) { if ( file_exists ( TENANT_PATH . DS . self :: getSiteName ( ) . DS . 'settings.ini' ) ) { App :: uses ( 'IniReader' , 'Configure' ) ; Configure :: config ( 'ini' , new IniReader ( TENANT_PATH . DS . self :: getSiteName ( ) . DS ) ) ; Configure :: load ( 'settings' , 'ini' ) ; App :: uses ( 'CakeNumber' , 'Utility' ) ; CakeNumber :: defaultCurrency ( Configure :: read ( 'Geo.currency_code' ) ) ; } else { throw new CakeException ( "El archivo de configuracion para el sitio " . self :: getSiteName ( ) . " no pudo ser encontrado" ) ; } } }
Loads settings files from Tenant folder
42,982
public static function count ( $ data = false ) { if ( $ data && Validate :: isArray ( $ data ) ) { return count ( $ data ) ; } else if ( $ data && Validate :: isObject ( $ data ) ) { return count ( get_object_vars ( $ data ) ) ; } return 0 ; }
Count the numbers of keys in a given array or object .
42,983
public static function keys ( $ data = false ) { if ( $ data && Validate :: isArray ( $ data ) ) { return array_keys ( $ data ) ; } else if ( $ data && Validate :: isObject ( $ data ) ) { return get_object_vars ( $ data ) ; } return false ; }
Get all keys from a given array or object .
42,984
public static function random ( $ data = false ) { if ( $ data ) { if ( Validate :: isObject ( $ data ) ) { $ data = Format :: objectToArray ( $ data ) ; } if ( Validate :: isArray ( $ data ) ) { return $ data [ array_rand ( $ data , 1 ) ] ; } } return false ; }
Return a random value from a given array or object .
42,985
public function sanitize ( $ input = false ) { if ( $ input ) { if ( Validate :: isArray ( $ input ) ) { return filter_var_array ( $ input , FILTER_SANITIZE_STRING ) ; } if ( Validate :: isString ( $ input ) ) { return filter_var ( $ input , FILTER_SANITIZE_STRING ) ; } } return false ; }
Sanitize input .
42,986
public static function type ( $ data = false ) { if ( $ data ) { $ dataType = gettype ( $ data ) ; if ( $ dataType === 'string' ) { if ( Validate :: isJson ( $ data ) ) { $ dataType = 'json' ; } } return $ dataType ; } return false ; }
Return type of a given variable .
42,987
public function display ( $ tpl = null ) { $ attributes = array ( ) ; $ query = array ( ) ; $ app = JFactory :: getApplication ( ) ; $ input = $ app -> input ; $ routeName = $ input -> get ( 'route' , null , 'string' ) ; $ path = $ input -> get ( 'path' , null , 'string' ) ; $ route = self :: $ router -> getRouteCollection ( ) -> get ( $ routeName ) ; $ defaults = $ route -> getDefaults ( ) ; if ( $ path !== null ) { $ path = rtrim ( $ route -> getPath ( ) , '/' ) . '/' . $ path ; $ defaults = self :: $ router -> match ( $ path , null , false ) ; } unset ( $ attributes [ '_controller' ] ) ; foreach ( $ defaults as $ key => $ default ) { if ( ! isset ( $ attributes [ $ key ] ) ) { $ attributes [ $ key ] = $ default ; } } $ subRequest = self :: $ requestStack -> getCurrentRequest ( ) -> duplicate ( $ query , null , $ attributes ) ; $ this -> response = self :: $ kernel -> handle ( $ subRequest , \ Symfony \ Component \ HttpKernel \ HttpKernelInterface :: SUB_REQUEST , false ) ; parent :: display ( $ tpl ) ; }
Display the Hello World view
42,988
public function render ( $ options = array ( ) ) { $ pattern = $ options [ 'pattern' ] ; $ data = $ options [ 'data' ] ; return $ this -> renderTpl ( $ pattern , $ data ) ; }
Render a pattern .
42,989
public function preparePassword ( ) { $ this -> { $ this -> securePasswordField } = crypt ( $ this -> { $ this -> securePasswordField } , '$2y$10$' . sha1 ( microtime ( ) . $ this -> username . $ this -> email ) . '$' ) ; }
Crypts the users password .
42,990
private static function registerUsersAdmin ( ) { if ( ! Gate :: allows ( 'users_read' ) ) { return ; } Agencms :: registerRoute ( Route :: init ( 'users' , [ 'Users' => 'Manage Users' ] , '/agencms-auth/users' ) -> icon ( 'person' ) -> addGroup ( Group :: large ( 'Details' ) -> addField ( Field :: number ( 'id' , 'Id' ) -> readonly ( ) -> list ( ) , Field :: string ( 'name' , 'Name' ) -> medium ( ) -> required ( ) -> list ( ) , Field :: string ( 'email' , 'Email' ) -> medium ( ) -> required ( ) -> list ( ) , Field :: related ( 'roleids' , 'Roles' ) -> model ( Relationship :: make ( 'roles' ) ) ) , Group :: small ( 'Extra' ) -> addField ( Field :: boolean ( 'active' , 'Active' ) -> list ( ) , Field :: image ( 'avatar' , 'Profile Picture' ) -> ratio ( 600 , 600 , $ resize = true ) ) ) ) ; }
Register the Agencms endpoints for User administration
42,991
private static function registerUserProfile ( ) { Agencms :: registerRoute ( Route :: initSingle ( 'profile' , '' , '/agencms-auth/profile' ) -> icon ( 'person' ) -> addGroup ( Group :: large ( 'Details' ) -> addField ( Field :: number ( 'id' , 'Id' ) -> readonly ( ) -> list ( ) , Field :: string ( 'name' , 'Name' ) -> medium ( ) -> required ( ) -> list ( ) , Field :: string ( 'email' , 'Email' ) -> medium ( ) -> readonly ( ) -> list ( ) ) , Group :: small ( 'Extra' ) -> addField ( Field :: image ( 'avatar' , 'Profile Picture' ) -> ratio ( 600 , 600 , $ resize = true ) ) ) ) ; }
Register the Agencms endpoints for the User s account profile
42,992
public function get_view_path ( ) { return $ this -> _element -> view ? $ this -> _element -> view : self :: VIEWS_DIR . DIRECTORY_SEPARATOR . $ this -> _template_dir . DIRECTORY_SEPARATOR . $ this -> template ; }
Get the path of the view file
42,993
public static function average ( $ array = false , $ decimals = 2 ) { if ( $ array && Validate :: isArray ( $ array ) ) { return self :: round ( ( array_sum ( $ array ) / count ( $ array ) ) , $ decimals ) ; } return false ; }
Get the average value of a given array .
42,994
public static function max ( $ array = false , $ decimals = 3 ) { if ( $ array && Validate :: isArray ( $ array ) ) { return self :: round ( max ( $ array ) , $ decimals ) ; } return false ; }
Get the heighest value of a given array .
42,995
public static function min ( $ array = false , $ decimals = 3 ) { if ( $ array && Validate :: isArray ( $ array ) ) { return self :: round ( min ( $ array ) , $ decimals ) ; } return false ; }
Get the lowest value of a given array .
42,996
public static function percentage ( $ number1 = false , $ number2 = false , $ decimals = 2 ) { if ( $ number1 && $ number2 ) { return self :: round ( ( $ number1 / $ number2 ) * 100 , $ decimals ) ; } return false ; }
Get the percentage .
42,997
public static function round ( $ number = false , $ decimals = false ) { if ( $ number ) { return number_format ( ( float ) $ number , $ decimals ) ; } return false ; }
Get a round number .
42,998
public static function total ( $ array = false , $ decimals = 2 ) { if ( $ array && Validate :: isArray ( $ array ) ) { return self :: round ( array_sum ( $ array ) , $ decimals ) ; } return false ; }
Get the sum total of a given array s values .
42,999
public function execute ( ResponseInterface $ httpResponse ) { $ headerFunction = $ this -> headerFunction ; $ bodyFunction = $ this -> bodyFunction ; $ headerFunction ( 'HTTP/' . $ httpResponse -> getProtocolVersion ( ) . ' ' . $ httpResponse -> getStatusCode ( ) . ' ' . $ httpResponse -> getReasonPhrase ( ) ) ; foreach ( $ httpResponse -> getHeaders ( ) as $ name => $ values ) { foreach ( $ values as $ value ) { $ headerFunction ( sprintf ( '%s: %s' , $ name , $ value ) ) ; } } $ bodyFunction ( $ httpResponse -> getBody ( ) ) ; }
Process a ResponseInterface into an output .