idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
40,100 | protected function getAllFilesFromSuite ( $ suite ) { if ( ! file_exists ( $ suite -> testsFullPath ) ) { die ( 'FATAL ERROR: directory not found: ' . $ suite -> testsFullPath . '.' ) ; } $ files = Finder :: create ( ) -> files ( ) -> in ( $ suite -> testsFullPath ) ; if ( $ suite -> file_mask ) { $ files -> name ( $ suite -> file_mask ) ; } return iterator_to_array ( $ files , false ) ; } | Get all files from a suite . |
40,101 | public function getSuitesForPath ( $ path ) { $ projects = $ this -> getProjects ( ) ; $ filtered_projects = $ projects -> filter ( function ( $ project ) use ( $ path ) { return substr_count ( $ path , $ project -> path ) > 0 ; } ) ; $ depends = $ projects -> filter ( function ( $ project ) use ( $ filtered_projects ) { if ( ! is_null ( $ depends = config ( "tddd.projects.{$project->name}.depends" ) ) ) { return collect ( $ depends ) -> filter ( function ( $ item ) use ( $ filtered_projects ) { return ! is_null ( $ filtered_projects -> where ( 'name' , $ item ) -> first ( ) ) ; } ) ; } return false ; } ) ; return Suite :: whereIn ( 'project_id' , $ filtered_projects -> merge ( $ depends ) -> pluck ( 'id' ) ) -> get ( ) ; } | Get all suites for a path . |
40,102 | protected function formatName ( Item $ item ) { return empty ( $ item -> description ) ? $ item -> name : $ item -> name . ' (' . $ item -> description . ')' ; } | Formats name . |
40,103 | protected function updateChildren ( ) { $ children = $ this -> manager -> getChildren ( $ this -> item -> name ) ; $ childrenNames = array_keys ( $ children ) ; if ( is_array ( $ this -> children ) ) { foreach ( array_diff ( $ childrenNames , $ this -> children ) as $ item ) { $ this -> manager -> removeChild ( $ this -> item , $ children [ $ item ] ) ; } foreach ( array_diff ( $ this -> children , $ childrenNames ) as $ item ) { $ this -> manager -> addChild ( $ this -> item , $ this -> manager -> getItem ( $ item ) ) ; } } else { $ this -> manager -> removeChildren ( $ this -> item ) ; } } | Updated items children . |
40,104 | public function create ( ) { if ( $ this -> scenario != self :: SCENARIO_CREATE ) { return false ; } if ( ! $ this -> validate ( ) ) { return false ; } $ rule = \ Yii :: createObject ( [ 'class' => $ this -> class , 'name' => $ this -> name , ] ) ; $ this -> authManager -> add ( $ rule ) ; $ this -> authManager -> invalidateCache ( ) ; return true ; } | Creates new auth rule . |
40,105 | public function actionIndex ( ) { $ filterModel = new Search ( $ this -> type ) ; return $ this -> render ( 'index' , [ 'filterModel' => $ filterModel , 'dataProvider' => $ filterModel -> search ( \ Yii :: $ app -> request -> get ( ) ) , ] ) ; } | Lists all created items . |
40,106 | public function actionDelete ( $ name ) { $ item = $ this -> getItem ( $ name ) ; \ Yii :: $ app -> authManager -> remove ( $ item ) ; return $ this -> redirect ( [ 'index' ] ) ; } | Deletes item . |
40,107 | public function actionCreate ( ) { $ model = $ this -> getModel ( Rule :: SCENARIO_CREATE ) ; if ( \ Yii :: $ app -> request -> isAjax && $ model -> load ( \ Yii :: $ app -> request -> post ( ) ) ) { \ Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; return ActiveForm :: validate ( $ model ) ; } if ( $ model -> load ( \ Yii :: $ app -> request -> post ( ) ) && $ model -> create ( ) ) { \ Yii :: $ app -> session -> setFlash ( 'success' , \ Yii :: t ( 'rbac' , 'Rule has been added' ) ) ; return $ this -> redirect ( [ 'index' ] ) ; } return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; } | Shows page where new rule can be added . |
40,108 | public function actionDelete ( $ name ) { $ rule = $ this -> findRule ( $ name ) ; $ this -> authManager -> remove ( $ rule ) ; $ this -> authManager -> invalidateCache ( ) ; \ Yii :: $ app -> session -> setFlash ( 'success' , \ Yii :: t ( 'rbac' , 'Rule has been removed' ) ) ; return $ this -> redirect ( [ 'index' ] ) ; } | Removes rule . |
40,109 | public function actionSearch ( $ q = null ) { \ Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; return [ 'results' => $ this -> getSearchModel ( ) -> getRuleNames ( $ q ) ] ; } | Searches for rules . |
40,110 | public function up ( ) { $ transaction = $ this -> authManager -> db -> beginTransaction ( ) ; try { if ( $ this -> safeUp ( ) === false ) { $ transaction -> rollBack ( ) ; return false ; } $ transaction -> commit ( ) ; $ this -> authManager -> invalidateCache ( ) ; return true ; } catch ( \ Exception $ e ) { echo "Rolling transaction back\n" ; echo 'Exception: ' . $ e -> getMessage ( ) . ' (' . $ e -> getFile ( ) . ':' . $ e -> getLine ( ) . ")\n" ; echo $ e -> getTraceAsString ( ) . "\n" ; $ transaction -> rollBack ( ) ; return false ; } } | This method contains the logic to be executed when applying this migration . Child classes should not override this method but use safeUp instead . |
40,111 | protected function createPermission ( $ name , $ description = '' , $ ruleName = null , $ data = null ) { echo " > create permission $name ..." ; $ time = microtime ( true ) ; $ permission = $ this -> authManager -> createPermission ( $ name ) ; $ permission -> description = $ description ; $ permission -> ruleName = $ ruleName ; $ permission -> data = $ data ; $ this -> authManager -> add ( $ permission ) ; echo ' done (time: ' . sprintf ( '%.3f' , microtime ( true ) - $ time ) . "s)\n" ; return $ permission ; } | Creates new permission . |
40,112 | protected function createRule ( $ ruleName , $ definition ) { echo " > create rule $ruleName ..." ; $ time = microtime ( true ) ; if ( is_array ( $ definition ) ) { $ definition [ 'name' ] = $ ruleName ; } else { $ definition = [ 'class' => $ definition , 'name' => $ ruleName , ] ; } $ rule = \ Yii :: createObject ( $ definition ) ; $ this -> authManager -> add ( $ rule ) ; echo ' done (time: ' . sprintf ( '%.3f' , microtime ( true ) - $ time ) . "s)\n" ; return $ rule ; } | Creates new rule . |
40,113 | protected function findItem ( $ name ) { $ item = $ this -> authManager -> getRole ( $ name ) ; if ( $ item instanceof Role ) { return $ item ; } $ item = $ this -> authManager -> getPermission ( $ name ) ; if ( $ item instanceof Permission ) { return $ item ; } return null ; } | Finds either role or permission or throws an exception if it is not found . |
40,114 | protected function findRole ( $ name ) { $ role = $ this -> authManager -> getRole ( $ name ) ; if ( $ role instanceof Role ) { return $ role ; } return null ; } | Finds the role or throws an exception if it is not found . |
40,115 | protected function findPermission ( $ name ) { $ permission = $ this -> authManager -> getPermission ( $ name ) ; if ( $ permission instanceof Permission ) { return $ permission ; } return null ; } | Finds the permission or throws an exception if it is not found . |
40,116 | protected function removeItem ( $ item ) { if ( is_string ( $ item ) ) { $ item = $ this -> findItem ( $ item ) ; } echo " > removing $item->name ..." ; $ time = microtime ( true ) ; $ this -> authManager -> remove ( $ item ) ; echo ' done (time: ' . sprintf ( '%.3f' , microtime ( true ) - $ time ) . "s)\n" ; } | Removes auth item . |
40,117 | protected function addChild ( $ parent , $ child ) { if ( is_string ( $ parent ) ) { $ parent = $ this -> findItem ( $ parent ) ; } if ( is_string ( $ child ) ) { $ child = $ this -> findItem ( $ child ) ; } echo " > adding $child->name as child to $parent->name ..." ; $ time = microtime ( true ) ; $ this -> authManager -> addChild ( $ parent , $ child ) ; echo ' done (time: ' . sprintf ( '%.3f' , microtime ( true ) - $ time ) . "s)\n" ; } | Adds child . |
40,118 | protected function updateRole ( $ role , $ description = '' , $ ruleName = null , $ data = null ) { if ( is_string ( $ role ) ) { $ role = $ this -> findRole ( $ role ) ; } echo " > update role $role->name ..." ; $ time = microtime ( true ) ; $ role -> description = $ description ; $ role -> ruleName = $ ruleName ; $ role -> data = $ data ; $ this -> authManager -> update ( $ role -> name , $ role ) ; echo ' done (time: ' . sprintf ( '%.3f' , microtime ( true ) - $ time ) . "s)\n" ; return $ role ; } | Updates role . |
40,119 | protected function updatePermission ( $ permission , $ description = '' , $ ruleName = null , $ data = null ) { if ( is_string ( $ permission ) ) { $ permission = $ this -> findPermission ( $ permission ) ; } echo " > update permission $permission->name ..." ; $ time = microtime ( true ) ; $ permission -> description = $ description ; $ permission -> ruleName = $ ruleName ; $ permission -> data = $ data ; $ this -> authManager -> update ( $ permission -> name , $ permission ) ; echo ' done (time: ' . sprintf ( '%.3f' , microtime ( true ) - $ time ) . "s)\n" ; return $ permission ; } | Updates permission . |
40,120 | protected function updateRule ( $ ruleName , $ className ) { echo " > update rule $ruleName ..." ; $ time = microtime ( true ) ; $ rule = \ Yii :: createObject ( [ 'class' => $ className , 'name' => $ ruleName , ] ) ; $ this -> authManager -> update ( $ ruleName , $ rule ) ; echo ' done (time: ' . sprintf ( '%.3f' , microtime ( true ) - $ time ) . "s)\n" ; return $ rule ; } | Updates rule . |
40,121 | public function getNameList ( ) { $ rows = ( new Query ) -> select ( [ 'name' ] ) -> andWhere ( [ 'type' => $ this -> type ] ) -> from ( $ this -> manager -> itemTable ) -> all ( ) ; return ArrayHelper :: map ( $ rows , 'name' , 'name' ) ; } | Returns list of item names . |
40,122 | public function getRuleList ( ) { $ rows = ( new Query ( ) ) -> select ( [ 'name' ] ) -> from ( $ this -> manager -> ruleTable ) -> all ( ) ; return ArrayHelper :: map ( $ rows , 'name' , 'name' ) ; } | Returns list of rule names . |
40,123 | public function updateAssignments ( ) { if ( ! $ this -> validate ( ) ) { return false ; } if ( ! is_array ( $ this -> items ) ) { $ this -> items = [ ] ; } $ assignedItems = $ this -> manager -> getItemsByUser ( $ this -> user_id ) ; $ assignedItemsNames = array_keys ( $ assignedItems ) ; foreach ( array_diff ( $ assignedItemsNames , $ this -> items ) as $ item ) { $ this -> manager -> revoke ( $ assignedItems [ $ item ] , $ this -> user_id ) ; } foreach ( array_diff ( $ this -> items , $ assignedItemsNames ) as $ item ) { $ this -> manager -> assign ( $ this -> manager -> getItem ( $ item ) , $ this -> user_id ) ; } $ this -> updated = true ; return true ; } | Updates auth assignments for user . |
40,124 | public function getAvailableItems ( ) { return ArrayHelper :: map ( $ this -> manager -> getItems ( ) , 'name' , function ( $ item ) { return empty ( $ item -> description ) ? $ item -> name : $ item -> name . ' (' . $ item -> description . ')' ; } ) ; } | Returns all available auth items to be attached to user . |
40,125 | public function ignore ( $ value , $ column = 'id' ) { $ this -> ignoreValue = $ value ; $ this -> ignoreColumn = $ column ; return $ this ; } | Ignore any record that has a column with the given value . |
40,126 | public function validate ( $ attribute , $ value , $ parameters , $ validator ) { list ( $ name , $ locale ) = $ this -> getAttributeNameAndLocale ( $ attribute ) ; if ( $ this -> isUnique ( $ value , $ name , $ locale , $ parameters ) ) { return true ; } $ this -> addErrorsToValidator ( $ validator , $ parameters , $ name , $ locale ) ; return false ; } | Check if the translated value is unique in the database . |
40,127 | protected function getAttributeNameAndLocale ( $ attribute ) { $ parts = explode ( '.' , $ attribute ) ; $ name = $ parts [ 0 ] ; $ locale = $ parts [ 1 ] ?? App :: getLocale ( ) ; return [ $ name , $ locale ] ; } | Get the attribute name and locale . |
40,128 | protected function getConnectionAndTable ( $ parameters ) { $ parts = explode ( '.' , $ this -> getParameter ( $ parameters , 0 ) ) ; $ connection = isset ( $ parts [ 1 ] ) ? $ parts [ 0 ] : Config :: get ( 'database.default' ) ; $ table = $ parts [ 1 ] ?? $ parts [ 0 ] ; return [ $ connection , $ table ] ; } | Get the database connection and table name . |
40,129 | protected function isUnique ( $ value , $ name , $ locale , $ parameters ) { list ( $ connection , $ table ) = $ this -> getConnectionAndTable ( $ parameters ) ; $ column = $ this -> getParameter ( $ parameters , 1 ) ?? $ name ; $ ignoreValue = $ this -> getParameter ( $ parameters , 2 ) ; $ ignoreColumn = $ this -> getParameter ( $ parameters , 3 ) ; $ query = $ this -> findTranslation ( $ connection , $ table , $ column , $ locale , $ value ) ; $ query = $ this -> ignore ( $ query , $ ignoreColumn , $ ignoreValue ) ; $ query = $ this -> addConditions ( $ query , $ this -> getUniqueExtra ( $ parameters ) ) ; $ isUnique = $ query -> count ( ) === 0 ; return $ isUnique ; } | Check if a translation is unique . |
40,130 | protected function findTranslation ( $ connection , $ table , $ column , $ locale , $ value ) { return DB :: connection ( $ connection ) -> table ( $ table ) -> where ( "{$column}->{$locale}" , '=' , $ value ) ; } | Find the given translated value in the database . |
40,131 | protected function ignore ( $ query , $ column = null , $ value = null ) { if ( $ value !== null && $ column === null ) { $ column = 'id' ; } if ( $ column !== null ) { $ query = $ query -> where ( $ column , '!=' , $ value ) ; } return $ query ; } | Ignore the column with the given value . |
40,132 | protected function addErrorsToValidator ( $ validator , $ parameters , $ name , $ locale ) { $ rule = 'unique_translation' ; $ message = $ this -> getFormattedMessage ( $ validator , $ rule , $ parameters , $ name , $ locale ) ; $ validator -> errors ( ) -> add ( $ name , $ message ) -> add ( "{$name}.{$locale}" , $ message ) ; } | Add error messages to the validator . |
40,133 | protected function getFormattedMessage ( $ validator , $ rule , $ parameters , $ name , $ locale ) { $ message = $ this -> getMessage ( $ validator , $ rule , $ name , $ locale ) ; return $ validator -> makeReplacements ( $ message , $ name , $ rule , $ parameters ) ; } | Get the formatted error message . |
40,134 | protected function getMessage ( $ validator , $ rule , $ name , $ locale ) { $ keys = [ "{$name}.{$rule}" , "{$name}.*.{$rule}" , "{$name}.{$locale}.{$rule}" , ] ; foreach ( $ keys as $ key ) { if ( array_key_exists ( $ key , $ validator -> customMessages ) ) { return $ validator -> customMessages [ $ key ] ; } } return trans ( 'validation.unique' ) ; } | Get any custom message from the validator or return a default message . |
40,135 | public function create ( $ _ , $ assoc_args ) { if ( ! \ WP_CLI \ Utils \ get_flag_value ( $ assoc_args , 'force' ) && Utils \ locate_wp_config ( ) ) { WP_CLI :: error ( "The 'wp-config.php' file already exists." ) ; } $ defaults = [ 'dbhost' => 'localhost' , 'dbpass' => '' , 'dbprefix' => 'wp_' , 'dbcharset' => 'utf8' , 'dbcollate' => '' , 'locale' => self :: get_initial_locale ( ) , ] ; $ assoc_args = array_merge ( $ defaults , $ assoc_args ) ; if ( preg_match ( '|[^a-z0-9_]|i' , $ assoc_args [ 'dbprefix' ] ) ) { WP_CLI :: error ( '--dbprefix can only contain numbers, letters, and underscores.' ) ; } $ mysql_db_connection_args = [ 'execute' => ';' , 'host' => $ assoc_args [ 'dbhost' ] , 'user' => $ assoc_args [ 'dbuser' ] , 'pass' => $ assoc_args [ 'dbpass' ] , ] ; if ( ! Utils \ get_flag_value ( $ assoc_args , 'skip-check' ) ) { Utils \ run_mysql_command ( '/usr/bin/env mysql --no-defaults' , $ mysql_db_connection_args ) ; } if ( Utils \ get_flag_value ( $ assoc_args , 'extra-php' ) === true ) { $ assoc_args [ 'extra-php' ] = file_get_contents ( 'php://stdin' ) ; } if ( ! Utils \ get_flag_value ( $ assoc_args , 'skip-salts' ) ) { try { $ assoc_args [ 'keys-and-salts' ] = true ; $ assoc_args [ 'auth-key' ] = self :: unique_key ( ) ; $ assoc_args [ 'secure-auth-key' ] = self :: unique_key ( ) ; $ assoc_args [ 'logged-in-key' ] = self :: unique_key ( ) ; $ assoc_args [ 'nonce-key' ] = self :: unique_key ( ) ; $ assoc_args [ 'auth-salt' ] = self :: unique_key ( ) ; $ assoc_args [ 'secure-auth-salt' ] = self :: unique_key ( ) ; $ assoc_args [ 'logged-in-salt' ] = self :: unique_key ( ) ; $ assoc_args [ 'nonce-salt' ] = self :: unique_key ( ) ; $ assoc_args [ 'wp-cache-key-salt' ] = self :: unique_key ( ) ; } catch ( Exception $ e ) { $ assoc_args [ 'keys-and-salts' ] = false ; $ assoc_args [ 'keys-and-salts-alt' ] = self :: read_ ( 'https://api.wordpress.org/secret-key/1.1/salt/' ) ; } } if ( Utils \ wp_version_compare ( '4.0' , '<' ) ) { $ assoc_args [ 'add-wplang' ] = true ; } else { $ assoc_args [ 'add-wplang' ] = false ; } $ command_root = Utils \ phar_safe_path ( dirname ( __DIR__ ) ) ; $ out = Utils \ mustache_render ( "{$command_root}/templates/wp-config.mustache" , $ assoc_args ) ; $ bytes_written = file_put_contents ( ABSPATH . 'wp-config.php' , $ out ) ; if ( ! $ bytes_written ) { WP_CLI :: error ( "Could not create new 'wp-config.php' file." ) ; } else { WP_CLI :: success ( "Generated 'wp-config.php' file." ) ; } } | Generates a wp - config . php file . |
40,136 | public function edit ( ) { $ config_path = $ this -> get_config_path ( ) ; $ contents = file_get_contents ( $ config_path ) ; $ r = Utils \ launch_editor_for_input ( $ contents , 'wp-config.php' , 'php' ) ; if ( false === $ r ) { WP_CLI :: warning ( 'No changes made to wp-config.php.' , 'Aborted' ) ; } else { file_put_contents ( $ config_path , $ r ) ; } } | Launches system editor to edit the wp - config . php file . |
40,137 | public function list_ ( $ args , $ assoc_args ) { $ path = $ this -> get_config_path ( ) ; $ strict = Utils \ get_flag_value ( $ assoc_args , 'strict' ) ; if ( $ strict && empty ( $ args ) ) { WP_CLI :: error ( 'The --strict option can only be used in combination with a filter.' ) ; } $ default_fields = array ( 'name' , 'value' , 'type' , ) ; $ defaults = array ( 'fields' => implode ( ',' , $ default_fields ) , 'format' => 'table' , ) ; $ assoc_args = array_merge ( $ defaults , $ assoc_args ) ; $ values = self :: get_wp_config_vars ( ) ; if ( ! empty ( $ args ) ) { $ values = $ this -> filter_values ( $ values , $ args , $ strict ) ; } if ( empty ( $ values ) ) { WP_CLI :: error ( "No matching entries found in 'wp-config.php'." ) ; } Utils \ format_items ( $ assoc_args [ 'format' ] , $ values , $ assoc_args [ 'fields' ] ) ; } | Lists variables constants and file includes defined in wp - config . php file . |
40,138 | public function get ( $ args , $ assoc_args ) { $ path = $ this -> get_config_path ( ) ; list ( $ name ) = $ args ; $ type = Utils \ get_flag_value ( $ assoc_args , 'type' ) ; $ value = $ this -> return_value ( $ name , $ type , self :: get_wp_config_vars ( ) ) ; WP_CLI :: print_value ( $ value , $ assoc_args ) ; } | Gets the value of a specific constant or variable defined in wp - config . php file . |
40,139 | private static function get_wp_config_vars ( ) { $ wp_cli_original_defined_constants = get_defined_constants ( ) ; $ wp_cli_original_defined_vars = get_defined_vars ( ) ; $ wp_cli_original_includes = get_included_files ( ) ; eval ( WP_CLI :: get_runner ( ) -> get_wp_config_code ( ) ) ; $ wp_config_vars = self :: get_wp_config_diff ( get_defined_vars ( ) , $ wp_cli_original_defined_vars , 'variable' , array ( 'wp_cli_original_defined_vars' ) ) ; $ wp_config_constants = self :: get_wp_config_diff ( get_defined_constants ( ) , $ wp_cli_original_defined_constants , 'constant' ) ; foreach ( $ wp_config_vars as $ name => $ value ) { if ( 'wp_cli_original_includes' === $ value [ 'name' ] ) { $ name_backup = $ name ; break ; } } unset ( $ wp_config_vars [ $ name_backup ] ) ; $ wp_config_vars = array_values ( $ wp_config_vars ) ; $ wp_config_includes = array_diff ( get_included_files ( ) , $ wp_cli_original_includes ) ; $ wp_config_includes_array = [ ] ; foreach ( $ wp_config_includes as $ name => $ value ) { $ wp_config_includes_array [ ] = [ 'name' => basename ( $ value ) , 'value' => $ value , 'type' => 'includes' , ] ; } return array_merge ( $ wp_config_vars , $ wp_config_constants , $ wp_config_includes_array ) ; } | Get the array of wp - config . php constants and variables . |
40,140 | public function set ( $ args , $ assoc_args ) { $ path = $ this -> get_config_path ( ) ; list ( $ name , $ value ) = $ args ; $ type = Utils \ get_flag_value ( $ assoc_args , 'type' ) ; $ options = array ( ) ; $ option_flags = array ( 'raw' => false , 'add' => true , 'anchor' => null , 'placement' => null , 'separator' => null , ) ; foreach ( $ option_flags as $ option => $ default ) { $ option_value = Utils \ get_flag_value ( $ assoc_args , $ option , $ default ) ; if ( null !== $ option_value ) { $ options [ $ option ] = $ option_value ; if ( 'separator' === $ option ) { $ options [ 'separator' ] = $ this -> parse_separator ( $ options [ 'separator' ] ) ; } } } $ adding = false ; try { $ config_transformer = new WPConfigTransformer ( $ path ) ; switch ( $ type ) { case 'all' : $ has_constant = $ config_transformer -> exists ( 'constant' , $ name ) ; $ has_variable = $ config_transformer -> exists ( 'variable' , $ name ) ; if ( $ has_constant && $ has_variable ) { WP_CLI :: error ( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." ) ; } if ( ! $ has_constant && ! $ has_variable ) { if ( ! $ options [ 'add' ] ) { $ message = "The constant or variable '{$name}' is not defined in the 'wp-config.php' file." ; WP_CLI :: error ( $ message ) ; } $ type = 'constant' ; $ adding = true ; } else { $ type = $ has_constant ? 'constant' : 'variable' ; } break ; case 'constant' : case 'variable' : if ( ! $ config_transformer -> exists ( $ type , $ name ) ) { if ( ! $ options [ 'add' ] ) { WP_CLI :: error ( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." ) ; } $ adding = true ; } } $ config_transformer -> update ( $ type , $ name , $ value , $ options ) ; } catch ( Exception $ exception ) { WP_CLI :: error ( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" ) ; } $ raw = $ options [ 'raw' ] ? 'raw ' : '' ; if ( $ adding ) { $ message = "Added the {$type} '{$name}' to the 'wp-config.php' file with the {$raw}value '{$value}'." ; } else { $ message = "Updated the {$type} '{$name}' in the 'wp-config.php' file with the {$raw}value '{$value}'." ; } WP_CLI :: success ( $ message ) ; } | Sets the value of a specific constant or variable defined in wp - config . php file . |
40,141 | public function delete ( $ args , $ assoc_args ) { $ path = $ this -> get_config_path ( ) ; list ( $ name ) = $ args ; $ type = Utils \ get_flag_value ( $ assoc_args , 'type' ) ; try { $ config_transformer = new WPConfigTransformer ( $ path ) ; switch ( $ type ) { case 'all' : $ has_constant = $ config_transformer -> exists ( 'constant' , $ name ) ; $ has_variable = $ config_transformer -> exists ( 'variable' , $ name ) ; if ( $ has_constant && $ has_variable ) { WP_CLI :: error ( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." ) ; } if ( ! $ has_constant && ! $ has_variable ) { WP_CLI :: error ( "The constant or variable '{$name}' is not defined in the 'wp-config.php' file." ) ; } else { $ type = $ has_constant ? 'constant' : 'variable' ; } break ; case 'constant' : case 'variable' : if ( ! $ config_transformer -> exists ( $ type , $ name ) ) { WP_CLI :: error ( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." ) ; } } $ config_transformer -> remove ( $ type , $ name ) ; } catch ( Exception $ exception ) { WP_CLI :: error ( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" ) ; } WP_CLI :: success ( "Deleted the {$type} '{$name}' from the 'wp-config.php' file." ) ; } | Deletes a specific constant or variable from the wp - config . php file . |
40,142 | public function has ( $ args , $ assoc_args ) { $ path = $ this -> get_config_path ( ) ; list ( $ name ) = $ args ; $ type = Utils \ get_flag_value ( $ assoc_args , 'type' ) ; try { $ config_transformer = new WPConfigTransformer ( $ path ) ; switch ( $ type ) { case 'all' : $ has_constant = $ config_transformer -> exists ( 'constant' , $ name ) ; $ has_variable = $ config_transformer -> exists ( 'variable' , $ name ) ; if ( $ has_constant && $ has_variable ) { WP_CLI :: error ( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." ) ; } if ( ! $ has_constant && ! $ has_variable ) { WP_CLI :: halt ( 1 ) ; } else { WP_CLI :: halt ( 0 ) ; } break ; case 'constant' : case 'variable' : if ( ! $ config_transformer -> exists ( $ type , $ name ) ) { WP_CLI :: halt ( 1 ) ; } WP_CLI :: halt ( 0 ) ; } } catch ( Exception $ exception ) { WP_CLI :: error ( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" ) ; } } | Checks whether a specific constant or variable exists in the wp - config . php file . |
40,143 | public function shuffle_salts ( $ args , $ assoc_args ) { $ constant_list = array ( 'AUTH_KEY' , 'SECURE_AUTH_KEY' , 'LOGGED_IN_KEY' , 'NONCE_KEY' , 'AUTH_SALT' , 'SECURE_AUTH_SALT' , 'LOGGED_IN_SALT' , 'NONCE_SALT' , ) ; try { foreach ( $ constant_list as $ key ) { $ secret_keys [ $ key ] = trim ( self :: unique_key ( ) ) ; } } catch ( Exception $ ex ) { $ remote_salts = self :: read_ ( 'https://api.wordpress.org/secret-key/1.1/salt/' ) ; $ remote_salts = explode ( "\n" , $ remote_salts ) ; foreach ( $ remote_salts as $ k => $ salt ) { if ( ! empty ( $ salt ) ) { $ key = $ constant_list [ $ k ] ; $ secret_keys [ $ key ] = trim ( substr ( $ salt , 28 , 64 ) ) ; } } } $ path = $ this -> get_config_path ( ) ; try { $ config_transformer = new WPConfigTransformer ( $ path ) ; foreach ( $ secret_keys as $ constant => $ key ) { $ config_transformer -> update ( 'constant' , $ constant , ( string ) $ key ) ; } } catch ( Exception $ exception ) { WP_CLI :: error ( "Could not process the 'wp-config.php' transformation.\nReason: {$exception->getMessage()}" ) ; } WP_CLI :: success ( 'Shuffled the salt keys.' ) ; } | Refreshes the salts defined in the wp - config . php file . |
40,144 | private static function get_wp_config_diff ( $ list , $ previous_list , $ type , $ exclude_list = array ( ) ) { $ result = array ( ) ; foreach ( $ list as $ name => $ val ) { if ( array_key_exists ( $ name , $ previous_list ) || in_array ( $ name , $ exclude_list , true ) ) { continue ; } $ out = [ ] ; $ out [ 'name' ] = $ name ; $ out [ 'value' ] = $ val ; $ out [ 'type' ] = $ type ; $ result [ ] = $ out ; } return $ result ; } | Filters wp - config . php file configurations . |
40,145 | private function return_value ( $ name , $ type , $ values ) { $ results = array ( ) ; foreach ( $ values as $ value ) { if ( $ name === $ value [ 'name' ] && ( 'all' === $ type || $ type === $ value [ 'type' ] ) ) { $ results [ ] = $ value ; } } if ( count ( $ results ) > 1 ) { WP_CLI :: error ( "Found both a constant and a variable '{$name}' in the 'wp-config.php' file. Use --type=<type> to disambiguate." ) ; } if ( ! empty ( $ results ) ) { return $ results [ 0 ] [ 'value' ] ; } $ type = 'all' === $ type ? 'constant or variable' : $ type ; $ names = array_column ( $ values , 'name' ) ; $ candidate = Utils \ get_suggestion ( $ name , $ names ) ; if ( ! empty ( $ candidate ) && $ candidate !== $ name ) { WP_CLI :: error ( "The {$type} '{$name}' is not defined in the 'wp-config.php' file.\nDid you mean '{$candidate}'?" ) ; } WP_CLI :: error ( "The {$type} '{$name}' is not defined in the 'wp-config.php' file." ) ; } | Prints the value of a constant or variable defined in the wp - config . php file . |
40,146 | private function filter_values ( $ values , $ filters , $ strict ) { $ result = array ( ) ; foreach ( $ values as $ value ) { foreach ( $ filters as $ filter ) { if ( $ strict && $ filter !== $ value [ 'name' ] ) { continue ; } if ( false === strpos ( $ value [ 'name' ] , $ filter ) ) { continue ; } $ result [ ] = $ value ; } } return $ result ; } | Filters the values based on a provider filter key . |
40,147 | static function recursiveDelete ( $ dir , $ rootCheck = true ) { if ( ! is_dir ( $ dir ) ) { eZDebug :: writeError ( "The path: $dir is not a folder" , __METHOD__ ) ; return false ; } if ( $ rootCheck ) { $ allowedDirs = eZINI :: instance ( ) -> variable ( 'FileSettings' , 'AllowedDeletionDirs' ) ; $ rootDir = eZSys :: rootDir ( ) . DIRECTORY_SEPARATOR ; array_unshift ( $ allowedDirs , $ rootDir ) ; $ dirRealPath = dirname ( realpath ( $ dir ) ) . DIRECTORY_SEPARATOR ; $ canDelete = false ; foreach ( $ allowedDirs as $ allowedDir ) { if ( strpos ( $ dirRealPath , realpath ( $ allowedDir ) ) === 0 ) { $ canDelete = true ; break ; } } if ( ! $ canDelete ) { eZDebug :: writeError ( "Recursive delete denied for '$dir' as its realpath '$dirRealPath' is outside eZ Publish root and not registered in AllowedDeletionDirs." ) ; return false ; } } if ( ! ( $ handle = @ opendir ( $ dir ) ) ) { eZDebug :: writeError ( "Cannot access folder:" . dirname ( $ dir ) , __METHOD__ ) ; return false ; } while ( ( $ file = readdir ( $ handle ) ) !== false ) { if ( ( $ file == "." ) || ( $ file == ".." ) ) { continue ; } if ( is_dir ( $ dir . '/' . $ file ) ) { eZDir :: recursiveDelete ( $ dir . '/' . $ file , false ) ; } else { unlink ( $ dir . '/' . $ file ) ; } } @ closedir ( $ handle ) ; return rmdir ( $ dir ) ; } | Removes a directory and all it s contents recursively . |
40,148 | function setError ( $ connection = false ) { if ( $ this -> IsConnected ) { if ( $ connection === false ) $ connection = $ this -> DBConnection ; if ( $ connection instanceof MySQLi ) { $ this -> ErrorMessage = mysqli_error ( $ connection ) ; $ this -> ErrorNumber = mysqli_errno ( $ connection ) ; } } else { $ this -> ErrorMessage = mysqli_connect_error ( ) ; $ this -> ErrorNumber = mysqli_connect_errno ( ) ; } } | Sets the internal error messages & number |
40,149 | static function createFromNode ( $ node ) { $ row = array ( 'node_id' => $ node -> attribute ( 'node_id' ) , 'parent_node_id' => $ node -> attribute ( 'parent_node_id' ) , 'main_node_id' => $ node -> attribute ( 'main_node_id' ) , 'contentobject_id' => $ node -> attribute ( 'contentobject_id' ) , 'contentobject_version' => $ node -> attribute ( 'contentobject_version' ) , 'contentobject_is_published' => $ node -> attribute ( 'contentobject_is_published' ) , 'depth' => $ node -> attribute ( 'depth' ) , 'sort_field' => $ node -> attribute ( 'sort_field' ) , 'sort_order' => $ node -> attribute ( 'sort_order' ) , 'priority' => $ node -> attribute ( 'priority' ) , 'modified_subnode' => $ node -> attribute ( 'modified_subnode' ) , 'path_string' => $ node -> attribute ( 'path_string' ) , 'path_identification_string' => $ node -> attribute ( 'path_identification_string' ) , 'remote_id' => $ node -> attribute ( 'remote_id' ) , 'is_hidden' => $ node -> attribute ( 'is_hidden' ) , 'is_invisible' => $ node -> attribute ( 'is_invisible' ) , 'trashed' => time ( ) ) ; $ trashNode = new eZContentObjectTrashNode ( $ row ) ; return $ trashNode ; } | Creates a new eZContentObjectTrashNode based on an eZContentObjectTreeNode |
40,150 | function storeToTrash ( ) { $ this -> store ( ) ; $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ contentObject = $ this -> attribute ( 'object' ) ; $ offset = 0 ; $ limit = 20 ; while ( $ contentobjectAttributes = $ contentObject -> allContentObjectAttributes ( $ contentObject -> attribute ( 'id' ) , true , array ( 'limit' => $ limit , 'offset' => $ offset ) ) ) { foreach ( $ contentobjectAttributes as $ contentobjectAttribute ) { $ dataType = $ contentobjectAttribute -> dataType ( ) ; if ( ! $ dataType ) continue ; $ dataType -> trashStoredObjectAttribute ( $ contentobjectAttribute ) ; } $ offset += $ limit ; } $ db -> commit ( ) ; } | Stores this object to the trash |
40,151 | static function purgeForObject ( $ contentObjectID ) { if ( ! is_numeric ( $ contentObjectID ) ) return false ; $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ db -> query ( "DELETE FROM ezcontentobject_trash WHERE contentobject_id='$contentObjectID'" ) ; $ db -> commit ( ) ; } | Purges an object from the trash effectively deleting it from the database |
40,152 | function originalParentPathIdentificationString ( ) { $ originalParent = $ this -> originalParent ( ) ; if ( $ originalParent ) { return $ originalParent -> attribute ( 'path_identification_string' ) ; } $ path = $ this -> attribute ( 'path_identification_string' ) ; $ path = substr ( $ path , 0 , strrpos ( $ path , '/' ) ) ; return $ path ; } | Returns the path identification string of the node s parent if available . Otherwise returns the node s path identification string |
40,153 | public static function fetchByContentObjectID ( $ contentObjectID , $ asObject = true , $ contentObjectVersion = false ) { $ conds = array ( 'contentobject_id' => $ contentObjectID ) ; if ( $ contentObjectVersion !== false ) { $ conds [ 'contentobject_version' ] = $ contentObjectVersion ; } return self :: fetchObject ( self :: definition ( ) , null , $ conds , $ asObject ) ; } | Fetches a trash node by its content object id |
40,154 | function processBySchemaPresence ( $ element ) { $ parent = $ element -> parentNode ; if ( $ parent instanceof DOMElement ) { if ( ! $ this -> XMLSchema -> exists ( $ element ) ) { if ( $ element -> nodeName == 'custom' ) { $ this -> handleError ( self :: ERROR_SCHEMA , ezpI18n :: tr ( 'kernel/classes/datatypes/ezxmltext' , "Custom tag '%1' is not allowed." , false , array ( $ element -> getAttribute ( 'name' ) ) ) ) ; } $ element = $ parent -> removeChild ( $ element ) ; return false ; } if ( $ element -> nodeType == XML_ELEMENT_NODE && ( $ this -> XMLSchema -> childrenRequired ( $ element ) || $ element -> getAttribute ( 'children_required' ) ) && ! $ element -> hasChildNodes ( ) ) { $ element = $ parent -> removeChild ( $ element ) ; if ( ! $ element -> getAttributeNS ( 'http://ez.no/namespaces/ezpublish3/temporary/' , 'new-element' ) ) { $ this -> handleError ( self :: ERROR_SCHEMA , ezpI18n :: tr ( 'kernel/classes/datatypes/ezxmltext' , "<%1> tag can't be empty." , false , array ( $ element -> nodeName ) ) ) ; return false ; } } } elseif ( $ element -> nodeName != 'section' ) { return false ; } return true ; } | Check if the element is allowed to exist in this document and remove it if not . |
40,155 | function processBySchemaTree ( $ element ) { $ parent = $ element -> parentNode ; if ( $ parent instanceof DOMElement ) { $ schemaCheckResult = $ this -> XMLSchema -> check ( $ parent , $ element ) ; if ( ! $ schemaCheckResult ) { if ( $ schemaCheckResult === false ) { if ( $ element -> nodeType == XML_TEXT_NODE && ! trim ( $ element -> textContent ) ) { $ element = $ parent -> removeChild ( $ element ) ; return false ; } $ elementName = $ element -> nodeType == XML_ELEMENT_NODE ? '<' . $ element -> nodeName . '>' : $ element -> nodeName ; $ this -> handleError ( self :: ERROR_SCHEMA , ezpI18n :: tr ( 'kernel/classes/datatypes/ezxmltext' , "%1 is not allowed to be a child of <%2>." , false , array ( $ elementName , $ parent -> nodeName ) ) ) ; } $ this -> fixSubtree ( $ element , $ element ) ; return false ; } } elseif ( $ element -> nodeName != 'section' ) { return false ; } return true ; } | Check that element has a correct position in the tree and fix it if not . |
40,156 | function createAndPublishElement ( $ elementName , & $ ret ) { $ element = $ this -> Document -> createElement ( $ elementName ) ; $ element -> setAttributeNS ( 'http://ez.no/namespaces/ezpublish3/temporary/' , 'tmp:new-element' , 'true' ) ; if ( ! isset ( $ ret [ 'new_elements' ] ) ) { $ ret [ 'new_elements' ] = array ( ) ; } $ ret [ 'new_elements' ] [ ] = $ element ; return $ element ; } | and call structure and publish handlers ) |
40,157 | static function instance ( ) { if ( ! isset ( $ GLOBALS [ "eZHTTPToolInstance" ] ) || ! ( $ GLOBALS [ "eZHTTPToolInstance" ] instanceof eZHTTPTool ) ) { $ GLOBALS [ "eZHTTPToolInstance" ] = new eZHTTPTool ( ) ; $ GLOBALS [ "eZHTTPToolInstance" ] -> createPostVarsFromImageButtons ( ) ; } return $ GLOBALS [ "eZHTTPToolInstance" ] ; } | Return a unique instance of the eZHTTPTool class |
40,158 | static function redirect ( $ path , $ parameters = array ( ) , $ status = false , $ encodeURL = true , $ returnRedirectObject = false ) { $ url = eZHTTPTool :: createRedirectUrl ( $ path , $ parameters ) ; if ( strlen ( $ status ) > 0 ) { header ( $ _SERVER [ 'SERVER_PROTOCOL' ] . " " . $ status ) ; eZHTTPTool :: headerVariable ( "Status" , $ status ) ; } if ( $ encodeURL ) { $ url = eZURI :: encodeURL ( $ url ) ; } eZHTTPTool :: headerVariable ( 'Location' , $ url ) ; $ escapedUrl = htmlspecialchars ( $ url ) ; $ content = <<<EOT<HTML><HEAD><META HTTP-EQUIV="Refresh" Content="0;URL=$escapedUrl"><META HTTP-EQUIV="Location" Content="$escapedUrl"></HEAD><BODY></BODY></HTML>EOT ; if ( $ returnRedirectObject ) { return new ezpKernelRedirect ( $ url , $ status ? : null , $ content ) ; } echo $ content ; } | Performs an HTTP redirect . |
40,159 | static private function filterKeys ( array & $ keys ) { if ( isset ( $ GLOBALS [ 'eZRequestError' ] ) && $ GLOBALS [ 'eZRequestError' ] === true ) { $ requestUri = eZSys :: requestURI ( ) ; foreach ( $ keys as $ i => & $ key ) { if ( is_array ( $ key ) ) { self :: filterKeys ( $ key ) ; } else if ( $ key === $ requestUri ) { unset ( $ keys [ $ i ] ) ; } } } } | Filters cache keys when needed . Useful to avoid having current URI as a cache key if an error has occurred and has been caught by error module . |
40,160 | public static function fetchForClientUser ( ezpRestClient $ client , eZUser $ user ) { $ session = ezcPersistentSessionInstance :: get ( ) ; $ q = $ session -> createFindQuery ( __CLASS__ ) ; $ q -> where ( $ q -> expr -> eq ( 'rest_client_id' , $ q -> bindValue ( $ client -> id ) ) ) -> where ( $ q -> expr -> eq ( 'user_id' , $ q -> bindValue ( $ user -> attribute ( 'contentobject_id' ) ) ) ) ; $ results = $ session -> find ( $ q , __CLASS__ ) ; if ( count ( $ results ) != 1 ) return false ; else return array_shift ( $ results ) ; } | Returns the authorization object for a user & application |
40,161 | static function create ( $ workflowID , $ typeString ) { $ row = array ( "id" => null , "version" => 1 , "workflow_id" => $ workflowID , "workflow_type_string" => $ typeString , "description" => "" , "placement" => eZPersistentObject :: newObjectOrder ( eZWorkflowEvent :: definition ( ) , "placement" , array ( "version" => 1 , "workflow_id" => $ workflowID ) ) ) ; return new eZWorkflowEvent ( $ row ) ; } | Creates a new workflow event |
40,162 | function sort ( ) { $ rootNodes = $ this -> getRootNodes ( ) ; $ sorted = array ( ) ; while ( count ( $ this -> nodes ) > 0 ) { if ( count ( $ rootNodes ) === 0 ) return false ; $ current = array_shift ( $ rootNodes ) ; $ sorted [ ] = $ current -> name ; while ( $ child = $ current -> popChild ( ) ) { $ child -> unregisterParent ( $ this -> nodes [ $ current -> name ] ) ; if ( $ child -> parentCount ( ) === 0 ) $ rootNodes [ ] = $ child ; } unset ( $ this -> nodes [ $ current -> name ] ) ; } return $ sorted ; } | Performs the topological linear ordering . |
40,163 | private function getRootNodes ( ) { $ output = array ( ) ; foreach ( $ this -> nodes as $ node ) if ( ! $ node -> parentCount ( ) ) $ output [ ] = $ node ; return $ output ; } | Returns a list of node objects that do not have parents . |
40,164 | protected function address ( ) { $ user = eZUser :: fetch ( $ this -> UserID ) ; if ( $ user instanceof eZUser ) { return $ user -> attribute ( 'email' ) ; } return '' ; } | Returns the email address of the user associated with the digest settings . |
40,165 | static function fetchByUserId ( $ userId , $ asObject = true ) { return eZPersistentObject :: fetchObject ( self :: definition ( ) , null , array ( 'user_id' => $ userId ) , $ asObject ) ; } | Returns the digest settings object for the user |
40,166 | public static function decodeIRI ( $ str ) { $ str = urldecode ( $ str ) ; $ codec = eZTextCodec :: instance ( 'utf-8' ) ; return $ codec -> convertString ( $ str ) ; } | Decodes a path string which is in IRI format and returns the new path in the internal encoding . |
40,167 | public static function encodeIRI ( $ str ) { $ codec = eZTextCodec :: instance ( false , 'utf-8' ) ; $ str = $ codec -> convertString ( $ str ) ; $ out = explode ( "/" , $ str ) ; foreach ( $ out as $ i => $ o ) { if ( preg_match ( "#^[\(]([a-zA-Z0-9_]+)[\)]#" , $ o , $ m ) ) { $ out [ $ i ] = '(' . urlencode ( $ m [ 1 ] ) . ')' ; } else { $ out [ $ i ] = urlencode ( $ o ) ; } } $ tmp = join ( "/" , $ out ) ; $ tmp = str_replace ( '%7E' , '~' , $ tmp ) ; return $ tmp ; } | Encodes path string in internal encoding to a new string which conforms to the IRI specification . |
40,168 | public function setURIString ( $ uri , $ fullInitialize = true ) { if ( strlen ( $ uri ) > 0 and $ uri [ 0 ] == '/' ) $ uri = substr ( $ uri , 1 ) ; $ uri = eZURI :: decodeIRI ( $ uri ) ; $ this -> URI = $ uri ; $ this -> URIArray = explode ( '/' , $ uri ) ; $ this -> Index = 0 ; if ( ! $ fullInitialize ) return ; $ this -> OriginalURI = $ uri ; $ this -> UserArray = array ( ) ; unset ( $ paramName , $ paramValue ) ; foreach ( array_keys ( $ this -> URIArray ) as $ key ) { if ( ! isset ( $ this -> URIArray [ $ key ] ) ) continue ; if ( preg_match ( "/^[\(][a-zA-Z0-9_]+[\)]/" , $ this -> URIArray [ $ key ] ) ) { if ( isset ( $ paramName , $ paramValue ) ) { $ this -> UserArray [ $ paramName ] = $ paramValue ; unset ( $ paramName , $ paramValue ) ; } $ paramName = substr ( $ this -> URIArray [ $ key ] , 1 , strlen ( $ this -> URIArray [ $ key ] ) - 2 ) ; if ( isset ( $ this -> URIArray [ $ key + 1 ] ) ) { $ this -> UserArray [ $ paramName ] = $ this -> URIArray [ $ key + 1 ] ; unset ( $ this -> URIArray [ $ key + 1 ] ) ; } else $ this -> UserArray [ $ paramName ] = "" ; unset ( $ this -> URIArray [ $ key ] ) ; } else if ( isset ( $ paramName ) ) { $ this -> UserArray [ $ paramName ] .= '/' . $ this -> URIArray [ $ key ] ; unset ( $ this -> URIArray [ $ key ] ) ; } } $ this -> URI = implode ( '/' , $ this -> URIArray ) ; if ( eZINI :: instance ( 'template.ini' ) -> variable ( 'ControlSettings' , 'AllowUserVariables' ) == 'false' ) { $ this -> UserArray = array ( ) ; } $ this -> convertFilterString ( ) ; } | Sets uri string for instance |
40,169 | public function element ( $ index = 0 , $ relative = true ) { $ pos = $ index ; if ( $ relative ) $ pos += $ this -> Index ; if ( isset ( $ this -> URIArray [ $ pos ] ) ) return $ this -> URIArray [ $ pos ] ; $ ret = null ; return $ ret ; } | Get element index from uri |
40,170 | public function elements ( $ as_text = true ) { $ elements = array_slice ( $ this -> URIArray , $ this -> Index ) ; if ( $ as_text ) { $ retValue = implode ( '/' , $ elements ) ; return $ retValue ; } else return $ elements ; } | Return all URI elements |
40,171 | public function dropBase ( ) { $ elements = array_slice ( $ this -> URIArray , $ this -> Index ) ; $ this -> URIArray = $ elements ; $ this -> URI = implode ( '/' , $ this -> URIArray ) ; $ uri = $ this -> URI ; foreach ( $ this -> UserArray as $ name => $ value ) { $ uri .= '/(' . $ name . ')/' . $ value ; } $ this -> OriginalURI = $ uri ; $ this -> Index = 0 ; } | Removes all elements below the current index recreates the URI string and sets index to 0 . |
40,172 | public function base ( $ as_text = true ) { $ elements = array_slice ( $ this -> URIArray , 0 , $ this -> Index ) ; if ( $ as_text ) { $ baseAsText = '/' . implode ( '/' , $ elements ) ; return $ baseAsText ; } else return $ elements ; } | Return the elements before pointer |
40,173 | public function attribute ( $ attr ) { switch ( $ attr ) { case 'element' : return $ this -> element ( ) ; break ; case 'tail' : return $ this -> elements ( ) ; break ; case 'base' : return $ this -> base ( ) ; break ; case 'index' : return $ this -> index ( ) ; break ; case 'uri' : return $ this -> uriString ( ) ; break ; case 'original_uri' : return $ this -> originalURIString ( ) ; break ; case 'query_string' : return eZSys :: queryString ( ) ; break ; default : { eZDebug :: writeError ( "Attribute '$attr' does not exist" , __METHOD__ ) ; return null ; } break ; } } | Get value for an attribute |
40,174 | public static function transformURI ( & $ href , $ ignoreIndexDir = false , $ serverURL = null , $ htmlEscape = true ) { if ( $ ignoreIndexDir ) { $ trimmedHref = ltrim ( $ href , '/' ) ; $ modifiedHref = eZClusterFileHandler :: instance ( ) -> applyServerUri ( $ trimmedHref ) ; if ( $ modifiedHref != $ trimmedHref ) { $ href = $ htmlEscape ? self :: escapeHtmlTransformUri ( $ href ) : $ href ; return true ; } unset ( $ modifiedHref ) ; } if ( $ serverURL === null ) { $ serverURL = self :: $ transformURIMode ; } if ( preg_match ( "#^[a-zA-Z0-9]+:#" , $ href ) || substr ( $ href , 0 , 2 ) == '//' ) return false ; if ( strlen ( $ href ) == 0 ) $ href = '/' ; else if ( $ href [ 0 ] == '#' ) { $ href = $ htmlEscape ? htmlspecialchars ( $ href ) : $ href ; return true ; } else if ( $ href [ 0 ] != '/' ) { $ href = '/' . $ href ; } $ sys = eZSys :: instance ( ) ; $ dir = ! $ ignoreIndexDir ? $ sys -> indexDir ( ) : $ sys -> wwwDir ( ) ; $ serverURL = $ serverURL === 'full' ? $ sys -> serverURL ( ) : '' ; $ href = $ serverURL . $ dir . $ href ; if ( ! $ ignoreIndexDir ) { $ href = preg_replace ( "#^(//)#" , "/" , $ href ) ; $ href = preg_replace ( "#(^.*)(/+)$#" , "\$1" , $ href ) ; } $ href = $ htmlEscape ? self :: escapeHtmlTransformUri ( $ href ) : $ href ; if ( $ href == "" ) $ href = "/" ; return true ; } | Implementation of an ezurl template operator Makes valid eZ Publish urls to use in links |
40,175 | function initialize ( $ path , $ file , $ moduleName , $ checkFileExistence = true ) { if ( $ checkFileExistence === false || file_exists ( $ file ) ) { unset ( $ FunctionList ) ; unset ( $ Module ) ; unset ( $ ViewList ) ; include ( $ file ) ; $ this -> Functions = $ ViewList ; if ( isset ( $ FunctionList ) and is_array ( $ FunctionList ) and count ( $ FunctionList ) > 0 ) { ksort ( $ FunctionList , SORT_STRING ) ; $ this -> FunctionList = $ FunctionList ; } else { $ this -> FunctionList = array ( ) ; } if ( empty ( $ Module ) ) { $ Module = array ( "name" => "null" , "variable_params" => false , "function" => array ( ) ) ; } $ this -> Module = $ Module ; $ this -> Name = $ moduleName ; $ this -> Path = $ path ; $ this -> Title = "" ; $ this -> UIContext = 'navigation' ; $ this -> UIComponent = $ moduleName ; $ uiComponentMatch = 'module' ; if ( isset ( $ this -> Module [ 'ui_component_match' ] ) ) { $ uiComponentMatch = $ this -> Module [ 'ui_component_match' ] ; } $ this -> UIComponentMatch = $ uiComponentMatch ; foreach ( $ this -> Functions as $ key => $ dummy ) { $ this -> Functions [ $ key ] [ "uri" ] = "/$moduleName/$key" ; } } else { $ this -> Functions = array ( ) ; $ this -> Module = array ( "name" => "null" , "variable_params" => false , "function" => array ( ) ) ; $ this -> Name = $ moduleName ; $ this -> Path = $ path ; $ this -> Title = "" ; $ this -> UIContext = 'navigation' ; $ this -> UIComponent = $ moduleName ; $ this -> UIComponentMatch = 'module' ; } $ this -> HookList = array ( ) ; $ this -> ExitStatus = self :: STATUS_IDLE ; $ this -> ErrorCode = 0 ; $ this -> ViewActions = array ( ) ; $ this -> OriginalParameters = null ; $ this -> UserParameters = array ( ) ; $ ini = eZINI :: instance ( 'module.ini' ) ; $ this -> NavigationParts = $ ini -> variable ( 'ModuleOverrides' , 'NavigationPart' ) ; } | Initializes the module object . |
40,176 | function functionURI ( $ function ) { if ( $ this -> singleFunction ( ) or $ function == '' ) return $ this -> uri ( ) ; if ( isset ( $ this -> Functions [ $ function ] ) ) return $ this -> Functions [ $ function ] [ "uri" ] ; else return null ; } | Returns the URI to a module s function |
40,177 | function setCurrentName ( $ name ) { $ this -> Name = $ name ; foreach ( $ this -> Functions as $ key => $ dummy ) { $ this -> Functions [ $ key ] [ "uri" ] = "/$name/$key" ; } } | Sets the name of the currently running module . The URIs will be updated accordingly |
40,178 | function handleError ( $ errorCode , $ errorType = false , $ parameters = array ( ) , $ userParameters = false ) { if ( self :: $ useExceptions && $ errorType === "kernel" ) { switch ( $ errorCode ) { case eZError :: KERNEL_MODULE_NOT_FOUND : throw new ezpModuleNotFound ( $ parameters [ "module" ] ) ; case eZError :: KERNEL_MODULE_DISABLED : if ( $ parameters [ "check" ] [ "view_checked" ] ) throw new ezpModuleViewDisabled ( $ parameters [ "check" ] [ 'module' ] , $ parameters [ "check" ] [ 'view' ] ) ; throw new ezpModuleDisabled ( $ parameters [ "check" ] [ 'module' ] ) ; case eZError :: KERNEL_MODULE_VIEW_NOT_FOUND : throw new ezpModuleViewNotFound ( $ parameters [ "check" ] [ 'module' ] , $ parameters [ "check" ] [ 'view' ] ) ; case eZError :: KERNEL_ACCESS_DENIED : throw new ezpAccessDenied ; case eZError :: KERNEL_NOT_AVAILABLE : case eZError :: KERNEL_NOT_FOUND : throw new ezpContentNotFoundException ( "" ) ; case eZError :: KERNEL_LANGUAGE_NOT_FOUND : throw new ezpLanguageNotFound ; } } if ( ! $ errorType ) { eZDebug :: writeWarning ( "No error type specified for error code $errorCode, assuming kernel.\nA specific error type should be supplied, please check your code." , __METHOD__ ) ; $ errorType = 'kernel' ; } $ errorModule = $ this -> errorModule ( ) ; $ module = self :: findModule ( $ errorModule [ 'module' ] , $ this ) ; if ( $ module === null ) { return false ; } $ result = $ module -> run ( $ errorModule [ 'view' ] , array ( $ errorType , $ errorCode , $ parameters , $ userParameters ) ) ; if ( $ this -> exitStatus ( ) != self :: STATUS_REDIRECT and $ this -> exitStatus ( ) != self :: STATUS_RERUN ) { $ this -> setExitStatus ( self :: STATUS_FAILED ) ; $ this -> setErrorCode ( $ errorCode ) ; } return $ result ; } | Runs the defined error module Sets the state of the module object to \ c failed and sets the error code . |
40,179 | function redirectToView ( $ viewName = '' , $ parameters = array ( ) , $ unorderedParameters = null , $ userParameters = false , $ anchor = false ) { return $ this -> redirectModule ( $ this , $ viewName , $ parameters , $ unorderedParameters , $ userParameters , $ anchor ) ; } | Redirects to another view in the current module |
40,180 | function currentRedirectionURI ( ) { $ module = $ this ; $ viewName = self :: currentView ( ) ; $ parameters = $ this -> OriginalViewParameters ; $ unorderedParameters = $ this -> OriginalUnorderedParameters ; $ userParameters = $ this -> UserParameters ; return $ this -> redirectionURIForModule ( $ module , $ viewName , $ parameters , $ unorderedParameters , $ userParameters ) ; } | Creates the redirection URI for the current module view & parameters |
40,181 | function parameters ( $ viewName = '' ) { if ( $ viewName == '' ) $ viewName = self :: currentView ( ) ; $ viewData = $ this -> viewData ( $ viewName ) ; if ( isset ( $ viewData [ 'params' ] ) ) { return $ viewData [ 'params' ] ; } return null ; } | Returns the defined parameter for a view . |
40,182 | function unorderedParameters ( $ viewName = '' ) { if ( $ viewName == '' ) $ viewName = self :: currentView ( ) ; $ viewData = $ this -> viewData ( $ viewName ) ; if ( isset ( $ viewData [ 'unordered_params' ] ) ) { return $ viewData [ 'unordered_params' ] ; } return null ; } | Returns the unordered parameters definition . |
40,183 | function viewData ( $ viewName = '' ) { if ( $ viewName == '' ) $ viewName = self :: currentView ( ) ; if ( $ this -> singleFunction ( ) ) $ viewData = $ this -> Module [ "function" ] ; else $ viewData = $ this -> Functions [ $ viewName ] ; return $ viewData ; } | Returns data for a view |
40,184 | function redirectTo ( $ uri ) { $ originalURI = $ uri ; $ uri = preg_replace ( "#(^.*)(/+)$#" , "\$1" , $ uri ) ; if ( strlen ( $ originalURI ) != 0 and strlen ( $ uri ) == 0 ) $ uri = '/' ; $ urlComponents = parse_url ( $ uri ) ; $ currentHostname = eZSys :: hostname ( ) ; $ currentHostnameParsed = parse_url ( $ currentHostname , PHP_URL_HOST ) ; $ currentHostname = $ currentHostnameParsed ? $ currentHostnameParsed : $ currentHostname ; if ( isset ( $ urlComponents [ 'host' ] ) && $ urlComponents [ 'host' ] !== $ currentHostname ) { $ allowedHosts = $ this -> getAllowedRedirectHosts ( ) ; if ( ! isset ( $ allowedHosts [ $ urlComponents [ 'host' ] ] ) ) { eZDebug :: writeError ( "Redirection requested on non-authorized host '{$urlComponents['host']}'" ) ; header ( $ _SERVER [ 'SERVER_PROTOCOL' ] . ' 403 Forbidden' ) ; echo "Redirection requested on non-authorized host" ; eZDB :: checkTransactionCounter ( ) ; eZExecution :: cleanExit ( ) ; } } $ this -> RedirectURI = $ uri ; $ this -> setExitStatus ( self :: STATUS_REDIRECT ) ; } | Sets the module to redirect at the end of the execution |
40,185 | private function getAllowedRedirectHosts ( ) { $ ini = eZINI :: instance ( ) ; $ allowedHosts = array_fill_keys ( $ ini -> variable ( 'SiteSettings' , 'AllowedRedirectHosts' ) , true ) ; if ( $ ini -> hasVariable ( 'SiteAccessSettings' , 'HostMatchMapItems' ) ) { $ hostMatchMapItems = $ ini -> variable ( 'SiteAccessSettings' , 'HostMatchMapItems' ) ; foreach ( $ hostMatchMapItems as $ item ) { list ( $ host , $ sa ) = explode ( ';' , $ item ) ; $ allowedHosts [ $ host ] = true ; } } foreach ( $ ini -> variable ( 'SiteAccessSettings' , 'HostUriMatchMapItems' ) as $ item ) { list ( $ host , $ uri , $ sa ) = explode ( ';' , $ item ) ; $ allowedHosts [ $ host ] = true ; } return $ allowedHosts ; } | Returns the set of hosts that are allowed for absolute redirection |
40,186 | function attribute ( $ attr ) { switch ( $ attr ) { case "uri" : return $ this -> uri ( ) ; break ; case "functions" : return $ this -> Functions ; case "views" : return $ this -> Functions ; case "name" : return $ this -> Name ; case "path" : return $ this -> Path ; case "info" : return $ this -> Module ; case 'aviable_functions' : case 'available_functions' : return $ this -> FunctionList ; default : { eZDebug :: writeError ( "Attribute '$attr' does not exist" , __METHOD__ ) ; return null ; } break ; } } | Returns the value of an attribute |
40,187 | function setCurrentAction ( $ actionName , $ view = '' ) { if ( $ view == '' ) $ view = self :: currentView ( ) ; if ( $ view == '' or $ actionName == '' ) return false ; $ this -> ViewActions [ $ view ] = $ actionName ; } | Sets the current action for a view |
40,188 | function currentAction ( $ view = '' ) { if ( $ view == '' ) $ view = self :: currentView ( ) ; if ( isset ( $ this -> ViewActions [ $ view ] ) ) return $ this -> ViewActions [ $ view ] ; $ http = eZHTTPTool :: instance ( ) ; if ( isset ( $ this -> Functions [ $ view ] [ 'default_action' ] ) ) { $ defaultAction = $ this -> Functions [ $ view ] [ 'default_action' ] ; foreach ( $ defaultAction as $ defaultActionStructure ) { $ actionName = $ defaultActionStructure [ 'name' ] ; $ type = $ defaultActionStructure [ 'type' ] ; if ( $ type == 'post' ) { $ parameters = array ( ) ; if ( isset ( $ defaultActionStructure [ 'parameters' ] ) ) $ parameters = $ defaultActionStructure [ 'parameters' ] ; $ hasParameters = true ; foreach ( $ parameters as $ parameterName ) { if ( ! $ http -> hasPostVariable ( $ parameterName ) ) { $ hasParameters = false ; break ; } } if ( $ hasParameters ) { $ this -> ViewActions [ $ view ] = $ actionName ; return $ this -> ViewActions [ $ view ] ; } } else { eZDebug :: writeWarning ( 'Unknown default action type: ' . $ type , __METHOD__ ) ; } } } if ( isset ( $ this -> Functions [ $ view ] [ 'single_post_actions' ] ) ) { $ singlePostActions = $ this -> Functions [ $ view ] [ 'single_post_actions' ] ; foreach ( $ singlePostActions as $ postActionName => $ realActionName ) { if ( $ http -> hasPostVariable ( $ postActionName ) ) { $ this -> ViewActions [ $ view ] = $ realActionName ; return $ this -> ViewActions [ $ view ] ; } } } if ( isset ( $ this -> Functions [ $ view ] [ 'post_actions' ] ) ) { $ postActions = $ this -> Functions [ $ view ] [ 'post_actions' ] ; foreach ( $ postActions as $ postActionName ) { if ( $ http -> hasPostVariable ( $ postActionName ) ) { $ this -> ViewActions [ $ view ] = $ http -> postVariable ( $ postActionName ) ; return $ this -> ViewActions [ $ view ] ; } } } $ this -> ViewActions [ $ view ] = false ; return false ; } | Returns the current action name . |
40,189 | function setActionParameter ( $ parameterName , $ parameterValue , $ view = '' ) { if ( $ view == '' ) $ view = self :: currentView ( ) ; $ this -> ViewActionParameters [ $ view ] [ $ parameterName ] = $ parameterValue ; } | Sets an action parameter value |
40,190 | function actionParameter ( $ parameterName , $ view = '' ) { if ( $ view == '' ) $ view = self :: currentView ( ) ; if ( isset ( $ this -> ViewActionParameters [ $ view ] [ $ parameterName ] ) ) return $ this -> ViewActionParameters [ $ view ] [ $ parameterName ] ; $ currentAction = $ this -> currentAction ( $ view ) ; $ http = eZHTTPTool :: instance ( ) ; if ( isset ( $ this -> Functions [ $ view ] [ 'post_action_parameters' ] [ $ currentAction ] ) ) { $ postParameters = $ this -> Functions [ $ view ] [ 'post_action_parameters' ] [ $ currentAction ] ; if ( isset ( $ postParameters [ $ parameterName ] ) && $ http -> hasPostVariable ( $ postParameters [ $ parameterName ] ) ) { return $ http -> postVariable ( $ postParameters [ $ parameterName ] ) ; } eZDebug :: writeError ( "No such action parameter: $parameterName" , __METHOD__ ) ; } if ( isset ( $ this -> Functions [ $ view ] [ 'post_value_action_parameters' ] [ $ currentAction ] ) ) { $ postParameters = $ this -> Functions [ $ view ] [ 'post_value_action_parameters' ] [ $ currentAction ] ; if ( isset ( $ postParameters [ $ parameterName ] ) ) { $ postVariables = $ http -> attribute ( 'post' ) ; $ postVariableNameMatch = $ postParameters [ $ parameterName ] ; $ regMatch = "/^" . $ postVariableNameMatch . "_(.+)$/" ; foreach ( $ postVariables as $ postVariableName => $ postVariableValue ) { if ( preg_match ( $ regMatch , $ postVariableName , $ matches ) ) { $ parameterValue = $ matches [ 1 ] ; $ this -> ViewActionParameters [ $ view ] [ $ parameterName ] = $ parameterValue ; return $ parameterValue ; } } eZDebug :: writeError ( "No such action parameter: $parameterName" , __METHOD__ ) ; } } return null ; } | Returns an action parameter value |
40,191 | function hasActionParameter ( $ parameterName , $ view = '' ) { if ( $ view == '' ) $ view = self :: currentView ( ) ; if ( isset ( $ this -> ViewActionParameters [ $ view ] [ $ parameterName ] ) ) return true ; $ currentAction = $ this -> currentAction ( $ view ) ; $ http = eZHTTPTool :: instance ( ) ; if ( isset ( $ this -> Functions [ $ view ] [ 'post_action_parameters' ] [ $ currentAction ] ) ) { $ postParameters = $ this -> Functions [ $ view ] [ 'post_action_parameters' ] [ $ currentAction ] ; if ( isset ( $ postParameters [ $ parameterName ] ) and $ http -> hasPostVariable ( $ postParameters [ $ parameterName ] ) ) { return true ; } } if ( isset ( $ this -> Functions [ $ view ] [ 'post_value_action_parameters' ] [ $ currentAction ] ) ) { $ postParameters = $ this -> Functions [ $ view ] [ 'post_value_action_parameters' ] [ $ currentAction ] ; if ( isset ( $ postParameters [ $ parameterName ] ) ) { $ postVariables = $ http -> attribute ( 'post' ) ; $ postVariableNameMatch = $ postParameters [ $ parameterName ] ; $ regMatch = "/^" . $ postVariableNameMatch . "_(.+)$/" ; foreach ( $ postVariables as $ postVariableName => $ postVariableValue ) { if ( preg_match ( $ regMatch , $ postVariableName , $ matches ) ) { $ parameterValue = $ matches [ 1 ] ; $ this -> ViewActionParameters [ $ view ] [ $ parameterName ] = $ parameterValue ; return true ; } } } } return false ; } | Checks if an action parameter is defined for a view |
40,192 | function isCurrentAction ( $ actionName , $ view = '' ) { if ( $ view == '' ) $ view = self :: currentView ( ) ; if ( $ view == '' or $ actionName == '' ) return false ; return $ this -> currentAction ( $ view ) == $ actionName ; } | Checks if the current action is the given one |
40,193 | function setViewResult ( $ result , $ view = '' ) { if ( $ view == '' ) $ view = $ this -> currentView ( ) ; $ this -> ViewResult [ $ view ] = $ result ; } | Sets the view result |
40,194 | function hasViewResult ( $ view = '' ) { if ( $ view == '' ) $ view = $ this -> currentView ( ) ; return isset ( $ this -> ViewResult [ $ view ] ) ; } | Checks if a view has a result set |
40,195 | function viewResult ( $ view = '' ) { if ( $ view == '' ) $ view = $ this -> currentView ( ) ; if ( isset ( $ this -> ViewResult [ $ view ] ) ) { return $ this -> ViewResult [ $ view ] ; } return null ; } | Returns the view result |
40,196 | static function activeModuleRepositories ( $ useExtensions = true ) { $ moduleINI = eZINI :: instance ( 'module.ini' ) ; $ moduleRepositories = $ moduleINI -> variable ( 'ModuleSettings' , 'ModuleRepositories' ) ; if ( $ useExtensions ) { $ extensionRepositories = $ moduleINI -> variable ( 'ModuleSettings' , 'ExtensionRepositories' ) ; $ extensionDirectory = eZExtension :: baseDirectory ( ) ; $ activeExtensions = eZExtension :: activeExtensions ( ) ; $ globalExtensionRepositories = array ( ) ; foreach ( $ extensionRepositories as $ extensionRepository ) { $ extPath = $ extensionDirectory . '/' . $ extensionRepository ; $ modulePath = $ extPath . '/modules' ; if ( ! in_array ( $ extensionRepository , $ activeExtensions ) ) { eZDebug :: writeWarning ( "Extension '$extensionRepository' was reported to have modules but has not yet been activated.\n" . "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions\n" . "or make sure it is activated in the setting ExtensionSettings/ActiveExtensions in site.ini." ) ; } else if ( file_exists ( $ modulePath ) ) { $ globalExtensionRepositories [ ] = $ modulePath ; } else if ( ! file_exists ( $ extPath ) ) { eZDebug :: writeWarning ( "Extension '$extensionRepository' was reported to have modules but the extension itself does not exist.\n" . "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions.\n" . "You should probably remove this extension from the list." ) ; } else { eZDebug :: writeWarning ( "Extension '$extensionRepository' does not have the subdirectory 'modules' allthough it reported it had modules.\n" . "Looked for directory '" . $ modulePath . "'\n" . "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extension." ) ; } } $ moduleRepositories = array_merge ( $ moduleRepositories , $ globalExtensionRepositories ) ; } return $ moduleRepositories ; } | Returns the list of active module repositories as defined in module . ini |
40,197 | static function addGlobalPathList ( $ pathList ) { if ( ! is_array ( $ GLOBALS [ 'eZModuleGlobalPathList' ] ) ) { $ GLOBALS [ 'eZModuleGlobalPathList' ] = array ( ) ; } if ( ! is_array ( $ pathList ) ) { $ pathList = array ( $ pathList ) ; } $ GLOBALS [ 'eZModuleGlobalPathList' ] = array_merge ( $ GLOBALS [ 'eZModuleGlobalPathList' ] , $ pathList ) ; } | Adds a new entry to the global path list |
40,198 | static function exists ( $ moduleName , $ pathList = null , $ showError = false ) { $ module = null ; return self :: findModule ( $ moduleName , $ module , $ pathList , $ showError ) ; } | Loads a module object by name |
40,199 | static function canFetch ( $ httpName , $ maxSize = false ) { if ( ! isset ( $ GLOBALS [ "eZHTTPFile-$httpName" ] ) || ! ( $ GLOBALS [ "eZHTTPFile-$httpName" ] instanceof eZHTTPFile ) ) { if ( $ maxSize === false ) { return isset ( $ _FILES [ $ httpName ] ) and $ _FILES [ $ httpName ] [ 'name' ] != "" and $ _FILES [ $ httpName ] [ 'error' ] == 0 ; } if ( isset ( $ _FILES [ $ httpName ] ) and $ _FILES [ $ httpName ] [ 'name' ] != "" ) { switch ( $ _FILES [ $ httpName ] [ 'error' ] ) { case ( UPLOAD_ERR_NO_FILE ) : { return eZHTTPFile :: UPLOADEDFILE_DOES_NOT_EXIST ; } break ; case ( UPLOAD_ERR_INI_SIZE ) : { return eZHTTPFile :: UPLOADEDFILE_EXCEEDS_PHP_LIMIT ; } break ; case ( UPLOAD_ERR_FORM_SIZE ) : { return eZHTTPFile :: UPLOADEDFILE_EXCEEDS_MAX_SIZE ; } break ; case ( UPLOAD_ERR_NO_TMP_DIR ) : { return eZHTTPFile :: UPLOADEDFILE_MISSING_TMP_DIR ; } break ; case ( UPLOAD_ERR_CANT_WRITE ) : { return eZHTTPFile :: UPLOADEDFILE_CANT_WRITE ; } break ; case ( 0 ) : { return ( $ maxSize == 0 || $ _FILES [ $ httpName ] [ 'size' ] <= $ maxSize ) ? eZHTTPFile :: UPLOADEDFILE_OK : eZHTTPFile :: UPLOADEDFILE_EXCEEDS_MAX_SIZE ; } break ; default : { return eZHTTPFile :: UPLOADEDFILE_UNKNOWN_ERROR ; } } } else { return eZHTTPFile :: UPLOADEDFILE_DOES_NOT_EXIST ; } } if ( $ maxSize === false ) return eZHTTPFile :: UPLOADEDFILE_OK ; else return true ; } | Returns whether a file can be fetched . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.