idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
30,700
public function delete ( $ request , $ match ) { $ model = Pluf_Shortcuts_GetObjectOr404 ( 'User_Role' , $ match [ 'id' ] ) ; $ model2 = new User_Role ( $ match [ 'id' ] ) ; if ( $ model -> delete ( ) ) { return new Pluf_HTTP_Response_Json ( $ model2 ) ; } throw new Pluf_HTTP_Error500 ( 'Unexpected error while removing role: ' . $ model2 -> code_name ) ; }
Deletes a role .
30,701
public static function closeLoggerStream ( $ type = SEASLOG_CLOSE_LOGGER_STREAM_MOD_ALL , string $ name = '' ) : bool { if ( empty ( $ name ) ) { return SeasLog :: closeLoggerStream ( $ type ) ; } return SeasLog :: closeLoggerStream ( $ type , $ name ) ; }
Manually release stream flow from logger
30,702
public function getUserdata ( $ key , $ namespace ) { $ ret = $ this -> read ( $ key , $ namespace ) ; list ( , , $ userdata ) = $ ret ; return $ userdata ; }
This method returns the userdata from preloaded dataset .
30,703
protected function addToRuntimeCache ( $ key , array $ dataset , $ namespace ) { if ( ! isset ( $ this -> runtimeCache [ $ namespace ] ) ) { $ this -> runtimeCache [ $ namespace ] = [ ] ; } $ this -> runtimeCache [ $ namespace ] [ $ key ] = $ dataset ; }
Setter for runtime cache element .
30,704
protected function getFromRuntimeCache ( $ key , $ namespace ) { $ result = false ; if ( isset ( $ this -> runtimeCache [ $ namespace ] [ $ key ] ) === true ) { $ result = $ this -> runtimeCache [ $ namespace ] [ $ key ] ; } return $ result ; }
Getter for runtime cache element .
30,705
protected function purgeRuntimeCache ( $ key = null , $ namespace = null ) { $ result = false ; if ( $ namespace !== null && ! isset ( $ this -> runtimeCache [ $ namespace ] ) ) { $ result = true ; } else { if ( $ key === null && $ namespace === null ) { $ this -> runtimeCache = [ ] ; } else { if ( $ key === null ) { $ this -> runtimeCache [ $ namespace ] = [ ] ; } else { unset ( $ this -> runtimeCache [ $ namespace ] [ $ key ] ) ; } } } return $ result ; }
Purges the runtime cache .
30,706
protected function options ( array $ requested = [ ] , array $ allowed = [ ] ) { foreach ( $ allowed as $ key => $ value ) { if ( isset ( $ requested [ $ value ] ) === true ) { $ this -> { $ value } = $ requested [ $ value ] ; } } return $ this ; }
This method is intend to import the requested datafields as object variables if allowed .
30,707
protected function encode ( $ data ) { if ( $ this -> getEncoding ( ) === self :: ENCODING_BASE64 ) { return base64_encode ( serialize ( $ data ) ) ; } else { return serialize ( $ data ) ; } }
This method is intend to encode the data for the storage container .
30,708
protected function decode ( $ data ) { if ( $ this -> getEncoding ( ) === self :: ENCODING_BASE64 ) { return unserialize ( base64_decode ( $ data ) ) ; } else { return unserialize ( $ data ) ; } }
This method is intend to decode the data for the storage container .
30,709
public function getMetaComponents ( ) { return [ $ this -> getFieldnameToken ( ) => $ this -> generateTokenComponent ( ) , $ this -> getFieldnameStep ( ) => $ this -> generateStepField ( ) , $ this -> getFieldnameSteps ( ) => $ this -> generateStepsField ( ) , $ this -> getFieldnameSubmitted ( ) => $ this -> generateSubmittedField ( ) , $ this -> getFieldnameUpload ( ) => $ this -> generateUploadField ( ) , ] ; }
Returns a collection of meta control layer fields .
30,710
protected function metaComponentFactory ( $ name , $ value , $ angularDirectives = false , $ scope = '' , $ type = 'hidden' ) { $ input = $ this -> getRegistry ( ) -> getContainer ( ) -> build ( 'doozr.form.service.component.input' ) ; $ input -> setName ( $ name ) ; $ input -> setType ( $ type ) ; $ input -> setValue ( $ value ) ; if ( true === $ angularDirectives ) { $ input -> setAttribute ( 'ng-model' , sprintf ( '%s%s' , $ scope , $ name ) ) ; $ input -> setAttribute ( 'value-transfer' , $ scope ) ; } return $ input ; }
Factory for creating meta layer fields .
30,711
protected function generateStepField ( ) { return $ this -> metaComponentFactory ( $ this -> getFieldnameStep ( ) , $ this -> getStep ( ) , $ this -> getAngularDirectives ( ) , $ this -> getScope ( ) ) ; }
Returns a generated step field . This field contains the current step for state transfer and for progress indication and so on .
30,712
protected function generateStepsField ( ) { return $ this -> metaComponentFactory ( $ this -> getFieldnameSteps ( ) , $ this -> getSteps ( ) , $ this -> getAngularDirectives ( ) , $ this -> getScope ( ) ) ; }
Returns a generated steps field . This field contains the total of steps available in the form .
30,713
protected function generateSubmittedField ( ) { return $ this -> metaComponentFactory ( $ this -> getFieldnameSubmitted ( ) , $ this -> getScope ( ) , $ this -> getAngularDirectives ( ) , $ this -> getScope ( ) ) ; }
Returns a generated submitted field . This field contains the scope identifier and is the signal for Doozr Form Service for a submitted form .
30,714
public function read ( $ filename ) { $ this -> setUuid ( md5 ( $ filename ) ) ; $ configuration = null ; if ( true === $ this -> cacheEnabled ( ) ) { try { $ configuration = $ this -> getCacheService ( ) -> read ( $ this -> getUuid ( ) ) ; } catch ( Doozr_Cache_Service_Exception $ exception ) { } } if ( null === $ configuration ) { $ configuration = parent :: read ( $ filename ) ; } $ configuration = $ this -> validate ( $ configuration ) ; if ( false === $ configuration ) { throw new Doozr_Configuration_Reader_Exception ( 'Configuration could no be parsed. Ensure its valid.' ) ; } $ this -> setDecodedContent ( $ configuration ) ; if ( true === $ this -> cacheEnabled ( ) ) { $ this -> getCacheService ( ) -> update ( $ this -> getUuid ( ) , $ configuration ) ; } return $ configuration ; }
Here we proxy the call to parents generic reading and replacing functionality . We do this to receive the processed result here in place to convert it to a real object which is served as fluent API .
30,715
protected function validate ( $ input , $ processSections = self :: PHP_INI_PARSER_PROCESS_SECTIONS ) { if ( true === is_string ( $ input ) ) { $ input = @ parse_ini_string ( $ input , $ processSections ) ; $ input = array_to_object ( array_change_key_case_recursive ( $ input ) ) ; } return $ input ; }
Validates that a passed string is valid ini .
30,716
public function isCanRefill ( Item $ item , $ field ) { return in_array ( $ field , $ this -> supported_fields ) && $ this -> getSourceForFill ( $ item ) ; }
Is can refill item from source .
30,717
public function refillFromSearchResult ( Item $ item , $ field , array $ data ) { if ( ! empty ( $ data [ 'url' ] ) ) { $ item -> addSource ( ( new Source ( ) ) -> setUrl ( $ data [ 'url' ] ) ) ; $ item = $ this -> refill ( $ item , $ field ) ; } return $ item ; }
Refill item field from search result .
30,718
public function getLibraryFiles ( $ input ) { $ result = array ( $ input ) ; if ( method_exists ( $ this , 'getRequiredLibraryFiles' ) ) { $ result = $ this -> getRequiredLibraryFiles ( $ input ) ; } return $ result ; }
Returns the library files required for ORM as array
30,719
public function getActiveSetup ( ) { $ localizationSetup = $ this -> config -> kernel -> localization ; return array ( 'charset' => $ localizationSetup -> charset , 'encoding' => $ localizationSetup -> encoding , 'language' => $ localizationSetup -> language , 'locale' => $ localizationSetup -> locale , ) ; }
Returns the current locale setup
30,720
public function createMainMenu ( Request $ request ) { $ menu = $ this -> factory -> createItem ( 'root' ) ; $ menu -> setChildrenAttribute ( 'id' , 'nav' ) ; $ menu -> addChild ( 'Dashboard' , array ( 'route' => 'serius_admin_dashboard_index' , 'labelAttributes' => array ( 'class' => 'fa fa-home' ) , ) ) ; foreach ( $ this -> adminPool -> getDashboardGroups ( ) as $ group ) { $ count = 0 ; foreach ( $ group [ 'items' ] as $ admin ) { if ( $ admin -> hasRoute ( 'list' ) ) { $ count ++ ; } } if ( $ count == 1 ) { $ admin = $ group [ 'items' ] [ 0 ] ; $ item = $ this -> addAdmin ( $ menu , $ admin , $ request , $ group ) ; $ item -> setLabelAttributes ( array ( 'class' => $ group [ 'icon' ] ? : 'fa fa-folder' , ) ) ; } elseif ( $ count > 1 ) { $ label = $ group [ 'label' ] ; if ( $ group [ 'label_catalogue' ] ) { $ label = $ this -> translator -> trans ( $ label , array ( ) , $ group [ 'label_catalogue' ] ) ; } $ groupItem = $ menu -> addChild ( $ label , array ( 'uri' => '#' , 'labelAttributes' => array ( 'class' => $ group [ 'icon' ] ? : 'fa fa-folder' , ) , ) ) ; foreach ( $ group [ 'items' ] as $ admin ) { $ this -> addAdmin ( $ groupItem , $ admin , $ request , $ group ) ; } } } return $ menu ; }
Creates the main menu
30,721
public function filter ( QueryBuilder $ queryBuilder , $ options = array ( ) ) { if ( ! $ options instanceof DateTime ) { throw new InvalidArgumentException ( '$options is expected to be an instance of DateTime' ) ; } $ aliases = $ queryBuilder -> getRootAliases ( ) ; $ queryBuilder -> andWhere ( sprintf ( '%s.%s %s :%s' , $ aliases [ 0 ] , $ this -> getPropertyName ( ) , $ this -> getComparison ( ) , $ this -> getName ( ) ) ) ; $ queryBuilder -> setParameter ( $ this -> getName ( ) , $ options -> format ( 'Y-m-d H:i:s' ) ) ; }
Generic DateTime filter
30,722
private function addWithFormattedHour ( EntryInterface $ entry , $ dateTimeFormat ) { $ entryKey = $ this -> generateEntryKey ( $ entry -> getToken ( ) , $ entry -> getEvent ( ) , $ entry -> getCreatedAt ( ) -> format ( $ dateTimeFormat ) ) ; $ entryType = $ entry -> getType ( ) ; if ( $ entryType & ElcodiMetricTypes :: TYPE_BEACON_UNIQUE ) { $ this -> addBeaconMetricUnique ( $ entry , $ entryKey ) ; } if ( $ entryType & ElcodiMetricTypes :: TYPE_BEACON_TOTAL ) { $ this -> addBeaconMetricTotal ( $ entryKey ) ; } if ( $ entryType & ElcodiMetricTypes :: TYPE_ACCUMULATED ) { $ this -> addAccumulativeEntry ( $ entry , $ entryKey ) ; } if ( $ entryType & ElcodiMetricTypes :: TYPE_DISTRIBUTIVE ) { $ this -> addDistributedEntry ( $ entry , $ entryKey ) ; } return $ this ; }
Add metric given hour formatted .
30,723
public function isFile ( String $ name ) : Bool { $ file = Method :: files ( $ name ) ; if ( is_array ( $ file ) ) { return ( bool ) $ file [ 0 ] ; } return ( bool ) Method :: files ( $ name ) ; }
Is file input name
30,724
public function start ( String $ fileName = 'upload' , String $ rootDir = NULL ) : Bool { $ fileName = $ this -> settings [ 'source' ] ?? $ fileName ; $ rootDir = $ this -> settings [ 'target' ] ?? $ rootDir ?? $ this -> uploadDirectory ; if ( ! is_dir ( $ rootDir ) ) { mkdir ( $ rootDir ) ; } $ extensions = $ this -> _separator ( 'extensions' ) ; $ mimes = $ this -> _separator ( 'mimes' ) ; $ this -> file = $ fileName ; $ encryption = $ this -> settings [ 'prefix' ] ?? '' ; $ name = $ _FILES [ $ fileName ] [ 'name' ] ?? NULL ; $ source = $ _FILES [ $ fileName ] [ 'tmp_name' ] ?? NULL ; $ root = Base :: suffix ( $ rootDir , '/' ) ; if ( is_array ( $ name ) ) { for ( $ index = 0 ; $ index < count ( $ name ) ; $ index ++ ) { $ this -> _upload ( $ rootDir , $ root , $ source [ $ index ] , $ name [ $ index ] , $ extensions , $ mimes , $ encryption ) ; } $ return = true ; } else { $ return = $ this -> _upload ( $ rootDir , $ root , $ source , $ name , $ extensions , $ mimes , $ encryption ) ; } $ this -> _default ( ) ; return $ return ; }
Start file upload
30,725
public function transform ( MemberCategory $ memberCategory ) { return [ 'createdAt' => $ memberCategory -> created_at -> toW3cString ( ) , 'description' => $ memberCategory -> description , 'id' => $ memberCategory -> id , 'name' => $ memberCategory -> name , ] ; }
Transformer to generate JSON response with MemberCategory
30,726
public function run ( ) { $ response = $ this -> getResponse ( ) ; $ presenter = $ this -> getPresenter ( ) ; $ action = $ this -> getAction ( ) ; $ view = $ this -> getView ( ) ; $ method = $ action . 'Action' ; if ( true === $ httpStatus = $ this -> validateRequest ( $ presenter , $ method ) ) { if ( null !== $ view && $ view instanceof Doozr_Base_View ) { $ presenter -> attach ( $ view ) ; } $ data = $ presenter -> { $ method } ( ) ; $ responseBody = new Doozr_Response_Body ( 'php://memory' , 'w' ) ; $ responseBody -> write ( $ data [ Doozr_Base_Presenter :: IDENTIFIER_VIEW ] ) ; $ response = $ response -> withBody ( $ responseBody ) ; $ response = $ response -> withStatus ( Doozr_Http :: OK ) ; } else { switch ( $ httpStatus ) { case Doozr_Http :: BAD_REQUEST : $ message = sprintf ( 'No Presenter to execute route ("%s"). Sure it exists?' , $ this -> getRoute ( ) ) ; break ; case Doozr_Http :: NOT_FOUND : default : $ message = sprintf ( 'Method "%s()" of class "%s" not callable. Sure it exists and it\'s public?' , $ method , 'Presenter_' . ucfirst ( $ this -> getClassName ( ) ) ) ; break ; } throw new Doozr_Route_Exception ( $ message , $ httpStatus ) ; } return $ response ; }
Dispatches the request to the backend layers . This can be Model View Presenter .
30,727
protected function initMvp ( $ target , Doozr_Registry $ registry , Request $ request ) { $ model = $ this -> modelFactory ( $ target , [ $ registry , $ request , ] ) ; $ view = $ this -> viewFactory ( $ target , [ $ registry , $ request , ] ) ; $ presenter = $ this -> presenterFactory ( $ target , [ $ registry , $ request , $ model , ] ) ; $ this -> setModel ( $ model ) ; $ this -> setView ( $ view ) ; $ this -> setPresenter ( $ presenter ) ; }
Initializes the MVP layer by creating instances of Model View & Presenter .
30,728
public function set ( $ identifier , $ path , $ force = false ) { if ( ( true === isset ( self :: $ path [ $ identifier ] ) ) && ( ( null !== self :: $ path [ $ identifier ] ) && ( false === $ force ) ) ) { throw new Doozr_Exception ( sprintf ( 'Path with identifier "%s" already defined! Set $force to TRUE to overwrite it.' , $ identifier ) ) ; } self :: $ path [ $ identifier ] = self :: fixPath ( $ path ) ; return true ; }
Register an path from external - maybe created at runtime .
30,729
public static function fixPath ( $ path ) { switch ( DIRECTORY_SEPARATOR ) { case '\\' : $ wrongDirection = '/' ; break ; case '/' : default : $ wrongDirection = '\\' ; break ; } if ( false !== stristr ( $ path , $ wrongDirection ) ) { $ path = str_replace ( $ wrongDirection , DIRECTORY_SEPARATOR , $ path ) ; if ( stristr ( $ path , '\\\\' ) ) { $ path = str_replace ( '\\\\' , '\\' , $ path ) ; } elseif ( stristr ( $ path , '//' ) ) { $ path = str_replace ( '//' , '/' , $ path ) ; } } return $ path ; }
Fix slashes with wrong direction in a path and returns it .
30,730
public static function serviceToPath ( $ serviceName , $ scope = DOOZR_NAMESPACE ) { $ service = ucfirst ( str_replace ( '_' , DIRECTORY_SEPARATOR , $ serviceName ) ) ; return self :: fixPath ( self :: $ path [ 'service' ] . $ scope . DIRECTORY_SEPARATOR . $ service . DIRECTORY_SEPARATOR ) ; }
Converts a given service name to its path representation .
30,731
protected function init ( $ pathToRoot , $ pathToApplication ) { switch ( $ pathToRoot ) { case null : $ pathToRoot = str_replace ( str_replace ( '_' , DIRECTORY_SEPARATOR , __CLASS__ ) . '.php' , '' , __FILE__ ) ; break ; case 'DOOZR' : default : $ pathToRoot = DOOZR_DOCUMENT_ROOT ; break ; } if ( null === $ pathToApplication ) { $ pathToApplication = $ this -> retrievePathToApplication ( ) ; } $ this -> initPaths ( $ pathToRoot , $ pathToApplication ) -> configureIncludePaths ( ) ; }
initializes all required operations .
30,732
protected function retrievePathToApplication ( ) { if ( false === defined ( 'DOOZR_APP_ROOT' ) ) { if ( false !== $ environment = getenv ( 'DOOZR_APP_ROOT' ) ) { $ path = $ this -> mergePath ( $ environment , 'app/' ) ; } else { $ path = $ this -> mergePath ( DOOZR_DOCUMENT_ROOT , '../app/' ) ; } define ( 'DOOZR_APP_ROOT' , $ path ) ; } return DOOZR_APP_ROOT ; }
Returns path to the application .
30,733
protected function up ( $ path , $ level = 1 , $ preserveTrailingSlash = false ) { $ postfix = '' ; if ( substr ( $ path , - 1 , 1 ) === DIRECTORY_SEPARATOR ) { ++ $ level ; if ( $ preserveTrailingSlash ) { $ postfix = DIRECTORY_SEPARATOR ; } } $ path = explode ( DIRECTORY_SEPARATOR , $ path ) ; $ path = array_slice ( $ path , 0 , count ( $ path ) - $ level ) ; return implode ( DIRECTORY_SEPARATOR , $ path ) . $ postfix ; }
Returns the path n levels up from input .
30,734
protected function initPaths ( $ pathToRoot , $ pathToApplication ) { $ root = $ this -> up ( $ pathToRoot , 1 , true ) ; self :: $ path [ 'document_root' ] = $ root ; self :: $ path [ 'core' ] = $ this -> combine ( $ root , [ 'src' , 'Doozr' ] ) ; self :: $ path [ 'framework' ] = $ this -> combine ( $ root , [ 'src' ] ) ; self :: $ path [ 'app' ] = $ pathToApplication ; self :: $ path [ 'model' ] = $ this -> combine ( $ root , [ 'src' , 'Model' ] ) ; self :: $ path [ 'service' ] = $ this -> combine ( $ root , [ 'src' , 'Service' ] ) ; self :: $ path [ 'controller' ] = $ this -> combine ( $ root , [ 'src' , 'Doozr' , 'Controller' ] ) ; self :: $ path [ 'data' ] = $ this -> combine ( $ root , [ 'src' , 'Data' ] ) ; self :: $ path [ 'data_private' ] = $ this -> combine ( $ root , [ 'src' , 'Data' , 'Private' ] ) ; self :: $ path [ 'auth' ] = $ this -> combine ( $ root , [ 'src' , 'Data' , 'Private' , 'Auth' ] ) ; self :: $ path [ 'cache' ] = DOOZR_DIRECTORY_TEMP ; self :: $ path [ 'configuration' ] = $ this -> combine ( $ root , [ 'src' , 'Data' , 'Private' , 'Config' ] ) ; self :: $ path [ 'font' ] = $ this -> combine ( $ root , [ 'src' , 'Data' , 'Private' , 'Font' ] ) ; self :: $ path [ 'log' ] = DOOZR_DIRECTORY_TEMP ; self :: $ path [ 'temp' ] = DOOZR_DIRECTORY_TEMP ; self :: $ path [ 'data_public' ] = $ this -> combine ( $ pathToApplication , [ 'Data' , 'Public' ] ) ; self :: $ path [ 'www' ] = $ this -> combine ( $ pathToApplication , [ 'Data' , 'Public' , 'www' ] ) ; self :: $ path [ 'upload' ] = $ this -> combine ( $ pathToApplication , [ 'Data' , 'Private' , 'Upload' ] ) ; self :: $ path [ 'localisation' ] = $ this -> combine ( $ pathToApplication , [ 'Data' , 'Private' , 'Locale' ] ) ; return $ this ; }
Configures the default paths of Doozr & Application .
30,735
protected function combine ( $ base = '' , array $ relativePaths = [ ] ) { foreach ( $ relativePaths as $ relativePath ) { $ base .= $ relativePath . DIRECTORY_SEPARATOR ; } return $ base ; }
This method is intend to return a combined path based on input .
30,736
protected function configureIncludePaths ( ) { $ iniIncludePaths = explode ( PATH_SEPARATOR , ini_get ( 'include_path' ) ) ; $ includePathsDoozr = '.' ; foreach ( self :: $ path as $ path ) { $ includePathsDoozr .= self :: buildPath ( $ path ) ; } if ( ! empty ( $ iniIncludePaths ) ) { foreach ( $ iniIncludePaths as $ iniIncludePath ) { if ( in_array ( $ iniIncludePath , self :: $ path ) || trim ( $ iniIncludePath ) == '.' ) { continue ; } $ includePathsDoozr .= self :: buildPath ( $ iniIncludePath ) ; } } ini_set ( 'include_path' , $ includePathsDoozr ) ; return $ this ; }
Configures the include paths of PHP .
30,737
public function createFtpDriver ( array $ config ) { $ ftpConfig = Arr :: only ( $ config , [ 'host' , 'username' , 'password' , 'port' , 'root' , 'passive' , 'ssl' , 'timeout' , ] ) ; return $ this -> adapt ( $ this -> createFlysystem ( new FtpAdapter ( $ ftpConfig ) , $ config ) ) ; }
Create an instance of the ftp driver .
30,738
public function findByCredentials ( array $ credentials , $ is_set_token = true , $ length = 55 ) { $ user = $ this -> userProvider -> findByCredentials ( $ credentials ) ; if ( $ is_set_token ) { $ this -> user = $ user ; $ this -> user -> token_api = $ this -> user -> getRandomString ( $ length ) ; $ this -> user -> token_expired = strtotime ( date ( 'Y-m-d H:i:s' , strtotime ( '+4 hour' ) ) ) ; $ this -> user -> save ( ) ; } return $ user ; }
Customize function Get user info by user account login
30,739
public static function createRole ( $ name , AVACL $ acl ) { $ role = AVObject :: create ( static :: $ avClassName ) ; $ role -> setName ( $ name ) ; $ role -> setACL ( $ acl ) ; return $ role ; }
Create a AVRole object with a given name and ACL .
30,740
public function setName ( $ name ) { if ( $ this -> getObjectId ( ) ) { throw new AVException ( "A role's name can only be set before it has been saved." ) ; } if ( ! is_string ( $ name ) ) { throw new AVException ( "A role's name must be a string." ) ; } return $ this -> set ( "name" , $ name ) ; }
Sets the role name .
30,741
public static function asset ( string $ file ) { $ template = new Template ( ) ; return file_get_contents ( $ template -> assets . $ template -> cleanPath ( $ file ) ) ; }
Get asset content
30,742
protected function createQueryBuilder ( $ alias = 'a' ) { $ repository = $ this -> get ( 'orm.em' ) -> getRepository ( $ this -> getEntityClass ( ) ) ; $ queryBuilder = $ repository -> createQueryBuilder ( $ alias ) ; return $ queryBuilder ; }
Create query builder from the current repository
30,743
protected function applyQueryFilters ( QueryBuilder $ queryBuilder , $ alias = 'a' , $ filters = array ( ) ) { foreach ( $ filters as $ filter => $ value ) { if ( $ value ) { $ reader = new AnnotationReader ( ) ; $ reflProperty = new ReflectionProperty ( $ this -> getEntityClass ( ) , $ filter ) ; $ OneToMany = $ reader -> getPropertyAnnotation ( $ reflProperty , '\Doctrine\ORM\Mapping\OneToMany' ) ; $ ManyToMany = $ reader -> getPropertyAnnotation ( $ reflProperty , '\Doctrine\ORM\Mapping\ManyToMany' ) ; if ( $ OneToMany || $ ManyToMany ) { $ queryBuilder -> leftJoin ( $ alias . '.' . $ filter , $ filter ) ; $ queryBuilder -> andWhere ( $ filter . ' = :' . $ filter ) ; } else { $ queryBuilder -> andWhere ( $ alias . '.' . $ filter . ' = :' . $ filter ) ; } $ queryBuilder -> setParameter ( $ filter , $ value ) ; } } return $ queryBuilder ; }
Apply filters to query builder
30,744
protected function applyQuerySort ( QueryBuilder $ queryBuilder , $ alias = 'a' ) { $ sort = $ this -> get ( 'request' ) -> get ( 'sort' ) ; $ order = $ this -> get ( 'request' ) -> get ( 'order' ) ; if ( $ sort ) { $ repository = $ this -> get ( 'orm.em' ) -> getRepository ( $ this -> getEntityClass ( ) ) ; $ sortMethodName = 'getQueryBuilderOrderedBy' . ucfirst ( strtolower ( $ sort ) ) ; if ( method_exists ( $ repository , $ sortMethodName ) ) { $ queryBuilder = call_user_method_array ( $ sortMethodName , $ repository , array ( $ order , $ queryBuilder ) ) ; } elseif ( $ sort && property_exists ( $ this -> getEntityClass ( ) , $ sort ) ) { $ queryBuilder -> orderBy ( $ alias . '.' . $ sort , $ order ) ; } } elseif ( $ sort = $ this -> getSortableColumn ( ) ) { if ( $ sortGroup = $ this -> getSortableGroup ( ) ) { $ queryBuilder -> orderBy ( $ alias . '.' . $ sortGroup ) ; } $ queryBuilder -> addOrderBy ( $ alias . '.' . $ sort ) ; } return $ queryBuilder ; }
Gets by sort query builder
30,745
protected function getSortableColumn ( ) { $ reader = new AnnotationReader ( ) ; $ reflClass = new ReflectionClass ( $ this -> getEntityClass ( ) ) ; foreach ( $ reflClass -> getProperties ( ) as $ property ) { $ reflProperty = new ReflectionProperty ( $ this -> getEntityClass ( ) , $ property -> name ) ; $ annotation = $ reader -> getPropertyAnnotation ( $ reflProperty , '\Gedmo\Mapping\Annotation\SortablePosition' ) ; if ( $ annotation ) { return $ property -> name ; } } }
Gets the sortable column if defined on entity class
30,746
public function setSortableColumns ( $ columns = array ( ) ) { $ repository = $ this -> get ( 'orm.em' ) -> getRepository ( $ this -> getEntityClass ( ) ) ; foreach ( $ columns as $ column => $ options ) { $ sortMethodName = 'getQueryBuilderOrderedBy' . ucfirst ( strtolower ( $ column ) ) ; if ( method_exists ( $ repository , $ sortMethodName ) ) { $ columns [ $ column ] [ 'sortable' ] = true ; continue ; } if ( property_exists ( $ this -> getEntityClass ( ) , $ column ) ) { $ reader = new \ Doctrine \ Common \ Annotations \ AnnotationReader ( ) ; $ reflProperty = new \ ReflectionProperty ( $ this -> getEntityClass ( ) , $ column ) ; $ OneToMany = $ reader -> getPropertyAnnotation ( $ reflProperty , '\Doctrine\ORM\Mapping\OneToMany' ) ; $ ManyToMany = $ reader -> getPropertyAnnotation ( $ reflProperty , '\Doctrine\ORM\Mapping\ManyToMany' ) ; if ( ! $ OneToMany && ! $ ManyToMany ) { $ columns [ $ column ] [ 'sortable' ] = true ; continue ; } } $ columns [ $ column ] [ 'sortable' ] = false ; } return $ columns ; }
Defines a sortable parameter on each column if it s sortable
30,747
protected function getFiltersType ( ) { $ form = $ this -> get ( 'form.factory' ) -> createNamed ( 'filters' , 'form' , null , array ( 'action' => $ this -> generateUrl ( $ this -> getRoutePrefix ( ) , array ( 'sort' => $ this -> get ( 'request' ) -> get ( 'sort' ) , 'order' => $ this -> get ( 'request' ) -> get ( 'order' ) , ) ) , 'method' => 'GET' , 'csrf_protection' => false , 'attr' => array ( 'class' => 'form-inline' , ) , ) ) ; return $ form ; }
Create filters form
30,748
public function DisplaySinglePost ( $ slug ) { if ( $ this -> isBladeFile ( $ slug ) ) { return view ( 'pages/' . $ slug , [ 'DatesHelper' => DatesHelper :: class , 'HTMLHelper' => HTMLHelper :: class , 'ImagesHelper' => $ this -> imagesHelper , ] ) ; } $ post = $ this -> repository -> findEnabledPostBySlug ( $ slug ) ; if ( count ( $ post ) == 0 ) { return $ this -> home ( ) ; } $ post -> featured_image = $ this -> imagesHelper -> categoryImageDefaultOrSpecified ( $ post -> featured_image ) ; $ this -> imagesHelper -> createPostResizedImageFiles ( $ post -> featured_image ) ; if ( $ post -> featured_image == "" ) { $ post -> featured_image = Config :: get ( 'lasallecmsfrontend.social_media_default_image' ) ; } $ post -> urlImage = $ this -> imagesHelper -> urlOfImage ( $ post -> featured_image , 600 , 600 ) ; $ openGraph = HTMLHelper :: createOpenGraphTagsForPost ( $ post ) ; $ twitter = HTMLHelper :: createTwitterTagsForPost ( $ post ) ; $ google = HTMLHelper :: createGoogleTagsForPost ( $ post ) ; $ category = $ this -> repository -> findCategoryForPostById ( $ post -> id ) ; if ( count ( $ category ) == 1 ) { $ nextPost = $ this -> repository -> getNextPost ( $ category [ 0 ] -> category_id , $ post -> publish_on ) ; $ previousPost = $ this -> repository -> getPreviousPost ( $ category [ 0 ] -> category_id , $ post -> publish_on ) ; $ categoryTitle = $ this -> repository -> getCategoryTitleById ( $ category [ 0 ] -> category_id ) ; } $ tagTitles = $ this -> repository -> getTagTitlesByPostId ( $ post -> id ) ; return view ( 'posts/single_post' , [ 'post' => $ post , 'DatesHelper' => DatesHelper :: class , 'HTMLHelper' => HTMLHelper :: class , 'ImagesHelper' => $ this -> imagesHelper , 'openGraph' => $ openGraph , 'twitter' => $ twitter , 'google' => $ google , 'nextPost' => $ nextPost , 'previousPost' => $ previousPost , 'categoryTitle' => $ categoryTitle , 'tagTitles' => $ tagTitles , ] ) ; }
Display the individual post
30,749
private function suppressPostFromHomePage ( $ post ) { $ categoriesToSuppress = Config :: get ( 'lasallecmsfrontend.frontend_suppress_categories_on_home_page' ) ; if ( empty ( $ categoriesToSuppress ) ) return false ; $ categories = $ this -> repository -> findCategoryForPostById ( $ post -> id ) ; foreach ( $ categories as $ category ) { $ categoryName = $ this -> repository -> getCategoryTitleById ( $ category -> category_id ) ; if ( in_array ( $ categoryName , $ categoriesToSuppress ) ) return true ; } return false ; }
Should this post be suppressed on the home based on the categories the post is associated?
30,750
public function set ( $ key , $ value ) { $ keys = explode ( '.' , $ key ) ; $ data = & $ this -> parameters ; while ( count ( $ keys ) > 1 ) { $ pkey = $ keys [ 0 ] ; if ( ! array_key_exists ( $ pkey , $ data ) || ! is_array ( $ data [ $ pkey ] ) ) { $ data [ $ pkey ] = [ ] ; } $ data = & $ data [ $ pkey ] ; array_shift ( $ keys ) ; } $ data [ $ keys [ 0 ] ] = $ value ; return $ this ; }
Sets a parameter by name .
30,751
public function has ( $ key ) { $ data = $ this -> parameters ; foreach ( explode ( '.' , $ key ) as $ pkey ) { if ( ! array_key_exists ( $ pkey , $ data ) || ! is_array ( $ data ) ) { return false ; } $ data = $ data [ $ pkey ] ; } return true ; }
Returns true if the parameter is defined .
30,752
public function filter ( array $ keys ) { $ this -> parameters = array_intersect_key ( $ this -> parameters , array_flip ( $ keys ) ) ; return $ this ; }
Filter current bag with specific parameters by keys .
30,753
public function skipDatabaseQuery ( $ slug ) { $ pagesSkippingDatabaseQuery = Config :: get ( 'lasallecmsfrontend.pages_not_using_database' ) ; foreach ( $ pagesSkippingDatabaseQuery as $ page ) { if ( $ page == ucwords ( $ slug ) ) { return true ; } } return false ; }
Skip querying the database for this page?
30,754
public function isBladeFile ( $ slug ) { $ fullPath = base_path ( ) . '/' . Config :: get ( 'lasallecmsfrontend.pathToTheBladeFiles' ) . '/pages/' . $ slug . '.blade.php' ; if ( $ this -> filesystem -> isFile ( $ fullPath ) ) { return true ; } return false ; }
Does a blade file exist for this page?
30,755
protected function write ( string $ data ) { $ this -> clearTimeout ( ) ; $ this -> conn -> write ( $ data . static :: NEW_LINE ) ; $ this -> log ( '<-' . $ data ) ; $ this -> setTimeout ( ) ; }
Write data to the connection
30,756
protected function setTimeout ( ) { $ this -> timeoutTimer = $ this -> loop -> addTimer ( self :: CONNECTION_TIMEOUT , function ( ) { $ this -> close ( ) ; } ) ; }
Set a timeout that disconnects the client when it s idle for to long
30,757
protected function clearTimeout ( ) { if ( $ this -> timeoutTimer !== null ) { $ this -> loop -> cancelTimer ( $ this -> timeoutTimer ) ; $ this -> timeoutTimer = null ; } }
Clear the timeout if it s set
30,758
public function onData ( string $ data ) { $ data = trim ( $ data ) ; $ this -> log ( '->' . $ data ) ; $ chunks = explode ( ' ' , $ data ) ; $ command = $ chunks [ 0 ] ; unset ( $ chunks [ 0 ] ) ; $ input = '' ; if ( count ( $ chunks ) > 0 ) { $ input = implode ( ' ' , $ chunks ) ; } $ input = trim ( $ input ) ; if ( $ this -> node -> getCommands ( ) -> has ( $ command ) ) { $ this -> node -> getCommands ( ) -> get ( $ command ) -> handle ( $ this , $ input ) -> then ( function ( array $ lines ) { foreach ( $ lines as $ line ) { $ this -> write ( $ line ) ; } } ) ; return ; } $ list = implode ( ', ' , $ this -> node -> getCommands ( ) -> keys ( ) ) ; $ this -> write ( '# Unknown command. Try ' . substr_replace ( $ list , ' or ' , strrpos ( $ list , ', ' ) , 2 ) ) ; }
Handle a command call from the clients side
30,759
public function createModels ( $ rows ) { $ models = [ ] ; foreach ( $ rows as $ row ) { $ models [ ] = $ this -> createModel ( $ row ) ; } return $ models ; }
Converts found rows into model instances .
30,760
public function getFeed ( ) { return $ this -> getCachedProperty ( 'feed' , function ( ) { return $ this -> getExtensions ( ) -> parseElement ( $ this , $ this -> getDomDocument ( ) -> documentElement ) ; } ) ; }
Return feed .
30,761
public function getImageHandler ( ) { if ( ! $ this -> imageHandler ) { $ this -> imageHandler = new CaptchaImage ( ) ; $ object = $ this -> imageHandler ; $ object -> width = 90 ; $ object -> height = 26 ; $ object -> background = 1 ; $ object -> adulterate = 1 ; $ object -> scatter = '' ; $ object -> color = 1 ; $ object -> size = 0 ; $ object -> shadow = 1 ; $ object -> animator = 0 ; } return $ this -> imageHandler ; }
get image handler
30,762
private function checkAndAssignClassName ( $ objects ) { foreach ( $ objects as $ object ) { if ( $ this -> targetClassName === null ) { $ this -> targetClassName = $ object -> getClassName ( ) ; } if ( $ this -> targetClassName != $ object -> getClassName ( ) ) { throw new \ Exception ( 'All objects in a relation must be of the same class.' ) ; } } }
Helper function to check that all passed AVObjects have same class name and assign targetClassName variable .
30,763
private function addObjects ( $ objects , & $ container ) { if ( ! is_array ( $ objects ) ) { $ objects = [ $ objects ] ; } foreach ( $ objects as $ object ) { if ( $ object -> getObjectId ( ) == null ) { $ container [ 'null' ] [ ] = $ object ; } else { $ container [ $ object -> getObjectID ( ) ] = $ object ; } } }
Adds an object or array of objects to the array replacing any existing instance of the same object .
30,764
public function _apply ( $ oldValue , $ object , $ key ) { if ( $ oldValue == null ) { return new AVRelation ( $ object , $ key , $ this -> targetClassName ) ; } else if ( $ oldValue instanceof AVRelation ) { if ( $ this -> targetClassName != null && $ oldValue -> getTargetClass ( ) !== $ this -> targetClassName ) { throw new \ Exception ( 'Related object object must be of class ' . $ this -> targetClassName . ', but ' . $ oldValue -> getTargetClass ( ) . ' was passed in.' ) ; } return $ oldValue ; } else { throw new \ Exception ( "Operation is invalid after previous operation." ) ; } }
Applies the current operation and returns the result .
30,765
public function _mergeWithPrevious ( $ previous ) { if ( $ previous == null ) { return $ this ; } if ( $ previous instanceof AVRelationOperation ) { if ( $ previous -> targetClassName != null && $ previous -> targetClassName != $ this -> targetClassName ) { throw new \ Exception ( 'Related object object must be of class ' . $ this -> targetClassName . ', but ' . $ previous -> targetClassName . ' was passed in.' ) ; } $ newRelationToAdd = self :: convertToOneDimensionalArray ( $ this -> relationsToAdd ) ; $ newRelationToRemove = self :: convertToOneDimensionalArray ( $ this -> relationsToRemove ) ; $ previous -> addObjects ( $ newRelationToAdd , $ previous -> relationsToAdd ) ; $ previous -> removeObjects ( $ newRelationToAdd , $ previous -> relationsToRemove ) ; $ previous -> removeObjects ( $ newRelationToRemove , $ previous -> relationsToAdd ) ; $ previous -> addObjects ( $ newRelationToRemove , $ previous -> relationsToRemove ) ; $ newRelationToAdd = self :: convertToOneDimensionalArray ( $ previous -> relationsToAdd ) ; $ newRelationToRemove = self :: convertToOneDimensionalArray ( $ previous -> relationsToRemove ) ; return new AVRelationOperation ( $ newRelationToAdd , $ newRelationToRemove ) ; } throw new \ Exception ( 'Operation is invalid after previous operation.' ) ; }
Merge this operation with a previous operation and return the new operation .
30,766
public static function removeElementsFromArray ( $ elements , & $ array ) { if ( ! is_array ( $ elements ) ) { $ elements = [ $ elements ] ; } $ length = count ( $ array ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ exist = false ; foreach ( $ elements as $ element ) { if ( $ array [ $ i ] == $ element ) { $ exist = true ; break ; } } if ( $ exist ) { unset ( $ array [ $ i ] ) ; } } $ array = array_values ( $ array ) ; }
Remove element or array of elements from one dimensional array .
30,767
public static function convertToOneDimensionalArray ( $ array ) { $ newArray = array ( ) ; if ( is_array ( $ array ) ) { foreach ( $ array as $ value ) { $ newArray = array_merge ( $ newArray , self :: convertToOneDimensionalArray ( $ value ) ) ; } } else { $ newArray [ ] = $ array ; } return $ newArray ; }
Convert any array to one dimensional array .
30,768
public function initGame ( ) { $ this -> board = array ( ) ; $ this -> last_player = null ; for ( $ x = 0 ; $ x < $ this -> size ; $ x ++ ) { $ row = array ( ) ; for ( $ y = 0 ; $ y < $ this -> size ; $ y ++ ) { $ row [ ] = null ; } $ this -> board [ ] = $ row ; } $ this -> display ( ) ; }
Restarts the board and the game vars
30,769
public function display ( ) { $ message = '' ; $ message .= $ this -> getLineSeparator ( ) ; foreach ( $ this -> board as $ i => $ row ) { $ message .= $ this -> getRow ( $ i , $ row ) ; } $ message .= $ this -> getPlayers ( ) ; $ message .= $ this -> getLastMove ( ) ; $ this -> writeOutput ( $ message ) ; }
Draws the board
30,770
private function getRow ( $ row_number , array $ row ) { $ message = '' ; foreach ( $ row as $ cell_number => $ player ) { $ withBackground = $ this -> drawCellBackground ( $ row_number , $ cell_number ) ; $ message .= ( $ withBackground ? "|<bg={$this->background_color}> " : '| ' ) . $ this -> getPlayerChar ( $ player , $ withBackground ) . ( $ withBackground ? " </bg={$this->background_color}>" : ' ' ) ; } $ message .= "|\n" ; $ message .= $ this -> getLineSeparator ( ) ; return $ message ; }
Returns the row text that should be write
30,771
private function drawCellBackground ( $ row_number , $ cell_number ) { if ( $ this -> size % 2 ) { return $ this -> background && ( ( $ row_number % 2 && $ cell_number % 2 ) || ( ! ( $ row_number % 2 ) && ! ( $ cell_number % 2 ) ) ) ; } return $ this -> background && ( ( $ row_number % 2 && ! ( $ cell_number % 2 ) ) || ( ! ( $ row_number % 2 ) && $ cell_number % 2 ) ) ; }
Returns if the background cell should be drawn
30,772
public function updateGame ( $ x , $ y , $ player ) { if ( ! in_array ( $ player , array ( 1 , 2 ) ) ) { throw new PlayerNotFoundException ( $ player ) ; } if ( $ this -> last_player === $ player ) { throw new PlayerRepeatGameException ( $ player ) ; } if ( ! is_null ( $ this -> board [ $ x ] [ $ y ] ) ) { throw new MoveAlreadyDoneException ( $ x , $ y , $ this -> board [ $ x ] [ $ y ] ) ; } $ this -> last_player = $ player ; $ this -> board [ $ x ] [ $ y ] = $ player ; $ this -> display ( ) ; }
Update the board status and repaint the board
30,773
public function SetNotRequired ( ) { $ unsetIndices = array ( ) ; foreach ( $ this -> validators as $ index => $ validator ) { if ( $ validator instanceof Validation \ Required ) $ unsetIndices [ ] = $ index ; } foreach ( $ unsetIndices as $ index ) { unset ( $ this -> validators [ $ index ] ) ; } }
Marks this field as not required by removing required validator if it was previously set
30,774
public function SetRequired ( $ errorLabelPrefix = '' ) { foreach ( $ this -> validators as $ validator ) { if ( $ validator instanceof Validation \ Required ) return ; } $ this -> validators [ ] = new Validation \ Required ( $ errorLabelPrefix ) ; }
Marks this field as required by adding a validator
30,775
function Check ( $ value ) { $ this -> SetValue ( $ value ) ; $ required = $ this -> GetRequiredValidator ( ) ; if ( $ required && ! $ required -> Check ( $ value ) ) { $ this -> checkFailed = true ; return false ; } return parent :: Check ( $ value ) ; }
Searches and returns a required validator
30,776
function GetHtmlAttribute ( $ name ) { if ( isset ( $ this -> attributes [ $ name ] ) ) return $ this -> attributes [ $ name ] ; return null ; }
Gets a specific html attribute
30,777
public function setupQb ( QueryBuilder $ qb , $ filters ) { $ this -> qb = $ qb ; $ this -> c = 0 ; $ this -> bind = array ( ) ; $ filters = $ this -> _unify ( $ filters ) ; $ this -> _setupOrderyBy ( $ qb , $ filters [ 'orderby' ] ) ; $ this -> _setFilters ( $ qb , $ filters [ 'filters' ] ) ; $ filters [ 'offset' ] and $ qb -> setFirstResult ( $ filters [ 'offset' ] ) ; $ filters [ 'limit' ] and $ qb -> setMaxResults ( $ filters [ 'limit' ] ) ; return $ qb ; }
Ustawia qb dla zapytania przez EntityManager .
30,778
public function getAllParts ( ) { if ( ! $ this -> kqb ) { throw new KendoQbParserException ( 'First use setupFilters()' ) ; } return $ this -> kqb -> getAllParts ( ) . $ this -> kqb -> getLimitOffset ( ) ; }
Ustawia qb dla zapytania przez Dbal .
30,779
public function getProperty ( $ name ) : ? Property { if ( $ this -> hasProperty ( $ name ) ) { return $ this -> properties [ $ name ] ; } return null ; }
Get a single property of the Struct
30,780
public function access ( $ realPath = true , $ parentDirectoryAccess = false ) : Info { self :: $ access [ 'realPath' ] = $ realPath ; self :: $ access [ 'parentDirectoryAccess' ] = $ parentDirectoryAccess ; return $ this ; }
Sets access status
30,781
public static function createDate ( String $ file , String $ type = 'd.m.Y G:i:s' ) : String { $ file = self :: rpath ( $ file ) ; if ( ! file_exists ( $ file ) ) { throw new Exception \ FileNotFoundException ( NULL , $ file ) ; } $ date = filectime ( $ file ) ; return date ( $ type , $ date ) ; }
Get create date
30,782
public static function changeDate ( String $ file , String $ type = 'd.m.Y G:i:s' ) : String { $ file = self :: rpath ( $ file ) ; if ( ! file_exists ( $ file ) ) { throw new Exception \ FileNotFoundException ( NULL , $ file ) ; } $ date = filemtime ( $ file ) ; return date ( $ type , $ date ) ; }
Get change date
30,783
public static function owner ( String $ file ) { $ file = self :: rpath ( $ file ) ; if ( ! file_exists ( $ file ) ) { throw new Exception \ FileNotFoundException ( NULL , $ file ) ; } $ owner = fileowner ( $ file ) ; if ( function_exists ( 'posix_getpwuid' ) ) { return posix_getpwuid ( $ owner ) ; } else { return $ owner ; } }
Get file owner
30,784
public static function group ( String $ file ) { $ file = self :: rpath ( $ file ) ; if ( ! file_exists ( $ file ) ) { throw new Exception \ FileNotFoundException ( NULL , $ file ) ; } $ group = filegroup ( $ file ) ; if ( function_exists ( 'posix_getgrgid' ) ) { return posix_getgrgid ( $ group ) ; } else { return $ group ; } }
Get file group
30,785
public static function rowCount ( String $ file = '/' , Bool $ recursive = true ) : Int { $ file = self :: rpath ( $ file ) ; if ( ! file_exists ( $ file ) ) { throw new Exception \ FileNotFoundException ( NULL , $ file ) ; } if ( is_file ( $ file ) ) { return count ( file ( $ file ) ) ; } elseif ( is_dir ( $ file ) ) { $ files = FileList :: allFiles ( $ file , $ recursive ) ; $ rowCount = 0 ; foreach ( $ files as $ f ) { if ( is_file ( $ f ) ) { $ rowCount += count ( file ( $ f ) ) ; } } return $ rowCount ; } else { return false ; } }
Gets number of file row
30,786
public static function fileInfo ( String $ dir , String $ extension = NULL ) : Array { $ dir = self :: rpath ( $ dir ) ; if ( is_dir ( $ dir ) ) { $ files = FileList :: files ( $ dir , $ extension ) ; $ dir = Base :: suffix ( $ dir ) ; $ filesInfo = [ ] ; foreach ( $ files as $ file ) { $ filesInfo [ $ file ] [ 'basename' ] = self :: pathInfo ( $ dir . $ file , 'basename' ) ; $ filesInfo [ $ file ] [ 'size' ] = filesize ( $ dir . $ file ) ; $ filesInfo [ $ file ] [ 'date' ] = filemtime ( $ dir . $ file ) ; $ filesInfo [ $ file ] [ 'readable' ] = is_readable ( $ dir . $ file ) ; $ filesInfo [ $ file ] [ 'writable' ] = is_writable ( $ dir . $ file ) ; $ filesInfo [ $ file ] [ 'executable' ] = is_executable ( $ dir . $ file ) ; $ filesInfo [ $ file ] [ 'permission' ] = fileperms ( $ dir . $ file ) ; } return $ filesInfo ; } elseif ( is_file ( $ dir ) ) { return ( array ) self :: get ( $ dir ) ; } else { throw new Exception \ FolderNotFoundException ( NULL , $ dir ) ; } }
Used to get various information about a file or directory .
30,787
public static function disk ( String $ dir , String $ type = 'free' ) : Float { $ dir = self :: rpath ( $ dir ) ; if ( ! is_dir ( $ dir ) ) { throw new Exception \ FolderNotFoundException ( NULL , $ dir ) ; } if ( $ type === 'free' ) { return disk_free_space ( $ dir ) ; } else { return disk_total_space ( $ dir ) ; } }
Get free disk space
30,788
public function setTheme ( $ theme ) { $ otheme = $ this -> options [ 'theme' ] ; $ this -> options [ 'theme' ] = $ theme ; if ( $ otheme != $ theme ) { $ this -> initViewConfig ( ) ; } return $ this ; }
set theme dir
30,789
public function getEngineInstance ( ) { if ( ! isset ( $ this -> _engineInstance ) ) { $ this -> _engineInstance = new static :: $ engines [ $ this -> options [ 'engine' ] ] ; } return $ this -> _engineInstance ; }
get template engine instance
30,790
public function render ( $ template , $ vdata = array ( ) ) { if ( ! $ this -> templateExists ( $ template ) ) { return 'Template is not exists:' . $ this -> getTemplateRelativePath ( $ template ) ; } if ( $ this -> getData ( ) -> keys ( ) ) { extract ( $ this -> getData ( ) -> all ( ) , EXTR_SKIP ) ; } if ( $ vdata instanceof Collection ) { extract ( $ vdata -> all ( ) , EXTR_SKIP ) ; } elseif ( $ vdata ) { extract ( $ vdata , EXTR_SKIP ) ; } unset ( $ vdata ) ; $ _layout = static :: getLayoutFromTemplate ( $ template ) ; if ( is_null ( $ _layout ) ) { if ( $ this -> getLayout ( ) && $ template !== $ this -> getLayout ( ) && ( $ this -> options [ 'nolayout' ] || ! in_array ( $ template , $ this -> options [ 'nolayout' ] ) ) ) { $ __content_template__ = $ template ; $ template = $ this -> getLayout ( ) ; } } elseif ( $ _layout ) { $ __content_template__ = $ template ; $ template = $ _layout ; } ob_start ( ) ; require $ this -> getCompiledFile ( $ template ) ; $ content = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ content ; }
render template file to string
30,791
public function getLayoutFromTemplate ( $ template ) { $ content = file_get_contents ( $ this -> getTemplateFile ( $ template ) ) ; return $ this -> getEngineInstance ( ) -> getLayout ( $ content ) ; }
get layout from template
30,792
public function getTemplateFile ( $ template ) { if ( ! is_file ( $ template ) ) { $ template = $ this -> getTemplatePath ( ) . $ this -> _getRelativeTemplate ( $ template ) . $ this -> getSuffix ( ) ; } return $ template ; }
get template absolute path
30,793
public function getTemplateRelativePath ( $ template ) { $ rootPath = Config :: getRootPath ( ) ; return str_replace ( $ rootPath , '' , $ this -> getTemplatePath ( ) ) . $ this -> _getRelativeTemplate ( $ template ) . $ this -> getSuffix ( ) ; }
get template relative path
30,794
public function getCompiledFile ( $ template ) { $ tplFile = static :: getTemplateFile ( $ template ) ; if ( $ this -> options [ 'engine' ] === 'php' ) { return $ tplFile ; } if ( file_exists ( $ tplFile ) ) { if ( is_file ( $ template ) ) { $ tplCompiledFile = static :: getCompiledPath ( ) . '/_file/' . md5 ( $ template ) . '.php' ; } else { $ tplCompiledFile = static :: getCompiledPath ( ) . $ this -> _getRelativeTemplate ( $ template ) . '.php' ; } if ( ! $ this -> options [ 'isCompiled' ] || ! file_exists ( $ tplCompiledFile ) || ( @ filemtime ( $ tplFile ) > @ filemtime ( $ tplCompiledFile ) ) ) { $ tplCompiledPath = dirname ( $ tplCompiledFile ) ; if ( ! file_exists ( $ tplCompiledPath ) ) { Dir :: create ( $ tplCompiledPath , 0755 ) ; } $ content = file_get_contents ( $ tplFile ) ; $ content = $ this -> parse ( $ content ) ; $ strlen = file_put_contents ( $ tplCompiledFile , $ content ) ; chmod ( $ tplCompiledFile , 0755 ) ; } return $ tplCompiledFile ; } else { throw new ViewException ( 'template: ' . $ tplFile . ' is not exists.' ) ; } }
get compiled template full path
30,795
public function clearCache ( ) { $ path = $ this -> getCompiledPath ( ) ; if ( is_dir ( $ path ) ) { return Dir :: delete ( $ path ) ; } return true ; }
clear template cache
30,796
public function renderMessageBox ( $ data = null ) { $ needData = [ 'url' => '_stop' , 'rootUrl' => Config :: getRootUrl ( ) , 'errtype' => '提示' ] ; $ data = $ data ? : [ ] ; $ data = array_merge ( $ needData , $ data ) ; $ template = $ this -> getMessageBoxTemplate ( ) ; return $ this -> setLayout ( null ) -> render ( $ template , $ data ) ; }
render messageBox template
30,797
public function contentfulEntryName ( string $ entryId ) : string { try { $ contentfulEntry = $ this -> contentful -> loadContentfulEntry ( $ entryId ) ; } catch ( Throwable $ t ) { return '' ; } return $ contentfulEntry -> getName ( ) ; }
Returns the Contentful entry name .
30,798
public function contentfulSpaceName ( string $ spaceId ) : string { $ client = $ this -> contentful -> getClientBySpaceId ( $ spaceId ) ; if ( ! $ client instanceof Client ) { return '' ; } return $ client -> getSpace ( ) -> getName ( ) ; }
Returns the Contentful space name .
30,799
public function contentfulContentTypeName ( string $ contentTypeId ) : string { $ contentType = $ this -> contentful -> getContentType ( $ contentTypeId ) ; if ( ! $ contentType instanceof ContentType ) { return '' ; } return $ contentType -> getName ( ) ; }
Returns the Contentful content type name .