idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
42,500 | protected function getFormattedSimpleQuestion ( $ question , $ default , array $ options ) { $ question .= '%s' ; $ question = sprintf ( $ question , ( $ options ? ' (' . implode ( '/' , $ options ) . ')' : '' ) ) ; return $ question ; } | Get formatted simple question |
42,501 | protected function getValidator ( array $ options , $ required , $ optionValueIsAnswer ) { if ( $ options ) { $ useValue = $ this -> isList ( $ options ) && $ optionValueIsAnswer ; return function ( $ value ) use ( $ options , $ useValue ) { if ( $ useValue && ! array_key_exists ( $ value , $ options ) || ! $ useValue && ! in_array ( $ value , $ options , true ) ) { throw new LogicException ( "Incorrect value '$value'." ) ; } return $ useValue ? $ options [ $ value ] : $ value ; } ; } else { return function ( $ value ) use ( $ required ) { if ( $ required && ( null === $ value ) ) { throw new LogicException ( 'Empty value.' ) ; } return $ value ; } ; } } | Get value validator |
42,502 | public static function copy ( HttpRequest $ request ) { return new self ( $ request -> getHost ( ) , $ request -> getUri ( ) , $ request -> getMethod ( ) , $ request -> getHeaders ( ) , $ request -> getBody ( ) ) ; } | Create copy from request |
42,503 | public function jsonSerialize ( ) { return [ 'host' => $ this -> host , 'uri' => $ this -> uri , 'method' => $ this -> method , 'headers' => $ this -> headers , 'body' => $ this -> body ] ; } | Serialize request properties for JSON as array |
42,504 | protected function setEventsManager ( ) { $ ev = new EventsManager ( ) ; $ ev -> enablePriorities ( true ) ; $ ev -> collectResponses ( true ) ; $ this -> set ( 'eventsManager' , $ ev , true ) ; return $ this ; } | Override events manager default in Phalcon |
42,505 | public function setData ( array $ data , bool $ doReload = true ) { $ this -> logInfo ( 'Manual set new data' . ( $ doReload ? ' and reload.' : '.' ) , __CLASS__ ) ; $ this -> _options [ 'data' ] = $ data ; if ( $ doReload ) { $ this -> reload ( ) ; } return $ this ; } | Sets a new array with translation data that should be used . |
42,506 | public function read ( $ identifier , $ defaultTranslation = false ) { if ( ! isset ( $ this -> _options [ 'data' ] ) ) { $ this -> reload ( ) ; } if ( ! \ is_int ( $ identifier ) && ! \ is_string ( $ identifier ) ) { return $ this -> _options [ 'data' ] ; } if ( ! isset ( $ this -> _options [ 'data' ] [ $ identifier ] ) ) { return $ defaultTranslation ; } return $ this -> _options [ 'data' ] [ $ identifier ] ; } | Reads one or more translation values . |
42,507 | public static function addConfigurationLoader ( $ id , $ loader ) { if ( array_key_exists ( $ id , self :: $ configurationLoaders ) ) { throw new \ Exception ( "there is already a configuration loader for id $id" ) ; } $ reflection = new \ ReflectionClass ( $ loader ) ; if ( ! $ reflection -> implementsInterface ( ConfigurationLoader :: class ) ) { throw new \ Exception ( "given loader must implement the ConfigurationLoader interface" ) ; } self :: $ configurationLoaders [ $ id ] = $ loader ; ksort ( self :: $ configurationLoaders ) ; } | Add a new configuration loader to the list of supported configuration loaders |
42,508 | private function createReport ( ObjectManager $ manager , array $ name , array $ options = array ( ) ) { echo $ name [ 'fr' ] . " \n" ; $ cFGroup = ( new CustomFieldsGroup ( ) ) -> setName ( $ name ) -> setEntity ( 'Chill\ReportBundle\Entity\Report' ) -> setOptions ( $ options ) ; $ manager -> persist ( $ cFGroup ) ; return $ cFGroup ; } | create a report and persist in the db |
42,509 | public function actionRegenerateSlugs ( ) { $ this -> elements = ( new Query ( ) ) -> select ( [ 'id' , 'parent_id' ] ) -> from ( BaseStructure :: tableName ( ) ) -> orderBy ( [ 'parent_id' => SORT_ASC ] ) -> indexBy ( 'id' ) -> all ( ) ; foreach ( $ this -> elements as & $ element ) { if ( ( int ) $ element [ 'parent_id' ] === 0 ) { $ this -> setTreeUrl ( $ element ) ; } } } | Check and regenerate compiled urls |
42,510 | private function constructException ( ) { $ this -> details [ 'argument_type_error' ] [ $ this -> argument ] = $ this -> details [ 'argument_type_error' ] [ 'ARG' ] ; $ this -> details [ 'argument_type_error' ] [ $ this -> argument ] = str_replace ( [ 'VAR_TYPE' , 'ARG_TYPE' ] , [ $ this -> argumentValueType , $ this -> argumentType ] , $ this -> details [ 'argument_type_error' ] [ $ this -> argument ] ) ; unset ( $ this -> details [ 'argument_type_error' ] [ 'ARG' ] ) ; $ this -> resolution = str_replace ( 'ARG_TYPE' , $ this -> argumentType , $ this -> resolution ) ; } | Fill in templates with given values |
42,511 | public function listed ( string $ url , $ returnType = false ) { if ( empty ( $ this -> apiKey ) ) { throw new Exception ( 'A Google Safebrowsing API key has not been specified' ) ; } $ result = $ this -> getSafebrowsingResult ( $ url ) ; if ( is_object ( $ result ) and isset ( $ result -> matches ) ) { foreach ( $ result -> matches as $ match ) { if ( $ match -> threat -> url == $ url ) { if ( $ returnType ) { return $ match -> threatType ; } return true ; } } } return false ; } | Return listed status from Google Safebrowsing . Returns true on listed status |
42,512 | protected function getSafebrowsingResult ( string $ url ) { $ safebrowsingUrl = sprintf ( 'https://safebrowsing.googleapis.com/v4/threatMatches:find?key=%s' , $ this -> apiKey ) ; $ safebrowsingPayload = [ 'client' => [ 'clientId' => 'Ampersa/SafeBrowsing' , 'clientVersion' => '0.1' , ] , 'threatInfo' => [ 'threatTypes' => [ 'MALWARE' , 'SOCIAL_ENGINEERING' , 'UNWANTED_SOFTWARE' , 'POTENTIALLY_HARMFUL_APPLICATION' , ] , 'platformTypes' => [ 'ANY_PLATFORM' ] , 'threatEntryTypes' => [ 'URL' , ] , 'threatEntries' => [ [ 'url' => $ url ] , ] , ] ] ; try { $ response = ( new HttpClient ) -> post ( $ safebrowsingUrl , [ 'json' => $ safebrowsingPayload ] ) ; } catch ( Exception $ e ) { return new StdClass ; } $ result = json_decode ( ( string ) $ response -> getBody ( ) ) ; return $ result ; } | Prepare the request to Google Safebrowsing retrieve the result and decode before returning . |
42,513 | public function checkAuthorisation ( $ object , $ functionName ) { if ( $ this -> isAuthenticated ( ) ) { $ class = $ object ; if ( is_object ( $ class ) ) { $ class = get_class ( $ class ) ; } Logger :: get ( ) -> debug ( "Checking authorisation for {$class}:{$functionName}..." ) ; if ( ! ( in_array ( '*' , $ this -> permissions ) || @ $ this -> permissions [ $ class ] [ '*' ] || @ $ this -> permissions [ $ class ] [ $ functionName ] ) ) { throw new NotAuthorisedException ( "The current user does not have permission for '{$class}.{$functionName}'." ) ; } Logger :: get ( ) -> debug ( 'Authorised.' ) ; } else { throw new NotAuthenticatedException ( 'There is no current authenticated user.' ) ; } } | Checks whether a user is allowed to execute a particular function in a class . |
42,514 | public function destroy ( ) { parent :: destroy ( ) ; Logger :: get ( ) -> debug ( 'Destroying user ' . $ this -> id ) ; if ( ! empty ( $ _SESSION ) && ( $ _SESSION [ 'current_user' ] == $ this ) ) { unset ( $ _SESSION [ 'current_user' ] ) ; } } | Flag the user as no longer in existence so that it does not automatically get saved in the session . |
42,515 | public function authenticate ( IdentityProvider $ identityProvider ) { try { $ identityProvider -> authenticate ( ) ; $ this -> isAuthenticated = true ; $ this -> name = $ identityProvider -> getUserName ( ) ; $ this -> email = $ identityProvider -> getUserEmail ( ) ; } catch ( IdentityException $ exception ) { $ this -> isAuthenticated = false ; throw $ exception ; } } | Authenticates a user against an identity provider . |
42,516 | public function parse ( ) { $ input = $ this -> queryString ; if ( is_string ( $ this -> queryString ) ) { $ input = [ ] ; parse_str ( $ this -> queryString , $ input ) ; } $ this -> query = new Query ( $ input ) ; $ this -> parseQ ( ) ; $ this -> parseEmbeds ( ) ; $ this -> parseIncludes ( ) ; $ this -> parseExcludes ( ) ; $ this -> parseSorts ( ) ; return $ this -> query ; } | Parse a raw query into something more meaningful |
42,517 | protected function parseEmbeds ( ) { if ( $ this -> query -> has ( 'embeds' ) ) { $ embeds = explode ( ',' , $ this -> query -> getRaw ( 'embeds' ) ) ; foreach ( $ embeds as $ embed ) { $ this -> query -> addEmbed ( $ this -> parseEmbed ( $ embed ) ) ; } } } | Parse the embeds from the query string |
42,518 | protected function parseIncludes ( ) { if ( $ this -> query -> has ( 'includes' ) ) { $ this -> query -> setIncludes ( explode ( ',' , $ this -> query -> getRaw ( 'includes' ) ) ) ; } } | Parse the includees from the query string |
42,519 | protected function parseExcludes ( ) { if ( $ this -> query -> has ( 'excludes' ) ) { $ this -> query -> setExcludes ( explode ( ',' , $ this -> query -> getRaw ( 'excludes' ) ) ) ; } } | Parse the excludes from the query string |
42,520 | protected function parseSorts ( ) { if ( $ this -> query -> has ( 'sort' ) ) { $ sorts = explode ( ',' , $ this -> query -> getRaw ( 'sort' ) ) ; foreach ( $ sorts as $ sort ) { $ this -> query -> addSort ( $ this -> parseSort ( $ sort ) ) ; } } } | Parse the sorts from the query string |
42,521 | protected function parseSort ( $ sort ) { $ type = substr ( $ sort , 0 , 1 ) ; $ key = substr ( $ sort , 1 ) ; switch ( $ type ) { case '+' : $ type = Sort :: TYPE_ASC ; break ; case '-' : $ type = Sort :: TYPE_DESC ; break ; default : throw new NoSuchSortException ( ) ; } return new Sort ( $ type , $ key ) ; } | Parse a single sort from a raw query string |
42,522 | protected function doAutoLinks ( $ text ) { if ( ! $ this -> features [ 'auto_mailto' ] ) { return preg_replace_callback ( '{<((https?|ftp|dict):[^\'">\s]+)>}i' , array ( & $ this , '_doAutoLinks_url_callback' ) , $ text ) ; } return parent :: doAutoLinks ( $ text ) ; } | Disable mailto unless auto_mailto |
42,523 | public function getDataAttributes ( ) { $ attributes = [ 'data-toggle' => 'popover' , 'data-container' => 'body' , 'data-placement' => $ this -> getPlacement ( ) ] ; if ( ( $ parent = $ this -> getParent ( ) ) && $ parent -> ShowTitles ) { $ attributes [ 'data-title' ] = $ this -> Title ; } $ this -> extend ( 'updateDataAttributes' , $ attributes ) ; return $ attributes ; } | Answers an array of data attributes for the receiver . |
42,524 | public function getPlacement ( ) { if ( ( $ parent = $ this -> getParent ( ) ) && $ parent -> Placement ) { return $ parent -> Placement ; } return $ this -> config ( ) -> default_placement ; } | Answers the popover placement for the receiver . |
42,525 | public function getPlacementOptions ( ) { return [ self :: PLACEMENT_AUTO => _t ( __CLASS__ . '.AUTO' , 'Auto' ) , self :: PLACEMENT_TOP => _t ( __CLASS__ . '.TOP' , 'Top' ) , self :: PLACEMENT_LEFT => _t ( __CLASS__ . '.LEFT' , 'Left' ) , self :: PLACEMENT_RIGHT => _t ( __CLASS__ . '.RIGHT' , 'Right' ) , self :: PLACEMENT_BOTTOM => _t ( __CLASS__ . '.BOTTOM' , 'Bottom' ) , ] ; } | Answers an array of options for a placement field . |
42,526 | public function getButton ( ) { if ( $ class = $ this -> config ( ) -> button_class ) { $ button = $ class :: create ( ) ; $ this -> extend ( 'updateButton' , $ button ) ; return $ button ; } } | Answers the sharing button instance for the receiver . |
42,527 | protected function _getState ( $ key ) { $ sKey = ( string ) $ key ; return array_key_exists ( $ sKey , $ this -> states ) ? $ this -> states [ $ sKey ] : null ; } | Retrieves the state with a specific key . |
42,528 | protected function _addState ( $ state ) { if ( ! is_string ( $ state ) && ! ( $ state instanceof Stringable ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Argument is not a valid state.' ) , null , null , $ state ) ; } $ this -> states [ ( string ) $ state ] = $ state ; } | Adds a state to this instance . |
42,529 | public static function instance ( $ connectionStringOrConnectionName = null ) { $ config = Config :: instance ( ) ; if ( strpos ( $ connectionStringOrConnectionName , '://' ) === false ) { $ connectionString = $ connectionStringOrConnectionName ? $ config -> getConnection ( $ connectionStringOrConnectionName ) : $ config -> getDefaultConnectionString ( ) ; } else { $ connectionString = $ connectionStringOrConnectionName ; } if ( ! $ connectionString ) throw new DatabaseException ( "Empty connection string" ) ; $ info = static :: parseConnectionUrl ( $ connectionString ) ; $ fqclass = static :: loadAdapterClass ( $ info -> protocol ) ; try { $ connection = new $ fqclass ( $ info ) ; $ connection -> protocol = $ info -> protocol ; $ connection -> logging = $ config -> getLogging ( ) ; $ connection -> logger = $ connection -> logging ? $ config -> getLogger ( ) : null ; if ( isset ( $ info -> charset ) ) $ connection -> setEncoding ( $ info -> charset ) ; } catch ( PDOException $ e ) { throw new DatabaseException ( $ e ) ; } return $ connection ; } | Retrieve a database connection . |
42,530 | private static function loadAdapterClass ( $ adapter ) { $ class = ucwords ( $ adapter ) . 'Adapter' ; $ fqclass = 'ActiveRecord\\' . $ class ; $ source = __DIR__ . "/Adapters/$class.php" ; if ( ! file_exists ( $ source ) ) throw new DatabaseException ( "$fqclass not found!" ) ; require_once ( $ source ) ; return $ fqclass ; } | Loads the specified class for an adapter . |
42,531 | public static function parseConnectionUrl ( $ connectionUrl ) { $ url = @ parse_url ( $ connectionUrl ) ; if ( ! isset ( $ url [ 'host' ] ) ) { throw new DatabaseException ( 'Database host must be specified in the connection string. If you want to specify an absolute filename, use e.g. sqlite://unix(/path/to/file)' ) ; } $ info = new \ stdClass ( ) ; $ info -> protocol = $ url [ 'scheme' ] ; $ info -> host = $ url [ 'host' ] ; $ info -> db = isset ( $ url [ 'path' ] ) ? substr ( $ url [ 'path' ] , 1 ) : null ; $ info -> user = isset ( $ url [ 'user' ] ) ? $ url [ 'user' ] : null ; $ info -> pass = isset ( $ url [ 'pass' ] ) ? $ url [ 'pass' ] : null ; $ allowBlankDb = ( $ info -> protocol == 'sqlite' ) ; if ( $ info -> host == 'unix(' ) { $ socketDatabase = $ info -> host . '/' . $ info -> db ; if ( $ allowBlankDb ) $ unixRegex = '/^unix\((.+)\)\/?().*$/' ; else $ unixRegex = '/^unix\((.+)\)\/(.+)$/' ; if ( preg_match_all ( $ unixRegex , $ socketDatabase , $ matches ) > 0 ) { $ info -> host = $ matches [ 1 ] [ 0 ] ; $ info -> db = $ matches [ 2 ] [ 0 ] ; } } elseif ( substr ( $ info -> host , 0 , 8 ) == 'windows(' ) { $ info -> host = urldecode ( substr ( $ info -> host , 8 ) . '/' . substr ( $ info -> db , 0 , - 1 ) ) ; $ info -> db = null ; } if ( $ allowBlankDb && $ info -> db ) { $ info -> host .= '/' . $ info -> db ; } if ( isset ( $ url [ 'port' ] ) ) { $ info -> port = $ url [ 'port' ] ; } if ( strpos ( $ connectionUrl , 'decode=true' ) !== false ) { if ( $ info -> user ) $ info -> user = urldecode ( $ info -> user ) ; if ( $ info -> pass ) $ info -> pass = urldecode ( $ info -> pass ) ; } if ( isset ( $ url [ 'query' ] ) ) { foreach ( explode ( '/&/' , $ url [ 'query' ] ) as $ pair ) { list ( $ name , $ value ) = explode ( '=' , $ pair ) ; if ( $ name == 'charset' ) { $ info -> charset = $ value ; } } } return $ info ; } | Use this for any adapters that can take connection info in the form below to set the adapters connection info . |
42,532 | public function columns ( $ table ) { $ columns = array ( ) ; $ sth = $ this -> queryColumnInfo ( $ table ) ; while ( ( $ row = $ sth -> fetch ( ) ) ) { $ c = $ this -> createColumn ( $ row ) ; $ columns [ $ c -> name ] = $ c ; } return $ columns ; } | Retrieves column meta data for the specified table . |
42,533 | public function query ( $ sql , & $ values = array ( ) ) { if ( $ this -> logging ) { if ( $ values ) { $ this -> logger -> addInfo ( $ sql , $ values ) ; } else { $ this -> logger -> addInfo ( $ sql ) ; } } $ this -> lastQuery = $ sql ; try { if ( ! ( $ sth = $ this -> connection -> prepare ( $ sql ) ) ) throw new DatabaseException ( $ this ) ; } catch ( PDOException $ e ) { throw new DatabaseException ( $ this ) ; } $ sth -> setFetchMode ( PDO :: FETCH_ASSOC ) ; try { if ( ! $ sth -> execute ( $ values ) ) throw new DatabaseException ( $ this ) ; } catch ( PDOException $ e ) { throw new DatabaseException ( $ e ) ; } return $ sth ; } | Execute a raw SQL query on the database . |
42,534 | public function queryAndFetchOne ( $ sql , & $ values = array ( ) ) { $ sth = $ this -> query ( $ sql , $ values ) ; $ row = $ sth -> fetch ( PDO :: FETCH_NUM ) ; return $ row [ 0 ] ; } | Execute a query that returns maximum of one row with one field and return it . |
42,535 | public function queryAndFetch ( $ sql , Closure $ handler ) { $ sth = $ this -> query ( $ sql ) ; while ( ( $ row = $ sth -> fetch ( PDO :: FETCH_ASSOC ) ) ) $ handler ( $ row ) ; } | Execute a raw SQL query and fetch the results . |
42,536 | public function tables ( ) { $ tables = array ( ) ; $ sth = $ this -> queryForTables ( ) ; while ( ( $ row = $ sth -> fetch ( PDO :: FETCH_NUM ) ) ) $ tables [ ] = $ row [ 0 ] ; return $ tables ; } | Returns all tables for the current database . |
42,537 | public function quoteName ( $ string ) { return $ string [ 0 ] === static :: $ QUOTE_CHARACTER || $ string [ strlen ( $ string ) - 1 ] === static :: $ QUOTE_CHARACTER ? $ string : static :: $ QUOTE_CHARACTER . $ string . static :: $ QUOTE_CHARACTER ; } | Quote a name like table names and field names . |
42,538 | public function stringToDateTime ( $ string ) { $ date = date_create ( $ string ) ; $ errors = \ DateTime :: getLastErrors ( ) ; if ( $ errors [ 'warning_count' ] > 0 || $ errors [ 'error_count' ] > 0 ) return null ; return new DateTime ( $ date -> format ( static :: $ dateTimeFormat ) ) ; } | Converts a string representation of a datetime into a DateTime object . |
42,539 | public function cleanup ( ) : void { foreach ( $ this -> getStore ( ) as $ key => $ value ) { $ this -> remove ( $ key ) ; } } | cleanup content from container |
42,540 | protected function getDefaultTemplateEngine ( ) { $ smarty = new Smarty ( ) ; $ smarty -> debugging = false ; $ smarty -> caching = false ; $ smarty -> left_delimiter = '{|' ; $ smarty -> right_delimiter = '|}' ; $ smarty -> setTemplateDir ( $ this -> resourcePath ) ; return $ smarty ; } | get default template engine |
42,541 | public function getTemplateEngine ( ) { if ( null == $ this -> templateEngine ) { $ this -> setTemplateEngine ( $ this -> getDefaultTemplateEngine ( ) ) ; } return $ this -> templateEngine ; } | set template engine |
42,542 | public function getCodeFromDocComment ( string $ docComment ) : string { $ startExampleKeyword = strpos ( $ docComment , Constants :: EXAMPLE_KEYWORD ) ; $ startCodeKeyword = strpos ( $ docComment , Constants :: CODE_KEYWORD ) ; if ( $ startExampleKeyword !== false ) { $ matches = $ this -> getCodeWithExampleKeyword ( $ docComment , $ startExampleKeyword ) ; } elseif ( $ startCodeKeyword !== false ) { $ matches = $ this -> getCodeWithCodeKeyword ( $ docComment , $ startCodeKeyword ) ; } else { return '' ; } if ( ! $ matches ) { return '' ; } $ codeLines = array_filter ( array_map ( function ( $ line ) { return ltrim ( trim ( $ line , " \t\n\r\0\x0B" ) , '*' ) ; } , is_array ( $ matches ) ? $ matches : explode ( "\n" , ( string ) $ matches ) ) ) ; return rtrim ( implode ( "\n" , $ codeLines ) . ';' ) ; } | Extract the example code from the doc comment |
42,543 | public function getCodeFromDocumentation ( string $ fileContent ) : array { $ start = strpos ( $ fileContent , Constants :: MARKDOWN_PHP_CODE_KEYWORD ) ; $ code = substr ( $ fileContent , $ start ) ; $ regularExpression = '!' . Constants :: MARKDOWN_PHP_CODE_KEYWORD . self :: DOCUMENTATION_REGEX . '!' ; if ( ! preg_match_all ( $ regularExpression , $ code , $ matches ) ) { return [ ] ; } return array_map ( function ( $ line ) { return trim ( $ line ) ; } , $ matches [ 1 ] ) ; } | Extract the example code from the documentation file |
42,544 | public function render ( ) { $ html = parent :: render ( ) ; if ( is_null ( $ this -> value ) ) { $ html = str_replace ( '%value%' , '' , $ html ) ; } else if ( $ this -> value ) { $ content = static :: getAssetContent ( 'true' ) ; $ html = str_replace ( '%value%' , $ content , $ html ) ; } else { $ content = static :: getAssetContent ( 'false' ) ; $ html = str_replace ( '%value%' , $ content , $ html ) ; } return $ html ; } | Effectue le rendu du composant |
42,545 | public function editTinyMcePluginLoaderConfig ( $ arrTinyConfig ) { $ arrTinyConfig [ "insertdatetime_formats" ] = '["' . $ this -> transformFormat ( $ GLOBALS [ 'TL_CONFIG' ] [ 'dateFormat' ] ) . '", "' . $ this -> transformFormat ( $ GLOBALS [ 'TL_CONFIG' ] [ 'timeFormat' ] ) . '"],' ; return $ arrTinyConfig ; } | Adding config for output behavoir |
42,546 | private function transformFormat ( $ strFormat ) { $ arrFormatTokens = str_split ( $ strFormat ) ; foreach ( $ arrFormatTokens as $ i => $ token ) { if ( ctype_alpha ( $ token ) ) { $ arrFormatTokens [ $ i ] = $ this -> arrMapping [ $ token ] ; } } return implode ( '' , $ arrFormatTokens ) ; } | Transforms a format from PHP into TinyMCE preferred |
42,547 | public static function load ( $ package , $ path = null ) { if ( is_array ( $ package ) ) { foreach ( $ package as $ pkg => $ path ) { if ( is_numeric ( $ pkg ) ) { $ pkg = $ path ; $ path = null ; } static :: load ( $ pkg , $ path ) ; } return false ; } if ( static :: loaded ( $ package ) ) { return ; } if ( $ path === null ) { $ paths = \ Config :: get ( 'package_paths' , array ( ) ) ; empty ( $ paths ) and $ paths = array ( PKGPATH ) ; if ( ! empty ( $ paths ) ) { foreach ( $ paths as $ modpath ) { if ( is_dir ( $ path = $ modpath . strtolower ( $ package ) . DS ) ) { break ; } } } } if ( ! is_dir ( $ path ) ) { throw new \ PackageNotFoundException ( "Package '$package' could not be found at '" . \ Fuel :: clean_path ( $ path ) . "'" ) ; } \ Finder :: instance ( ) -> add_path ( $ path , 1 ) ; \ Fuel :: load ( $ path . 'bootstrap.php' ) ; static :: $ packages [ $ package ] = $ path ; return true ; } | Loads the given package . If a path is not given if will search through the defined package_paths . If not defined then PKGPATH is used . It also accepts an array of packages as the first parameter . |
42,548 | public static function exists ( $ package ) { if ( array_key_exists ( $ package , static :: $ packages ) ) { return static :: $ packages [ $ package ] ; } else { $ paths = \ Config :: get ( 'package_paths' , array ( ) ) ; empty ( $ paths ) and $ paths = array ( PKGPATH ) ; foreach ( $ paths as $ path ) { if ( is_dir ( $ path . $ package ) ) { return $ path . $ package . DS ; } } } return false ; } | Checks if the given package exists . |
42,549 | static function forceInstance ( Singleton $ object , $ class = null ) { if ( $ class == null ) $ class = get_class ( $ object ) ; if ( ! isset ( self :: $ instances [ $ class ] ) ) { self :: $ instances [ $ class ] = $ object ; } else { throw new \ Exception ( sprintf ( 'Object of class %s was previously instanciated' , $ class ) ) ; } } | Force a singleton object to be instanciated with the given instance Use with care! |
42,550 | public function registerGroup ( $ name , $ alias , $ fields ) { $ grp = new BConfigCategoryGroup ( ) ; $ grp -> alias = $ alias ; $ grp -> name = $ name ; foreach ( $ fields as $ fld ) { $ grp -> fields [ $ fld -> alias ] = $ fld ; } $ this -> groups [ $ alias ] = $ grp ; return $ grp ; } | Register group Create BConfigCategoryGroup object & register it |
42,551 | public function get ( $ name , $ default = null ) { $ parts = explode ( '.' , $ name ) ; $ partsSize = count ( $ parts ) ; if ( $ partsSize < 1 ) { throw new Exception ( 'Invalid config::get format !' ) ; } $ this -> loadData ( $ parts [ 0 ] ) ; if ( $ partsSize == 1 ) { return $ this -> data [ $ parts [ 0 ] ] ; } $ path = implode ( '.' , array_slice ( $ parts , 1 , $ partsSize ) ) ; return Arr :: get ( $ this -> data [ $ parts [ 0 ] ] , $ path , $ default ) ; } | Get config option |
42,552 | private function connect ( array & $ connections ) { $ exceptions = [ ] ; while ( count ( $ connections ) > 0 ) { $ connection = array_pop ( $ connections ) ; try { if ( $ connection -> open ( ) ) { return $ connection ; } } catch ( DatabaseException $ e ) { $ exceptions [ ] = $ e -> getMessage ( ) ; } } throw new ConnectionException ( 'Unable to select connection.' , '' , 0 , count ( $ exceptions ) > 0 ? new ConnectionException ( implode ( ' ' , $ exceptions ) ) : null ) ; } | Calls the connect method for every connection in the given array and returns the connection on success . |
42,553 | public function debug ( $ layoutId = null , $ data = array ( ) ) { $ layoutId = $ layoutId ? : 'default' ; $ renderer = new \ JLayoutFile ( $ layoutId ) ; $ renderer -> setIncludePaths ( $ this -> getLayoutPaths ( ) ) ; return $ renderer -> debug ( array_merge ( $ this -> getLayoutData ( ) , $ data ) ) ; } | Debug a layout rendering . |
42,554 | private function readContent ( ) : bool { $ rawContent = $ this -> getRequest ( ) -> getRawContent ( ) ; if ( $ rawContent === '' ) { $ this -> content = null ; return true ; } $ this -> content = json_decode ( $ rawContent , true ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { $ this -> getResponse ( ) -> setStatusCode ( new StatusCode ( StatusCode :: BAD_REQUEST ) ) ; return false ; } return true ; } | Reads the content . |
42,555 | public static function concat ( iterable $ pieces , ? string $ delimiter = null ) : self { $ delimiter = is_null ( $ delimiter ) ? Text :: EMPTY_TEXT : $ delimiter ; $ temp = TextVector :: make ( $ pieces ) -> concat ( $ delimiter ) ; return self :: make ( $ temp ) ; } | Crea una nueva instancia concatenando varias cadenas de texto |
42,556 | public function toCamelCase ( ) : self { return $ this -> split ( '/[_\s\W]+/' ) -> reduce ( function ( Text $ carry , Text $ piece ) { return $ carry -> append ( $ piece -> toUpperFirst ( ) -> stringify ( ) ) ; } , self :: make ( ) ) -> toLowerFirst ( ) ; } | Transforma la cadena de texto a formato camelCase |
42,557 | public function toSnakeCase ( string $ separator = '_' ) : self { return $ this -> toCamelCase ( ) -> replace ( '/[A-Z]/' , function ( $ piece ) use ( $ separator ) { return sprintf ( '%s%s' , $ separator , strtolower ( $ piece ) ) ; } ) ; } | Transforma la cadena de texto a formato snake_case |
42,558 | public function explode ( string $ delimiter , int $ limit = PHP_INT_MAX ) : TextVector { $ pieces = explode ( $ delimiter , $ this -> text , $ limit ) ; return TextVector :: make ( $ pieces ) ; } | Divide una cadena en varias mediante un delimitador |
42,559 | public function highlight ( $ htmlString ) { $ tags = implode ( '|' , $ this -> validContainers ) ; $ pattern = '#(<(' . $ tags . ')[^>]' . $ this -> langAttribute . '=["\']+([^\'".]*)["\']+>)(.*?)(</\2\s*>|$)#s' ; return preg_replace_callback ( $ pattern , array ( $ this , '_processCodeBlock' ) , $ htmlString ) ; } | Highlight a block of HTML containing defined blocks . Converts blocks from plain text into highlighted code . |
42,560 | public function highlightText ( $ text , $ language , $ withStylesheet = false ) { $ this -> _getGeshi ( ) ; $ this -> _geshi -> set_source ( $ text ) ; $ this -> _geshi -> set_language ( $ language ) ; return ! $ withStylesheet ? $ this -> _geshi -> parse_code ( ) : $ this -> _includeStylesheet ( ) . $ this -> _geshi -> parse_code ( ) ; } | Highlight all the provided text as a given language . |
42,561 | protected function _getGeshi ( ) { if ( ! $ this -> _geshi ) { $ this -> _geshi = new GeSHi ( ) ; } $ this -> _configureInstance ( $ this -> _geshi ) ; return $ this -> _geshi ; } | Get the instance of GeSHI used by the helper . |
42,562 | protected function _processCodeBlock ( $ matches ) { list ( $ block , $ openTag , $ tagName , $ lang , $ code , $ closeTag ) = $ matches ; unset ( $ matches ) ; $ lang = $ this -> validLang ( $ lang ) ; $ code = html_entity_decode ( $ code , ENT_QUOTES ) ; if ( isset ( $ this -> containerMap [ $ tagName ] ) ) { $ patt = '/' . preg_quote ( $ tagName ) . '/' ; $ openTag = preg_replace ( $ patt , $ this -> containerMap [ $ tagName ] [ 0 ] , $ openTag ) ; $ closeTag = preg_replace ( $ patt , $ this -> containerMap [ $ tagName ] [ 1 ] , $ closeTag ) ; } if ( $ this -> showPlainTextButton ) { $ button = '<a href="#null" class="geshi-plain-text">Show Plain Text</a>' ; $ openTag = $ button . $ openTag ; } if ( $ lang ) { $ highlighted = $ this -> highlightText ( trim ( $ code ) , $ lang ) ; return $ openTag . $ highlighted . $ closeTag ; } return $ openTag . $ code . $ closeTag ; } | Preg Replace Callback Uses matches made earlier runs geshi returns processed code blocks . |
42,563 | public function validLang ( $ lang ) { if ( in_array ( $ lang , $ this -> validLanguages ) ) { return $ lang ; } if ( $ this -> defaultLanguage ) { return $ this -> defaultLanguage ; } return false ; } | Check if the current language is a valid language . |
42,564 | protected function _configureInstance ( $ geshi ) { if ( empty ( $ this -> features ) ) { if ( empty ( $ this -> configPath ) ) { $ this -> configPath = ROOT . DS . 'config' . DS ; } if ( file_exists ( $ this -> configPath . 'geshi.php' ) ) { include $ this -> configPath . 'geshi.php' ; } return ; } foreach ( $ this -> features as $ key => $ value ) { foreach ( $ value as & $ test ) { if ( defined ( $ test ) ) { $ test = constant ( $ test ) ; } } unset ( $ test ) ; call_user_func_array ( array ( $ geshi , $ key ) , $ value ) ; } } | Configure a geshi Instance the way we want it . |
42,565 | public function render ( ) { if ( ! empty ( self :: $ titleList -> toArray ( ) ) ) { return '<title>' . implode ( '' , self :: $ titleList -> toArray ( ) ) . '</title>' . PHP_EOL ; } else { return false ; } } | Return HTML code for Title |
42,566 | protected function _createTerm ( $ name , $ type , $ value ) { switch ( $ this -> getOperator ( ) ) { case '==' : $ escaped = $ this -> _escape ( $ this -> getOperator ( ) , SORT_STRING , $ value ) ; $ term = new Zend_Search_Lucene_Index_Term ( $ this -> _empty ( $ escaped ) , $ name ) ; return new Zend_Search_Lucene_Search_Query_Term ( $ term ) ; case '!=' : $ escaped = $ this -> _escape ( $ this -> getOperator ( ) , SORT_STRING , $ value ) ; $ term = new Zend_Search_Lucene_Index_Term ( $ this -> _empty ( $ escaped ) , $ name ) ; return new Zend_Search_Lucene_Search_Query_MultiTerm ( array ( $ term ) , array ( false ) ) ; case '~=' : if ( ( $ parts = explode ( ' ' , $ value ) ) === false ) { throw new MW_Common_Exception ( 'Empty term is not allowed for wildcard queries' ) ; } $ query = new Zend_Search_Lucene_Search_Query_Boolean ( ) ; foreach ( $ parts as $ part ) { $ escaped = $ this -> _escape ( $ this -> getOperator ( ) , SORT_STRING , $ part ) ; $ term = new Zend_Search_Lucene_Index_Term ( strtolower ( $ this -> _empty ( $ escaped ) ) . '*' , $ name ) ; $ query -> addSubquery ( new Zend_Search_Lucene_Search_Query_Wildcard ( $ term ) ) ; } return $ query ; case '>=' : case '>' : $ escaped = $ this -> _escape ( $ this -> getOperator ( ) , SORT_STRING , $ value ) ; $ term = new Zend_Search_Lucene_Index_Term ( $ this -> _empty ( $ escaped ) , $ name ) ; $ inclusive = self :: $ _operators [ $ this -> getOperator ( ) ] ; return new Zend_Search_Lucene_Search_Query_Range ( $ term , null , $ inclusive ) ; case '<=' : case '<' : $ escaped = $ this -> _escape ( $ this -> getOperator ( ) , SORT_STRING , $ value ) ; $ term = new Zend_Search_Lucene_Index_Term ( $ this -> _empty ( $ escaped ) , $ name ) ; $ inclusive = self :: $ _operators [ $ this -> getOperator ( ) ] ; return new Zend_Search_Lucene_Search_Query_Range ( null , $ term , $ inclusive ) ; } } | Creates a Lucene query object from the given parameters . |
42,567 | protected function _createListTerm ( $ name , $ type ) { $ sign = null ; switch ( $ this -> getOperator ( ) ) { case '!=' : $ sign = false ; case '==' : $ multiterm = new Zend_Search_Lucene_Search_Query_MultiTerm ( ) ; foreach ( $ this -> getValue ( ) as $ value ) { $ escaped = $ this -> _escape ( $ this -> getOperator ( ) , SORT_STRING , $ value ) ; $ term = new Zend_Search_Lucene_Index_Term ( $ this -> _empty ( $ escaped ) , $ name ) ; $ multiterm -> addTerm ( $ term , $ sign ) ; } return $ multiterm ; case '~=' : $ query = new Zend_Search_Lucene_Search_Query_Boolean ( ) ; foreach ( $ this -> getValue ( ) as $ value ) { $ escaped = $ this -> _escape ( $ this -> getOperator ( ) , SORT_STRING , $ value ) ; $ term = new Zend_Search_Lucene_Index_Term ( strtolower ( $ this -> _empty ( $ escaped ) ) . '*' , $ name ) ; $ query -> addSubquery ( new Zend_Search_Lucene_Search_Query_Wildcard ( $ term ) ) ; } return $ query ; } } | Creates a Lucene query object from a list of values . |
42,568 | public static function getInstance ( $ extension , $ options = array ( ) ) { $ hash = md5 ( $ extension . serialize ( $ options ) ) ; if ( isset ( self :: $ instances [ $ hash ] ) ) { return self :: $ instances [ $ hash ] ; } $ parts = explode ( '.' , $ extension ) ; $ component = 'com_' . strtolower ( $ parts [ 0 ] ) ; $ section = count ( $ parts ) > 1 ? $ parts [ 1 ] : '' ; $ classname = ucfirst ( substr ( $ component , 4 ) ) . ucfirst ( $ section ) . 'Categories' ; if ( ! class_exists ( $ classname ) ) { $ path = JPATH_SITE . '/components/' . $ component . '/helpers/category.php' ; if ( is_file ( $ path ) ) { include_once $ path ; } else { return false ; } } self :: $ instances [ $ hash ] = new $ classname ( $ options ) ; return self :: $ instances [ $ hash ] ; } | Returns a reference to a JCategories object |
42,569 | public function get ( $ id = 'root' , $ forceload = false ) { if ( $ id !== 'root' ) { $ id = ( int ) $ id ; if ( $ id == 0 ) { $ id = 'root' ; } } if ( ( ! isset ( $ this -> _nodes [ $ id ] ) && ! isset ( $ this -> _checkedCategories [ $ id ] ) ) || $ forceload ) { $ this -> _load ( $ id ) ; } if ( isset ( $ this -> _nodes [ $ id ] ) ) { return $ this -> _nodes [ $ id ] ; } elseif ( isset ( $ this -> _checkedCategories [ $ id ] ) ) { return ; } return false ; } | Loads a specific category and all its children in a JCategoryNode object |
42,570 | public function setParent ( $ parent ) { if ( $ parent instanceof JCategoryNode || is_null ( $ parent ) ) { if ( ! is_null ( $ this -> _parent ) ) { $ key = array_search ( $ this , $ this -> _parent -> _children ) ; unset ( $ this -> _parent -> _children [ $ key ] ) ; } if ( ! is_null ( $ parent ) ) { $ parent -> _children [ ] = & $ this ; } $ this -> _parent = $ parent ; if ( $ this -> id != 'root' ) { if ( $ this -> parent_id != 1 ) { $ this -> _path = $ parent -> getPath ( ) ; } $ this -> _path [ ] = $ this -> id . ':' . $ this -> alias ; } if ( count ( $ parent -> _children ) > 1 ) { end ( $ parent -> _children ) ; $ this -> _leftSibling = prev ( $ parent -> _children ) ; $ this -> _leftSibling -> _rightsibling = & $ this ; } } } | Set the parent of this category |
42,571 | public function removeChild ( $ id ) { $ key = array_search ( $ this , $ this -> _parent -> _children ) ; unset ( $ this -> _parent -> _children [ $ key ] ) ; } | Remove a specific child |
42,572 | public function & getChildren ( $ recursive = false ) { if ( ! $ this -> _allChildrenloaded ) { $ temp = $ this -> _constructor -> get ( $ this -> id , true ) ; if ( $ temp ) { $ this -> _children = $ temp -> getChildren ( ) ; $ this -> _leftSibling = $ temp -> getSibling ( false ) ; $ this -> _rightSibling = $ temp -> getSibling ( true ) ; $ this -> setAllLoaded ( ) ; } } if ( $ recursive ) { $ items = array ( ) ; foreach ( $ this -> _children as $ child ) { $ items [ ] = $ child ; $ items = array_merge ( $ items , $ child -> getChildren ( true ) ) ; } return $ items ; } return $ this -> _children ; } | Get the children of this node |
42,573 | public function setSibling ( $ sibling , $ right = true ) { if ( $ right ) { $ this -> _rightSibling = $ sibling ; } else { $ this -> _leftSibling = $ sibling ; } } | Function to set the left or right sibling of a category |
42,574 | public function getSibling ( $ right = true ) { if ( ! $ this -> _allChildrenloaded ) { $ temp = $ this -> _constructor -> get ( $ this -> id , true ) ; $ this -> _children = $ temp -> getChildren ( ) ; $ this -> _leftSibling = $ temp -> getSibling ( false ) ; $ this -> _rightSibling = $ temp -> getSibling ( true ) ; $ this -> setAllLoaded ( ) ; } if ( $ right ) { return $ this -> _rightSibling ; } else { return $ this -> _leftSibling ; } } | Returns the right or left sibling of a category |
42,575 | public function getParams ( ) { if ( ! ( $ this -> params instanceof Registry ) ) { $ temp = new Registry ; $ temp -> loadString ( $ this -> params ) ; $ this -> params = $ temp ; } return $ this -> params ; } | Returns the category parameters |
42,576 | public function getMetadata ( ) { if ( ! ( $ this -> metadata instanceof Registry ) ) { $ temp = new Registry ; $ temp -> loadString ( $ this -> metadata ) ; $ this -> metadata = $ temp ; } return $ this -> metadata ; } | Returns the category metadata |
42,577 | public function getAuthor ( $ modified_user = false ) { if ( $ modified_user ) { return JFactory :: getUser ( $ this -> modified_user_id ) ; } return JFactory :: getUser ( $ this -> created_user_id ) ; } | Returns the user that created the category |
42,578 | public function setAllLoaded ( ) { $ this -> _allChildrenloaded = true ; foreach ( $ this -> _children as $ child ) { $ child -> setAllLoaded ( ) ; } } | Set to load all children |
42,579 | public function getNumItems ( $ recursive = false ) { if ( $ recursive ) { $ count = $ this -> numitems ; foreach ( $ this -> getChildren ( ) as $ child ) { $ count = $ count + $ child -> getNumItems ( true ) ; } return $ count ; } return $ this -> numitems ; } | Returns the number of items . |
42,580 | public function fromZip ( $ zip ) { $ this -> data = null ; $ this -> error = null ; $ this -> renamed = false ; $ this -> tempname = null ; $ this -> module_id = null ; $ this -> destination = null ; if ( ! $ this -> setModuleId ( $ zip ) ) { return $ this -> error ; } if ( ! $ this -> extract ( ) ) { $ this -> rollback ( ) ; return $ this -> error ; } if ( ! $ this -> validate ( ) ) { $ this -> rollback ( ) ; return $ this -> error ; } if ( ! $ this -> backup ( ) ) { return $ this -> error ; } return true ; } | Installs a module from a ZIP file |
42,581 | public function fromUrl ( array $ sources ) { $ total = count ( $ sources ) ; $ finish_message = $ this -> translation -> text ( 'New modules: %inserted, updated: %updated' ) ; $ vars = array ( '@url' => $ this -> url -> get ( '' , array ( 'download_errors' => true ) ) ) ; $ errors_message = $ this -> translation -> text ( 'New modules: %inserted, updated: %updated, errors: %errors. <a href="@url">See error log</a>' , $ vars ) ; $ data = array ( 'total' => $ total , 'data' => array ( 'sources' => $ sources ) , 'id' => 'installer_download_module' , 'log' => array ( 'errors' => $ this -> getErrorLogFile ( ) ) , 'redirect_message' => array ( 'finish' => $ finish_message , 'errors' => $ errors_message ) ) ; $ this -> job -> submit ( $ data ) ; } | Install modules from multiple URLs |
42,582 | protected function backup ( ) { if ( empty ( $ this -> tempname ) ) { return true ; } $ module = $ this -> data ; $ module += array ( 'directory' => $ this -> tempname , 'module_id' => $ this -> module_id ) ; $ result = $ this -> getBackupModule ( ) -> backup ( 'module' , $ module ) ; if ( $ result === true ) { gplcart_file_delete_recursive ( $ this -> tempname ) ; return true ; } $ this -> error = $ this -> translation -> text ( 'Failed to backup module @id' , array ( '@id' => $ this -> module_id ) ) ; return false ; } | Backup the previous version of the updated module |
42,583 | protected function extract ( ) { $ this -> destination = GC_DIR_MODULE . "/{$this->module_id}" ; if ( file_exists ( $ this -> destination ) ) { $ this -> tempname = gplcart_file_unique ( $ this -> destination . '~' ) ; if ( ! rename ( $ this -> destination , $ this -> tempname ) ) { $ this -> error = $ this -> translation -> text ( 'Failed to rename @old to @new' , array ( '@old' => $ this -> destination , '@new' => $ this -> tempname ) ) ; return false ; } $ this -> renamed = true ; } if ( $ this -> zip -> extract ( GC_DIR_MODULE ) ) { return true ; } $ this -> error = $ this -> translation -> text ( 'Failed to extract to @name' , array ( '@name' => $ this -> destination ) ) ; return false ; } | Extracts module files to the system directory |
42,584 | protected function rollback ( ) { if ( ! $ this -> isUpdate ( ) || ( $ this -> isUpdate ( ) && $ this -> renamed ) ) { gplcart_file_delete_recursive ( $ this -> destination ) ; } if ( isset ( $ this -> tempname ) ) { rename ( $ this -> tempname , $ this -> destination ) ; } } | Restore the original module files |
42,585 | protected function validate ( ) { $ this -> data = $ this -> module -> getInfo ( $ this -> module_id ) ; if ( empty ( $ this -> data ) ) { $ this -> error = $ this -> translation -> text ( 'Failed to read module @id' , array ( '@id' => $ this -> module_id ) ) ; return false ; } try { $ this -> module_model -> checkCore ( $ this -> data ) ; $ this -> module_model -> checkPhpVersion ( $ this -> data ) ; return true ; } catch ( Exception $ ex ) { $ this -> error = $ ex -> getMessage ( ) ; return false ; } } | Validates a module data |
42,586 | public function getFilesFromZip ( $ file ) { try { $ files = $ this -> zip -> set ( $ file ) -> getList ( ) ; } catch ( Exception $ e ) { return array ( ) ; } return count ( $ files ) < 2 ? array ( ) : $ files ; } | Returns an array of files from a ZIP file |
42,587 | protected function setModuleId ( $ file ) { $ module_id = $ this -> getModuleIdFromZip ( $ file ) ; try { $ this -> module_model -> checkModuleId ( $ module_id ) ; } catch ( Exception $ ex ) { $ this -> error = $ ex -> getMessage ( ) ; return false ; } if ( $ this -> isEnabledModule ( $ module_id ) ) { $ this -> error = $ this -> translation -> text ( 'Module @id is enabled and cannot be updated' , array ( '@id' => $ module_id ) ) ; return false ; } $ this -> module_id = $ module_id ; return true ; } | Set a module id |
42,588 | protected function isEnabledModule ( $ module_id ) { $ sql = 'SELECT module_id FROM module WHERE module_id=? AND status > 0' ; $ result = $ this -> db -> fetchColumn ( $ sql , array ( $ module_id ) ) ; return ! empty ( $ result ) ; } | Check if a module ID has enabled status in the database |
42,589 | public function getModuleIdFromZip ( $ file ) { $ list = $ this -> getFilesFromZip ( $ file ) ; if ( empty ( $ list ) ) { return false ; } $ folder = reset ( $ list ) ; if ( strrchr ( $ folder , '/' ) !== '/' ) { return false ; } $ nested = 0 ; foreach ( $ list as $ item ) { if ( strpos ( $ item , $ folder ) === 0 ) { $ nested ++ ; } } if ( count ( $ list ) != $ nested ) { return false ; } return rtrim ( $ folder , '/' ) ; } | Returns a module id from a zip file or false on error |
42,590 | private function checkResultCount ( array $ result , $ query ) { if ( count ( $ result ) === 0 ) { throw new RowNotFoundException ( 'Row not found for query: ' . $ query ) ; } if ( count ( $ result ) > 1 ) { throw new MultipleRowFoundException ( 'Multiple row found for query: ' . $ query ) ; } } | Checks the result against the proper row number |
42,591 | public static function getSimpleAnnouncement ( $ announcementPathFile = Null ) { if ( ! $ announcementPathFile ) { $ announcementPathFile = '/data/ssp-announcement.php' ; } if ( ! file_exists ( $ announcementPathFile ) ) { return Null ; } try { $ announcement = include $ announcementPathFile ; } catch ( Exception $ e ) { return Null ; } if ( ! is_string ( $ announcement ) ) { return Null ; } return $ announcement ; } | Includes a php file and if it is only a string returns that string . Otherwise returns Null . |
42,592 | public function build ( ) { $ config = new Config ( ) ; $ event = new GetConfigEvent ( $ config ) ; $ this -> eventDispatcher -> dispatch ( GuiEvents :: GET_CONFIG , $ event ) ; return $ config ; } | Gather configs and return config array . |
42,593 | public function monthInRoman ( $ number ) { $ number = intval ( $ number ) ; $ romanNumbers = array ( 1 => 'I' , 2 => 'II' , 3 => 'III' , 4 => 'IV' , 5 => 'V' , 6 => 'VI' , 7 => 'VII' , 8 => 'VIII' , 9 => 'IX' , 10 => 'X' , 11 => 'XI' , 12 => 'XII' ) ; if ( $ number >= 0 && $ number <= 12 ) { return $ romanNumbers [ $ number ] ; } else { return $ number ; } } | Convert month into romans |
42,594 | public function humanTimeDiff ( $ time , $ chunk = false ) { if ( ! is_integer ( $ time ) ) { $ time = strtotime ( $ time ) ; } if ( $ chunk ) { $ different = time ( ) - $ time ; $ seconds = $ different ; $ minutes = round ( $ different / 60 ) ; $ hours = round ( $ different / 3600 ) ; $ days = round ( $ different / 86400 ) ; $ weeks = round ( $ different / 604800 ) ; $ months = round ( $ different / 2419200 ) ; $ years = round ( $ different / 29030400 ) ; if ( $ seconds <= 60 ) { if ( $ seconds == 1 ) { return "$seconds second ago" ; } else { return "$seconds seconds ago" ; } } elseif ( $ minutes <= 60 ) { if ( $ minutes == 1 ) { return "$minutes minute ago" ; } else { return "$minutes minutes ago" ; } } elseif ( $ hours <= 24 ) { if ( $ hours == 1 ) { return "$hours hour ago" ; } else { return "$hours hours ago" ; } } elseif ( $ days <= 7 ) { if ( $ days = 1 ) { return "$days day ago" ; } else { return "$days days ago" ; } } elseif ( $ weeks <= 4 ) { if ( $ weeks == 1 ) { return "$weeks week ago" ; } else { return "$weeks weeks ago" ; } } elseif ( $ months <= 12 ) { if ( $ months == 1 ) { return "$months month ago" ; } else { return "$months months ago" ; } } else { if ( $ years == 1 ) { return "$years year ago" ; } else { return "$years years ago" ; } } } else { $ dtF = new \ DateTime ( '@0' ) ; $ dtT = new \ DateTime ( "@$time" ) ; return $ dtF -> diff ( $ dtT ) -> format ( '%a days, %h hours, %i minutes and %s seconds' ) ; } } | Human time different |
42,595 | public function dateArray ( $ begin , $ end , $ format = 'Y-m-d' ) { $ begin = new \ DateTime ( $ begin ) ; $ end = new \ DateTime ( $ end ) ; $ end = $ end -> modify ( '+1 day' ) ; $ interval = new \ DateInterval ( 'P1D' ) ; $ daterange = new \ DatePeriod ( $ begin , $ interval , $ end ) ; $ dateArray = array ( ) ; foreach ( $ daterange as $ date ) { $ dateArray [ ] = $ date -> format ( $ format ) ; } return $ dateArray ; } | Generate date array |
42,596 | public function monthArray ( $ begin , $ end , $ year = '' ) { if ( empty ( $ year ) ) { $ year = date ( 'Y' ) ; } $ dateArray = array ( ) ; for ( $ i = $ begin ; $ i <= $ end ; ++ $ i ) { $ dateArray [ ] = $ i ; } return $ dateArray ; } | Generate month number array |
42,597 | public function yearArray ( $ begin , $ end ) { $ dateArray = array ( ) ; for ( $ i = $ begin ; $ i <= $ end ; ++ $ i ) { $ dateArray [ ] = $ i ; } return $ dateArray ; } | Generate Year array |
42,598 | public function upcast ( SerializedEvent $ event , UpcastingContext $ context ) { $ result = [ ] ; $ events = [ $ event ] ; foreach ( $ this -> upcasters as $ upcaster ) { $ result = [ ] ; foreach ( $ events as $ event ) { if ( $ upcaster -> supports ( $ event ) ) { $ upcasted = $ upcaster -> upcast ( $ event , $ context ) ; if ( ! is_array ( $ upcasted ) ) { @ trigger_error ( 'Upcasters need to return an array collection of upcasted events, ' . 'non array return values are deprecated and support will be removed in the next major release' , E_USER_DEPRECATED ) ; $ upcasted = [ $ upcasted ] ; } array_push ( $ result , ... $ upcasted ) ; } } $ events = $ result ; } return $ result ; } | Upcasts via a chain of upcasters . |
42,599 | public function getRepository ( $ className ) { if ( isset ( $ this -> repositories [ $ className ] ) ) { return $ this -> repositories [ $ className ] ; } $ metadata = $ this -> getClassMetadata ( $ className ) ; $ customRepositoryClassName = $ metadata -> getCustomRepositoryClassName ( ) ; if ( $ customRepositoryClassName !== null ) { $ repository = new $ customRepositoryClassName ( $ this , $ this -> unitOfWork , $ metadata ) ; } else { $ repository = new ModelRepository ( $ this , $ this -> unitOfWork , $ metadata ) ; } $ this -> repositories [ $ className ] = $ repository ; return $ repository ; } | Returns the model repository instance given by model name . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.