idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
236,100 | public function cmdGetLanguage ( ) { $ list = $ this -> getListLanguage ( ) ; $ this -> outputFormat ( $ list ) ; $ this -> outputFormatTableLanguage ( $ list ) ; $ this -> output ( ) ; } | Callback for language - get command |
236,101 | public function cmdDeleteLanguage ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = false ; if ( isset ( $ id ) ) { $ result = $ this -> language -> delete ( $ id ) ; ... | Callback for language - delete command |
236,102 | protected function submitAddLanguage ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'language' ) ; $ this -> addLanguage ( ) ; } | Add a language at once |
236,103 | protected function wizardAddLanguage ( ) { $ this -> validatePrompt ( 'code' , $ this -> text ( 'Code' ) , 'language' ) ; $ this -> validatePrompt ( 'name' , $ this -> text ( 'Name' ) , 'language' , '' ) ; $ this -> validatePrompt ( 'native_name' , $ this -> text ( 'Native name' ) , 'language' , '' ) ; $ this -> valida... | Adds a language step by step |
236,104 | protected function oneOf ( $ name , $ conditions ) { $ method = 'get' . ucfirst ( $ name ) ; if ( method_exists ( $ this , $ method ) ) { $ q = call_user_func ( [ $ this , $ method ] ) ; $ q -> andOnCondition ( $ conditions ) ; return $ q -> one ( ) ; } throw new InvalidArgumentException ( Yii :: t ( 'error' , 'Method ... | One of functionality |
236,105 | public function set ( $ key , $ value ) { header ( '' . $ key . ': ' . $ value . '' , true ) ; $ this -> vars [ $ key ] = $ value ; } | Alias of add But if key exists it will be replaced |
236,106 | public function getEphemeral ( $ name ) { $ ephemeral = $ this -> get ( self :: EPHEMERAL ) ; if ( isset ( $ ephemeral [ $ name ] [ self :: VARIABLE ] ) ) { return $ ephemeral [ $ name ] [ self :: VARIABLE ] ; } else { return null ; } } | Get Session ephemeral variable specified . |
236,107 | public function hasEphemeral ( $ name ) { $ ephemeral = $ this -> get ( self :: EPHEMERAL ) ; return isset ( $ ephemeral [ $ name ] ) ; } | Check if have specified ephemeral var in Session . |
236,108 | public function clearEphemeral ( ) { if ( $ this -> has ( self :: EPHEMERAL ) ) { $ ephemeral = $ this -> get ( self :: EPHEMERAL ) ; foreach ( $ ephemeral as $ name => & $ var ) { if ( true === $ var [ self :: ACTIVE ] ) { $ var [ self :: ACTIVE ] = false ; } else { unset ( $ ephemeral [ $ name ] ) ; } } } else { $ ep... | Initialize Session . Remove old ephemeral var in Session . |
236,109 | public function setEphemeral ( $ name , $ value ) { $ ephemeral = $ this -> get ( self :: EPHEMERAL ) ; $ ephemeral [ $ name ] [ self :: ACTIVE ] = true ; $ ephemeral [ $ name ] [ self :: VARIABLE ] = $ value ; $ this -> set ( self :: EPHEMERAL , $ ephemeral ) ; return $ this ; } | Set ephemeral variable in Session . |
236,110 | protected function CanCreateAfter ( ) { $ parent = $ this -> tree -> ParentOf ( $ this -> page ) ; if ( $ parent ) { return BackendModule :: Guard ( ) -> Allow ( BackendAction :: Create ( ) , $ parent ) ; } return BackendModule :: Guard ( ) -> GrantAddPageToSite ( $ this -> page -> GetSite ( ) ) -> ToBool ( ) ; } | True if page can be appended |
236,111 | protected function AreaUrl ( Area $ area ) { $ params = array ( ) ; $ params [ 'page' ] = $ this -> page -> GetID ( ) ; $ params [ 'area' ] = $ area -> GetID ( ) ; return BackendRouter :: ModuleUrl ( new PageContentTree ( ) , $ params ) ; } | Gets the content tree url |
236,112 | final public static function parseAttributes ( $ attributes , $ ignore = array ( ) ) { if ( ! is_array ( $ attributes ) ) { return $ attributes ; } $ return = "" ; foreach ( $ attributes as $ attr => $ value ) { if ( in_array ( $ attr , $ ignore ) ) continue ; $ return .= $ attr . '="' . $ value . '" ' ; } return $ ret... | Parses the attributes for use |
236,113 | public static function carousel ( array $ items , array $ attributes = array ( ) ) { self :: $ carousels ++ ; $ id = ( isset ( $ attributes [ 'id' ] ) ) ? $ attributes [ 'id' ] : 'myCarousel' . self :: $ carousels ; $ class = ( isset ( $ attributes [ 'class' ] ) ) ? $ attributes [ 'class' ] . ' carousel slide' : 'carou... | Creates a carousel |
236,114 | public static function accordion ( array $ groups , array $ attributes = array ( ) ) { self :: $ accordions ++ ; $ collapse = 1 ; ob_start ( ) ; ?> <div data-close=" <?= @ $ attributes [ 'close' ] ?> " class="accordion <?= @ $ attributes [ 'class' ] ?> " id="accordion <?= self :: $ accordions ?> " <?= self :: parseAt... | Creates an accordion |
236,115 | public static function groupIntoRows ( array $ items , $ itemsPerRow , array $ options = array ( ) ) { ob_start ( ) ; ?> <div class="row-fluid <?= @ $ options [ 'rows' ] [ 'class' ] ?> " <?= self :: parseAttributes ( @ $ options [ 'rows' ] , array ( 'class' ) ) ?> > <?php foreach ( $ item... | Groups given items into rows with class row - fluid |
236,116 | public static function progress ( $ message = 'Loading. Please wait ...' , $ percentage = 100 , $ style = 'info' , $ striped = true , $ active = true ) { ob_start ( ) ; ?> <div class="progress <?= ( $ striped ) ? 'progress-striped' : '' ?> progress- <?= $ style ?> <?= ( $ striped ) ? 'active' : '' ?> "> <di... | Creates a progress bar |
236,117 | public static function popover ( $ content , $ label , $ placement = 'top' , $ title = null , $ class = null ) { ob_start ( ) ; ?> <a href="#" class=" <?= $ class ?> " rel="popover" data-placement=" <?= $ placement ?> " data-content=' <?= $ content ?> ' <?= $ title ? ' data-original-title="' . $ title . '"' ... | Create a popover and it s link |
236,118 | protected function controllerMiddleware ( ) { list ( $ class , $ method ) = explode ( '@' , $ this -> action [ 'uses' ] ) ; $ controller = UniversalBuilder :: resolve ( $ class ) ; return ( new ControllerDispatcher ( $ this -> router ) ) -> getMiddleware ( $ controller , $ method ) ; } | Get the controller middleware for the route . |
236,119 | static function lock ( $ string , $ key = null ) { return openssl_encrypt ( $ string , self :: _getSecMethod ( ) , Utils :: spare ( $ key , self :: _geteSecKey ( ) ) , false , self :: _getSecIv ( ) ) ; } | Encrypts values passed |
236,120 | static function unlock ( $ cipher , $ key = null ) { return openssl_decrypt ( $ cipher , self :: _getSecMethod ( ) , Utils :: spare ( $ key , self :: _geteSecKey ( ) ) , false , self :: _getSecIv ( ) ) ; } | Decrypts values passed |
236,121 | public function runApplicationComponents ( $ applicationComponents ) { foreach ( $ applicationComponents as $ key => $ applicationComponent ) { $ class = $ applicationComponent -> component ; $ parameters = $ applicationComponent -> parameters ; $ applicationComponents [ $ key ] -> { 'object' } = $ this -> getComponent... | Loop through all application components and run them |
236,122 | protected function newField ( $ name , array $ options ) : FieldConfig { if ( OrderField :: isOrder ( $ name ) ) { return new OrderField ( $ name , $ this , $ options ) ; } return new SearchField ( $ name , $ this , $ options ) ; } | Creates a new SearchField instance . |
236,123 | protected function compileSelectPart ( Query $ query , array & $ bindings ) : string { $ columns = [ ] ; foreach ( ( $ query -> select ? : [ '*' ] ) as $ alias => $ column ) { if ( $ column instanceof Aggregate ) { $ column = $ this -> compileAggregate ( $ column , $ bindings ) ; } else { $ column = $ this -> compileId... | Compiles a SELECT part of an SQL query . |
236,124 | protected function compileFromPart ( Query $ query , array & $ bindings ) : string { if ( $ query -> table === null ) { throw new InvalidQueryException ( 'The FROM table is not set' ) ; } return 'FROM ' . $ this -> compileIdentifierWithAlias ( $ query -> table , $ query -> tableAlias , $ bindings ) ; } | Compiles a FROM part of an SQL query . |
236,125 | protected function compileJoinPart ( Query $ query , array & $ bindings ) : string { $ joinsSQL = [ ] ; foreach ( $ query -> join as $ join ) { $ joinsSQL [ ] = $ this -> compileOneJoin ( $ join , $ bindings ) ; } return $ this -> implodeSQL ( $ joinsSQL ) ; } | Compiles a JOIN parts of an SQL query . |
236,126 | protected function compileWherePart ( Query $ query , array & $ bindings ) : string { $ sql = $ this -> compileCriteria ( $ query -> where , $ bindings ) ; if ( $ sql !== '' ) { $ sql = 'WHERE ' . $ sql ; } return $ sql ; } | Compiles a WHERE part of an SQL query . |
236,127 | protected function compileOrderPart ( Query $ query , array & $ bindings ) : string { $ ordersSQL = [ ] ; foreach ( $ query -> order as $ order ) { $ orderSQL = $ this -> compileOneOrder ( $ order , $ bindings ) ; if ( $ orderSQL !== '' ) { $ ordersSQL [ ] = $ orderSQL ; } } return $ ordersSQL ? 'ORDER BY ' . implode (... | Compiles a ORDER part of an SQL query . |
236,128 | protected function compileUpdateValues ( array $ values , array & $ bindings ) : string { $ parts = [ ] ; foreach ( $ values as $ column => $ value ) { $ parts [ ] = $ this -> quoteCompositeIdentifier ( $ column ) . ' = ' . $ this -> compileValue ( $ value , $ bindings ) ; } return implode ( ', ' , $ parts ) ; } | Compiles a values list for the SET part of a update SQL query . |
236,129 | protected function compileValue ( $ value , array & $ bindings ) : string { if ( $ value instanceof Query || $ value instanceof StatementInterface ) { return $ this -> compileSubQuery ( $ value , $ bindings ) ; } $ this -> mergeBindings ( $ bindings , [ $ value ] ) ; return '?' ; } | Converts a value to a part of an SQL query text . Actually it sends all the values to the bindings . |
236,130 | protected function compileSubQuery ( $ subQuery , array & $ bindings , bool $ parenthesise = true ) : string { if ( $ subQuery instanceof Query ) { try { $ subQuery = $ this -> compile ( $ subQuery ) ; } catch ( InvalidQueryException $ exception ) { throw new InvalidQueryException ( 'Error in subquery: ' . $ exception ... | Converts a subquery to an SQL query text . |
236,131 | protected function compileAggregate ( Aggregate $ aggregate , array & $ bindings ) : string { return $ aggregate -> function . '(' . $ this -> compileIdentifier ( $ aggregate -> column , $ bindings ) . ')' ; } | Converts an Aggregate object to an SQL query text . |
236,132 | protected function compileOneJoin ( Join $ join , array & $ bindings ) : string { $ sql = $ join -> type . ' JOIN ' . $ this -> compileIdentifierWithAlias ( $ join -> table , $ join -> tableAlias , $ bindings ) ; if ( $ join -> criteria ) { $ sql .= ' ON ' . $ this -> compileCriteria ( $ join -> criteria , $ bindings )... | Converts a Join object ot an SQL query text . |
236,133 | protected function compileOneOrder ( $ order , array & $ bindings ) : string { if ( $ order instanceof Order ) { return $ this -> compileIdentifier ( $ order -> column , $ bindings ) . ' ' . ( $ order -> isDescending ? 'DESC' : 'ASC' ) ; } if ( $ order instanceof OrderByIsNull ) { return $ this -> compileIdentifier ( $... | Converts a single order to an SQL query text . |
236,134 | protected function compileInsertFromValues ( $ table , string $ tableAlias = null , array $ values ) : array { if ( empty ( $ values ) ) { return [ ] ; } $ bindings = [ ] ; $ columns = [ ] ; foreach ( $ values as $ row ) { foreach ( $ row as $ column => $ value ) { if ( ! isset ( $ columns [ $ column ] ) ) { $ columns ... | Compiles set of full INSERT queries from an array of values . |
236,135 | protected function compileInsertFromSelect ( $ table , string $ tableAlias = null , array $ columns = null , $ selectQuery ) : StatementInterface { $ bindings = [ ] ; $ sqlLine1 = 'INSERT INTO ' . $ this -> compileIdentifierWithAlias ( $ table , $ tableAlias , $ bindings ) ; if ( $ columns !== null ) { $ sqlLine1 .= ' ... | Compiles a full INSERT query from a select query . |
236,136 | protected function mergeBindings ( array & $ target , array $ source ) { $ targetBindingsAmount = count ( $ target ) ; $ sourceBindingsIndex = 0 ; foreach ( $ source as $ name => $ value ) { $ key = is_int ( $ name ) ? $ targetBindingsAmount + $ sourceBindingsIndex : $ name ; $ target [ $ key ] = $ value ; $ sourceBind... | Merges two arrays of bound values . |
236,137 | protected function implodeSQL ( array $ parts ) : string { $ result = '' ; foreach ( $ parts as $ part ) { if ( $ part === '' ) { continue ; } $ result .= ( $ result === '' ? '' : "\n" ) . $ part ; } return $ result ; } | Implodes parts of SQL query to a single string . |
236,138 | public function registerRoutes ( ) { $ this -> _route = new Route ( ) ; $ this -> _config = Config :: from ( 'app' ) ; $ router = $ this ; require_once $ this -> _config -> from ( 'app' ) -> get ( 'routes' ) ; } | Handles registering defined routes . |
236,139 | public function getRoute ( $ url ) { $ routes = $ this -> _route -> getRoutes ( ) ; $ return = '' ; foreach ( $ routes as $ route ) { $ routeURI = $ this -> _config -> from ( 'app' ) -> get ( 'basepath' ) . $ route [ 'uri' ] ; if ( isset ( $ _POST ) ) { foreach ( $ _POST as $ key => $ value ) { $ route [ 'query' ] [ ] ... | Gets the route from supplied URL . |
236,140 | public function round ( $ decimals = 2 ) { if ( false === ( '-' . intval ( $ decimals ) == '-' . $ decimals ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ decimals ) ) , E_USER_ERROR ) ; } return $ this -> convert ( function ( $ numb... | Round all the numbers with a precision |
236,141 | public function toFixed ( $ decimals = 2 ) { if ( false === ( '-' . intval ( $ decimals ) == '-' . $ decimals ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ decimals ) ) , E_USER_ERROR ) ; } return $ this -> convert ( function ( $ nu... | Converts number into a string keeping a specified number of decimal |
236,142 | public function val ( $ index = 0 ) { if ( false === ( '-' . intval ( $ index ) == '-' . $ index ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ index ) ) , E_USER_ERROR ) ; } $ val = $ this -> strip ( ) ; if ( true === isset ( $ val ... | Strips all the numbers from a string and returns the value with an optional index to retrieve |
236,143 | public function format ( $ decimals = 2 , $ point = '.' , $ thousands_sep = ',' , $ currency = null ) { if ( false === ( '-' . intval ( $ decimals ) == '-' . $ decimals ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ decimals ) ) , E_... | Converts all the numbers in a string to a specific format |
236,144 | private function convert ( $ callback , $ variables = [ ] ) { $ this -> number = preg_replace_callback ( '~[0-9\.,]+~' , function ( $ number ) use ( $ callback , $ variables ) { return call_user_func_array ( $ callback , array_merge ( [ ( float ) str_replace ( ',' , '' , $ number [ 0 ] ) ] , $ variables ) ) ; } , $ thi... | Executes a callable function and returns this instance |
236,145 | public function addData ( array $ data , string $ type = "all" ) : self { $ this -> viewData [ $ type ] = array_merge ( $ this -> viewData [ $ type ] ?? [ ] , $ data ) ; return $ this ; } | Add view data |
236,146 | public function loadController ( $ module , $ controller ) { if ( false === is_string ( $ module ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ module ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $ controller ) ) { return trigg... | Loads controller by module name and controller name |
236,147 | private function executeController ( $ controller , Route $ method , $ matches ) { if ( false === is_object ( $ controller ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type object, "%s" given' , __METHOD__ , gettype ( $ controller ) ) , E_USER_ERROR ) ; } if ( false === is_array ( $ ... | Executes default controller functions |
236,148 | private function loadBoot ( $ module ) { if ( false === is_string ( $ module ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ module ) ) , E_USER_ERROR ) ; } $ boot = Path :: get ( 'modules' ) . $ module . DIRECTORY_SEPARATOR . Files ::... | Load the module boot file if exists and readable |
236,149 | public static function specifyType ( $ domain ) { if ( false !== filter_var ( $ domain , FILTER_VALIDATE_IP ) ) { return new IPAddress ( $ domain ) ; } return new Hostname ( $ domain ) ; } | Returns a Hostname or a IPAddress object depending on passed value |
236,150 | function result ( $ _top = '' ) { ob_start ( ) ; $ this -> output ( $ _top ) ; $ result = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ result ; } | Parser Wrapper Returns Template Output as a String |
236,151 | function output ( $ _top = '' ) { global $ _top ; if ( strlen ( $ this -> template_dir ) && substr ( $ this -> template_dir , - 1 ) != '/' ) { $ this -> template_dir .= '/' ; } if ( strlen ( $ this -> temp_dir ) && substr ( $ this -> temp_dir , - 1 ) != '/' ) { $ this -> temp_dir .= '/' ; } if ( ! is_array ( $ _top ) )... | Execute parsed Template Prints Parsing Results to Standard Output |
236,152 | function use_cache ( $ key = '' ) { if ( empty ( $ _POST ) ) { $ this -> cache_filename = $ this -> cache_dir . 'cache_' . md5 ( $ _SERVER [ 'REQUEST_URI' ] . serialize ( $ key ) ) . '.ser' ; if ( ( $ _SERVER [ 'HTTP_CACHE_CONTROL' ] != 'no-cache' ) && ( $ _SERVER [ 'HTTP_PRAGMA' ] != 'no-cache' ) && @ is_file ( $ this... | Start Ouput Content Buffering |
236,153 | function cache_callback ( $ output ) { if ( $ hd = @ fopen ( $ this -> cache_filename , 'w' ) ) { fputs ( $ hd , $ output ) ; fclose ( $ hd ) ; } return $ output ; } | Output Buffer Callback Function |
236,154 | public function getOffsetPosting ( ) { $ this -> getJournal ( ) -> assertIsSimpleJournal ( ) ; foreach ( $ this -> getJournal ( ) -> getPostings ( ) as $ posting ) { if ( $ posting != $ this ) { return $ posting ; } } } | Get offset posting |
236,155 | public function reverseTransform ( $ stringPoint ) { if ( ! $ stringPoint ) { return null ; } if ( null === $ stringPoint ) { throw new TransformationFailedException ( sprintf ( 'An area with number "%s" does not exist!' , $ stringPoint ) ) ; } if ( is_array ( $ stringPoint ) ) { $ stringPoint = $ stringPoint [ 'gpsCoo... | Transforms a string to an object . |
236,156 | public function findVendorForSlug ( $ slug ) { $ criteria = Criteria :: create ( ) -> where ( Criteria :: expr ( ) -> eq ( 'slug' , $ slug ) ) ; return $ this -> getVendors ( ) -> matching ( $ criteria ) -> first ( ) ; } | Find Vendor given slug |
236,157 | public static function decodeUnicodeString ( $ chrs ) { $ chrs = ( string ) $ chrs ; $ utf8 = '' ; $ strlenChrs = strlen ( $ chrs ) ; for ( $ i = 0 ; $ i < $ strlenChrs ; $ i ++ ) { $ ordChrsC = ord ( $ chrs [ $ i ] ) ; switch ( true ) { case preg_match ( '/\\\u[0-9A-F]{4}/i' , substr ( $ chrs , $ i , 6 ) ) : $ utf16 =... | Decode Unicode Characters from \ u0000 ASCII syntax . |
236,158 | protected function _decodeValue ( ) { switch ( $ this -> token ) { case self :: DATUM : $ result = $ this -> tokenValue ; $ this -> _getNextToken ( ) ; return ( $ result ) ; case self :: LBRACE : return ( $ this -> _decodeObject ( ) ) ; case self :: LBRACKET : return ( $ this -> _decodeArray ( ) ) ; } } | Recursive driving routine for supported toplevel tops |
236,159 | protected function _eatWhitespace ( ) { if ( preg_match ( '/([\t\b\f\n\r ])*/s' , $ this -> source , $ matches , PREG_OFFSET_CAPTURE , $ this -> offset ) && $ matches [ 0 ] [ 1 ] == $ this -> offset ) { $ this -> offset += strlen ( $ matches [ 0 ] [ 0 ] ) ; } } | Removes whitespace characters from the source input |
236,160 | protected static function _utf162utf8 ( $ utf16 ) { if ( function_exists ( 'mb_convert_encoding' ) ) { return mb_convert_encoding ( $ utf16 , 'UTF-8' , 'UTF-16' ) ; } $ bytes = ( ord ( $ utf16 { 0 } ) << 8 ) | ord ( $ utf16 { 1 } ) ; switch ( true ) { case ( ( 0x7F & $ bytes ) == $ bytes ) : return chr ( 0x7F & $ bytes... | Convert a string from one UTF - 16 char to one UTF - 8 char . |
236,161 | final public function reportError ( $ errno , $ errstr , $ errfile , $ errline , array $ errcontext = array ( ) ) { $ this -> _addRow ( array ( $ errstr ) , $ this -> _formatLocation ( $ errfile , $ errline ) , self :: ERROR ) ; } | logs a PHP error to the console as an error |
236,162 | final public function reportException ( \ Exception $ e ) { $ this -> _addRow ( array ( $ e -> getMessage ( ) ) , $ this -> _formatLocation ( $ e -> getFile ( ) , $ e -> getLine ( ) ) , self :: WARN ) ; } | logs a PHP exception to the console as a warn |
236,163 | public static function phone ( $ value , $ format ) { $ value = preg_replace ( '/[^0-9]+/' , '' , $ value ) ; if ( is_array ( $ format ) ) { $ length = mb_strlen ( $ value ) ; if ( $ length >= 11 ) { $ format = $ format [ 11 ] ; } else if ( $ length >= 10 ) { $ format = $ format [ 10 ] ; } else { $ format = $ format [ ... | Format a phone number . A phone number can support multiple variations depending on how many numbers are present . |
236,164 | protected static function _replaceRuleText ( $ text , $ rule ) { for ( $ parts = 1 ; $ parts < 20 ; $ parts ++ ) { if ( false === strpos ( $ rule , "{T$parts}" ) ) break ; } if ( 1 === $ parts ) { return str_replace ( [ "T" , "T1" ] , $ text , $ rule ) ; } $ text = str_replace ( "\\|" , "<<__E\$C@P#D__>>" , $ text ) ; ... | Replaced found text for a rule . |
236,165 | public function getRelationship ( $ key ) { if ( isset ( $ this -> relationships [ $ key ] ) ) { return $ this -> relationships [ $ key ] ; } return null ; } | Gets a relationship from this entity . Returns null if the relationship doesn t exist . |
236,166 | public function pushData ( Entity $ entity ) { if ( $ this -> isMany ( ) ) { $ this -> primaryData [ ] = $ entity ; return $ this ; } $ this -> primaryData = $ entity ; return $ this ; } | Pushes entities to this resource . |
236,167 | protected function hex2rgb ( $ hexcolor ) { preg_match ( "/^#{0,1}([0-9a-f]{1,6})$/i" , $ hexcolor , $ match ) ; if ( ! isset ( $ match [ 1 ] ) ) { return [ ] ; } $ color = $ match [ 1 ] ; if ( 6 == strlen ( $ color ) ) { list ( $ r , $ g , $ b ) = [ $ color [ 0 ] . $ color [ 1 ] , $ color [ 2 ] . $ color [ 3 ] , $ col... | Return RGB array from hex color . |
236,168 | public function get_html_path ( $ resource_path ) { $ uri = $ this -> sm -> get ( 'pegase.core.request' ) -> get_uri ( ) ; $ uri = explode ( '?' , $ uri ) ; $ uri = $ uri [ 0 ] ; $ nb = substr_count ( $ uri , '/' ) - 1 ; $ path = "" ; for ( $ i = 0 ; $ i < $ nb ; $ i ++ ) { $ path .= "../" ; } $ pos = strpos ( $ resour... | relatif pour les liens dans le html |
236,169 | protected function _stringableSplit ( $ subject , $ separator ) { $ subject = $ this -> _normalizeString ( $ subject ) ; $ separator = $ this -> _normalizeString ( $ separator ) ; return explode ( $ separator , $ subject ) ; } | Splits a stringable into pieces using a separator . |
236,170 | public static function get_mime_type ( $ filename ) { if ( extension_loaded ( 'fileinfo' ) ) { try { $ finfo = new \ finfo ( FILEINFO_MIME_TYPE ) ; return $ finfo -> file ( $ filename ) ; } catch ( \ Exception $ e ) { } } if ( function_exists ( 'mime_content_type' ) ) { try { return mime_content_type ( $ filename ) ; }... | Determine the mime - type of a file . |
236,171 | public static function normalize_filename ( $ input ) { if ( empty ( $ input ) ) { return false ; } $ pathinfo = pathinfo ( $ input ) ; $ ext = mb_strtolower ( $ pathinfo [ 'extension' ] ) ; if ( $ ext === 'jpeg' ) { $ ext = 'jpg' ; } $ filename = $ pathinfo [ 'filename' ] . '.' . $ ext ; $ filename = static :: sanitiz... | This helps us create normalized filenames . |
236,172 | public static function sanitize_filename ( $ i , $ allow_subdirs = false , $ allowabsolute = false ) { $ i = trim ( $ i ) ; $ replacements = [ '../' , './' ] ; if ( $ allow_subdirs === false ) { $ replacements [ ] = '/' ; } if ( $ allowabsolute !== true && $ i { 0 } === '/' ) { $ i = substr ( $ i , 1 ) ; } return str_r... | Sanitize a filename . |
236,173 | public static function create_directory_structure ( $ folders , $ base_dir ) { if ( ! empty ( $ folders ) && is_array ( $ folders ) ) { foreach ( $ folders as $ name => $ subfolders ) { if ( ! file_exists ( $ base_dir . $ name . '/' ) ) { mkdir ( $ base_dir . $ name . '/' ) ; } touch ( $ base_dir . $ name . '/index.htm... | Create a complete directory structure in a given path . |
236,174 | public static function rrmdir ( $ path ) { if ( is_file ( $ path ) ) { return unlink ( $ path ) ; } elseif ( is_dir ( $ path ) ) { $ dir_members = scandir ( $ path ) ; foreach ( $ dir_members as $ member ) { if ( $ member !== '.' && $ member !== '..' ) { static :: rrmdir ( $ path . '/' . $ member ) ; } } return @ rmdir... | Delete a folder and all subfolders . |
236,175 | public static function unzip ( $ file , $ destination ) { if ( ! file_exists ( $ file ) ) { return false ; } if ( ! file_exists ( $ destination ) ) { mkdir ( $ destination ) ; } if ( class_exists ( 'ZipArchive' ) ) { $ result = static :: unzip_using_ziparchive ( $ file , $ destination ) ; if ( $ result === true ) { ret... | Unzip a zip file into a directory . |
236,176 | public static function unzip_using_ziparchive ( $ file , $ destination ) { $ za = new \ ZipArchive ; $ zares = $ za -> open ( $ file ) ; if ( $ zares === true ) { $ za -> extractTo ( $ destination ) ; $ za -> close ( ) ; return true ; } else { return false ; } } | Unzip a file into a directory using the ZipArchive class . |
236,177 | public static function get_file_type_from_mime ( $ mime ) { $ validtypes = [ 'application' , 'audio' , 'image' , 'message' , 'multipart' , 'text' , 'video' ] ; if ( mb_stripos ( $ mime , '/' ) === false ) { return false ; } $ iparts = explode ( '/' , $ mime ) ; if ( count ( $ iparts ) !== 2 ) { return false ; } return ... | Get the general file type from a mime type . |
236,178 | public static function make_human_readable_filesize ( $ bytes ) { $ units = array ( 'B' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' ) ; $ num_units = count ( $ units ) ; $ size = $ bytes ; foreach ( $ units as $ i => $ unit ) { if ( $ size < 1024 || ( ( $ i + 1 ) === $ num_units ) ) { return round ( $ size , 2 ) . $ unit ; } $ ... | Convert bytes into a human - readable format . |
236,179 | public static function dirsize ( $ dir , $ createifmissing = false ) { $ dirsize = 0 ; if ( ! file_exists ( $ dir ) ) { if ( $ createifmissing === true ) { mkdir ( $ dir ) ; return 0 ; } throw new \ Exception ( 'Directory does not exist!' , 400 ) ; } $ dir_info = scandir ( $ dir ) ; if ( $ dir { ( mb_strlen ( $ dir ) -... | Get the disk usage of a given directory . |
236,180 | static function guessMimeType ( $ file , $ def = 'application/octet-stream' ) { $ ext = substr ( strrchr ( strtolower ( $ file ) , '.' ) , 1 ) ; switch ( $ ext ) { case 'gif' : case 'jpeg' : case 'png' : return "image/$ext" ; case 'jpg' : return 'image/jpeg' ; case 'mp4' : case 'mpeg' : case 'avi' : return "video/$ext"... | Guess Mime type from file name |
236,181 | public static function getConstants ( $ name ) { if ( isset ( self :: $ _const [ $ name ] ) ) { return self :: $ _const [ $ name ] ; } $ self = new \ ReflectionClass ( new static ( ) ) ; $ contants = $ self -> getConstants ( ) ; $ prefix = strtoupper ( $ name ) . '_' ; $ prefixLength = strlen ( $ prefix ) ; $ prefixOff... | get constants by name |
236,182 | public function fillerAction ( $ plugin , Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ chain = $ this -> get ( 'anime_db.plugin.filler' ) ; if ( ! ( $ filler = $ chain -> getPlugin ( $ plugin ) ) ) { t... | Create new item from source fill . |
236,183 | public function searchFillerAction ( Request $ request ) { $ chain = $ this -> get ( 'anime_db.plugin.filler' ) ; $ response = $ this -> getResponseFromChain ( $ chain ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ entity = new SearchFiller ( $ chain ) ; $ form = $ this -> createForm ( n... | Search filler by URL for fill item . |
236,184 | protected function getResponseFromChain ( Chain $ chain ) { if ( ! $ chain -> getPlugins ( ) ) { throw $ this -> createNotFoundException ( 'No any plugins' ) ; } $ names = '' ; foreach ( $ chain -> getPlugins ( ) as $ plugin ) { $ names .= '|' . $ plugin -> getName ( ) ; } return $ this -> getCacheTimeKeeper ( ) -> get... | Get response from plugins chain . |
236,185 | private function serialize ( EntityMetadata $ metadata ) { switch ( $ this -> serializer ) { case self :: SERIALIZER_PHP : return serialize ( $ metadata ) ; case self :: SERIALIZER_IGBINARY : return igbinary_serialize ( $ metadata ) ; default : throw new RuntimeException ( 'Unable to handle serialization of the metadat... | Serializes the metadata object based on the selected serializer . |
236,186 | private function unserialize ( $ value ) { switch ( $ this -> serializer ) { case self :: SERIALIZER_PHP : return unserialize ( $ value ) ; case self :: SERIALIZER_IGBINARY : return igbinary_unserialize ( $ value ) ; default : throw new RuntimeException ( 'Unable to handle unserialization of the metadata object' ) ; } ... | Unserializes the metadata object based on the selected serializer . |
236,187 | private function setPercentSize ( \ Jb \ Bundle \ TagCloudBundle \ Model \ Tag $ tag , $ max ) { $ percent = ( $ tag -> getCounter ( ) / $ max ) * 100 ; $ weight = floor ( $ percent / 10 ) ; if ( $ percent >= 5 ) { $ weight ++ ; } if ( $ percent >= 80 && $ percent < 100 ) { $ weight = 8 ; } elseif ( $ percent == 100 ) ... | Set a size |
236,188 | public function documentNotFound ( $ proxy , Identifier $ identifier ) { $ eventArgs = new DocumentNotFoundEventArgs ( $ proxy , $ this -> dm , $ identifier ) ; $ this -> evm -> dispatchEvent ( Event :: documentNotFound , $ eventArgs ) ; return $ eventArgs -> isExceptionDisabled ( ) ; } | Return whether the exceptionDisabled flag was set . |
236,189 | protected function installEntryFiles ( PackageInterface $ package ) { foreach ( $ this -> getEntryFileLocations ( $ package ) as $ src => $ dest ) { $ copied = $ this -> filesystem -> copyFile ( $ src , $ dest ) ; $ this -> io -> notice ( sprintf ( ' <fg=default>Copying <fg=magenta>%1$s</> to <fg=magenta>%2$s</> -</... | Install each must - use plugin entry file |
236,190 | protected function uninstallEntryFiles ( PackageInterface $ package ) { foreach ( $ this -> getEntryFileLocations ( $ package ) as $ dest ) { $ unlinked = $ this -> filesystem -> unlinkFile ( $ dest ) ; $ this -> io -> notice ( sprintf ( ' <fg=default>Removing <fg=magenta>%1$s</> -</> %2$s' , $ dest , $ unlinked ? '... | Uninstall each must - use plugin entry file |
236,191 | protected function getPackageExtra ( PackageInterface $ package , $ key , $ default = null ) { $ extra = $ package -> getExtra ( ) ; return array_key_exists ( $ key , $ extra ) ? $ extra [ $ key ] : $ default ; } | Get an item from the package extra array |
236,192 | protected function getPackageEntryPoints ( PackageInterface $ package ) { $ dir = $ this -> composer -> getInstallationManager ( ) -> getInstallPath ( $ package ) ; $ entry = $ this -> getPackageExtra ( $ package , 'wordpress-muplugin-entry' ) ; $ entryPoints = $ entry ? ( is_array ( $ entry ) ? $ entry : [ $ entry ] )... | Get the package entry points |
236,193 | protected function looksLikePlugin ( $ file ) { if ( ! $ file || ! $ this -> filesystem -> isFile ( $ file ) || ! $ this -> filesystem -> isReadable ( $ file ) ) { return false ; } $ chunk = str_replace ( "\r" , "\n" , file_get_contents ( $ file , false , null , 0 , 8192 ) ) ; return preg_match ( '/^[ \t\/*#@]*Plugin N... | Does the file look like a WordPress plugin? |
236,194 | public function RenderBlock ( $ block ) { $ templateFile = $ this -> BuiltInTemplateFile ( ) ; $ blockFile = Path :: AddExtension ( $ templateFile , $ block , true ) ; $ blockFileExt = Path :: AddExtension ( $ blockFile , 'phtml' ) ; if ( ! File :: Exists ( $ blockFileExt ) ) { return '' ; } ob_start ( ) ; require $ bl... | Renders a block by name |
236,195 | public function setFromArray ( array $ fields ) { foreach ( $ fields as $ key => $ value ) { $ this -> fields [ $ key ] = $ value ; unset ( $ key ) ; unset ( $ value ) ; } } | Sets the fields on the object . |
236,196 | public function createAddCommentForm ( Content $ content , $ user = null ) { $ comment = new Comment ( ) ; $ comment -> setContent ( $ content ) ; if ( $ user !== 'anon.' ) { $ comment -> setEmail ( $ user -> getEmail ( ) ) ; } $ form = $ this -> form_factory -> create ( new CommentType ( ) , $ comment ) ; return $ for... | Creates a form to comment on a content . |
236,197 | public function attachParents ( array $ parents ) { $ this -> _parents = [ ] ; foreach ( $ parents as $ parent ) { $ this -> attachParent ( $ parent , false ) ; } } | Loops on each given parent and attach it to this object . |
236,198 | public function hasParent ( $ parentClassName ) { $ found = false ; $ this -> alongParents ( function ( $ parent ) use ( $ parentClassName , & $ found ) { if ( $ parent instanceof $ parentClassName ) { $ found = true ; return false ; } return true ; } ) ; return $ found ; } | Returns true if the class has a given parent . |
236,199 | public function withFirstParent ( $ parentClassName , callable $ callback , callable $ notFoundCallback = null ) { $ result = null ; if ( $ this -> hasParent ( $ parentClassName ) ) { $ parent = $ this -> getFirstParent ( $ parentClassName ) ; $ result = call_user_func ( $ callback , $ parent ) ; } elseif ( null !== $ ... | Will fetch the first parent which matches the given class name . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.