idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
24,900 | protected function _RenderXml ( $ Data , $ Node = 'Data' , $ Indent = '' ) { if ( is_numeric ( $ Node ) ) $ Node = 'Item' ; if ( ! $ Node ) return ; echo "$Indent<$Node>" ; if ( is_scalar ( $ Data ) ) { echo htmlspecialchars ( $ Data ) ; } else { $ Data = ( array ) $ Data ; if ( count ( $ Data ) > 0 ) { foreach ( $ Data as $ Key => $ Value ) { echo "\n" ; $ this -> _RenderXml ( $ Value , $ Key , $ Indent . ' ' ) ; } echo "\n" ; } } echo "</$Node>" ; } | A simple default method for rendering xml . |
24,901 | public function SetData ( $ Key , $ Value = NULL , $ AddProperty = FALSE ) { if ( is_array ( $ Key ) ) { $ this -> Data = array_merge ( $ this -> Data , $ Key ) ; if ( $ AddProperty === TRUE ) { foreach ( $ Key as $ Name => $ Value ) { $ this -> $ Name = $ Value ; } } return ; } $ this -> Data [ $ Key ] = $ Value ; if ( $ AddProperty === TRUE ) { $ this -> $ Key = $ Value ; } return $ Value ; } | Set data from a method call . |
24,902 | public function SetLastModified ( $ LastModifiedDate ) { $ GMD = gmdate ( 'D, d M Y H:i:s' , $ LastModifiedDate ) . ' GMT' ; $ this -> SetHeader ( 'Etag' , '"' . $ GMD . '"' ) ; $ this -> SetHeader ( 'Last-Modified' , $ GMD ) ; $ IncomingHeaders = getallheaders ( ) ; if ( isset ( $ IncomingHeaders [ 'If-Modified-Since' ] ) && isset ( $ IncomingHeaders [ 'If-None-Match' ] ) ) { $ IfNoneMatch = $ IncomingHeaders [ 'If-None-Match' ] ; $ IfModifiedSince = $ IncomingHeaders [ 'If-Modified-Since' ] ; if ( $ GMD == $ IfNoneMatch && $ IfModifiedSince == $ GMD ) { $ Database = Gdn :: Database ( ) ; if ( ! is_null ( $ Database ) ) $ Database -> CloseConnection ( ) ; $ this -> SetHeader ( 'Content-Length' , '0' ) ; $ this -> SendHeaders ( ) ; header ( 'HTTP/1.1 304 Not Modified' ) ; exit ( "\n\n" ) ; } } } | Looks for a Last - Modified header from the browser and compares it to the supplied date . If the Last - Modified date is after the supplied date the controller will send a 304 Not Modified response code to the web browser and stop all execution . Otherwise it sets the Last - Modified header for this page and continues processing . |
24,903 | public function Title ( $ Title = NULL , $ Subtitle = NULL ) { if ( ! is_null ( $ Title ) ) $ this -> SetData ( 'Title' , $ Title ) ; if ( ! is_null ( $ Subtitle ) ) $ this -> SetData ( '_Subtitle' , $ Subtitle ) ; return $ this -> Data ( 'Title' ) ; } | If this object has a Head object as a property this will set it s Title value . |
24,904 | protected function __getLoopsId ( $ refkey = NULL ) { if ( $ this -> __parent ) { return $ this -> __parent -> __getLoopsId ( $ this -> __name ) . "-" . $ this -> __name ; } return spl_object_hash ( $ this ) ; } | Generate the Loops id of this object . |
24,905 | public function offsetGet ( $ offset ) { $ value = parent :: offsetGet ( $ offset ) ; return $ offset === "context" ? $ value : $ this -> initChild ( $ offset , $ value ) ; } | Automatically initializes child elements in case they were not initialized yet |
24,906 | public function offsetSet ( $ offset , $ value ) { parent :: offsetSet ( $ offset , $ value ) ; $ this -> initChild ( $ offset , $ value , TRUE ) ; } | Automatically initailizes child elements in case they were not initialized yet |
24,907 | public function offsetUnset ( $ offset ) { $ detach = NULL ; if ( parent :: offsetExists ( $ offset ) ) { $ child = parent :: offsetGet ( $ offset ) ; if ( $ child instanceof Element && $ child -> __parent === $ this ) { $ detach = $ child ; } } parent :: offsetUnset ( $ offset ) ; if ( $ detach ) { $ detach -> detach ( ) ; } } | Automatically detaches child elements if they belong to this element |
24,908 | public function action ( $ parameter ) { $ result = FALSE ; if ( $ parameter ) { $ name = $ parameter [ 0 ] ; $ method_name = $ name . "Action" ; if ( method_exists ( $ this , $ method_name ) ) { $ result = $ this -> $ method_name ( array_slice ( $ parameter , 1 ) ) ; } if ( in_array ( $ result , [ FALSE , NULL ] , TRUE ) ) { if ( $ parameter && $ this -> offsetExists ( $ name ) ) { $ child = $ this -> offsetGet ( $ name ) ; if ( $ child instanceof ElementInterface ) { $ result = $ child -> action ( array_slice ( $ parameter , 1 ) ) ; } } } } if ( in_array ( $ result , [ FALSE , NULL ] , TRUE ) ) { if ( $ this -> delegate_action ) { if ( $ this -> offsetExists ( $ this -> delegate_action ) ) { $ child = $ this -> offsetGet ( $ this -> delegate_action ) ; if ( $ child instanceof ElementInterface ) { $ result = $ child -> action ( $ parameter ) ; } } } } if ( in_array ( $ result , [ FALSE , NULL ] , TRUE ) ) { if ( ! $ parameter ) { if ( $ this -> direct_access ) { $ result = TRUE ; } else { $ loops = $ this -> getLoops ( ) ; if ( $ loops -> hasService ( "request" ) && $ loops -> getService ( "request" ) -> isAjax ( ) && $ this -> ajax_access ) { $ result = TRUE ; } } } } if ( $ result === TRUE ) { $ result = $ this ; } return $ result ; } | Default action processing |
24,909 | public function detach ( ) { if ( $ this -> __parent ) { $ this -> __parent -> offsetUnset ( $ this -> __name ) ; } $ this -> __parent = NULL ; $ this -> __name = NULL ; return $ this ; } | Reset the internal caching mechanism of the parent element and name . This may be needed if you want to assign the element on a different object . |
24,910 | public function each ( callable $ func ) { for ( $ index = 0 ; $ index < count ( $ this -> fetch ) ; $ index ++ ) { call_user_func ( $ func , $ this -> fetch [ $ index ] ) ; } } | Metodo que mapea el ResultSet y devuelve cada una de las filas . |
24,911 | protected function setResourceClassName ( $ resourceClassName ) { if ( ! is_string ( $ resourceClassName ) ) { throw new \ InvalidArgumentException ( 'The resource class name could be a string.' ) ; } if ( empty ( $ resourceClassName ) ) { throw new \ InvalidArgumentException ( 'The resource class name could not be empty.' ) ; } $ this -> resourceClassName = $ resourceClassName ; } | Set a resource class name . |
24,912 | public function add ( $ data , $ overwrite = true ) { foreach ( $ data as $ property => $ value ) { if ( $ overwrite || ! $ this -> offsetExists ( $ property ) ) { $ this -> set ( $ property , $ value ) ; } } return $ this ; } | Add data in batch from an array |
24,913 | protected function constructQuery ( Query $ query , $ selector = NULL ) { if ( $ selector !== NULL ) { throw new InvalidArgumentException ( 'You must not provide a selector if query is first argument. Use find for that(!)' ) ; } $ this -> setSelector ( $ query -> getSelector ( ) ) ; $ this -> document = $ query -> getDocument ( ) ; parent :: __construct ( $ query -> toArray ( ) ) ; $ this -> length = count ( $ this ) ; } | Clones a Query Object |
24,914 | public function find ( $ selector ) { if ( ! is_string ( $ selector ) ) throw new \ InvalidArgumentException ( 'Kann bis jetzt nur string als find Parameter' ) ; $ cnt = count ( $ this ) ; if ( $ cnt != 1 ) { throw new Exception ( 'Kann bis jetzt nur find() auf Query-Objekten mit genau 1 Element. ' . $ this -> selector . ' (' . $ cnt . ')' ) ; } $ Query = new self ( $ selector , $ this -> getElement ( ) ) ; $ Query -> setPrevObject ( $ this ) ; $ Query -> setSelector ( $ this -> selector . ' ' . $ selector ) ; return $ Query ; } | Find an Element in the matched elements of this element |
24,915 | public function setSelector ( $ selector ) { $ this -> literalSelector = $ selector ; $ this -> selector = $ selector ; $ this -> selector = str_replace ( ':first' , ':nth-of-type(1)' , $ this -> selector ) ; $ this -> selector = Preg :: replace_callback ( $ this -> selector , '/:eq\(([0-9]+)\)/' , function ( $ m ) { return sprintf ( ':nth-of-type(%d)' , $ m [ 1 ] + 1 ) ; } ) ; return $ this ; } | Sets and parses the selector |
24,916 | public function attr ( $ name , $ value = NULL ) { if ( ( $ el = $ this -> getElement ( ) ) === NULL ) return NULL ; if ( $ el -> hasAttribute ( $ name ) ) { if ( func_num_args ( ) == 2 ) { $ el -> setAttribute ( $ name , $ value ) ; } return $ el -> getAttribute ( $ name ) ; } return NULL ; } | Returns or sets the attribute of the first matched Element |
24,917 | public function outerHtml ( ) { if ( ( $ el = $ this -> getElement ( ) ) === NULL ) return NULL ; return $ el -> ownerDocument -> saveXML ( $ el ) ; } | Returns the whole HTML of the first matched element |
24,918 | protected function getEnvironment ( ) { if ( $ this -> environment === null ) { $ loader = new \ Twig_Loader_Filesystem ( $ this -> getTemplatesDirectories ( ) ) ; $ this -> environment = new \ Twig_Environment ( $ loader ) ; $ filter = new Twig_SimpleFilter ( 'write' , function ( WritableInterface $ host ) { return $ host -> accept ( $ this ) ; } ) ; $ this -> environment -> addFilter ( $ filter ) ; $ filter = new Twig_SimpleFilter ( 'slugify' , function ( $ string ) { return StringUtils :: slugify ( $ string ) ; } ) ; $ this -> environment -> addFilter ( $ filter ) ; $ filter = new Twig_SimpleFilter ( 'html_attribute' , function ( $ string ) { return preg_replace ( array ( '/[^a-zA-Z0-9 -]/' , '/^-|-$/' ) , array ( '' , '' ) , $ string ) ; } ) ; $ this -> environment -> addFilter ( $ filter ) ; $ filter = new Twig_SimpleFilter ( 'md5' , function ( $ string ) { return md5 ( $ string ) ; } ) ; $ this -> environment -> addFilter ( $ filter ) ; $ filter = new Twig_SimpleFilter ( 'stripForm' , function ( $ string ) { $ string = str_replace ( "<form" , "<div" , $ string ) ; $ string = preg_replace ( '#<div class="form-actions">(.*?)</div>#' , '' , $ string ) ; $ string = str_replace ( "form-actions" , "form-actions hidden" , $ string ) ; $ string = str_replace ( " form-errors" , " form-errors hidden" , $ string ) ; $ string = str_replace ( '"form-errors' , '"form-errors hidden' , $ string ) ; $ string = str_replace ( "</form>" , "</div>" , $ string ) ; return $ string ; } ) ; $ this -> environment -> addFilter ( $ filter ) ; $ filter = new Twig_SimpleFilter ( 'saferaw' , function ( $ string ) { if ( $ string instanceof SafeString ) { $ string = ( string ) $ string ; } else { $ string = htmlentities ( $ string ) ; } return $ string ; } ) ; $ this -> environment -> addFilter ( $ filter ) ; $ filter = new Twig_SimpleFilter ( 'writedata' , function ( $ data ) { $ string = ' ' ; foreach ( $ data as $ key => $ value ) { $ key = htmlentities ( $ key ) ; $ value = htmlentities ( $ value ) ; $ string .= "data-$key=\"$value\" " ; } return trim ( $ string ) ; } ) ; $ this -> environment -> addFilter ( $ filter ) ; $ requestURI = array_key_exists ( "REQUEST_URI" , $ _SERVER ) === true ? $ _SERVER [ "REQUEST_URI" ] : "" ; $ this -> environment -> addGlobal ( "requestURI" , $ requestURI ) ; } return $ this -> environment ; } | Get this Writer s Twig_Environment ; create if it doesn t exist ; |
24,919 | private function register ( ) { $ this -> options [ 'labels' ] = $ this -> label ; if ( ! isset ( $ this -> options [ 'rewrite' ] ) ) { $ this -> options [ 'rewrite' ] = array ( 'slug' => $ this -> singular ) ; } $ _self = & $ this ; add_action ( 'init' , function ( ) use ( & $ _self ) { register_taxonomy ( $ _self -> singular , $ _self -> post_types , $ this -> options ) ; } ) ; } | Register the Taxonomy |
24,920 | private function _setLabel ( $ label ) { if ( $ label && is_array ( $ label ) ) { $ this -> label = $ label ; return true ; } $ singular = $ this -> singular ; $ plural = $ this -> plural ? : $ singular . $ this -> plural_end ; $ this -> label = array ( 'name' => ucfirst ( $ plural ) , 'singular' => ucfirst ( $ singular ) , 'menu_name' => ucfirst ( $ singular ) , 'all_items' => __ ( 'All' , 'wba_taxonomy' ) . ' ' . $ plural , 'parent_item' => __ ( 'Parent' , 'wba_taxonomy' ) . ' ' . $ singular , 'parent_item_colon' => __ ( 'Parent' , 'wba_taxonomy' ) . ' ' . $ singular , 'new_item_name' => __ ( 'New' , 'wba_taxonomy' ) . ' ' . $ singular , 'add_new_item' => __ ( 'Add New' , 'wba_taxonomy' ) . ' ' . $ singular , 'edit_item' => __ ( 'Edit' , 'wba_taxonomy' ) . ' ' . $ singular , 'update_item' => __ ( 'Update' , 'wba_taxonomy' ) . ' ' . $ singular , 'view_item' => __ ( 'View' , 'wba_taxonomy' ) . ' ' . $ singular , 'separate_items_with_commas' => __ ( 'Separate' , 'wba_taxonomy' ) . strtolower ( $ singular ) . ' ' . __ ( 'with commas' , 'wba_taxonomy' ) , 'add_or_remove_items' => __ ( 'Add or remove' , 'wba_taxonomy' ) . strtolower ( $ singular ) , 'choose_from_most_used' => __ ( 'Choose from the most used' , 'wba_taxonomy' ) , 'popular_items' => ucfirst ( $ plural ) , 'search_items' => __ ( 'Search' , 'wba_taxonomy' ) . ' ' . $ singular , 'not_found' => __ ( 'Not Found' , 'wba_taxonomy' ) , 'no_terms' => __ ( 'No' , 'wba_taxonomy' ) . ' ' . $ singular , 'items_list' => ucfirst ( $ singular ) . ' ' . __ ( 'list' , 'wba_taxonomy' ) , 'items_list_navigation' => ucfirst ( $ singular ) . ' ' . __ ( 'list navigation' , 'wba_taxonomy' ) , ) ; return true ; } | Sets the The labels for post type . |
24,921 | private function rksort ( array $ array ) { ksort ( $ array ) ; foreach ( $ array as $ k => $ v ) { if ( is_array ( $ v ) ) { $ array [ $ k ] = $ this -> rksort ( $ v ) ; } } return $ array ; } | Recursively ksorts an array |
24,922 | private function validateCollectionNaming ( EntityMetadata $ metadata ) { $ persistence = $ metadata -> persistence ; if ( false === $ this -> entityUtil -> isEntityTypeValid ( $ persistence -> collection ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , sprintf ( 'The entity persistence collection "%s" is invalid based on the configured name format "%s"' , $ persistence -> collection , $ this -> entityUtil -> getRestConfig ( ) -> getEntityFormat ( ) ) ) ; } } | Validates that the collection naming is correct based on entity format config . |
24,923 | private function validateDatabase ( EntityMetadata $ metadata ) { $ persistence = $ metadata -> persistence ; if ( false === $ metadata -> isChildEntity ( ) && ( empty ( $ persistence -> db ) || empty ( $ persistence -> collection ) ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , 'The persistence database and collection names cannot be empty.' ) ; } } | Validates that the proper database properties are set . |
24,924 | private function validateIdStrategy ( EntityMetadata $ metadata ) { $ persistence = $ metadata -> persistence ; $ validIdStrategies = [ 'object' ] ; if ( ! in_array ( $ persistence -> idStrategy , $ validIdStrategies ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , sprintf ( 'The persistence id strategy "%s" is invalid. Valid types are "%s"' , $ persistence -> idStrategy , implode ( '", "' , $ validIdStrategies ) ) ) ; } } | Validates the proper id strategy . |
24,925 | private function validateSchemata ( EntityMetadata $ metadata ) { $ persistence = $ metadata -> persistence ; foreach ( $ persistence -> schemata as $ k => $ schema ) { if ( ! isset ( $ schema [ 'keys' ] ) || empty ( $ schema [ 'keys' ] ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , 'At least one key must be specified to define an index.' ) ; } $ persistence -> schemata [ $ k ] [ 'options' ] [ 'name' ] = sprintf ( 'modlr_%s' , md5 ( json_encode ( $ schema ) ) ) ; } } | Validates the schema definitions |
24,926 | public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Configuration' ) ; $ coreConfig = isset ( $ config [ 'modules' ] [ 'Grid\Core' ] ) ? ( array ) $ config [ 'modules' ] [ 'Grid\Core' ] : array ( ) ; return new EnabledList ( isset ( $ coreConfig [ 'enabledPackages' ] ) ? ( array ) $ coreConfig [ 'enabledPackages' ] : array ( ) , isset ( $ coreConfig [ 'modifyPackages' ] ) ? ( bool ) $ coreConfig [ 'modifyPackages' ] : true ) ; } | Create the enabled - list - service |
24,927 | private function registerLaravelTrackerPackage ( ) { $ this -> registerProvider ( LaravelTrackerServiceProvider :: class ) ; $ config = $ this -> config ( ) ; $ items = $ config -> get ( 'arcanesoft.tracker' ) ; $ config -> set ( 'laravel-tracker.database' , Arr :: get ( $ items , 'database' ) ) ; $ config -> set ( 'laravel-tracker.models' , Arr :: get ( $ items , 'models' ) ) ; $ config -> set ( 'laravel-tracker.tracking' , Arr :: get ( $ items , 'tracking' ) ) ; $ config -> set ( 'laravel-tracker.routes' , Arr :: get ( $ items , 'routes' ) ) ; } | Register Laravel Tracker package . |
24,928 | public static function generate ( array $ payload , $ key ) { if ( ! is_array ( $ payload ) ) { throw new InvalidArgumentException ( 'Token payload must be an array' ) ; } if ( empty ( $ payload ) || empty ( $ key ) ) { throw new InvalidArgumentException ( 'Both payload and key must have a value' ) ; } $ payloadEncoded = base64_encode ( json_encode ( $ payload , JSON_FORCE_OBJECT ) ) ; $ signature = hash_hmac ( $ algo = 'SHA256' , $ data = $ payloadEncoded , $ key ) ; return implode ( '.' , [ $ payloadEncoded , $ signature ] ) ; } | Generate an authentication token . |
24,929 | public static function getPayload ( $ token , $ jsonDecode = true ) { list ( $ payload , $ signature ) = explode ( '.' , $ token ) ; $ payloadJSON = base64_decode ( $ payload ) ; if ( $ jsonDecode ) { return json_decode ( $ payloadJSON , true ) ; } return $ payloadJSON ; } | Get the payload from the token . |
24,930 | public static function verify ( $ token , $ key ) { if ( empty ( $ token ) || empty ( $ key ) ) { return false ; } list ( $ payloadJSON_encoded , $ signature ) = explode ( '.' , $ token ) ; $ signatureGenerated = hash_hmac ( 'SHA256' , $ payloadJSON_encoded , $ key ) ; return ( $ signature === $ signatureGenerated ) ; } | Verify the given token with the given signature key . |
24,931 | public function showAction ( Departamento $ departamento ) { $ deleteForm = $ this -> createDeleteForm ( $ departamento ) ; return $ this -> render ( 'UbicacionBundle:departamento:show.html.twig' , array ( 'departamento' => $ departamento , 'delete_form' => $ deleteForm -> createView ( ) , ) ) ; } | Finds and displays a Departamento entity . |
24,932 | public function deleteAction ( Request $ request , Departamento $ departamento ) { $ form = $ this -> createDeleteForm ( $ departamento ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> remove ( $ departamento ) ; $ em -> flush ( ) ; } return $ this -> redirectToRoute ( 'departamento_index' ) ; } | Deletes a Departamento entity . |
24,933 | private function createDeleteForm ( Departamento $ departamento ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'departamento_delete' , array ( 'id' => $ departamento -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; } | Creates a form to delete a Departamento entity . |
24,934 | public function copy ( $ dest ) { if ( ! file_exists ( $ this -> path ) ) { throw new \ Exception ( "Source don't exist : " . $ this -> path , 1 ) ; } if ( file_exists ( $ dest ) ) { throw new \ Exception ( "Destination already exist : $dest" , 1 ) ; } if ( is_file ( $ this -> path ) ) { if ( is_dir ( $ dest ) ) { $ dest = $ this -> addSlash ( $ dest ) . basename ( $ this -> path ) ; } copy ( $ this -> path , $ dest ) ; return ; } $ dest = $ this -> addSlash ( $ dest ) ; $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ this -> path , \ RecursiveDirectoryIterator :: SKIP_DOTS ) ) ; foreach ( $ iterator as $ path => $ file ) { $ fileDest = $ dest . $ iterator -> getSubPathName ( ) ; if ( ! file_exists ( dirname ( $ fileDest ) ) ) { mkdir ( dirname ( $ fileDest ) , 0777 , true ) ; } copy ( $ path , $ fileDest ) ; } } | Copy this file to destination |
24,935 | protected function _delete ( $ where ) { $ params = array ( ) ; $ query = "DELETE FROM $this->_name" ; $ iWhere = 0 ; $ query .= " WHERE (" ; foreach ( $ where as $ key => $ value ) { if ( ! is_int ( $ key ) ) { $ query .= "$key = :where$iWhere AND " ; $ params [ ":where$iWhere" ] = $ value ; $ iWhere ++ ; } else { $ query .= "$value AND" ; } } $ query = substr ( $ query , 0 , - 4 ) ; $ query .= ")" ; $ db = $ this -> db ; $ sth = $ db -> prepare ( $ query ) ; foreach ( $ params as $ key => $ val ) { if ( is_int ( $ val ) ) { $ sth -> bindValue ( "$key" , $ val , $ db :: PARAM_INT ) ; } else { $ sth -> bindValue ( "$key" , $ val ) ; } } $ response = $ sth -> execute ( ) ; if ( $ response ) { return true ; } return false ; } | Delete a row or rowset |
24,936 | public function edit_custom_taxonomy ( ) { if ( ! isset ( $ _GET [ 'custom_taxonomy_id' ] ) ) { $ this -> mf_redirect ( null , null , array ( 'message' => 'success' ) ) ; } $ custom_taxonomy = $ this -> get_custom_taxonomy ( $ _GET [ 'custom_taxonomy_id' ] ) ; if ( ! $ custom_taxonomy ) { $ this -> mf_redirect ( null , null , array ( 'message' => 'error' ) ) ; } $ data = $ this -> fields_form ( ) ; $ post_types = array ( ) ; if ( isset ( $ custom_taxonomy [ 'post_types' ] ) ) { foreach ( $ custom_taxonomy [ 'post_types' ] as $ k => $ v ) { array_push ( $ post_types , $ v ) ; } $ data [ 'taxonomy' ] [ 'post_type' ] = $ post_types ; } $ perm = array ( 'core' , 'option' , 'label' ) ; foreach ( $ custom_taxonomy as $ key => $ value ) { if ( in_array ( $ key , $ perm ) ) { foreach ( $ value as $ id => $ val ) { $ data [ $ key ] [ $ id ] [ 'value' ] = $ val ; } } } $ this -> form_custom_taxonomy ( $ data ) ; } | Edit custom taxonomy |
24,937 | public function get_custom_taxonomy ( $ custom_taxonomy_id ) { global $ wpdb ; $ query = sprintf ( 'SELECT * FROM %s WHERE id = %s' , MF_TABLE_CUSTOM_TAXONOMY , $ custom_taxonomy_id ) ; $ custom_taxonomy = $ wpdb -> get_row ( $ query , ARRAY_A ) ; if ( $ custom_taxonomy ) { $ custom_taxonomy = unserialize ( $ custom_taxonomy [ 'arguments' ] ) ; $ custom_taxonomy [ 'core' ] [ 'id' ] = $ custom_taxonomy_id ; return $ custom_taxonomy ; } return false ; } | get a specific post type |
24,938 | public function save_custom_taxonomy ( ) { global $ mf_domain ; check_admin_referer ( 'form_custom_taxonomy_mf_custom_taxonomy' ) ; if ( isset ( $ _POST [ 'mf_custom_taxonomy' ] ) ) { $ mf = $ _POST [ 'mf_custom_taxonomy' ] ; if ( $ mf [ 'core' ] [ 'id' ] ) { $ this -> update_custom_taxonomy ( $ mf ) ; } else { if ( $ this -> new_custom_taxonomy ( $ mf ) ) { } else { } } } $ this -> mf_redirect ( null , null , array ( 'message' => 'success' ) ) ; } | save a custom taxonomy |
24,939 | public function delete_custom_taxonomy ( ) { global $ wpdb ; check_admin_referer ( 'delete_custom_taxonomy_mf_custom_taxonomy' ) ; if ( isset ( $ _GET [ 'custom_taxonomy_id' ] ) ) { $ id = ( int ) $ _GET [ 'custom_taxonomy_id' ] ; if ( is_int ( $ id ) ) { $ sql = $ wpdb -> prepare ( "DELETE FROM " . MF_TABLE_CUSTOM_TAXONOMY . " WHERE id = %d" , $ id ) ; $ wpdb -> query ( $ sql ) ; $ this -> mf_redirect ( null , null , array ( 'message' => 'success' ) ) ; } } } | delete a custom taxonomy |
24,940 | public function get_value ( $ option_name , $ default_value = false ) { $ service_name = substr ( $ option_name , 0 , strpos ( $ option_name , '.' ) ) ; $ option_name = str_replace ( $ service_name . '.' , '' , $ option_name ) ; $ value = false ; if ( array_key_exists ( $ service_name , $ this -> _configs ) ) { if ( array_key_exists ( $ option_name , $ this -> _configs [ $ service_name ] ) ) { $ value = $ this -> _configs [ $ service_name ] [ $ option_name ] ; } else if ( $ default_value ) { $ value = $ default_value ; } } return $ value ; } | Recupere la valeur de l option de config |
24,941 | public function get_values ( $ service_name = false ) { if ( $ service_name ) { $ values = $ this -> _configs [ $ service_name ] ; } else { $ values = $ this -> _configs ; } return $ values ; } | Retourne toute la configuration . |
24,942 | public function merge_with_default ( $ service_name , $ default_values ) { if ( is_array ( $ default_values ) && is_array ( $ this -> _configs [ $ service_name ] ) ) { $ this -> _configs [ $ service_name ] = array_merge ( $ default_values , $ this -> _configs [ $ service_name ] ) ; } return $ this -> _configs [ $ service_name ] ; } | Fusionne les valeurs par defaut avec celle du fichier de config . |
24,943 | private function _set_config ( ) { $ ok = false ; $ this -> _configs = array ( ) ; if ( $ this -> _file_lib -> check_dir ( ) ) { $ all_configs_file = $ this -> _file_lib -> get_path_files ( ) ; $ wise = Wise :: create ( $ this -> _file_lib ) ; foreach ( $ all_configs_file as $ service_name => $ config_file ) { $ this -> _configs [ $ service_name ] = $ wise -> loadFlat ( $ config_file ) ; } } return $ ok ; } | Charge les configs trouver dans le repertoire |
24,944 | public function definedClasses ( ) { $ loops = $ this -> getLoops ( ) ; $ cache = $ loops -> getService ( "cache" ) ; $ key = "Loops-Application-definedClasses" ; if ( $ cache -> contains ( $ key ) ) { return $ cache -> fetch ( $ key ) ; } $ require = function ( $ dir ) use ( & $ require , & $ classes ) { foreach ( scandir ( $ dir ) as $ file ) { if ( substr ( $ file , 0 , 1 ) == '.' ) { continue ; } $ filename = "$dir/$file" ; if ( is_dir ( $ filename ) ) { $ require ( $ filename ) ; } else { require_once ( $ filename ) ; } } } ; $ dirs = $ this -> include_dir ; array_walk ( $ dirs , $ require ) ; $ classes = array_values ( array_filter ( get_declared_classes ( ) , function ( $ classname ) use ( $ dirs , $ cache ) { $ reflection = new ReflectionClass ( $ classname ) ; $ filename = $ reflection -> getFileName ( ) ; if ( ! $ filename ) { return FALSE ; } if ( $ this -> enable_cached_autoload ) { $ key = "Loops-Application-autoload-$classname" ; $ cache -> save ( $ key , $ filename ) ; } foreach ( $ dirs as $ dir ) { if ( substr ( $ filename , 0 , strlen ( $ dir ) ) == $ dir ) { return TRUE ; } } return FALSE ; } ) ) ; $ cache -> save ( $ key , $ classes ) ; return $ classes ; } | Get a list of all classnames that are defined in the app directory |
24,945 | private static function isolated_boot ( $ loops ) { if ( is_file ( $ loops -> getService ( "application" ) -> boot ) && is_readable ( $ loops -> getService ( "application" ) -> boot ) ) { require ( $ loops -> getService ( "application" ) -> boot ) ; } } | Includes the boot file in an isolated namespace |
24,946 | protected function disableInnoDbStats ( ) { $ sql = "show global variables like 'innodb_stats_on_metadata'" ; try { $ results = $ this -> adapter -> query ( $ sql ) ; if ( count ( $ results ) > 0 ) { $ row = $ results -> offsetGet ( 0 ) ; $ value = strtoupper ( $ row [ 'Value' ] ) ; if ( $ value != 'OFF' ) { $ this -> mysql_innodbstats_value = $ value ; $ this -> adapter -> query ( "set global innodb_stats_on_metadata='OFF'" ) ; } } } catch ( \ Exception $ e ) { } } | Disable innodbstats will increase speed of metadata lookups . |
24,947 | public function check ( $ file , $ ret_ext = false ) { $ exp = explode ( '.' , $ file ) ; $ ext = end ( $ exp ) ; if ( $ this -> ext ( '.' . $ ext ) ) { return ( ! $ ret_ext ) ? true : $ ext ; } return false ; } | Check whether extensions are valid to themes |
24,948 | public function prefix ( $ field , $ value ) { if ( ! $ value instanceof Expr \ ConditionalExpression ) { $ value = $ this -> buildPart ( Expr \ TextComparisonExpression :: escapeString ( ( string ) $ value ) . Expr \ TextComparisonExpression :: WILDCARD_STRING ) ; } return new Expr \ TextComparisonExpression ( $ field , $ value , Expr \ TextComparisonExpression :: MATCH ) ; } | prefix Match prefix |
24,949 | protected function _normalizeString ( $ subject ) { if ( $ subject instanceof Stringable ) { return $ subject -> __toString ( ) ; } if ( is_scalar ( $ subject ) ) { return ( string ) $ subject ; } throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Not a stringable value' ) , null , null , $ subject ) ; } | Normalizes a value to its string representation . |
24,950 | public function run ( ServerRequestInterface $ request = null ) { $ request = $ request ? : ServerRequestFactory :: fromGlobals ( ) ; $ response = $ this -> handle ( $ request ) ; $ this -> responseEmitter -> emit ( $ response ) ; } | Handle the global incoming request and sends the response . |
24,951 | protected function getAllowedPostedAttributes ( ) { $ arrAddAttributes = [ ] ; $ arrAllowedAttributes = [ ] ; foreach ( $ this -> config [ 'attributes' ] as $ attr ) { $ arrAllowedAttributes [ ] = $ attr [ 'name' ] ; } foreach ( $ _POST as $ key => $ val ) { if ( ! in_array ( $ key , $ arrAllowedAttributes ) ) { continue ; } $ arrAddAttributes [ $ key ] = $ val ; } return $ arrAddAttributes ; } | Catches all POST attributes that were sent from the webform providing they are defined in the JSON Config |
24,952 | protected function addPostAttributes ( File $ file ) { $ arrAddAttributes = $ this -> getAllowedPostedAttributes ( ) ; $ file -> addAttributes ( $ arrAddAttributes ) ; return $ file ; } | Add the POST variables to the placeholders |
24,953 | public function execute ( ) { if ( ! count ( $ this -> config [ 'files' ] ) ) { return ; } if ( isset ( $ _POST ) && count ( $ _POST ) > 0 ) { $ this -> createFiles ( ) ; $ this -> returnZipFile ( ) ; } else { echo $ this -> renderInputForm ( ) ; } } | Run the Page 1 . If no config set empty 2 . If no POST params show Webform 3 . If POST params generate and Zip Files |
24,954 | protected function renderInputForm ( ) { $ arrTableBody = [ ] ; foreach ( $ this -> config [ 'attributes' ] as $ attribute ) { $ label = isset ( $ attribute [ 'label' ] ) ? $ attribute [ 'label' ] : "" ; $ fieldName = isset ( $ attribute [ 'name' ] ) ? $ attribute [ 'name' ] : "" ; $ value = isset ( $ attribute [ 'default' ] ) ? $ attribute [ 'default' ] : "" ; $ arrTableBody [ ] = [ H :: label ( $ label , $ fieldName ) , H :: input ( $ fieldName , "input" , $ value ) , ] ; } $ content = H :: renderTable ( [ ] , $ arrTableBody ) . H :: button ( "Generate Code" ) ; $ output = H :: form ( $ _SERVER [ 'REQUEST_URI' ] , $ content ) ; $ headers = "" ; if ( defined ( 'css_headers' ) ) { foreach ( css_headers as $ css ) { $ headers .= H :: link ( "" , [ "href" => $ css , "rel" => "stylesheet" ] ) ; } } return H :: htmlDocument ( "Codemonkey" , $ headers , $ output ) ; } | Render webform for dynamic placeholders |
24,955 | protected function flushDir ( $ dir ) { if ( ! file_exists ( $ dir ) ) { echo "HELP cant find " . $ dir . "\n" ; return ; } $ objects = scandir ( $ dir ) ; foreach ( $ objects as $ object ) { try { $ this -> deleteFile ( $ object , $ dir ) ; } catch ( Exception $ e ) { echo "Can't remove Folder/File " . $ dir . DIRECTORY_SEPARATOR . $ object . "<br />\n" . $ e -> getMessage ( ) . "<br />\n" ; } } } | Deletes contents of a folder and content |
24,956 | protected function listTempDir ( $ dir = '' ) { $ arrFiles = [ ] ; $ scandir = ( $ dir != '' ) ? $ dir : '.' ; $ objects = scandir ( $ scandir ) ; foreach ( $ objects as $ object ) { if ( $ object == "." || $ object == ".." ) { continue ; } $ objectPath = ( $ dir != '' ) ? $ dir . DIRECTORY_SEPARATOR . $ object : $ object ; if ( is_dir ( $ objectPath ) ) { $ arrFiles = array_merge ( $ arrFiles , $ this -> listTempDir ( $ objectPath ) ) ; } else { $ arrFiles [ ] = $ objectPath ; } } return $ arrFiles ; } | Picks up all the file names in the temp folder . Needed to create a zip |
24,957 | public function validationPasswordOnly ( Validator $ validator ) { $ validator -> notEmpty ( 'password' , __d ( 'wasabi_core' , 'Please enter a password.' ) ) -> add ( 'password' , [ 'length' => [ 'rule' => [ 'minLength' , 6 ] , 'message' => __d ( 'wasabi_core' , 'Ensure your password consists of at least 6 characters.' ) ] ] ) -> notEmpty ( 'password_confirmation' , __d ( 'wasabi_core' , 'Please repeat your Password.' ) , function ( $ context ) { if ( $ context [ 'newRecord' ] === true ) { return true ; } if ( isset ( $ context [ 'data' ] [ 'password' ] ) && ! empty ( $ context [ 'data' ] [ 'password' ] ) ) { return true ; } return false ; } ) -> add ( 'password_confirmation' , 'equalsPassword' , [ 'rule' => function ( $ passwordConfirmation , $ provider ) { if ( $ passwordConfirmation !== $ provider [ 'data' ] [ 'password' ] ) { return __d ( 'wasabi_core' , 'The Password Confirmation does not match the Password field.' ) ; } return true ; } ] ) ; return $ validator ; } | Only validate password . |
24,958 | public function beforeMarshal ( Event $ event , ArrayObject $ data , ArrayObject $ options ) { if ( isset ( $ data [ 'id' ] ) ) { if ( isset ( $ data [ 'password' ] ) && empty ( $ data [ 'password' ] ) ) { unset ( $ data [ 'password' ] ) ; if ( isset ( $ data [ 'password_confirmation' ] ) ) { unset ( $ data [ 'password_confirmation' ] ) ; } } } } | Called before request data is converted to an entity . |
24,959 | public function findWithGroupName ( Query $ query ) { return $ query -> select ( [ 'id' , 'username' , 'email' , 'verified' , 'active' ] ) -> contain ( [ 'Groups' => function ( Query $ q ) { return $ q -> select ( [ 'name' ] ) ; } ] ) ; } | Find users including their group name . |
24,960 | public function findNotVerified ( $ email ) { return $ this -> find ( ) -> where ( [ $ this -> aliasField ( 'email' ) => $ email , $ this -> aliasField ( 'verified' ) => 0 ] ) -> first ( ) ; } | Find a user by unverified email address . |
24,961 | public function findUsersWithNoGroup ( ) { $ query = $ this -> find ( ) ; return $ query -> leftJoin ( [ $ this -> UsersGroups -> alias ( ) => $ this -> UsersGroups -> table ( ) ] , [ $ this -> aliasField ( 'id' ) . ' = ' . $ this -> UsersGroups -> aliasField ( 'user_id' ) ] ) -> select ( [ 'Users.id' , 'group_count' => $ query -> func ( ) -> count ( 'UsersGroups.group_id' ) ] ) -> group ( 'Users.id' ) -> having ( 'group_count = 0' ) ; } | Find all users that do not belong to a group . |
24,962 | public static function is_https ( ) { if ( ! empty ( $ _SERVER [ 'HTTPS' ] ) && strtolower ( $ _SERVER [ 'HTTPS' ] ) !== 'off' ) { return TRUE ; } elseif ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] ) && $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] === 'https' ) { return TRUE ; } elseif ( ! empty ( $ _SERVER [ 'HTTP_FRONT_END_HTTPS' ] ) && strtolower ( $ _SERVER [ 'HTTP_FRONT_END_HTTPS' ] ) !== 'off' ) { return TRUE ; } return FALSE ; } | Check if connected through https |
24,963 | public function createService ( ServiceLocatorInterface $ container ) { $ config = $ container -> get ( DbOptions :: class ) ; return new Adapter ( $ config -> toArray ( ) ) ; } | Create db adapter service |
24,964 | public function getCookie ( $ name ) { $ filter = $ default = '' ; $ cookie = $ this -> getVar ( $ name , $ filter , $ default , "cookies" ) ; return empty ( $ cookie ) ? false : $ cookie ; } | Gets the contents of a cookie by name |
24,965 | public function getVar ( $ name , $ filter = '' , $ default = '' , $ verb = 'get' , $ options = array ( ) ) { if ( strtolower ( $ verb ) == 'request' ) { $ verb = $ this -> getVerb ( ) ; } $ verb = strtolower ( $ verb ) ; if ( ! ( $ input = $ this -> data ( $ verb ) ) ) { return $ default ; } if ( empty ( $ name ) || ! isset ( $ input ) || ! isset ( $ input [ $ name ] ) ) { if ( isset ( $ default ) && ! empty ( $ default ) ) { return $ default ; } else { return null ; } } if ( ! isset ( $ filter ) || ! is_int ( $ filter ) ) { $ type = gettype ( $ input [ $ name ] ) ; switch ( $ type ) { case "interger" : $ filter = \ IS \ INTERGER ; break ; case "float" : case "double" : $ filter = \ IS \ FLOAT ; $ options = array ( "flags" => FILTER_FLAG_ALLOW_SCIENTIFIC | FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND , "options" => $ options ) ; break ; case "string" : $ filter = \ IS \ STRING ; $ options = array ( "flags" => ! FILTER_FLAG_STRIP_LOW , "options" => $ options ) ; break ; case "object" : case "resource" : case "NULL" : case "unknown type" : default : $ filter = \ IS \ RAW ; $ options = array ( "flags" => ! FILTER_FLAG_STRIP_LOW , "options" => $ options ) ; break ; } } $ variable = $ input [ $ name ] ; if ( get_magic_quotes_gpc ( ) && ( $ input [ $ name ] != $ default ) && ( $ verb != 'files' ) ) { $ variable = stripslashes ( $ input [ $ name ] ) ; } return $ this -> filter ( $ variable , $ filter , $ options ) ; } | Gets an input variable . Attempts to determine what its type is and returns a sanitized type |
24,966 | public function unRegisterGlobals ( ) { if ( ini_get ( 'register_globals' ) ) { $ SUPER_GLOBALS = array ( '_SESSION' , '_POST' , '_GET' , '_COOKIE' , '_REQUEST' , '_SERVER' , '_ENV' , '_FILES' ) ; foreach ( $ SUPER_GLOBALS as $ UNSAFE ) { foreach ( $ GLOBALS [ $ UNSAFE ] as $ key => $ var ) { unset ( $ GLOBALS [ $ key ] ) ; } } } } | Checks and removes registered globals |
24,967 | public function getEscapedVar ( $ name , $ default = '' , $ verb = 'get' , $ options = array ( ) ) { $ filter = \ IS \ ESCAPED ; $ escaped = $ this -> getVar ( $ name , $ filter , $ default , $ verb , $ options ) ; return $ escaped ; } | Magic Quotes StripSlashes |
24,968 | public function methodIs ( $ verb ) { $ method = $ this -> getVerb ( ) ; $ return = ( $ method === strtolower ( $ verb ) ) ? true : false ; return $ return ; } | Determines if the input method is of type POST or GET |
24,969 | public function getInt ( $ name , $ default = '' , $ verb = 'get' , $ options = array ( ) ) { $ filter = \ IS \ INTERGER ; $ interger = $ this -> getVar ( $ name , $ filter , $ default , $ verb , $ options ) ; return ( int ) $ interger ; } | Remove all characters except digits plus and minus sign . |
24,970 | public function getFormattedString ( $ name , $ default = '' , $ verb = 'post' , $ blacklisted = array ( ) ) { if ( strtolower ( $ verb ) == 'request' ) { $ verb = $ this -> getVerb ( ) ; } $ verb = strtolower ( $ verb ) ; if ( ! ( $ input = $ this -> data ( $ verb ) ) ) { return $ default ; } if ( empty ( $ name ) || ! isset ( $ input ) || ! isset ( $ input [ $ name ] ) ) { if ( isset ( $ default ) && ! empty ( $ default ) ) { return $ default ; } else { return null ; } } $ string = $ input [ $ name ] ; $ string = mb_convert_encoding ( $ string , 'utf-8' , mb_detect_encoding ( $ string ) ) ; $ string = mb_convert_encoding ( $ string , 'html-entities' , 'utf-8' ) ; if ( empty ( $ string ) ) return $ string ; $ doc = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ doc -> loadHTML ( $ string ) ; $ xpath = new \ DOMXPath ( $ doc ) ; $ nodes = $ xpath -> query ( '//*[@style]' ) ; foreach ( $ nodes as $ node ) : $ node -> removeAttribute ( 'style' ) ; endforeach ; $ original = $ xpath -> query ( "body/*" ) ; if ( $ original -> length > 0 ) { $ string = '' ; foreach ( $ original as $ node ) { $ string .= $ node -> nodeValue ; } } $ filter = \ IS \ SPECIAL_CHARS ; $ options = array ( "flags" => FILTER_FLAG_ENCODE_LOW , "options" => array ( ) ) ; $ string = $ this -> filter ( $ string , $ filter , $ options ) ; return $ string ; } | Returns a formatted string |
24,971 | public function getArray ( $ name , $ default = [ ] , $ verb = 'get' , $ options = array ( ) ) { if ( strtolower ( $ verb ) == 'request' ) { $ verb = $ this -> getVerb ( ) ; } $ verb = strtolower ( $ verb ) ; if ( ! ( $ input = $ this -> data ( $ verb ) ) ) { return $ default ; } if ( empty ( $ name ) || ! isset ( $ input ) || ! isset ( $ input [ $ name ] ) ) { if ( isset ( $ default ) && ! empty ( $ default ) ) { return $ default ; } else { return null ; } } $ filter = \ IS \ CUSTOM ; $ options = array ( "flags" => FILTER_REQUIRE_ARRAY , ) ; $ array = $ input [ $ name ] ; return ( array ) $ array ; } | Returns a cleaned Array |
24,972 | public function getBoolean ( $ name , $ default = '' , $ verb = 'get' , $ options = array ( ) ) { $ filter = \ IS \ BOOLEAN ; $ options = array ( "options" => $ options ) ; $ boolean = $ this -> getVar ( $ name , $ filter , $ default , $ verb , $ options ) ; return ( boolean ) $ boolean ; } | Remove all characters except digits 0 and 1 . Transforms into Boolean true or false where 0 = false and 1 = true |
24,973 | public function getWord ( $ name , $ default = '' , $ verb = 'get' , $ options = array ( ) ) { $ sentence = $ this -> getString ( $ name , $ default , false ) ; return ( string ) strstr ( $ sentence , ' ' , true ) ; } | Returns the first word a santized string Strip tags optionally strip or encode special characters . |
24,974 | protected function mapper ( $ alias = false ) { return Manager :: getInstance ( ) -> getMapper ( $ alias ? $ alias : $ this -> sMapperAlias ) ; } | Return a object mapper instance |
24,975 | protected function config ( $ sActionAlias ) { $ sFileName = RX_PATH . '/ruxon/modules/' . $ this -> sModuleAlias . '/config/controllers/' . $ this -> sControllerAlias . '/action' . $ sActionAlias . '.inc.php' ; if ( file_exists ( $ sFileName ) ) { $ aConfig = include ( $ sFileName ) ; $ sBasePath = 'ruxon/modules/' . $ this -> sModuleAlias ; $ aLang = array ( ) ; if ( file_exists ( RX_PATH . '/' . $ sBasePath . '/messages/' . Core :: app ( ) -> config ( ) -> getLang ( ) . '/messages.inc.php' ) ) { $ aLang = Core :: require_file ( $ sBasePath . '/messages/' . Core :: app ( ) -> config ( ) -> getLang ( ) . '/messages.inc.php' ) ; } else if ( file_exists ( RX_PATH . '/' . $ sBasePath . '/messages/' . Core :: app ( ) -> config ( ) -> getDefaultLang ( ) . '/messages.inc.php' ) ) { $ aLang = Core :: require_file ( $ sBasePath . '/messages/' . Core :: app ( ) -> config ( ) -> getDefaultLang ( ) . '/messages.inc.php' ) ; } else { $ aLang = array ( ) ; } $ aConfig = Core :: parseXmlI18n ( $ aConfig , $ aLang ) ; return $ aConfig ; } return false ; } | Return an action config |
24,976 | protected function validateEmailer ( ) { if ( $ this -> emailer === null ) { $ settingsInstance = $ this -> getSettingsInstance ( ) ; $ writerClasses = $ settingsInstance -> getDefaultEmailWriterClasses ( ) ; $ emailerClass = $ settingsInstance -> getDefaultEmailerClass ( ) ; $ writerInstances = [ ] ; foreach ( $ writerClasses as $ writerClass ) { $ writerInstances [ ] = new $ writerClass ( ) ; } $ this -> emailer = new $ emailerClass ( $ writerInstances ) ; } } | Construct a emailer from setting defaults if none has been provided . |
24,977 | protected function resetBuilder ( ) : void { $ this -> foreground = 39 ; $ this -> background = 49 ; $ this -> format = [ ] ; $ this -> width = null ; $ this -> indent = null ; } | Reset builder with default values . |
24,978 | public function regenerateHash ( ) { $ this -> hashWorkingRecord -> { $ this -> hashDbField } = $ this -> encrypt ( ) ; if ( $ this -> hashMustBeUnique && ! $ this -> hasUniqueHash ( ) ) { $ this -> regenerateHash ( ) ; } } | Regenerate a hash for this |
24,979 | protected function generateHashAndSave ( ) { if ( $ this -> hashWorkingRecord -> { $ this -> hashDbField } ) { return ; } $ this -> generateHash ( ) ; if ( $ this -> hashWorkingRecord -> { $ this -> hashDbField } ) { $ this -> hashWorkingRecord -> write ( ) ; } } | Generate hash and save if hash created |
24,980 | public function hasUniqueHash ( ) { $ hash = $ this -> hashWorkingRecord -> { $ this -> hashDbField } ? : $ this -> encrypt ( ) ; $ list = $ this -> hashWorkingRecord -> get ( ) -> filter ( $ this -> hashDbField , $ hash ) ; if ( $ this -> hashWorkingRecord -> ID ) { $ list = $ list -> exclude ( 'ID' , $ this -> hashWorkingRecord -> ID ) ; } return ! ( $ list -> exists ( ) ) ; } | Check if the hash for this object is unique |
24,981 | protected function _containerSetMany ( & $ container , $ data ) { $ data = $ this -> _normalizeIterable ( $ data ) ; foreach ( $ data as $ _k => $ _v ) { $ this -> _containerSet ( $ container , $ _k , $ _v ) ; } } | Sets multiple values on the container . |
24,982 | public function init ( ) { $ this -> setupSupportedArgs ( $ this -> supportedArgs ) ; $ this -> parseArgv ( $ this -> argv ) ; return $ this ; } | Local implementation of the init hook . |
24,983 | protected function parseArgv ( $ argv ) { foreach ( $ this -> argv as $ arg ) { $ parts = explode ( '=' , $ arg ) ; if ( ! isset ( $ parts [ 1 ] ) ) { continue ; } $ value = $ parts [ 1 ] ; $ key = strtr ( $ parts [ 0 ] , [ '-' => '' ] ) ; if ( array_key_exists ( $ key , $ this -> supportedArgs ) ) { $ this -> parsedArgs [ $ key ] = $ value ; } } return $ this ; } | Parses an array of arguments . |
24,984 | public function getArg ( $ name = '' ) { if ( ! isset ( $ this -> parsedArgs [ $ name ] ) ) { throw new \ PhpCli \ Exception ( self :: ERR_NO_ARG_BY_NAME ) ; } return $ this -> parsedArgs [ $ name ] ; } | Gets an argument by name |
24,985 | public function setupSupportedArgs ( $ arguments = [ ] ) { $ defaults = [ 'help' => 'The help menu' , ] ; $ arguments = array_merge ( $ defaults , $ arguments ) ; $ this -> supportedArgs = $ arguments ; return $ this ; } | Takes the supported arguments and does some setup on them |
24,986 | public function help ( ) { echo PHP_EOL ; $ output = new Output ; $ output -> write ( 'Available Commands' , [ 'color' => 'red' , 'bold' => true , 'underline' => true , ] ) ; echo PHP_EOL ; $ maxlen = 0 ; foreach ( $ this -> supportedArgs as $ key => $ description ) { $ len = strlen ( $ key ) ; if ( $ len > $ maxlen ) { $ maxlen = $ len ; } } foreach ( $ this -> supportedArgs as $ key => $ description ) { $ len = strlen ( $ key ) ; $ output -> write ( ' ' ) -> write ( $ key , [ 'color' => 'yellow' ] ) -> write ( str_repeat ( ' ' , $ maxlen - $ len ) ) -> write ( ' - ' ) -> write ( $ description ) ; echo PHP_EOL ; } echo PHP_EOL ; } | Outputs the help menu . |
24,987 | protected function getEmailByToken ( $ token ) { $ emailsUrl = 'https://api.bitbucket.org/2.0/user/emails?access_token=' . $ token ; try { $ response = $ this -> getHttpClient ( ) -> get ( $ emailsUrl ) ; } catch ( Exception $ e ) { return null ; } $ emails = json_decode ( $ response -> getBody ( ) , true ) ; foreach ( $ emails [ 'values' ] as $ email ) { if ( $ email [ 'type' ] == 'email' && $ email [ 'is_primary' ] && $ email [ 'is_confirmed' ] ) { return $ email [ 'email' ] ; } } } | Get the email for the given access token . |
24,988 | protected function validateRequestParameters ( Request $ request ) { $ data = $ request -> request -> all ( ) ; if ( isset ( $ data [ 'id' ] ) ) { unset ( $ data [ 'id' ] ) ; } $ this -> form -> submit ( $ data ) ; if ( ! $ this -> form -> isValid ( ) ) { throw new BadRequestHttpException ( $ this -> form -> getErrorsAsString ( ) ) ; } return $ this -> form ; } | Takes the request parameters and passes them through the form associated with this controller . |
24,989 | protected function convertResourceToPlainText ( $ format , Resource $ resource ) { switch ( $ format ) { case 'xml' : return ( string ) $ resource -> getXML ( ) -> asXml ( ) ; case 'json' : return ( string ) $ resource ; default : throw new NotAcceptableHttpException ( ) ; } } | Converts the give HAL Resource to a plain text representation that can be returned in the response . |
24,990 | public function getSelector ( ) : string { if ( empty ( $ this -> selector ) ) { $ this -> setSize ( $ this -> selector_size ) ; $ this -> selector = $ this -> generateRandomToken ( ) ; } return $ this -> selector ; } | Returns set selector |
24,991 | public function getToken ( ) : string { if ( empty ( $ this -> token ) ) { $ this -> setSize ( $ this -> token_size ) ; $ this -> token = $ this -> generateRandomToken ( ) ; } return $ this -> token ; } | Returns set token . |
24,992 | public function setExpires ( int $ days ) { $ this -> expires_days = $ days ; $ time = strtotime ( '+ ' . $ this -> expires_days . ' days' ) ; $ this -> expires_datetime = date ( 'Y-m-d H:i:s' , $ time ) ; $ this -> expires_timestamp = $ time ; } | Sets days after token gets expired |
24,993 | public function addLink ( string $ label , string $ url , bool $ active = false , bool $ disabled = false , string $ icon = null , string $ iconColor = null , string $ badge = null , string $ badgeColor = null ) { Checkers :: checkUrl ( $ url ) ; $ this -> items [ ] = [ 'label' => $ label , 'url' => $ url , 'active' => $ active , 'disabled' => $ disabled , 'icon' => $ icon , 'icolor' => $ iconColor , 'badge' => $ badge , 'bcolor' => $ badgeColor ] ; return $ this ; } | Add a link element to the nav bar |
24,994 | public function addMenu ( string $ label , Addon \ DropDownMenu $ menu , bool $ active = false , bool $ disabled = false ) { $ this -> items [ ] = [ 'label' => $ label , 'menu' => $ menu , 'active' => $ active , 'disabled' => $ disabled ] ; return $ this ; } | Add a menu element to the nav bar |
24,995 | public function add ( ) { if ( $ moduleMiddleware = $ this -> module -> middleware ( ) ) { $ middleware = $ this -> load ( ) ; $ middleware = array_merge ( $ middleware , $ moduleMiddleware ) ; return $ this -> set ( $ middleware ) ; } return true ; } | add middleware to middleware . php in cache |
24,996 | public function remove ( ) { if ( $ moduleMiddleware = $ this -> module -> middleware ( ) ) { $ middleware = $ this -> load ( ) ; $ middleware = array_diff ( $ middleware , $ moduleMiddleware ) ; return $ this -> set ( $ middleware ) ; } return true ; } | remove middleware to middleware . php in cache |
24,997 | public static function getDefaultFractionDigits ( $ currencyCode ) { $ defaultFractionDigits = static :: getCurrencyData ( $ currencyCode ) [ 'default_fraction_digits' ] ; if ( ! is_int ( $ defaultFractionDigits ) ) { throw new UnexpectedValueException ( sprintf ( 'The currency default fraction digits value must be an integer; "%s" given' , is_object ( $ defaultFractionDigits ) ? get_class ( $ defaultFractionDigits ) : gettype ( $ defaultFractionDigits ) ) ) ; } if ( $ defaultFractionDigits < 0 ) { throw new UnexpectedValueException ( sprintf ( 'The currency default fraction digits value must be greater than 0; "%s" given' , $ defaultFractionDigits ) ) ; } return $ defaultFractionDigits ; } | Returns the default number of fraction digits |
24,998 | public static function getSubUnit ( $ currencyCode ) { $ subunits = static :: getCurrencyData ( $ currencyCode ) [ 'sub_unit' ] ; if ( ! is_int ( $ subunits ) ) { throw new UnexpectedValueException ( sprintf ( 'The currency sub-units value must be an integer; "%s" given' , is_object ( $ subunits ) ? get_class ( $ subunits ) : gettype ( $ subunits ) ) ) ; } if ( $ subunits < 1 ) { throw new UnexpectedValueException ( sprintf ( 'The currency sub-units value must be greater than 1; "%s" given' , $ subunits ) ) ; } return $ subunits ; } | Returns the sub - unit value |
24,999 | public function renderCartWidget ( array $ options = [ ] ) { $ template = array_key_exists ( 'template' , $ options ) ? $ options [ 'template' ] : $ this -> config [ 'templates' ] [ 'widget' ] ; $ cart = array_key_exists ( 'cart' , $ options ) ? $ options [ 'cart' ] : $ this -> cartProvider -> getCart ( ) ; return $ this -> twig -> render ( $ template , [ 'cart' => $ cart ] ) ; } | Renders the cart widget . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.