idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
24,800 | function hasClient ( $ clientName ) { if ( ! isset ( $ this -> clients [ $ clientName ] ) ) { try { $ exists = true ; $ this -> getClient ( $ clientName ) ; } catch ( \ Exception $ e ) { $ exists = false ; } return $ exists ; } $ exists = array_key_exists ( $ clientName , $ this -> lazyClientOptions ) ; return $ exists ; } | Has Client Connection? |
24,801 | protected function _attainClient ( $ clientName ) { if ( ! isset ( $ this -> lazyClientOptions [ $ clientName ] ) ) throw new \ Exception ( sprintf ( 'MongoDB Client (%s) not Registered.' , $ clientName ) ) ; $ conf = $ this -> lazyClientOptions [ $ clientName ] ; if ( ! isset ( $ conf [ 'host' ] ) ) throw new \ Exception ( sprintf ( '"host" Option for Client (%s) not given.' , $ clientName , \ Poirot \ Std \ flatten ( $ conf ) ) ) ; $ uri = $ conf [ 'host' ] ; $ uriOptions = ( isset ( $ conf [ 'options_uri' ] ) ) ? $ conf [ 'options_uri' ] : array ( ) ; $ options = ( isset ( $ conf [ 'options_driver' ] ) ) ? $ conf [ 'options_driver' ] : array ( ) ; $ client = new MongoDB \ Client ( $ uri , $ uriOptions , $ options ) ; return $ client ; } | Attain Client Instance from LazyConfigs |
24,802 | public function getSearchControlValues ( ) { $ data = $ this -> model -> searchValues ; $ controlData = [ ] ; foreach ( $ this -> model -> searchControls as $ control ) { $ controlName = $ control -> getName ( ) ; if ( isset ( $ data [ $ controlName ] ) ) { $ controlData [ $ controlName ] = $ data [ $ controlName ] ; } } return $ controlData ; } | Returns a key value pair array of each control name and it s value |
24,803 | public function setSearchControlValues ( $ controlValues = [ ] , $ rememberPrevious = false ) { if ( $ rememberPrevious ) { $ this -> previousSearchValues = $ this -> model -> searchValues ; } else { if ( $ this -> previousSearchValues ) { $ this -> model -> searchValues = $ this -> previousSearchValues ; $ this -> previousSearchValues = null ; return ; } } $ controlValues = array_merge ( $ this -> defaultControlValues , $ controlValues ) ; foreach ( $ this -> model -> searchControls as $ control ) { $ controlName = $ control -> getName ( ) ; if ( isset ( $ controlValues [ $ controlName ] ) ) { $ this -> model -> searchValues [ $ controlName ] = $ controlValues [ $ controlName ] ; } } $ this -> reRender ( ) ; $ this -> searchedEvent -> raise ( ) ; } | Sets the values of the search controls . |
24,804 | protected function getUrlStateNames ( array $ searchControls ) { $ names = [ ] ; foreach ( $ searchControls as $ control ) { $ name = $ control -> getName ( ) ; $ names [ $ name ] = StringTools :: camelCaseToSeparated ( $ name ) ; } return $ names ; } | Return URL GET param names for the controls in this panel |
24,805 | public static function getApplicableRules ( ) { $ rules = [ FixerInterface :: PSR2_LEVEL => static :: getPsr2Rules ( ) , FixerInterface :: SYMFONY_LEVEL => static :: getSymfonyRules ( ) , FixerInterface :: CONTRIB_LEVEL => static :: getContribRules ( ) , ] ; return static :: _prepareRules ( $ rules ) ; } | Return all the rules that should be part of the config . |
24,806 | protected static function _prepareRules ( $ rules ) { foreach ( $ rules as $ _name => $ _rules ) { $ rules [ $ _name ] = array_flip ( $ _rules ) ; } $ rules = call_user_func_array ( 'array_merge' , $ rules ) ; return array_keys ( $ rules ) ; } | Combines a map of rule levels to rule lists into one list . |
24,807 | public static function getSymfonyRules20 ( ) { return [ 'blank_line_after_opening_tag' => true , 'blank_line_before_return' => true , 'cast_spaces' => true , 'concat_without_spaces' => false , 'function_typehint_space' => true , 'hash_to_slash_comment' => true , 'heredoc_to_nowdoc' => false , 'include' => true , 'lowercase_cast' => true , 'method_separation' => true , 'native_function_casing' => true , 'new_with_braces' => true , 'no_alias_functions' => true , 'no_blank_lines_after_class_opening' => true , 'no_blank_lines_after_phpdoc' => true , 'no_empty_statement' => true , 'no_extra_consecutive_blank_lines' => true , 'no_leading_import_slash' => true , 'no_leading_namespace_whitespace' => true , 'no_multiline_whitespace_around_double_arrow' => true , 'no_short_bool_cast' => true , 'no_singleline_whitespace_before_semicolons' => true , 'no_spaces_inside_offset' => true , 'no_trailing_comma_in_list_call' => true , 'no_trailing_comma_in_singleline_array' => true , 'no_unneeded_control_parentheses' => true , 'no_unreachable_default_argument_value' => true , 'no_unused_imports' => true , 'no_whitespace_before_comma_in_array' => true , 'no_whitespace_in_blank_lines' => true , 'object_operator_without_whitespace' => true , 'phpdoc_align' => true , 'phpdoc_indent' => true , 'phpdoc_inline_tag' => true , 'phpdoc_no_access' => true , 'phpdoc_no_empty_return' => true , 'phpdoc_no_package' => true , 'phpdoc_scalar' => true , 'phpdoc_separation' => true , 'phpdoc_single_line_var_spacing' => true , 'phpdoc_summary' => true , 'phpdoc_to_comment' => true , 'phpdoc_trim' => true , 'phpdoc_type_to_var' => true , 'phpdoc_types' => true , 'phpdoc_var_without_name' => true , 'pre_increment' => true , 'print_to_echo' => false , 'self_accessor' => false , 'short_scalar_cast' => true , 'simplified_null_return' => true , 'single_blank_line_before_namespace' => true , 'single_quote' => true , 'space_after_semicolon' => true , 'standardize_not_equals' => true , 'ternary_operator_spaces' => true , 'trailing_comma_in_multiline_array' => true , 'trim_array_spaces' => true , 'unalign_double_arrow' => true , 'unalign_equals' => true , 'unary_operator_spaces' => true , 'whitespace_after_comma_in_array' => true , ] ; } | Gets rules of the Symfony level that are applicable to this config . |
24,808 | public function getMenu ( $ subMenu = null ) { $ menu = array ( ) ; if ( ! $ subMenu ) { $ arr = include __DIR__ . '/../../config/administrator.php' ; $ subMenu = $ arr [ 'menu' ] ; } foreach ( $ subMenu as $ key => $ item ) { if ( is_string ( $ item ) ) { $ config = $ this -> configFactory -> make ( $ item ) ; if ( is_a ( $ config , 'Frozennode\Administrator\Config\Config' ) && $ config -> getOption ( 'permission' ) ) { $ menu [ $ item ] = $ config -> getOption ( 'title' ) ; } elseif ( $ config === true ) { $ menu [ $ item ] = $ key ; } } elseif ( is_array ( $ item ) ) { $ menu [ $ key ] = $ this -> getMenu ( $ item ) ; if ( empty ( $ menu [ $ key ] ) ) { unset ( $ menu [ $ key ] ) ; } } } return $ menu ; } | Gets the menu items indexed by their name with a value of the title . |
24,809 | public function calcPage ( $ currentQuery = null ) { $ page = 1 ; $ primaryKeys = static :: primaryKey ( ) ; if ( isset ( $ primaryKeys [ 0 ] ) ) { $ primaryKey = $ primaryKeys [ 0 ] ; $ num = $ this -> getOrderNumber ( $ this -> $ primaryKey , $ currentQuery ) ; if ( $ num > 0 ) { $ page = ( int ) ceil ( $ num / $ this -> pageSize ) ; } } return $ page ; } | Calculate page number for current record . |
24,810 | public static function moduleClass ( $ moduleName = 'Module' ) { $ result = false ; $ className = get_called_class ( ) ; $ refClass = new ReflectionClass ( $ className ) ; $ ns = $ refClass -> getNamespaceName ( ) ; $ len = strlen ( $ ns ) - strlen ( UniModule :: $ modelsSubdir ) ; if ( strrpos ( $ ns , UniModule :: $ modelsSubdir ) == $ len ) { $ ns = substr ( $ ns , 0 , $ len ) ; $ result = $ ns . $ moduleName ; } return $ result ; } | Try to get module class this model belong to . Get latest module in inheritance chain . |
24,811 | public function swapPrio ( $ id1 , $ id2 , $ orderField = 'prio' ) { $ item1 = self :: findOne ( [ 'id' => $ id1 ] ) ; if ( ! empty ( $ item1 -> $ orderField ) ) { $ prio1 = $ item1 -> $ orderField ; } else { return false ; } $ item2 = self :: findOne ( [ 'id' => $ id2 ] ) ; if ( ! empty ( $ item2 -> $ orderField ) ) { $ prio2 = $ item2 -> $ orderField ; } else { return false ; } $ transaction = Yii :: $ app -> db -> beginTransaction ( ) ; try { $ item1 -> $ orderField = $ prio2 ; $ n1 = $ item1 -> updateInternal ( ) ; $ item2 -> $ orderField = $ prio1 ; $ n2 = $ item2 -> updateInternal ( ) ; if ( $ n1 && $ n2 ) $ transaction -> commit ( ) ; } catch ( Exception $ e ) { $ transaction -> rollBack ( ) ; Yii :: error ( $ e ) ; if ( YII_DEBUG ) throw $ e ; } return true ; } | Swap order field values for |
24,812 | public function respondWithEmpty ( $ message = "The requested result set is empty." , $ status = 204 ) { if ( $ this -> options [ 'format' ] === 'html' ) { $ status = 200 ; } return $ this -> respondWithError ( $ message , $ status ) ; } | Return an empty response . |
24,813 | protected function setDomainList ( DomainList $ domainList ) { $ this -> urlPattern = null ; $ this -> domainList = $ domainList ; return $ this ; } | Set the domain - list |
24,814 | protected function getUrlPattern ( ) { if ( $ this -> urlPattern ) { return $ this -> urlPattern ; } $ domains = iterator_to_array ( $ this -> getDomainList ( ) ) ; if ( empty ( $ domains ) ) { $ domains = array ( 'localhost' ) ; } return $ this -> urlPattern = '(|(https?:)?//([^/]+\.)?(' . implode ( '|' , array_map ( 'preg_quote' , $ domains ) ) . ')(:\d+)?)' ; } | Get url pattern |
24,815 | public function ProfileExtenderPrep ( ) { $ ProfileKeyData = $ this -> SQL -> Select ( 'm.Name' ) -> Distinct ( ) -> From ( 'UserMeta m' ) -> Like ( 'm.Name' , 'Profile_%' ) -> Get ( ) ; $ ExistingKeys = array_filter ( ( array ) explode ( ',' , C ( 'Plugins.ProfileExtender.ProfileFields' , '' ) ) ) ; foreach ( $ ProfileKeyData -> Result ( ) as $ Key ) { $ Name = str_replace ( 'Profile.' , '' , $ Key -> Name ) ; if ( ! in_array ( $ Name , $ ExistingKeys ) ) { $ ExistingKeys [ ] = $ Name ; } } if ( count ( $ ExistingKeys ) ) SaveToConfig ( 'Plugins.ProfileExtender.ProfileFields' , implode ( ',' , $ ExistingKeys ) ) ; } | Get profile fields imported and add to ProfileFields list . |
24,816 | public static function hasTipo ( $ array , $ tipo ) { foreach ( $ array [ 'campos' ] as $ campo => $ configCampo ) { if ( is_array ( $ tipo ) ) { foreach ( $ tipo as $ miniTipo ) { if ( strtolower ( $ configCampo [ 'tipo' ] ) == strtolower ( $ miniTipo ) ) { return true ; } } } elseif ( strtolower ( $ configCampo [ 'tipo' ] ) == strtolower ( $ tipo ) ) { return true ; } } return false ; } | Know if a config array has any field of certain type |
24,817 | public function get ( $ attribute , $ arrayAsMap = true ) { if ( $ this -> has ( $ attribute ) ) { $ value = $ this -> attributes [ $ attribute ] ; if ( $ arrayAsMap === true && is_array ( $ value ) ) { $ value = new self ( $ value ) ; } return $ value ; } throw new \ OutOfBoundsException ( "Attribute '{$attribute}' does not exist" ) ; } | Returns value of given attribute name or throws an exception if the attribute does not exist |
24,818 | public function delete ( $ value ) { $ index = $ this -> index ( $ value ) ; if ( $ index !== false ) { $ this -> remove ( $ index ) ; } return $ this ; } | Removes an attribute by value |
24,819 | public function update ( $ attributes ) { if ( ! empty ( $ attributes ) ) { foreach ( $ attributes as $ attribute => $ value ) { $ this -> set ( $ attribute , $ value ) ; } } return $ this ; } | Update attributes with from given array |
24,820 | protected function end ( ) { $ content = ob_get_clean ( ) ; list ( $ name , $ rewrite ) = $ this -> record ; if ( $ rewrite ) { $ this -> blocks += [ $ name => $ content ] ; } else { echo isset ( $ this -> blocks [ $ name ] ) ? $ this -> blocks [ $ name ] : $ content ; } $ this -> record = null ; } | Stop recording block |
24,821 | public function connect ( $ server , $ user , $ password , $ database ) { if ( empty ( $ this -> database_info [ 'server' ] ) || $ this -> database_info [ 'server' ] == '' ) { $ this -> database_info [ 'server' ] = $ server ; } if ( empty ( $ this -> database_info [ 'user' ] ) || $ this -> database_info [ 'user' ] == '' ) { $ this -> database_info [ 'user' ] = $ user ; } if ( empty ( $ this -> database_info [ 'pass' ] ) || $ this -> database_info [ 'pass' ] == '' ) { $ this -> database_info [ 'pass' ] = $ password ; } if ( empty ( $ this -> database_info [ 'database' ] ) || $ this -> database_info [ 'database' ] == '' ) { $ this -> database_info [ 'database' ] = $ database ; } mysql_connect ( $ this -> database_info [ 'server' ] , $ this -> database_info [ 'user' ] , $ this -> database_info [ 'pass' ] ) ; @ mysql_select_db ( $ this -> database_info [ 'database' ] ) or die ( "Unable to connect to " . $ this -> database_info [ 'database' ] . " database." ) ; } | Connect to the database using credentials Credentiel input in constructor have priority |
24,822 | function execute ( $ request , $ silencieux = false ) { if ( $ silencieux == false ) { $ res = mysql_query ( $ request ) or die ( $ request . ' -- ' . mysql_error ( ) . ' -- <br/> Request in file : <b>' . debug_backtrace ( ) [ 0 ] [ 'file' ] . '</b><br/> on line <b>' . debug_backtrace ( ) [ 0 ] [ 'line' ] ) . '</b>' ; } else { $ res = mysql_query ( $ request ) ; } return $ res ; } | Executing the request in parameter |
24,823 | public function processRequest ( $ request , $ rowIndex = 'row' ) { $ requestResult = array ( ) ; $ result = $ this -> execute ( $ request ) ; $ i = 0 ; while ( $ row = mysql_fetch_assoc ( $ result ) ) { $ index = $ rowIndex . $ i ++ ; $ requestResult [ $ index ] = $ row ; } return $ requestResult ; } | Execute a request and return the result as an array |
24,824 | public function findClasses ( ) { $ files = $ this -> getFiles ( $ this -> searchPath ) ; $ this -> loadFiles ( $ files ) ; return $ this -> identifyClasses ( ) ; } | Start searching for files |
24,825 | private function getFiles ( $ directory ) { $ fileList = [ ] ; $ files = scandir ( $ directory ) ; $ this -> log ( sprintf ( "Scanning dir %s, found %d files" , $ directory , count ( $ files ) ) ) ; foreach ( $ files as $ index => $ file ) { if ( true === is_dir ( $ directory . DIRECTORY_SEPARATOR . $ file ) && ! in_array ( $ file , [ "." , ".." ] ) ) { $ fileList = array_merge ( $ fileList , $ this -> getFiles ( $ directory . DIRECTORY_SEPARATOR . $ file ) ) ; continue ; } if ( false === $ this -> isRequiredFile ( $ file ) ) { $ this -> log ( sprintf ( "Files %s is not required" , $ directory . DIRECTORY_SEPARATOR . $ file ) ) ; continue ; } $ this -> log ( sprintf ( "Collected %s" , $ directory . DIRECTORY_SEPARATOR . $ file ) ) ; $ fileList [ ] = $ directory . DIRECTORY_SEPARATOR . $ file ; } return $ fileList ; } | Scan a directory and list all files that correspond to given criteria |
24,826 | private function isA ( $ className , $ classType ) { $ types = array_merge ( class_parents ( $ className ) , class_implements ( $ className ) ) ; $ this -> log ( sprintf ( "Class %s is a %s" , $ className , implode ( ', ' , $ types ) ) ) ; return in_array ( $ classType , $ types ) ; } | Identify if a class - name extends a type or implements an interface |
24,827 | protected function get ( $ service , array & $ options ) { if ( isset ( $ options [ $ service ] ) && is_object ( $ options [ $ service ] ) ) { return $ options [ $ service ] ; } $ service = explode ( '_' , $ service ) ; $ service = array_map ( 'ucfirst' , $ service ) ; $ service = 'get' . implode ( '' , $ service ) ; return $ options [ $ service ] = $ this -> $ service ( $ options ) ; } | Generic service getter . |
24,828 | public function arrayOrderBy ( $ data , $ orderby ) { $ asc = SORT_ASC ; $ desc = SORT_DESC ; $ params = [ ] ; $ orderbys = explode ( ',' , $ orderby ) ; $ orderbys = array_map ( 'trim' , $ orderbys ) ; foreach ( $ orderbys as & $ orderby ) { $ parts = explode ( " " , $ orderby ) ; if ( ! isset ( $ parts [ 1 ] ) ) $ parts [ 1 ] = 'asc' ; $ parts [ 1 ] = strtolower ( $ parts [ 1 ] ) ; if ( ! in_array ( $ parts [ 1 ] , [ 'asc' , 'desc' ] ) ) $ parts [ 1 ] = 'asc' ; $ params [ ] = $ parts [ 0 ] ; if ( $ parts [ 1 ] == 'asc' ) $ params [ ] = & $ asc ; else $ params [ ] = & $ desc ; } $ temp = [ ] ; $ count = count ( $ params ) - 1 ; for ( $ i = 0 ; $ i <= $ count ; $ i = $ i + 2 ) { $ field = $ params [ $ i ] ; $ params [ $ i ] = [ ] ; foreach ( $ data as $ ii => $ row ) { $ temp [ $ field ] [ ] = strtolower ( $ row [ $ field ] ) ; } $ params [ $ i ] = & $ temp [ $ field ] ; } $ params [ ] = & $ data ; call_user_func_array ( 'array_multisort' , $ params ) ; return $ data ; } | Orders an array like in a SQL query . |
24,829 | public function arrayGet ( array & $ array , $ identifier = '' , $ fallback = null ) { if ( empty ( $ identifier ) ) return $ array ; $ parts = explode ( '.' , $ identifier ) ; $ returner = & $ array ; foreach ( $ parts as $ part ) { if ( isset ( $ returner [ $ part ] ) ) { $ returner = & $ returner [ $ part ] ; } else { unset ( $ returner ) ; break ; } } if ( isset ( $ returner ) ) return $ returner ; else return $ fallback ; } | Returns a branch or a value of a multidimensional array tree by use of the dot syntax to define subnodes . |
24,830 | public function arraySet ( array & $ array , $ identifier , $ value ) { $ returner = & $ array ; foreach ( explode ( '.' , $ identifier ) as $ part ) { if ( ! isset ( $ returner [ $ part ] ) ) { $ returner [ $ part ] = '' ; } $ returner = & $ returner [ $ part ] ; } $ returner = $ value ; } | Sets a branch or a value of a multidimensional array tree by use of the dot syntax to define subnodes . |
24,831 | public function arrayDelete ( array & $ array , $ identifier ) { $ parts = explode ( '.' , $ identifier ) ; $ returner = & $ array ; $ parent = & $ array ; foreach ( $ parts as $ part ) { if ( isset ( $ returner [ $ part ] ) && ! empty ( $ part ) ) { $ parent = & $ returner ; $ rkey = $ part ; $ returner = & $ returner [ $ part ] ; } else { unset ( $ returner ) ; break ; } } if ( isset ( $ returner ) ) { unset ( $ parent [ $ rkey ] ) ; } else { throw new \ Exception ( __CLASS__ . ': identifier "' . $ identifier . '" does not exist.' ) ; } } | Deletes a branch or a key of a multidimensional array tree by use of the dot syntax to define subnodes . |
24,832 | public function arrayExplode ( array $ array ) { $ data = [ ] ; foreach ( $ array as $ rkey => $ row ) { $ parent = & $ data ; $ parts = explode ( '.' , $ rkey ) ; foreach ( $ parts as $ part ) { if ( ! isset ( $ parent [ $ part ] ) || ! is_array ( $ parent [ $ part ] ) ) { if ( $ part === end ( $ parts ) ) { if ( ! is_array ( $ row ) ) $ parent [ $ part ] = $ row ; else $ parent [ $ part ] = $ this -> arrayExplode ( $ row ) ; } else $ parent [ $ part ] = [ ] ; } $ parent = & $ parent [ $ part ] ; } } return $ data ; } | Explodes an array with dotted keys to a normal array . |
24,833 | protected function initSessionBag ( $ reset = false ) { if ( $ reset || ! $ this -> sessionBag ) { $ name = str_replace ( "-" , "" , $ this -> appName ) ; $ session = $ this -> container -> get ( 'session' ) ; $ bag = new AttributeBag ( '_' . str_replace ( "-" , "_" , $ this -> appName ) ) ; $ bag -> setName ( $ name ) ; $ session -> registerBag ( $ bag ) ; $ this -> sessionBag = $ session -> getBag ( $ name ) ; } return $ this -> sessionBag ; } | Init OAuth session bag |
24,834 | protected function getCallbackUrl ( Request $ request ) { $ selfUrl = $ this -> getSelfUrl ( $ request ) ; if ( substr ( $ selfUrl , - 9 ) == "-callback" ) { return $ selfUrl ; } else { return $ selfUrl . "-callback" ; } } | Get the callback URL |
24,835 | protected function getParam ( $ name , $ required = false ) { if ( ! $ this -> container -> hasParameter ( $ name ) ) { if ( $ required ) { throw new SyrupComponentException ( 500 , "Parameter '{$name}' not set in parameters.yml" ) ; } else { return null ; } } else { return $ this -> container -> getParameter ( $ name ) ; } } | Get an attribute from parameters . yml |
24,836 | public function externalAuthAction ( Request $ request ) { $ this -> checkParams ( $ request -> query ) ; foreach ( $ request -> query -> all ( ) as $ k => $ v ) { $ request -> request -> set ( $ k , $ v ) ; } return $ this -> getOAuthAction ( $ request ) ; } | Handle a GET request with token&config parameters in URL |
24,837 | protected function returnResult ( $ data , $ status = "ok" ) { $ referrer = $ this -> sessionBag -> get ( "referrer" ) ; if ( ! empty ( $ referrer ) ) { return $ this -> redirect ( $ referrer ) ; } else { return new Response ( jsonDecode ( array_replace ( array ( "status" => $ status ) , ( array ) $ data ) ) , 200 , $ this -> defaultResponseHeaders ) ; } } | Return Decide whether to return a redirect to referrer or a JSON encoded response |
24,838 | protected function realGroup ( $ col , $ suffix = '' , $ rawMode = false ) { if ( is_array ( $ col ) ) { $ this -> multipleGroup ( $ col , $ suffix ) ; } else { $ clause = & $ this -> getClause ( 'GROUP BY' ) ; $ part = [ $ col , $ this -> isRaw ( $ col , $ rawMode ) ] ; if ( ! empty ( $ suffix ) ) { $ part [ ] = $ suffix ; } $ clause [ ] = $ part ; } return $ this ; } | real group by |
24,839 | public static function toRegex ( $ glob , $ strictLeadingDot = true , $ strictWildcardSlash = true , $ delimiter = '#' ) { $ firstByte = true ; $ escaping = false ; $ inCurlies = 0 ; $ regex = '' ; $ sizeGlob = strlen ( $ glob ) ; for ( $ i = 0 ; $ i < $ sizeGlob ; ++ $ i ) { $ car = $ glob [ $ i ] ; if ( $ firstByte ) { if ( $ strictLeadingDot && '.' !== $ car ) { $ regex .= '(?=[^\.])' ; } $ firstByte = false ; } if ( '/' === $ car ) { $ firstByte = true ; } if ( $ delimiter === $ car || '.' === $ car || '(' === $ car || ')' === $ car || '|' === $ car || '+' === $ car || '^' === $ car || '$' === $ car ) { $ regex .= "\\$car" ; } elseif ( '*' === $ car ) { $ regex .= $ escaping ? '\\*' : ( $ strictWildcardSlash ? '[^/]*' : '.*' ) ; } elseif ( '?' === $ car ) { $ regex .= $ escaping ? '\\?' : ( $ strictWildcardSlash ? '[^/]' : '.' ) ; } elseif ( '{' === $ car ) { $ regex .= $ escaping ? '\\{' : '(' ; if ( ! $ escaping ) { ++ $ inCurlies ; } } elseif ( '}' === $ car && $ inCurlies ) { $ regex .= $ escaping ? '}' : ')' ; if ( ! $ escaping ) { -- $ inCurlies ; } } elseif ( ',' === $ car && $ inCurlies ) { $ regex .= $ escaping ? ',' : '|' ; } elseif ( '\\' === $ car ) { if ( $ escaping ) { $ regex .= '\\\\' ; $ escaping = false ; } else { $ escaping = true ; } continue ; } else { $ regex .= $ car ; } $ escaping = false ; } return $ delimiter . '^' . $ regex . '$' . $ delimiter ; } | Returns a regexp which is the equivalent of the glob pattern . |
24,840 | private function _createRoute ( $ options ) { $ url = $ this -> _di -> getService ( "url" ) ; $ options [ "uri" ] = $ url -> getUriPrefix ( ) . $ options [ "uri" ] ; if ( isset ( $ options [ "controller_action" ] ) ) { $ controller_action_exploded = explode ( "#" , $ options [ "controller_action" ] ) ; $ options [ "controllerName" ] = $ controller_action_exploded [ 0 ] ; $ options [ "actionName" ] = $ controller_action_exploded [ 1 ] ; } return new Route ( $ options ) ; } | Helper function to create a route |
24,841 | public function reverseRoute ( $ controllerName , $ actionName ) { $ tempRoute = new Route ( [ "controllerName" => $ controllerName , "actionName" => $ actionName ] ) ; foreach ( $ this -> _routeDefinitions as $ routeDefinition ) { $ route = call_user_func ( $ routeDefinition ) ; if ( $ tempRoute -> getControllerName ( ) == $ route -> getControllerName ( ) && $ tempRoute -> getActionName ( ) == $ route -> getActionName ( ) ) { return $ route -> getUri ( ) ; } } } | Returns a route uri given controller name and action name |
24,842 | public function handle ( $ requestUri ) { $ url = $ this -> _di -> getService ( "url" ) ; $ requestUri = str_replace ( $ url -> getUriPrefix ( ) , "" , $ requestUri ) ; $ request_route = $ this -> _createRoute ( [ "uri" => $ requestUri ] ) ; $ request_route_uri_fragments = explode ( "/" , $ request_route -> getUri ( ) ) ; foreach ( $ this -> _routeDefinitions as $ routeDefinition ) { $ route = call_user_func ( $ routeDefinition ) ; $ route_uri_fragments = explode ( "/" , $ route -> getUri ( ) ) ; if ( count ( $ route_uri_fragments ) != count ( $ request_route_uri_fragments ) ) { continue ; } $ params = array ( ) ; for ( $ i = 0 ; $ i < count ( $ route_uri_fragments ) ; $ i ++ ) { if ( $ route_uri_fragments [ $ i ] == "{param}" ) { $ params [ ] = $ request_route_uri_fragments [ $ i ] ; continue ; } if ( $ route_uri_fragments [ $ i ] != $ request_route_uri_fragments [ $ i ] ) { continue 2 ; } } $ route -> setParams ( $ params ) ; $ this -> _matchRoute = $ route ; return ; } if ( isset ( $ this -> _notFoundRoute ) ) { $ this -> _matchRoute = $ this -> _notFoundRoute ; return ; } $ this -> _matchRoute = new Route ( ) ; } | Match a request uri with the route uris registered in this service |
24,843 | public function fetchUser ( User $ user ) { $ response = $ this -> getResponse ( sprintf ( '%s.json' , $ user -> getUsername ( ) ) ) ; return $ this -> hydrator -> hydrate ( $ user , $ response ) ; } | Fetch data from User URL |
24,844 | private function buildOptionValue ( \ DOMElement $ node ) : array { $ option = array ( ) ; $ defaultDefaultValue = 'select' === $ this -> node -> nodeName ? '' : 'on' ; $ defaultValue = ( isset ( $ node -> nodeValue ) && ! empty ( $ node -> nodeValue ) ) ? $ node -> nodeValue : $ defaultDefaultValue ; $ option [ 'value' ] = $ node -> hasAttribute ( 'value' ) ? $ node -> getAttribute ( 'value' ) : $ defaultValue ; $ option [ 'disabled' ] = $ node -> hasAttribute ( 'disabled' ) ; return $ option ; } | Returns option value with associated disabled flag . |
24,845 | public function findNamespace ( $ namespace ) { $ allNamespaces = $ this -> getNamespaces ( ) ; $ expr = preg_replace_callback ( '{([^:]+|)}' , function ( $ matches ) { return preg_quote ( $ matches [ 1 ] ) . '[^:]*' ; } , $ namespace ) ; $ namespaces = preg_grep ( '{^' . $ expr . '}' , $ allNamespaces ) ; if ( empty ( $ namespaces ) ) { $ message = sprintf ( 'There are no commands defined in the "%s" namespace.' , $ namespace ) ; if ( $ alternatives = $ this -> findAlternatives ( $ namespace , $ allNamespaces ) ) { if ( 1 == count ( $ alternatives ) ) { $ message .= "\n\nDid you mean this?\n " ; } else { $ message .= "\n\nDid you mean one of these?\n " ; } $ message .= implode ( "\n " , $ alternatives ) ; } throw new CommandNotFoundException ( $ message , $ alternatives ) ; } $ exact = in_array ( $ namespace , $ namespaces , true ) ; if ( count ( $ namespaces ) > 1 && ! $ exact ) { throw new CommandNotFoundException ( sprintf ( "The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s" , $ namespace , $ this -> getAbbreviationSuggestions ( array_values ( $ namespaces ) ) ) , array_values ( $ namespaces ) ) ; } return $ exact ? $ namespace : reset ( $ namespaces ) ; } | Finds a registered namespace by a name or an abbreviation . |
24,846 | public static function getAbbreviations ( $ names ) { $ abbrevs = array ( ) ; foreach ( $ names as $ name ) { for ( $ len = strlen ( $ name ) ; $ len > 0 ; -- $ len ) { $ abbrev = substr ( $ name , 0 , $ len ) ; $ abbrevs [ $ abbrev ] [ ] = $ name ; } } return $ abbrevs ; } | Returns an array of possible abbreviations given a set of names . |
24,847 | public function getTerminalDimensions ( ) { @ trigger_error ( sprintf ( '%s is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; return array ( $ this -> terminal -> getWidth ( ) , $ this -> terminal -> getHeight ( ) ) ; } | Tries to figure out the terminal dimensions based on the current environment . |
24,848 | public function setTerminalDimensions ( $ width , $ height ) { @ trigger_error ( sprintf ( '%s is deprecated as of 3.2 and will be removed in 4.0. Set the COLUMNS and LINES env vars instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; putenv ( 'COLUMNS=' . $ width ) ; putenv ( 'LINES=' . $ height ) ; return $ this ; } | Sets terminal dimensions . |
24,849 | protected function doRunCommand ( Command $ command , InputInterface $ input , OutputInterface $ output ) { foreach ( $ command -> getHelperSet ( ) as $ helper ) { if ( $ helper instanceof InputAwareInterface ) { $ helper -> setInput ( $ input ) ; } } if ( null === $ this -> dispatcher ) { return $ command -> run ( $ input , $ output ) ; } try { $ command -> mergeApplicationDefinition ( ) ; $ input -> bind ( $ command -> getDefinition ( ) ) ; } catch ( ExceptionInterface $ e ) { } $ event = new ConsoleCommandEvent ( $ command , $ input , $ output ) ; $ e = null ; try { $ this -> dispatcher -> dispatch ( ConsoleEvents :: COMMAND , $ event ) ; if ( $ event -> commandShouldRun ( ) ) { $ exitCode = $ command -> run ( $ input , $ output ) ; } else { $ exitCode = ConsoleCommandEvent :: RETURN_CODE_DISABLED ; } } catch ( \ Exception $ e ) { } catch ( \ Throwable $ e ) { } if ( null !== $ e ) { if ( $ this -> dispatcher -> hasListeners ( ConsoleEvents :: EXCEPTION ) ) { $ x = $ e instanceof \ Exception ? $ e : new FatalThrowableError ( $ e ) ; $ event = new ConsoleExceptionEvent ( $ command , $ input , $ output , $ x , $ x -> getCode ( ) ) ; $ this -> dispatcher -> dispatch ( ConsoleEvents :: EXCEPTION , $ event ) ; if ( $ x !== $ event -> getException ( ) ) { $ e = $ event -> getException ( ) ; } } $ event = new ConsoleErrorEvent ( $ input , $ output , $ e , $ command ) ; $ this -> dispatcher -> dispatch ( ConsoleEvents :: ERROR , $ event ) ; $ e = $ event -> getError ( ) ; if ( 0 === $ exitCode = $ event -> getExitCode ( ) ) { $ e = null ; } } $ event = new ConsoleTerminateEvent ( $ command , $ input , $ output , $ exitCode ) ; $ this -> dispatcher -> dispatch ( ConsoleEvents :: TERMINATE , $ event ) ; if ( null !== $ e ) { throw $ e ; } return $ event -> getExitCode ( ) ; } | Runs the current command . |
24,850 | private function extractAllNamespaces ( $ name ) { $ parts = explode ( ':' , $ name , - 1 ) ; $ namespaces = array ( ) ; foreach ( $ parts as $ part ) { if ( count ( $ namespaces ) ) { $ namespaces [ ] = end ( $ namespaces ) . ':' . $ part ; } else { $ namespaces [ ] = $ part ; } } return $ namespaces ; } | Returns all namespaces of the command name . |
24,851 | public function action ( $ action , $ parameters = [ ] , array $ query = [ ] ) { $ callback = function ( Route $ route ) use ( $ action ) { return $ route -> getActionName ( ) === $ action && $ route -> acceptedVerb ( 'GET' ) ; } ; $ route = $ this -> getRouteCollection ( ) -> firstOrFail ( $ callback ) ; return $ this -> to ( $ route -> toUri ( ( array ) $ parameters ) , $ query ) ; } | Generate url via string action |
24,852 | public function route ( $ route , $ prefix = null ) { $ this -> route = substr ( $ route , strlen ( $ prefix ) ) ; $ parameters = [ ] ; foreach ( $ this -> routeOrder as $ routeName ) { $ routeDescription = $ this -> routes [ $ routeName ] ; $ parameters = $ this -> match ( $ this -> route , $ routeDescription ) ; if ( $ parameters !== false ) { return [ 'route' => $ this -> route , 'parameters' => $ this -> fillInDefaultParameters ( $ routeDescription , $ parameters ) , 'description' => $ routeDescription ] ; } } return [ 'route' => $ this -> route , 'parameters' => $ parameters , 'description' => $ this -> routes [ 'default' ] ] ; } | Invoke the router to load a route . |
24,853 | public function getIndividualRadioButtonHtml ( $ value ) { return $ this -> view -> getInputHtml ( $ this -> model -> leafPath , $ value , null ) ; } | Call this from a hosting view to get a single radio button presented . |
24,854 | public function appendPages ( $ pages = array ( ) ) { $ iCur = $ this -> data [ 'i' ] ; if ( isset ( $ this -> data [ 'pages' ] [ $ iCur ] ) ) { $ pageCount = \ count ( $ this -> data [ 'pages' ] ) ; $ range = \ range ( $ pageCount , $ pageCount + \ count ( $ pages ) - 1 ) ; $ this -> data [ 'pages' ] [ $ iCur ] [ 'addPages' ] = \ array_merge ( $ this -> data [ 'pages' ] [ $ iCur ] [ 'addPages' ] , $ range ) ; } foreach ( $ pages as $ pageName ) { $ this -> data [ 'pages' ] [ ] = array ( 'name' => $ pageName , 'completed' => false , 'values' => array ( ) , 'addPages' => array ( ) , ) ; } } | Append additional pages to the end |
24,855 | public function remove ( ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ name = $ this -> data [ 'name' ] ; $ this -> trashCollectFiles ( $ this -> data ) ; $ this -> data = array ( ) ; unset ( $ _SESSION [ 'form_persist' ] [ $ name ] ) ; if ( empty ( $ _SESSION [ 'form_persist' ] ) ) { unset ( $ _SESSION [ 'form_persist' ] ) ; } $ this -> debug -> groupEnd ( ) ; } | remove current form s perist data |
24,856 | public function trashCollect ( ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ tsNow = \ microtime ( true ) ; if ( isset ( $ _SESSION [ 'form_persist' ] ) && \ is_array ( $ _SESSION [ 'form_persist' ] ) ) { foreach ( $ _SESSION [ 'form_persist' ] as $ formName => $ data ) { if ( ! isset ( $ data [ 'ver' ] ) ) { continue ; } $ tsDiff = $ tsNow - $ data [ 'timestamp' ] ; $ this -> debug -> log ( $ formName . ' created ' . \ number_format ( $ tsDiff , 4 ) . ' sec ago' ) ; $ remove = false ; if ( isset ( $ this -> data [ 'name' ] ) && $ formName == $ this -> data [ 'name' ] ) { $ this -> debug -> warn ( 'not trashing current form' ) ; continue ; } elseif ( $ data [ 'trashCollectable' ] && $ tsDiff > 10 ) { $ remove = true ; } if ( $ remove ) { $ this -> debug -> warn ( 'removing' , $ formName ) ; $ this -> trashCollectFiles ( $ data ) ; unset ( $ _SESSION [ 'form_persist' ] [ $ formName ] ) ; } } } if ( empty ( $ _SESSION [ 'form_persist' ] ) ) { unset ( $ _SESSION [ 'form_persist' ] ) ; } $ this -> debug -> groupEnd ( ) ; } | Remove session data |
24,857 | private function trashCollectFiles ( $ data = null ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ data = isset ( $ data ) ? $ data : $ this -> data ; foreach ( $ data [ 'pages' ] as $ info ) { foreach ( $ info [ 'values' ] as $ a ) { if ( \ is_array ( $ a ) && ! empty ( $ a [ 'tmp_name' ] ) && \ file_exists ( $ a [ 'tmp_name' ] ) ) { $ this -> debug -> log ( 'deleting ' . $ a [ 'tmp_name' ] ) ; \ unlink ( $ a [ 'tmp_name' ] ) ; } } } $ this -> debug -> groupEnd ( ) ; return ; } | remove temporary upload files |
24,858 | public function getItems ( ) { if ( count ( $ this -> items ) > $ this -> itemsPerPage ) { $ items = [ ] ; $ counter = 0 ; foreach ( $ this -> items as $ key => $ value ) { $ items [ $ key ] = $ value ; $ counter ++ ; if ( $ counter == $ this -> itemsPerPage ) { return $ items ; } } } return $ this -> items ; } | Get all the items that are set for this pagination |
24,859 | public function getTotalPages ( ) { if ( $ this -> totalItems > 0 && $ this -> itemsPerPage > 0 ) { if ( ( $ this -> totalItems % $ this -> itemsPerPage ) != 0 ) { return ( int ) ( $ this -> totalItems / $ this -> itemsPerPage ) + 1 ; } else { return ( int ) ( $ this -> totalItems / $ this -> itemsPerPage ) ; } } return 0 ; } | Get total number of pages |
24,860 | public function setSection ( string $ section , array $ data ) : self { $ this -> propertyData [ $ section ] = $ data ; return $ this ; } | sets a section |
24,861 | public function setValue ( string $ section , string $ name , $ value ) : self { if ( ! isset ( $ this -> propertyData [ $ section ] ) ) { $ this -> propertyData [ $ section ] = [ ] ; } $ this -> propertyData [ $ section ] [ $ name ] = ( string ) $ value ; return $ this ; } | sets value of property in given section |
24,862 | public function setBooleanValue ( string $ section , string $ name , $ value ) : self { return $ this -> setValue ( $ section , $ name , ( ( true === $ value ) ? ( 'true' ) : ( 'false' ) ) ) ; } | sets a boolean property value in given section |
24,863 | public function setArrayValue ( string $ section , string $ name , array $ value ) : self { return $ this -> setValue ( $ section , $ name , join ( '|' , $ value ) ) ; } | sets an array as property value in given section |
24,864 | public function setHashValue ( string $ section , string $ name , array $ hash ) : self { $ values = [ ] ; foreach ( $ hash as $ key => $ val ) { $ values [ ] = $ key . ':' . $ val ; } return $ this -> setArrayValue ( $ section , $ name , $ values ) ; } | sets a hash map as property value in given section |
24,865 | public function setRangeValue ( string $ section , string $ name , array $ range ) : self { return $ this -> setValue ( $ section , $ name , array_shift ( $ range ) . '..' . array_pop ( $ range ) ) ; } | sets a range as property value in given section |
24,866 | public function matchDate ( $ date ) { return $ this -> matchPart ( $ date , $ this -> formatRegex [ $ this -> format ] [ self :: STRDATE ] ) ; } | Match a date part |
24,867 | public function matchTime ( $ time ) { return $ this -> matchPart ( $ time , $ this -> formatRegex [ $ this -> format ] [ self :: STRTIME ] ) ; } | Match a time part |
24,868 | public function matchZone ( $ zone ) { return $ this -> matchPart ( $ zone , $ this -> formatRegex [ $ this -> format ] [ self :: STRZONE ] ) ; } | Match a zone part |
24,869 | public function matchDateAndTimeAndZone ( $ date , $ time , $ zone ) { return $ this -> matchDate ( $ date ) && $ this -> matchTime ( $ time ) && $ this -> matchZone ( $ zone ) ; } | Match a date time and zone datestring part |
24,870 | protected function matchPart ( $ value , array $ patterns ) { foreach ( $ patterns as $ key => $ pattern ) { if ( preg_match ( $ pattern , $ value ) === 1 ) { $ this -> messenger -> add ( new StringType ( $ key ) ) ; return true ; } } return false ; } | Match a datestring part |
24,871 | public function doAutoLogin ( ) { if ( $ this -> session [ 'logged_in' ] ) { return true ; } if ( isset ( $ this -> session [ 'autologin_failed' ] ) ) { setcookie ( $ this -> cookie_name , '' , 1 ) ; unset ( $ this -> session [ 'autologin_failed' ] ) ; return false ; } if ( ! isset ( $ _COOKIE [ $ this -> cookie_name ] ) ) { return false ; } list ( $ selector , $ token ) = explode ( ':' , $ _COOKIE [ $ this -> cookie_name ] ) ; $ this -> db -> qb ( [ 'table' => 'core_auth_tokens' , 'fields' => [ 'id_auth_token' , 'id' , 'token' , 'selector' , 'expires' ] , 'filter' => 'selector=:selector' , 'params' => [ ':selector' => $ selector ] ] ) ; $ data = $ this -> db -> all ( ) ; foreach ( $ data as $ auth_token ) { if ( strtotime ( $ auth_token [ 'expires' ] ) < time ( ) ) { $ this -> removeAutoLoginTokenAndCookie ( $ auth_token [ 'id' ] ) ; continue ; } if ( hash_equals ( $ auth_token [ 'token' ] , $ token ) ) { session_regenerate_id ( true ) ; $ this -> createAutoLoginTokenAndCookie ( $ auth_token [ 'id' ] ) ; $ this -> session [ 'logged_in' ] = true ; $ this -> session [ 'user' ] = $ auth_token [ 'id' ] ; unset ( $ this -> session [ 'autologin_failed' ] ) ; return $ this -> session [ 'user' ] ; } } if ( isset ( $ _COOKIE [ $ this -> cookie_name ] ) ) { unset ( $ _COOKIE [ $ this -> cookie_name ] ) ; } $ this -> session [ 'autologin_failed' ] = true ; $ this -> session [ 'logged_in' ] = false ; $ this -> session [ 'user' ] = 0 ; return false ; } | Tries to autologin the user by comparing token stored in cookie with a generated token created of user credentials . |
24,872 | public function createAutoLoginTokenAndCookie ( int $ id ) { $ authtok = new AuthToken ( $ this -> db ) ; $ authtok -> setId ( $ id ) ; $ authtok -> setExpires ( $ this -> expires_after ) ; setcookie ( $ this -> cookie_name , $ authtok -> generate ( ) , $ authtok -> getExpiresTimestamp ( ) , '/' ) ; } | Set auto login cookies with user generated token |
24,873 | public function removeAutoLoginTokenAndCookie ( int $ id ) { $ authtok = new AuthToken ( $ this -> db ) ; $ authtok -> setId ( $ id ) ; $ authtok -> deleteUserToken ( ) ; setcookie ( $ this -> cookie_name , '' , 1 , '/' ) ; } | Removes autologin cookies with user generated token |
24,874 | public static function array_insert ( & $ array , $ item , $ position ) { if ( $ position == 0 ) { array_unshift ( $ array , $ item ) ; } else { if ( count ( $ array ) == $ position ) { $ array [ ] = $ item ; } else { array_splice ( $ array , $ position , 0 , array ( $ item ) ) ; } } } | Inserts given item into given array at given position . |
24,875 | public static function isInformational ( int $ statusCode ) : bool { return ( $ statusCode >= HttpStatus :: INFORMATIONAL ) && ( $ statusCode < HttpStatus :: SUCCESSFUL ) ; } | Checks if the provided status code falls in the Informational range of HTTP statuses |
24,876 | public static function isSuccessful ( int $ statusCode ) : bool { return ( $ statusCode >= HttpStatus :: SUCCESSFUL ) && ( $ statusCode < HttpStatus :: REDIRECTION ) ; } | Checks if the provided status code falls in the Successful range of HTTP statuses |
24,877 | public static function isRedirection ( int $ statusCode ) : bool { return ( $ statusCode >= HttpStatus :: REDIRECTION ) && ( $ statusCode < HttpStatus :: CLIENT_ERROR ) ; } | Checks if the provided status code falls in the Redirection range of HTTP statuses |
24,878 | public static function isClientError ( int $ statusCode ) : bool { return ( $ statusCode >= HttpStatus :: CLIENT_ERROR ) && ( $ statusCode < HttpStatus :: SERVER_ERROR ) ; } | Checks if the provided status code falls in the Client error range of HTTP statuses |
24,879 | public static function isServerError ( int $ statusCode ) : bool { return ( $ statusCode >= HttpStatus :: SERVER_ERROR ) && ( $ statusCode < HttpStatus :: SERVER_ERROR_END ) ; } | Checks if the provided status code falls in the Server error range of HTTP statuses |
24,880 | public static function isError ( int $ statusCode ) : bool { return ( $ statusCode >= HttpStatus :: CLIENT_ERROR ) && ( $ statusCode < HttpStatus :: SERVER_ERROR_END ) ; } | Checks if the provided status code falls in the Client or Server error range of HTTP statuses |
24,881 | public static function getReasonPhrase ( int $ statusCode ) : string { if ( array_key_exists ( $ statusCode , HttpStatus :: REASON_PHRASES ) ) { return HttpStatus :: REASON_PHRASES [ $ statusCode ] ; } throw new \ InvalidArgumentException ( "Invalid status code" ) ; } | Retrieve the reason phrase for the provided HTTP status code |
24,882 | public function sortAction ( Request $ request ) { $ tid = $ request -> get ( 'tid' ) ; $ mode = $ request -> get ( 'mode' ) ; $ dir = strtolower ( $ request -> get ( 'dir' ) ) ; $ sortTids = $ request -> get ( 'sort_ids' ) ; $ sortTids = json_decode ( $ sortTids , true ) ; $ treeManager = $ this -> get ( 'phlexible_tree.tree_manager' ) ; $ nodeSorter = $ this -> get ( 'phlexible_tree.node_sorter' ) ; $ tree = $ treeManager -> getByNodeId ( $ tid ) ; $ node = $ tree -> get ( $ tid ) ; $ node -> setSortMode ( $ mode ) ; $ node -> setSortDir ( $ dir ) ; if ( $ mode !== TreeInterface :: SORT_MODE_FREE ) { $ sortTids = $ nodeSorter -> sort ( $ node ) ; } if ( count ( $ sortTids ) ) { $ tree -> reorderChildren ( $ node , $ sortTids ) ; } return new ResultResponse ( true , 'Tree sort published.' ) ; } | Node reordering . |
24,883 | public function loadConfig ( ) { $ this -> allLocales = config ( 'app.all_locales' ) ; $ this -> defaultLocales = config ( 'app.fallback_locale' ) ; $ this -> usePrefixForDefault = config ( 'routelocale.default_prefix' ) ; } | Load Routelocale configuration . All avalable locales and default locale . |
24,884 | public function getLocaleFromRoute ( $ segments = null ) { if ( is_null ( $ segments ) ) { $ segments = \ Request :: segments ( ) ; } $ locale = $ this -> getDefaultRoutelocale ( ) ; if ( $ allLocales = \ Routelocale :: getAllRoutelocales ( ) ) { if ( $ curLocaleIndex = array_search ( array_shift ( $ segments ) , $ allLocales ) ) { $ locale = $ allLocales [ $ curLocaleIndex ] ; } } return $ locale ; } | Returns the route locale . Fallback to default locale . |
24,885 | public function getRouteLocalePrefix ( $ locale = null ) { if ( is_null ( $ locale ) ) { $ locale = $ this -> getLocaleFromRoute ( ) ; } return $ this -> getDefaultRoutelocale ( ) === $ locale ? ( $ this -> isUsePrefixForDefaultLocale ( ) ? $ locale : '' ) : $ locale ; } | Returns locale to set as prefix to the route . Returns empty string it is default locale and if configuration set to no prefix for default locale |
24,886 | public function AddBreadcrumb ( $ Name , $ Link = NULL , $ Position = 'back' ) { $ Breadcrumb = array ( 'Name' => T ( $ Name ) , 'Url' => $ Link ) ; $ Breadcrumbs = $ this -> Data ( 'Breadcrumbs' , array ( ) ) ; switch ( $ Position ) { case 'back' : $ Breadcrumbs = array_merge ( $ Breadcrumbs , array ( $ Breadcrumb ) ) ; break ; case 'front' : $ Breadcrumbs = array_merge ( array ( $ Breadcrumb ) , $ Breadcrumbs ) ; break ; } $ this -> SetData ( 'Breadcrumbs' , $ Breadcrumbs ) ; } | Add a breadcrumb to the list |
24,887 | public function AddModule ( $ Module , $ AssetTarget = '' ) { $ this -> FireEvent ( 'BeforeAddModule' ) ; $ AssetModule = $ Module ; if ( ! is_object ( $ AssetModule ) ) { if ( property_exists ( $ this , $ Module ) && is_object ( $ this -> $ Module ) ) { $ AssetModule = $ this -> $ Module ; } else { $ ModuleClassExists = class_exists ( $ Module ) ; if ( $ ModuleClassExists ) { $ ReflectionClass = new ReflectionClass ( $ Module ) ; if ( $ ReflectionClass -> implementsInterface ( "Gdn_IModule" ) ) $ AssetModule = new $ Module ( $ this ) ; } } } if ( is_object ( $ AssetModule ) ) { $ AssetTarget = ( $ AssetTarget == '' ? $ AssetModule -> AssetTarget ( ) : $ AssetTarget ) ; $ this -> AddAsset ( $ AssetTarget , $ AssetModule , $ AssetModule -> Name ( ) ) ; } $ this -> FireEvent ( 'AfterAddModule' ) ; } | Adds the specified module to the specified asset target . |
24,888 | public function AddStache ( $ Template = '' , $ ControllerName = FALSE , $ ApplicationFolder = FALSE ) { $ Template = StringEndsWith ( $ Template , '.stache' , TRUE , TRUE ) ; $ StacheTemplate = "{$Template}.stache" ; $ TemplateData = $ this -> FetchView ( $ StacheTemplate , $ ControllerName , $ ApplicationFolder ) ; if ( $ TemplateData === FALSE ) return FALSE ; $ this -> _Staches [ $ Template ] = $ TemplateData ; } | Add a Mustache template to the output |
24,889 | public function Data ( $ Path , $ Default = '' ) { $ Result = GetValueR ( $ Path , $ this -> Data , $ Default ) ; return $ Result ; } | Get a value out of the controller s data array . |
24,890 | public function FetchView ( $ View = '' , $ ControllerName = FALSE , $ ApplicationFolder = FALSE ) { $ ViewPath = $ this -> FetchViewLocation ( $ View , $ ControllerName , $ ApplicationFolder ) ; $ ViewHandler = Gdn :: Factory ( 'ViewHandler' . strtolower ( strrchr ( $ ViewPath , '.' ) ) ) ; $ ViewContents = '' ; ob_start ( ) ; if ( is_null ( $ ViewHandler ) ) { include ( $ ViewPath ) ; } else { $ ViewHandler -> Render ( $ ViewPath , $ this ) ; } $ ViewContents = ob_get_clean ( ) ; return $ ViewContents ; } | Fetches the contents of a view into a string and returns it . Returns false on failure . |
24,891 | public function Image ( $ Img = FALSE ) { if ( $ Img ) { if ( ! is_array ( $ Img ) ) $ Img = array ( $ Img ) ; $ CurrentImages = $ this -> Data ( '_Images' ) ; if ( ! is_array ( $ CurrentImages ) ) $ this -> SetData ( '_Images' , $ Img ) ; else { $ Images = array_unique ( array_merge ( $ CurrentImages , $ Img ) ) ; $ this -> SetData ( '_Images' , $ Images ) ; } } $ Images = $ this -> Data ( '_Images' ) ; return is_array ( $ Images ) ? $ Images : array ( ) ; } | Allows images to be specified for the page to be used by the head module to add facebook open graph information . |
24,892 | public function InformMessage ( $ Message , $ Options = 'Dismissable AutoDismiss' ) { if ( ! is_array ( $ Options ) ) $ Options = array ( 'CssClass' => $ Options ) ; if ( ! $ Message && ! array_key_exists ( 'id' , $ Options ) ) return ; $ Options [ 'Message' ] = $ Message ; $ this -> _InformMessages [ ] = $ Options ; } | Add an inform message to be displayed to the user . |
24,893 | public function Initialize ( ) { if ( in_array ( $ this -> SyndicationMethod , array ( SYNDICATION_ATOM , SYNDICATION_RSS ) ) ) { $ this -> _Headers [ 'Content-Type' ] = 'text/xml; charset=' . C ( 'Garden.Charset' , '' ) ; } if ( is_object ( $ this -> Menu ) ) $ this -> Menu -> Sort = Gdn :: Config ( 'Garden.Menu.Sort' ) ; $ ResolvedPath = strtolower ( CombinePaths ( array ( Gdn :: Dispatcher ( ) -> Application ( ) , Gdn :: Dispatcher ( ) -> ControllerName , Gdn :: Dispatcher ( ) -> ControllerMethod ) ) ) ; $ this -> ResolvedPath = $ ResolvedPath ; $ this -> FireEvent ( 'Initialize' ) ; } | The initialize method is called by the dispatcher after the constructor has completed objects have been passed along assets have been retrieved and before the requested method fires . Use it in any extended controller to do things like loading script and CSS into the head . |
24,894 | public function Json ( $ Key , $ Value = NULL ) { if ( ! is_null ( $ Value ) ) { $ this -> _Json [ $ Key ] = $ Value ; } return ArrayValue ( $ Key , $ this -> _Json , NULL ) ; } | If JSON is going to be sent to the client this method allows you to add extra values to the JSON array . |
24,895 | public function MasterView ( ) { if ( $ this -> MasterView == '' ) { if ( $ this -> SyndicationMethod == SYNDICATION_ATOM ) $ this -> MasterView = 'atom' ; else if ( $ this -> SyndicationMethod == SYNDICATION_RSS ) $ this -> MasterView = 'rss' ; else $ this -> MasterView = 'default' ; } return $ this -> MasterView ; } | Define & return the master view . |
24,896 | public function PageName ( $ Value = NULL ) { if ( $ Value !== NULL ) { $ this -> _PageName = $ Value ; return $ Value ; } if ( $ this -> _PageName === NULL ) { if ( $ this -> ControllerName ) $ Name = $ this -> ControllerName ; else $ Name = get_class ( $ this ) ; $ Name = strtolower ( $ Name ) ; if ( StringEndsWith ( $ Name , 'controller' , FALSE ) ) $ Name = substr ( $ Name , 0 , - strlen ( 'controller' ) ) ; return $ Name ; } else { return $ this -> _PageName ; } } | Gets or sets the name of the page for the controller . The page name is meant to be a friendly name suitable to be consumed by developers . |
24,897 | public function Permission ( $ Permission , $ FullMatch = TRUE , $ JunctionTable = '' , $ JunctionID = '' ) { $ Session = Gdn :: Session ( ) ; if ( ! $ Session -> CheckPermission ( $ Permission , $ FullMatch , $ JunctionTable , $ JunctionID ) ) { if ( ! $ Session -> IsValid ( ) && $ this -> DeliveryType ( ) == DELIVERY_TYPE_ALL ) { Redirect ( '/entry/signin?Target=' . urlencode ( $ this -> SelfUrl ) ) ; } else { Gdn :: Dispatcher ( ) -> Dispatch ( 'DefaultPermission' ) ; exit ( ) ; } } } | Checks that the user has the specified permissions . If the user does not they are redirected to the DefaultPermission route . |
24,898 | public function RemoveCssFile ( $ FileName ) { foreach ( $ this -> _CssFiles as $ Key => $ FileInfo ) { if ( $ FileInfo [ 'FileName' ] == $ FileName ) { unset ( $ this -> _CssFiles [ $ Key ] ) ; return ; } } } | Removes a CSS file from the collection . |
24,899 | public function RemoveJsFile ( $ FileName ) { foreach ( $ this -> _JsFiles as $ Key => $ FileInfo ) { if ( $ FileInfo [ 'FileName' ] == $ FileName ) { unset ( $ this -> _JsFiles [ $ Key ] ) ; return ; } } } | Removes a JS file from the collection . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.