idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
240,100 | public static function getInstance ( $ arrAccepted = array ( ) , $ strDefault = 'de' ) { if ( self :: $ instance === NULL ) self :: $ instance = new self ( $ arrAccepted , $ strDefault ) ; return self :: $ instance ; } | Return the current instance |
240,101 | private function fileFormatDir ( $ strDirectory , $ strSlash = DIRECTORY_SEPARATOR ) { return substr ( $ strDirectory , - 1 ) != $ strSlash ? $ strDirectory . $ strSlash : $ strDirectory ; } | Makes sure the directory ends with a slash |
240,102 | public function load ( $ strSourcePath , $ strCachePath = false , $ bolStore = true ) { $ strSourcePath = $ this -> fileFormatDir ( $ strSourcePath ) ; $ strLang = self :: init ( $ this -> arrAccepted , $ this -> strDefault , $ bolStore ) ; $ this -> strCurrent = $ strLang ; if ( $ strCachePath ) { $ strCachePath = $ t... | Initialized the language variable |
240,103 | public function get ( $ strKey , $ bolReturnPath = true ) { $ data = $ this -> arrData ; foreach ( explode ( '.' , $ strKey ) as $ p ) { if ( isset ( $ data [ $ p ] ) ) $ data = $ data [ $ p ] ; else return $ bolReturnPath ? $ this -> returnKey ( $ strKey ) : false ; } if ( is_array ( $ data ) ) return $ bolReturnPath ... | Gets a variable value |
240,104 | public function getDateFormat ( $ strKey ) { $ format = $ this -> get ( $ strKey , false ) ; return $ format ? preg_replace ( '/%([A-Za-z%])/' , '$1' , $ format ) : 'Y-m-d H:i' ; } | Returns a date string without % for PHP compatibiltiy |
240,105 | public function insert ( $ strKey , $ arrReplace ) { $ data = $ this -> arrData ; foreach ( explode ( '.' , $ strKey ) as $ p ) { if ( isset ( $ data [ $ p ] ) ) $ data = $ data [ $ p ] ; else return $ this -> returnKey ( $ strKey ) . '(' . json_encode ( $ arrReplace ) . ')' ; } $ arrSearch = array ( ) ; $ arrValues = ... | Gets a variable value and replaces placeholders contained in it |
240,106 | public function replace ( $ strTemplate ) { preg_match_all ( $ this -> regex , $ strTemplate , $ matches ) ; $ arrReplace = array ( ) ; foreach ( $ matches [ 1 ] as $ match ) { $ arrReplace [ ] = $ this -> get ( $ match ) ; } return str_replace ( $ matches [ 0 ] , $ arrReplace , $ strTemplate ) ; } | Insert placeholders into a string |
240,107 | public function init ( $ arrAccepted , $ strDefault , $ bolStore = true ) { $ strLang = isset ( $ _GET [ 'lang' ] ) ? $ _GET [ 'lang' ] : ( isset ( $ _SESSION [ 'lang' ] ) ? $ _SESSION [ 'lang' ] : ( isset ( $ _COOKIE [ 'lang' ] ) ? $ _COOKIE [ 'lang' ] : false ) ) ; if ( ! $ strLang || ! in_array ( $ strLang , $ arrAc... | Initialized the language variable and stores it in the session |
240,108 | public static function askBrowser ( $ arrAccepted , $ strDefault = 'de' ) { $ res = array ( 'lang' => $ strDefault , 'other' => array ( ) ) ; try { $ lang_variable = ( isset ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ? $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] : null ) ; if ( empty ( $ lang_variable ) ) return $ res ; $ accep... | Returns the accepted browser language |
240,109 | public function getWebSrvUser ( ) { $ result = '' ; if ( $ this -> isOsWindows ( ) ) { return $ result ; } $ cmd = "ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1 2>/dev/null" ; $ output = [ ] ; $ exitCode = - 1 ; exec ( $ cmd , $ output , $ exitCode ) ; if ( ( $ e... | Return WEB server user . |
240,110 | public function getWebSrvUserGroup ( $ username = null ) { $ result = '' ; if ( $ this -> isOsWindows ( ) || empty ( $ username ) ) { return $ result ; } $ cmd = 'groups ' . $ username . ' | head -1 | cut -d\ -f1 2>/dev/null' ; $ output = [ ] ; $ exitCode = - 1 ; exec ( $ cmd , $ output , $ exitCode ) ; if ( ( $ exitC... | Return group of user . |
240,111 | public function isAppInstalled ( $ configKey = null , $ createMarkerFile = true ) { $ pathMarkerFileIsInstalled = $ this -> getPathMarkerFileIsInstalled ( ) ; if ( $ this -> _checkMarkerFile ( $ pathMarkerFileIsInstalled ) ) { return true ; } $ installTasks = $ this -> _modelConfigInstaller -> getListInstallerTasks ( )... | Check application is installed successfully |
240,112 | public function isAppReadyToInstall ( ) { $ checkPHPversion = $ this -> checkPhpVersion ( ) ; if ( $ checkPHPversion === false ) { return false ; } $ checkPHPextensions = $ this -> checkPhpExtensions ( true ) ; if ( $ checkPHPextensions === false ) { return false ; } return true ; } | Check application is ready to install |
240,113 | public function checkPhpVersion ( ) { $ phpVesion = $ this -> _modelConfigInstaller -> getPhpVersionConfig ( ) ; if ( empty ( $ phpVesion ) ) { return null ; } $ result = true ; foreach ( $ phpVesion as $ phpVesionItem ) { if ( ! is_array ( $ phpVesionItem ) ) { continue ; } $ phpVesionItem += [ '' , null ] ; list ( $ ... | Check version of PHP |
240,114 | public function getListDbConn ( $ path = null ) { if ( empty ( $ path ) ) { $ path = APP ; } $ configFile = $ path . 'Config' . DS . 'database.php' ; $ connections = [ ] ; if ( file_exists ( $ configFile ) ) { $ connections = array_keys ( ConnectionManager :: enumConnectionObjects ( ) ) ; } return $ connections ; } | Return list of configured database connection . |
240,115 | public function checkConnectDb ( $ path = null , $ returnBool = false ) { $ connections = $ this -> getListDbConn ( $ path ) ; if ( empty ( $ connections ) ) { return null ; } $ cfgConnections = $ this -> _modelConfigInstaller -> getListDbConnConfigs ( ) ; if ( empty ( $ cfgConnections ) ) { return null ; } $ connectio... | Check connections to database |
240,116 | public function checkSymLinksExists ( ) { $ symlinksList = $ this -> _modelConfigInstaller -> getListSymlinksCreation ( ) ; if ( empty ( $ symlinksList ) ) { return true ; } foreach ( $ symlinksList as $ link => $ target ) { if ( empty ( $ link ) ) { continue ; } if ( ! file_exists ( $ link ) || ( ! is_link ( $ link ) ... | Check symbolic links exists |
240,117 | public function checkCronJobsExists ( ) { if ( $ this -> isOsWindows ( ) ) { return true ; } $ apacheUser = $ this -> getWebSrvUser ( ) ; if ( empty ( $ apacheUser ) ) { return false ; } $ cronjobsList = $ this -> _modelConfigInstaller -> getListCronJobsCreation ( ) ; if ( empty ( $ cronjobsList ) ) { return true ; } $... | Check cron jobs exists |
240,118 | protected function _removeMarkerFile ( $ path ) { if ( empty ( $ path ) ) { return false ; } $ oFile = new File ( $ path , false ) ; if ( ! $ oFile -> exists ( ) ) { return false ; } return $ oFile -> delete ( ) ; } | Remove marker file |
240,119 | public function createProxyEvent ( Event $ event ) { if ( $ event instanceof GetResponseForControllerResultEvent ) { $ silexEvent = new PostDispatchEvent ( $ event ) ; } elseif ( $ event instanceof GetResponseEvent ) { $ silexEvent = new RequestEvent ( $ event ) ; } elseif ( $ event instanceof FilterControllerEvent ) {... | Create proxy event for given Symfony dispatcher event |
240,120 | final public static function database ( Configuration $ configuration ) { try { $ dbh = Database :: init ( $ configuration ) ; $ dbh -> connect ( ) ; $ manager = $ dbh -> getSchemaManager ( ) ; $ manager -> getTable ( $ configuration -> get ( 'database-jobs-table' ) ) ; $ manager -> getTable ( $ configuration -> get ( ... | Check if database is available and initialized correctly |
240,121 | protected function getActiveRecordCriteriaByName ( $ serviceLocator , $ name ) { $ criteria = $ serviceLocator -> get ( $ name ) ; if ( ! $ criteria instanceof AbstractCriteria ) { throw new Exception \ ServiceNotCreatedException ( sprintf ( 'Instance of type %s is invalid; must implement %s' , ( is_object ( $ criteria... | Retrieve PaginableCriteriaInterface object from config |
240,122 | protected function authFail ( $ message = null ) { $ this -> error ( $ message ) ; $ this -> view -> response [ 'auth_fail' ] = TRUE ; return FALSE ; } | Set response for an authentication failure |
240,123 | public function useTemplate ( $ template_name = false ) { $ templates = $ this -> getTemplates ( ) ; if ( $ template_name == false ) { $ template_name = $ templates [ 0 ] -> name ; } if ( $ template_name ) { $ this -> { $ template_name } ( ) ; } } | Add the fields defined for a specific template . |
240,124 | public function getTemplates ( ) { $ templates_array = [ ] ; $ templates_trait = new \ ReflectionClass ( 'App\GeoTemplates' ) ; $ templates = $ templates_trait -> getMethods ( ) ; if ( ! count ( $ templates ) ) { abort ( '403' , 'No templates have been found.' ) ; } return $ templates ; } | Get all defined templates . |
240,125 | public function getTemplatesArray ( ) { $ templates = $ this -> getTemplates ( ) ; foreach ( $ templates as $ template ) { $ templates_array [ $ template -> name ] = $ this -> crud -> makeLabel ( $ template -> name ) ; } return $ templates_array ; } | Get all defined template as an array . |
240,126 | protected function validateType ( $ embedType ) { $ valid = [ 'one' , 'many' ] ; if ( ! in_array ( $ embedType , $ valid ) ) { throw MetadataException :: invalidRelType ( $ embedType , $ valid ) ; } return true ; } | Validates the embed type . |
240,127 | public function castRowValues ( array & $ row ) { foreach ( $ row as $ field_name => $ value ) { $ row [ $ field_name ] = $ this -> castValue ( $ field_name , $ value ) ; } } | Cast row value to native PHP types based on caster settings . |
240,128 | public function castValue ( $ field_name , $ value ) { if ( $ value === null ) { return null ; } switch ( $ this -> getTypeByFieldName ( $ field_name ) ) { case self :: CAST_INT : return ( int ) $ value ; case self :: CAST_FLOAT : return ( float ) $ value ; case self :: CAST_STRING : return ( string ) $ value ; case se... | Cast a single value . |
240,129 | public function getTypeByFieldName ( $ field_name ) { if ( isset ( $ this -> dictated [ $ field_name ] ) ) { return $ this -> dictated [ $ field_name ] ; } if ( substr ( $ field_name , 0 , 3 ) === 'is_' || in_array ( substr ( $ field_name , 0 , 4 ) , [ 'has_' , 'had_' , 'was_' ] ) || in_array ( substr ( $ field_name , ... | Return type by field name . |
240,130 | public function createBinding ( String $ key , $ queryPart , $ params = [ ] , $ expr = '' , $ with = '' , $ addValue = true ) { if ( ! array_key_exists ( $ key , $ this -> bindings ) ) { return false ; } if ( $ key == 'sql' ) { return $ queryPart ; } if ( $ addValue == true ) { $ this -> bindings [ $ key ] = $ queryPar... | This method bindings together queries created with the query builder . |
240,131 | public function alias ( String $ column , String $ alias ) { $ alias = str_replace ( $ this -> generator -> getDisallowedChars ( ) , '' , $ alias ) ; return $ this -> attachSeparator ( $ column . ' AS ' . $ alias ) ; } | Create and return alias for a column . |
240,132 | public function getTemporaryUser ( $ email ) { $ email = trim ( strtolower ( $ email ) ) ; if ( ! filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { return false ; } $ userClass = $ this -> auth -> getUserClass ( ) ; $ user = $ userClass :: where ( 'email' , $ email ) -> first ( ) ; if ( ! $ user ) { return false ; } i... | Gets a temporary user from an email address if one exists . |
240,133 | public function createTemporaryUser ( $ parameters ) { $ email = trim ( strtolower ( array_value ( $ parameters , 'email' ) ) ) ; if ( ! filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { throw new AuthException ( 'Invalid email address' ) ; } $ insertArray = array_replace ( $ parameters , [ 'enabled' => false ] ) ; $ ... | Creates a temporary user . Useful for creating invites . |
240,134 | public function upgradeTemporaryUser ( UserInterface $ user , $ values = [ ] ) { if ( ! $ user -> isTemporary ( ) ) { throw new AuthException ( 'Cannot upgrade a non-temporary account' ) ; } $ values = array_replace ( $ values , [ 'created_at' => Utility :: unixToDb ( time ( ) ) , 'enabled' => true , ] ) ; $ user -> gr... | Upgrades the user from temporary to a fully registered account . |
240,135 | public function dispatch ( ) { while ( true ) { if ( $ this -> _break ) { break ; } if ( $ this -> _paused ) { $ this -> _title ( 'Paused, waiting' ) ; $ this -> _log -> debug ( 'Paused, waiting.' ) ; } while ( $ this -> _paused ) { pcntl_signal_dispatch ( ) ; sleep ( $ this -> _interval ) ; } $ this -> _title ( 'Waiti... | Main method to start processing loop and dispatch jobs . |
240,136 | protected function _trapSignals ( ) { $ this -> _log -> debug ( 'Trapping signals.' ) ; $ handler = function ( $ number ) { switch ( $ number ) { case SIGQUIT : $ this -> _log -> debug ( 'Received SIGQUIT, waiting and exiting.' ) ; $ this -> _break = true ; $ this -> _connection -> disconnect ( ) ; exit ( 0 ) ; case SI... | Registers signal handlers and handles signals once received . Controls the current processing loop by setting object properties and using the process manager . |
240,137 | public function getAttribute ( $ attribute ) { return ! empty ( $ this -> attributes [ $ attribute ] ) ? $ this -> attributes [ $ attribute ] : null ; } | Get a specific attribute for this tag . |
240,138 | public function appendContent ( $ content ) { if ( $ this -> isVoid ) { throw new Exception \ RuntimeException ( 'Void elements can\'t contain content.' ) ; } $ this -> content .= $ content ; return $ this ; } | Append content before other content |
240,139 | public function prependContent ( $ content ) { if ( $ this -> isVoid ) { throw new Exception \ RuntimeException ( 'Void elements can\'t contain content.' ) ; } $ this -> content = $ content . $ this -> content ; return $ this ; } | Prepend content before other content |
240,140 | public function addChild ( self $ child ) { if ( $ this -> isVoid ) { throw new Exception \ RuntimeException ( 'Void elements can\'t have child elements.' ) ; } $ this -> children [ ] = $ child ; return $ this ; } | Add child to tag |
240,141 | public function addChildren ( array $ children ) { if ( $ this -> isVoid ) { throw new Exception \ RuntimeException ( 'Void elements can\'t have child elements.' ) ; } foreach ( $ children as $ child ) { $ this -> addChild ( $ child ) ; } return $ this ; } | Add children to tag |
240,142 | protected function renderAttributes ( ) { $ attributes = '' ; foreach ( $ this -> attributes as $ key => $ value ) { $ attributes .= " $key" . ( null !== $ value ? "=\"$value\"" : '' ) ; } return $ attributes ; } | Render tag attributes |
240,143 | public function addEntry ( MenuEntry $ entry ) { if ( $ this -> prepared ) { throw new \ RuntimeException ( 'MenuGroup has been prepared and can\'t receive new entries.' ) ; } $ this -> entries [ ] = $ entry ; return $ this ; } | Adds an entry . |
240,144 | public function prepare ( ) { if ( $ this -> prepared ) { return ; } usort ( $ this -> entries , function ( MenuEntry $ a , MenuEntry $ b ) { if ( $ a -> getPosition ( ) == $ b -> getPosition ( ) ) { return 0 ; } return $ a -> getPosition ( ) > $ b -> getPosition ( ) ? 1 : - 1 ; } ) ; $ this -> prepared = true ; } | Prepares the group for rendering . |
240,145 | private function generarId ( ) { if ( function_exists ( 'random_bytes' ) ) { $ semilla = random_bytes ( 32 ) ; } elseif ( function_exists ( 'mcrypt_create_iv' ) ) { $ semilla = mcrypt_create_iv ( 32 , MCRYPT_DEV_URANDOM ) ; } elseif ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { $ semilla = openssl_random_pseu... | Genera un identificador nuevo usando una semilla aleatoria |
240,146 | public function anunciar ( $ mensaje , $ tipo = 'error' ) { $ this -> requerirInicio ( ) ; $ this -> datos [ '__anuncio' ] [ 'mensaje' ] = $ mensaje ; $ this -> datos [ '__anuncio' ] [ 'tipo' ] = $ tipo ; } | Define anuncio importante para el usuario . |
240,147 | public function obtener ( $ llave , $ valorAlterno = null ) { $ this -> requerirInicio ( ) ; return isset ( $ this -> datos [ $ llave ] ) ? $ this -> datos [ $ llave ] : $ valorAlterno ; } | Obtiene una variable de la sesion . |
240,148 | public function eliminar ( $ llave ) { $ this -> requerirInicio ( ) ; if ( isset ( $ this -> datos [ $ llave ] ) ) { $ valor = $ this -> datos [ $ llave ] ; unset ( $ this -> datos [ $ llave ] ) ; return $ valor ; } else { return null ; } } | Elimina una variable en la sesion . |
240,149 | public function parse ( $ content ) { if ( empty ( $ content ) ) return [ ] ; $ path = $ this -> getCleanPath ( $ content ) ; $ pathParts = [ $ this -> delimiter ] ; if ( mb_strpos ( $ path , $ this -> delimiter ) === false ) { if ( ! $ path ) { return [ $ this -> delimiter ] ; } $ tmpPathParts = [ $ this -> delimiter ... | parse method that fills the collection |
240,150 | public function getMenuIdFor ( int $ itemId ) : int { $ menuId = ( int ) $ this -> database -> query ( "SELECT menu_id FROM {umenu_item} WHERE id = ?" , [ $ itemId ] ) -> fetchField ( ) ; if ( ! $ menuId ) { throw new \ InvalidArgumentException ( sprintf ( "Item %d does not exist" , $ itemId ) ) ; } return $ menuId ; } | Get menu identifier for item |
240,151 | private function get_attrs ( ) { $ this -> attrs = new \ stdClass ; foreach ( $ this -> dom_element -> attributes as $ name => $ node ) { $ this -> attrs -> { strtolower ( $ name ) } = $ node -> nodeValue ; } return $ this ; } | Metodo que permite obtener todos atributos del elementos y convertirlos en un objeto stdClass . |
240,152 | private function get_childs ( ) { $ this -> childs = new \ PHPTools \ PHPHtmlDom \ Core \ PHPHtmlDomList ( $ this -> dom_element -> childNodes ) ; return $ this ; } | Metodo que permite obtener los elementos hijos y convertirlos en un objeto lista PHPHtmlDomList . |
240,153 | private function get_Text ( ) { $ text_formatting = array ( 'b' , 'strong' , 'em' , 'i' , 'small' , 'strong' , 'sub' , 'sup' , 'ins' , 'del' , 'mark' , 'br' , 'hr' ) ; foreach ( $ this -> dom_element -> childNodes as $ node ) { if ( $ node -> nodeType == 3 ) { $ this -> set_text ( trim ( $ node -> textContent ) ) ; $ t... | Metodo que permite obtener el texto que se encuentra dentro del elemento . |
240,154 | private function set_text ( $ text ) { if ( ! ! $ text ) { if ( ! ! $ this -> text ) { if ( ! ! is_array ( $ this -> text ) ) { $ this -> text [ ] = $ text ; } else { $ this -> text = array ( $ this -> text , $ text ) ; } } else { $ this -> text = $ text ; } } return $ this ; } | Metodo que permite definir e texto del elemento . |
240,155 | private function attrs_to_string ( $ attrs ) { $ attrs_string = '' ; foreach ( $ attrs as $ name => $ node ) { $ attrs_string .= sprintf ( ' %s="%s"' , $ name , $ node -> nodeValue ) ; } return $ attrs_string ; } | Este metodo permite concatenar un objeto de atributos en una sola cadena . |
240,156 | protected function makeParametersDDL ( $ separator = " " ) { $ params = [ ] ; foreach ( $ this -> parameters as $ parameter ) { $ params [ ] = $ parameter -> getDDL ( ) ; } return implode ( ',' . $ separator , $ params ) ; } | Make the portion of DDL for describing the parameters . |
240,157 | protected function saveAssignments ( ) { $ assignmentData = [ ] ; foreach ( $ this -> assignments as $ userId => $ assignments ) { foreach ( $ assignments as $ name => $ assignment ) { $ assignmentData [ $ userId ] [ ] = $ assignment -> roleName ; } } DiscHelper :: saveToFile ( $ assignmentData , $ this -> assignmentFi... | Saves assignments data into persistent storage . |
240,158 | protected function load ( ) { $ this -> assignments = [ ] ; $ assignments = DiscHelper :: loadFromFile ( $ this -> assignmentFile ) ; $ assignmentsMtime = @ filemtime ( $ this -> assignmentFile ) ; foreach ( $ assignments as $ userId => $ roles ) { foreach ( $ roles as $ role ) { $ this -> assignments [ $ userId ] [ $ ... | Loads authorization data from persistent storage . |
240,159 | private function create_package_migration ( $ name ) { list ( $ packagename , $ name ) = explode ( '/' , $ name ) ; $ skeleton_packages = \ Skeleton \ Core \ Skeleton :: get_all ( ) ; $ package = null ; foreach ( $ skeleton_packages as $ skeleton_package ) { if ( $ skeleton_package -> name == $ packagename ) { $ packag... | Create package migration |
240,160 | private function create_project_migration ( $ name ) { $ name = preg_replace ( array ( '/\s/' , '/\.[\.]+/' , '/[^\w_\.\-]/' ) , array ( '_' , '.' , '' ) , $ name ) ; $ datetime = date ( 'Ymd_His' ) ; $ filename = $ datetime . '_' . strtolower ( $ name ) . '.php' ; $ classname = 'Migration_' . $ datetime . '_' . ucfirs... | Create project migration |
240,161 | public static function table ( $ table ) { if ( Connect :: getConn ( ) == null ) { return new static ; } self :: $ table = self :: sanitize ( $ table ) ; return new static ; } | Sets the table on to which the various statements are executed . |
240,162 | private static function sanitize ( $ data ) { $ data = trim ( $ data ) ; $ data = stripslashes ( $ data ) ; $ data = htmlspecialchars ( $ data ) ; return $ data ; } | Sanitizes the data input values |
240,163 | public function orWhere ( $ param ) { if ( func_num_args ( ) == 3 ) { $ operator = strtolower ( func_get_arg ( 1 ) ) ; if ( is_numeric ( array_search ( $ operator , $ this -> condition ) ) ) { $ this -> whereby .= ' or ' . self :: sanitize ( func_get_arg ( 0 ) ) . ' ' . $ operator . ' \'' . self :: sanitize ( func_get_... | Adds condition for or in where clause |
240,164 | public function orderBy ( $ column = '' , $ sort = 'desc' ) { $ column = self :: sanitize ( $ column ) ; $ sort = strtoupper ( self :: sanitize ( $ sort ) ) ; if ( ! ( hash_equals ( 'DESC' , $ sort ) || hash_equals ( 'ASC' , $ sort ) ) ) { static :: $ response [ "status" ] = "error" ; static :: $ response [ "response" ... | Set order in which the return results will be return |
240,165 | public function get ( $ limit = 0 , $ offset = 0 ) { if ( static :: $ response [ 'status' ] == "error" ) { return static :: terminate ( static :: $ response ) ; } if ( ! is_numeric ( $ limit ) ) { static :: $ response [ "status" ] = "error" ; static :: $ response [ "response" ] = "Parameter limit should be numeric at f... | Fetch records form database |
240,166 | protected function fetch ( $ sql ) { try { try { $ stm = Connect :: getConn ( ) -> prepare ( $ sql ) ; } catch ( Exception $ e ) { static :: $ response [ "status" ] = "error" ; static :: $ response [ "response" ] = $ e -> getMessage ( ) ; static :: $ response [ 'code' ] = $ e -> getCode ( ) ; return static :: terminate... | Executes a query that returns data |
240,167 | public function all ( ) { $ table = trim ( self :: $ table ) ; if ( ! empty ( $ table ) ) { $ query = "SELECT * FROM {$table}" ; if ( ! empty ( $ this -> groupby ) ) { $ query .= ' GROUP BY ' . $ this -> groupby ; } if ( ! empty ( $ this -> order ) ) { $ query .= $ this -> order ; } return $ this -> fetch ( $ query ) ;... | Fetch all data without limits or offset |
240,168 | public function insert ( $ values ) { try { if ( func_num_args ( ) > 0 && ! is_array ( $ values ) ) { $ this -> values = array_merge ( $ this -> values , self :: sanitizeAV ( func_get_args ( ) ) ) ; } else if ( is_array ( $ values ) ) { $ this -> values = self :: sanitize ( $ values ) ; } else { static :: $ response [ ... | Sets the values to be inserted |
240,169 | public function into ( $ columns ) { $ valuesCount = count ( $ this -> values ) ; $ colStringCount = 0 ; if ( is_string ( $ columns ) ) { try { $ colStringCount = count ( explode ( ',' , $ columns ) ) ; } catch ( Exception $ e ) { static :: $ response [ "status" ] = "error" ; static :: $ response [ "response" ] = "Unre... | Sets the column to which the values will be inserted |
240,170 | protected function doInsert ( ) { if ( static :: $ response [ "status" ] == "error" ) { return static :: terminate ( static :: $ response ) ; } $ columnParam = array_map ( function ( ) { return '?' ; } , $ this -> values ) ; $ sql = 'INSERT INTO ' . self :: $ table . ' (' . $ this -> columns . ') VALUES(' . implode ( '... | Performs the actual database insert |
240,171 | private function isAssocStr ( $ array ) { if ( ! is_array ( $ array ) ) { return false ; } for ( reset ( $ array ) ; is_int ( key ( $ array ) ) ; next ( $ array ) ) { if ( is_null ( key ( $ array ) ) ) return false ; } return true ; } | Function to check if an array is association or sequential |
240,172 | protected function exec ( $ query ) { try { Connect :: getConn ( ) -> exec ( $ query ) ; } catch ( Exception $ e ) { static :: $ response [ "status" ] = "error" ; static :: $ response [ "response" ] = $ e -> getMessage ( ) ; static :: $ response [ "code" ] = $ e -> getCode ( ) ; return static :: terminate ( static :: $... | Executes a query that does not return any results |
240,173 | private static function valTable ( ) { if ( static :: $ table == null || ! is_string ( static :: $ table ) ) { static :: $ response [ "status" ] = "error" ; static :: $ response [ "response" ] = "check the table name provided" ; static :: $ response [ "code" ] = 5000 ; return self :: terminate ( static :: $ response ) ... | Validate that the table name has been provided and is a string |
240,174 | public function drop ( ) { static :: valTable ( ) ; $ sql = "DROP TABLE " . self :: $ table ; try { $ this -> exec ( $ sql ) ; static :: $ response [ "status" ] = "success" ; static :: $ response [ "response" ] = "success" ; return self :: terminate ( static :: $ response ) ; } catch ( Exception $ e ) { static :: $ res... | Function to drop a table |
240,175 | function setDependencies ( \ assegai \ Server $ server , ModuleContainer $ modules ) { $ this -> server = $ server ; $ this -> modules = $ modules ; } | Default module constructor . Loads options into properties . |
240,176 | protected function getOption ( $ option , $ default = false ) { return isset ( $ this -> options [ $ option ] ) ? $ this -> options [ $ option ] : $ default ; } | Just a convenient wrapper to retrieve an option . |
240,177 | public function getValue ( ) { $ val = $ this -> base [ 'value' ] ; if ( is_array ( $ val ) ) { $ posts = array ( ) ; foreach ( $ val as $ p ) { $ posts [ ] = $ this -> postFactory -> create ( $ this -> getPostObject ( $ p ) ) ; } return $ posts ; } elseif ( strlen ( $ val ) ) { return $ this -> postFactory -> create (... | Get a single post object or array of post objects . |
240,178 | private function detectarNucleosCPU ( ) { $ cantidad_cpu = 1 ; if ( is_file ( '/proc/cpuinfo' ) ) { $ cpu_info = file_get_contents ( '/proc/cpuinfo' ) ; preg_match_all ( '/^processor/m' , $ cpu_info , $ matches ) ; $ cantidad_cpu = count ( $ matches [ 0 ] ) ; } else if ( 'WIN' == strtoupper ( substr ( PHP_OS , 0 , 3 ) ... | Devuelve la cantidad de nucleos del CPU |
240,179 | public static function getPath ( $ data , $ path ) { $ path = explode ( '/' , $ path ) ; while ( null !== ( $ part = array_shift ( $ path ) ) ) { if ( ! is_array ( $ data ) || ! isset ( $ data [ $ part ] ) ) { return null ; } $ data = $ data [ $ part ] ; } return $ data ; } | Gets a value from an array using a path syntax to retrieve nested data . |
240,180 | public static function setPath ( & $ data , $ path , $ value ) { $ queue = explode ( '/' , $ path ) ; if ( count ( $ queue ) === 1 ) { $ data [ $ path ] = $ value ; return ; } $ current = & $ data ; while ( null !== ( $ key = array_shift ( $ queue ) ) ) { if ( ! is_array ( $ current ) ) { throw new \ RuntimeException (... | Set a value in a nested array key . Keys will be created as needed to set the value . |
240,181 | public static function uriTemplate ( $ template , array $ variables ) { if ( function_exists ( '\\uri_template' ) ) { return \ uri_template ( $ template , $ variables ) ; } static $ uriTemplate ; if ( ! $ uriTemplate ) { $ uriTemplate = new UriTemplate ( ) ; } return $ uriTemplate -> expand ( $ template , $ variables )... | Expands a URI template |
240,182 | public static function jsonDecode ( $ json , $ assoc = false , $ depth = 512 , $ options = 0 ) { if ( $ json === '' || $ json === null ) { return null ; } static $ jsonErrors = [ JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded' , JSON_ERROR_STATE_MISMATCH => 'JSON_ERROR_STATE_MISMATCH - Underflow o... | Wrapper for JSON decode that implements error detection with helpful error messages . |
240,183 | public static function getDefaultHandler ( ) { $ default = $ future = null ; if ( extension_loaded ( 'curl' ) ) { $ config = [ 'select_timeout' => getenv ( 'GUZZLE_CURL_SELECT_TIMEOUT' ) ? : 1 ] ; if ( $ maxHandles = getenv ( 'GUZZLE_CURL_MAX_HANDLES' ) ) { $ config [ 'max_handles' ] = $ maxHandles ; } if ( function_ex... | Create a default handler to use based on the environment |
240,184 | final public function parseDirectory ( $ rootDirectory , $ relativePath , $ translations = null , $ subParsersFilter = false , $ exclude3rdParty = true ) { if ( ! is_object ( $ translations ) ) { $ translations = new \ Gettext \ Translations ( ) ; } $ dir = ( string ) $ rootDirectory ; if ( $ dir !== '' ) { $ dir = @ r... | Extracts translations from a directory . |
240,185 | final public function parseRunningConcrete5 ( $ translations = null , $ subParsersFilter = false ) { if ( ! is_object ( $ translations ) ) { $ translations = new \ Gettext \ Translations ( ) ; } $ runningVersion = '' ; if ( defined ( '\C5_EXECUTE' ) && defined ( '\APP_VERSION' ) && is_string ( \ APP_VERSION ) ) { $ run... | Extracts translations from a running concrete5 instance . |
240,186 | final protected static function getDirectoryStructure ( $ rootDirectory , $ exclude3rdParty = true ) { $ rootDirectory = rtrim ( str_replace ( DIRECTORY_SEPARATOR , '/' , $ rootDirectory ) , '/' ) ; if ( ! isset ( self :: $ cache [ __FUNCTION__ ] ) ) { self :: $ cache [ __FUNCTION__ ] = array ( ) ; } $ cacheKey = $ roo... | Returns the directory structure underneath a given directory . |
240,187 | final public static function getAllParsers ( ) { $ result = array ( ) ; $ dir = __DIR__ . '/Parser' ; if ( is_dir ( $ dir ) && is_readable ( $ dir ) ) { $ matches = null ; foreach ( scandir ( $ dir ) as $ item ) { if ( ( $ item [ 0 ] !== '.' ) && preg_match ( '/^(.+)\.php$/i' , $ item , $ matches ) ) { $ fqClassName = ... | Retrieves all the available parsers . |
240,188 | public function send ( ) { setcookie ( $ this -> name , $ this -> value , ( int ) $ this -> expire -> format ( 'U' ) , $ this -> path , $ this -> domain , $ this -> secure , $ this -> httpOnly ) ; } | Sends the cookie header |
240,189 | protected static function triggerAopEvent ( $ controller_id , $ action_name , $ request = null , $ response = null ) { $ context = [ 'controller_id' => $ controller_id , 'action_id' => $ action_name , ] ; if ( $ request ) { $ context [ 'request' ] = $ request ; } if ( $ response ) { $ context [ 'response' ] = $ respons... | Trigger AOP Event |
240,190 | public function transform ( $ value ) { if ( $ value ) { $ from = '' ; if ( $ value -> getFrom ( ) ) { $ from = $ value -> getFrom ( ) -> format ( 'Y-m-d' ) ; } $ to = '' ; if ( $ value -> getTo ( ) ) { $ to = $ value -> getTo ( ) -> format ( 'Y-m-d' ) ; } return sprintf ( '%s%s%s' , $ from , $ this -> dateSeparator , ... | Transforms a DateRange into a string . |
240,191 | public function reverseTransform ( $ value ) { $ parts = explode ( $ this -> dateSeparator , $ value ) ; $ from = isset ( $ parts [ 0 ] ) ? $ parts [ 0 ] : null ; $ to = isset ( $ parts [ 1 ] ) ? $ parts [ 1 ] : null ; return new DAteRange ( $ from , $ to ) ; } | Transforms a string into a DateRange . |
240,192 | private function decode ( array $ row ) : ? array { if ( null === ( $ encoded = $ row [ $ this -> name ( ) ] ) ) { return null ; } if ( false === ( $ decoded = unserialize ( $ encoded , [ 'allowed_classes' => false ] ) ) ) { return null ; } if ( ! \ is_array ( $ decoded ) ) { return null ; } return $ decoded ; } | Decode the row value . |
240,193 | public function render ( ) { $ output = $ this -> each ( function ( $ tag ) { return $ tag -> render ( ) ; } ) ; return implode ( '' , $ output -> toArray ( ) ) ; } | Render tag elements |
240,194 | private function getNextItem ( Tag $ item , $ items ) { $ currentItem = $ items [ 0 ] ; while ( $ currentItem !== null and $ currentItem !== $ item ) { $ currentItem = next ( $ items ) ; } $ next = next ( $ items ) ; return $ next !== false ? $ next : null ; } | Get next item from items array |
240,195 | public function remove ( $ tag ) { if ( $ this -> count ( ) == 0 ) { return [ $ this , null ] ; } $ deleted = null ; foreach ( $ this -> items as $ key => $ element ) { if ( $ element === $ tag ) { $ this -> forget ( $ key ) ; $ deleted = $ tag ; break ; } } return [ $ this , $ deleted ] ; } | Remove tag element from collection |
240,196 | protected function findUseStatements ( File $ file ) { if ( array_key_exists ( $ file -> getFilename ( ) , static :: $ useCache ) ) { return static :: $ useCache [ $ file -> getFilename ( ) ] ; } $ tokens = $ file -> getTokens ( ) ; $ usePosition = $ file -> findNext ( T_USE , 0 ) ; $ useStatements = [ ] ; while ( $ us... | Find all use statements . |
240,197 | protected function shouldIgnoreUse ( File $ file , $ stackPtr ) { $ tokens = $ file -> getTokens ( ) ; $ next = $ file -> findNext ( T_WHITESPACE , ( $ stackPtr + 1 ) , null , true ) ; if ( $ tokens [ $ next ] [ 'code' ] === T_OPEN_PARENTHESIS ) { return true ; } if ( $ file -> hasCondition ( $ stackPtr , [ T_CLASS , T... | Check whether or not a USE statement should be ignored . |
240,198 | protected function resolveArrayType ( $ type ) { if ( strrpos ( $ type , '[]' , - 2 ) !== false ) { return substr ( $ type , 0 , strlen ( $ type ) - 2 ) ; } return $ type ; } | Attempt to resolve the type of an array . |
240,199 | protected function extractNamespace ( File $ file ) { $ namespace = '' ; $ tokens = $ file -> getTokens ( ) ; $ prev = $ file -> findNext ( T_NAMESPACE , 0 ) ; for ( $ i = $ prev + 2 ; $ i < count ( $ tokens ) ; $ i ++ ) { if ( ! in_array ( $ tokens [ $ i ] [ 'code' ] , [ T_STRING , T_NS_SEPARATOR ] ) ) { break ; } $ n... | Extract the first namespace found in the file . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.