idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
47,200
public function force ( $ request_controller , $ request_action = 'index' ) { $ this -> controller = $ request_controller ; $ this -> action = $ request_action ; $ handler = $ this -> loadController ( ) ; if ( ! $ handler ) { throw new LogicException ( sprintf ( 'No se existe la clase del controlador (%s)' , $ this -> controller ) ) ; } if ( ! method_exists ( $ handler , $ this -> action ) ) { $ reflection = new \ ReflectionClass ( $ handler ) ; throw new LogicException ( sprintf ( 'No existe el método (%s) del controlador (%s)' , $ this -> action , $ reflection -> getName ( ) ) , [ 'controller' => $ handler ] ) ; } return $ handler ; }
Forza la carga de un controlador
47,201
private function loadController ( ) { $ controller_name = Inflector :: classify ( $ this -> controller ) . 'Controller' ; $ controller_class = $ this -> controller === 'system' ? 'PowerOn\\Controller\\CoreController' : 'App\\Controller\\' . $ controller_name ; if ( ! class_exists ( $ controller_class ) ) { return FALSE ; } return new $ controller_class ( ) ; }
Verifica la existencia del controlador solicitado y lo devuelve
47,202
public function getParameter ( $ as = self :: AS_STRING ) { if ( $ as == self :: AS_SIMPLEXML ) { $ success = simplexml_load_string ( $ this -> parameter ) ; if ( $ success === false ) { $ error = libxml_get_last_error ( ) ; throw new \ RuntimeException ( "XML Syntax error: " . $ error -> message ) ; } return $ success ; } elseif ( $ as == self :: AS_DOM ) { $ dom = new \ DOMDocument ( ) ; if ( ! $ dom -> loadXML ( $ this -> parameter ) ) { $ error = libxml_get_last_error ( ) ; throw new \ RuntimeException ( "XML Syntax error: " . $ error -> message ) ; } return $ dom ; } return $ this -> parameter ; }
Obtains parameter in the specified format
47,203
public function makeAdd ( ) { if ( OWEB_DEBUG > 0 ) $ code .= $ this -> makeAddNormal ( ) ; else $ code .= $ this -> makeAddNormal ( ) ; Headers :: getInstance ( ) -> addHeader ( $ code , Headers :: jsCode ) ; }
Will add the headers registered to the main Headers Manager
47,204
public function makeAddDebug ( ) { $ s = "" ; foreach ( $ this -> headers as $ code ) { $ s .= '$( document ).ready(function() {' . "\n" ; $ s .= $ code ; $ s .= "\n});\n\n" ; } return $ s ; }
If debug is active we should separate each JS function to prevent one wrong code to brake all others
47,205
public function makeAddNormal ( ) { $ s = "var oweb_ready = function (){" ; foreach ( $ this -> headers as $ code ) $ s .= $ code . "\n\n" ; $ s .= "}\n\n" ; $ s .= '$( document ).ready(function() {' . "\n" ; $ s .= "oweb_ready(); \n" ; $ s .= "\n});\n\n" ; return $ s ; }
If Debug isn t active we will put them all in 1 ready function to increase performances and hope that all JS codes are okay .
47,206
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ this -> validateCommand ( $ input ) ; $ output -> writeln ( '> Loading configuration file' ) ; $ config = $ input -> getOption ( 'config' ) ; $ files = ( new ConfigResolver ( ) ) -> getFileList ( $ config ) ; $ output -> writeLn ( '- Found ' . count ( $ files ) . ' files' ) ; $ preloader = ( new Factory ( ) ) -> create ( $ this -> getOptions ( $ input ) ) ; $ outputFile = $ input -> getOption ( 'output' ) ; $ handle = $ preloader -> prepareOutput ( $ outputFile , $ input -> getOption ( 'strict_types' ) ) ; $ output -> writeln ( '> Compiling classes' ) ; $ count = 0 ; $ countSkipped = 0 ; $ comments = ! $ input -> getOption ( 'strip_comments' ) ; foreach ( $ files as $ file ) { $ count ++ ; try { $ code = $ preloader -> getCode ( $ file , $ comments ) ; $ output -> writeln ( '- Writing ' . $ file ) ; fwrite ( $ handle , $ code . "\n" ) ; } catch ( VisitorExceptionInterface $ e ) { $ countSkipped ++ ; $ output -> writeln ( '- Skipping ' . $ file ) ; } } fclose ( $ handle ) ; $ output -> writeln ( "> Compiled loader written to $outputFile" ) ; $ output -> writeln ( '- Files: ' . ( $ count - $ countSkipped ) . '/' . $ count . ' (skipped: ' . $ countSkipped . ')' ) ; $ output -> writeln ( '- Filesize: ' . ( round ( filesize ( $ outputFile ) / 1024 ) ) . ' kb' ) ; }
Executes the pre - compile command .
47,207
protected function getOptions ( InputInterface $ input ) { return [ 'dir' => ( bool ) $ input -> getOption ( 'fix_dir' ) , 'file' => ( bool ) $ input -> getOption ( 'fix_file' ) , 'skip' => ( bool ) $ input -> getOption ( 'skip_dir_file' ) , 'strict' => ( bool ) $ input -> getOption ( 'strict_types' ) , ] ; }
Get the options to pass to the factory .
47,208
public function & getViewData ( ) { if ( $ this -> view !== NULL ) return $ this -> view ; $ user = & \ MvcCore \ Ext \ Auths \ Basic :: GetInstance ( ) -> GetUser ( ) ; $ authenticated = $ user instanceof \ MvcCore \ Ext \ Auths \ Basics \ IUser ; $ this -> view = ( object ) [ 'user' => $ user , 'authenticated' => $ authenticated , ] ; return $ this -> view ; }
Set up view data if data are completed return them directly . - complete basic \ MvcCore core objects to complere other view data - complete user and authorized boolean - set result data into static field
47,209
public function find ( $ find , $ column = 'id' , array $ relations = [ ] , array $ columns = [ '*' ] ) { $ this -> model = $ this -> where ( $ column , $ find ) ; $ this -> model = $ this -> relation -> apply ( $ this -> model , $ this , $ relations ) ; return $ this -> model -> firstOrFail ( $ columns ) ; }
Find single record with secure relation keys only Eager relations can be taken from request input
47,210
public function findWith ( $ find , array $ with = [ ] , $ column = 'id' , array $ columns = [ '*' ] ) { return $ this -> whereWith ( $ find , $ column , $ with ) -> firstOrFail ( $ columns ) ; }
Find single record with custom relation query
47,211
public function onlyFillable ( array $ input ) { $ result = array_intersect_key ( $ input , array_flip ( $ this -> modelInstance -> getFillable ( ) ) ) ; foreach ( $ this -> avoidEmptyUpdate as $ avoid ) { if ( array_key_exists ( $ avoid , $ result ) && empty ( $ result [ $ avoid ] ) ) { unset ( $ result [ $ avoid ] ) ; } } return $ result ; }
Filter input from un allowed fields for model
47,212
protected function whereWith ( $ find , $ column , $ with , $ where_role = '=' ) { $ this -> where ( $ column , $ where_role , $ find ) ; $ this -> with ( $ with ) ; return $ this -> model ; }
Unfiltered querable with this model
47,213
public function get ( $ type , $ file = null ) { if ( ! isset ( $ this -> paths [ $ type ] ) ) { $ method = 'get' . Utils :: camelize ( $ type ) . 'Dir' ; if ( ! method_exists ( $ this , $ method ) ) { return null ; } $ this -> set ( $ type , $ this -> $ method ( ) ) ; } $ path = $ this -> paths [ $ type ] ; if ( $ file ) { if ( $ path instanceof pathmanager \ FallbackInterface ) { $ path = $ path -> resolve ( $ file ) ; } else { $ path .= '/' . ltrim ( $ file , '/' ) ; } } return $ path ; }
Returns a path
47,214
public function isNextToken ( $ token , $ ignoreSpaces = true ) { if ( $ this -> pos >= $ this -> len ) { return Tokens :: T_END == $ token ; } switch ( $ token ) { case Tokens :: T_END : return false ; case Tokens :: T_OPERATOR : return $ this -> isNextToken ( Tokens :: T_LOGICAL_OP , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_COMPARISON_OP , $ ignoreSpaces ) ; case Tokens :: T_QUOTE : return $ this -> isNextToken ( Tokens :: T_SINGLE_QUOTE , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_DOUBLE_QUOTE , $ ignoreSpaces ) ; case Tokens :: T_LOGICAL_OP : return $ this -> isNextToken ( Tokens :: T_AND , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_OR , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_NOT , $ ignoreSpaces ) ; break ; case Tokens :: T_COMPARISON_OP : return $ this -> isNextToken ( Tokens :: T_EQ , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_NE , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_GT , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_GE , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_LT , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_LE , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_IS_NULL , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_IS_ANY , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_IN , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_RANGE , $ ignoreSpaces ) || $ this -> isNextToken ( Tokens :: T_MATCH , $ ignoreSpaces ) ; break ; case Tokens :: T_IDENTIFIER : $ pos = $ this -> pos ; if ( $ ignoreSpaces ) { $ pos = $ this -> getPosAfterSpaces ( $ pos ) ; } return ctype_alpha ( $ this -> value [ $ pos ] ) || ( '_' == $ this -> value [ $ pos ] ) ; default : $ literal = $ this -> literals -> getLiteralForToken ( $ token ) ; if ( $ this -> literals -> isSpace ( $ literal ) ) { $ ignoreSpaces = false ; } return $ this -> isNextLiteral ( $ literal , $ ignoreSpaces ) ; break ; } }
isNextToken Check the next token or literal
47,215
public function setSender ( ContactInterface $ sender = null ) { if ( $ sender !== null && ! ( $ sender instanceof Contact ) ) { throw new InvalidArgumentException ( sprintf ( '%s expects an instance of %s.' , __FUNCTION__ , Contact :: class ) ) ; } $ this -> sender = $ sender ; return $ this ; }
Sets the sender . Optional OR Required . Optional where From is one person . Required where From is multiple people .
47,216
public function setBodyParts ( array $ bodyParts ) { $ collection = new EmailBodyPartCollection ( ) ; foreach ( $ bodyParts as $ k => $ v ) { $ collection -> add ( $ v ) ; } $ this -> bodyParts = $ collection ; return $ this ; }
Set the body of the email . For a single content - type email just put one in this array . It is presumed if you add multiple items to this array then it must be multipart .
47,217
public function respondTo ( $ func ) { $ route = Router :: currentRoute ( ) ; $ response = $ func ( $ route [ 'extension' ] , $ this ) ; if ( $ response === null ) { return $ this -> show404 ( ) ; } return $ response ; }
Easily respond to different request formats .
47,218
public function show404 ( ) { $ this -> executeAction = false ; return new Response ( function ( $ resp ) { $ resp -> status = 404 ; $ resp -> body = $ this -> renderView ( $ this -> notFoundView , [ '_layout' => $ this -> layout ] ) ; } ) ; }
Sets the response to a 404 Not Found
47,219
protected function addFilter ( $ when , $ action , $ callback ) { if ( ! is_callable ( $ callback ) && ! is_array ( $ callback ) ) { $ callback = [ $ this , $ callback ] ; } if ( is_array ( $ action ) ) { foreach ( $ action as $ method ) { $ this -> addFilter ( $ when , $ method , $ callback ) ; } } else { EventDispatcher :: addListener ( "{$when}." . get_called_class ( ) . "::{$action}" , $ callback ) ; } }
Adds the filter to the event dispatcher .
47,220
public function addAdaptor ( AbstractAdaptor $ adaptor ) { $ adaptorName = $ adaptor -> getName ( ) ? : $ this -> adaptorCount ; $ this -> adaptors [ $ adaptorName ] = $ adaptor ; $ this -> adaptorCount ++ ; }
Add an adaptor to write logs
47,221
public function showAction ( StockTransfer $ stocktransfer ) { $ editForm = $ this -> createForm ( new StockTransferType ( ) , $ stocktransfer , array ( 'action' => $ this -> generateUrl ( 'stock_transfers_update' , array ( 'id' => $ stocktransfer -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; $ deleteForm = $ this -> createDeleteForm ( $ stocktransfer -> getId ( ) , 'stock_transfers_delete' ) ; return array ( 'stocktransfer' => $ stocktransfer , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Finds and displays a StockTransfer entity .
47,222
public function newAction ( ) { $ stocktransfer = new StockTransfer ( ) ; $ nextCode = $ this -> get ( 'flower.stock.service.stock_transfer' ) -> getNextCode ( ) ; $ stocktransfer -> setCode ( $ nextCode ) ; $ stocktransfer -> setUser ( $ this -> getUser ( ) ) ; $ form = $ this -> createForm ( new StockTransferType ( ) , $ stocktransfer ) ; return array ( 'stocktransfer' => $ stocktransfer , 'form' => $ form -> createView ( ) , ) ; }
Displays a form to create a new StockTransfer entity .
47,223
public function createAction ( Request $ request ) { $ stocktransfer = new StockTransfer ( ) ; $ stocktransfer -> setUser ( $ this -> getUser ( ) ) ; $ form = $ this -> createForm ( new StockTransferType ( ) , $ stocktransfer ) ; if ( $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ stocktransfer ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'stock_transfers_show' , array ( 'id' => $ stocktransfer -> getId ( ) ) ) ) ; } return array ( 'stocktransfer' => $ stocktransfer , 'form' => $ form -> createView ( ) , ) ; }
Creates a new StockTransfer entity .
47,224
public function updateAction ( StockTransfer $ stocktransfer , Request $ request ) { $ editForm = $ this -> createForm ( new StockTransferType ( ) , $ stocktransfer , array ( 'action' => $ this -> generateUrl ( 'stock_transfers_update' , array ( 'id' => $ stocktransfer -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; if ( $ editForm -> handleRequest ( $ request ) -> isValid ( ) ) { $ this -> getDoctrine ( ) -> getManager ( ) -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'stock_transfers_show' , array ( 'id' => $ stocktransfer -> getId ( ) ) ) ) ; } $ deleteForm = $ this -> createDeleteForm ( $ stocktransfer -> getId ( ) , 'stock_transfers_delete' ) ; return array ( 'stocktransfer' => $ stocktransfer , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Edits an existing StockTransfer entity .
47,225
public function actionChangeStatus ( $ id , $ value ) { $ model = $ this -> findModel ( $ id ) ; if ( empty ( $ model ) ) { Yii :: $ app -> session -> setFlash ( 'error' , Yii :: t ( $ this -> tcModule , 'User {id} not found.' , [ 'id' => $ id ] ) ) ; } else { $ model -> status = $ value ; $ model -> pageSize = intval ( $ this -> module -> params [ 'pageSizeAdmin' ] ) ; $ result = $ model -> save ( true , [ 'status' ] ) ; if ( $ result ) { Yii :: $ app -> session -> setFlash ( 'success' , Yii :: t ( $ this -> tcModule , 'Status changed.' ) ) ; } else { foreach ( $ model -> errors as $ attribute => $ errors ) { Yii :: $ app -> session -> setFlash ( 'error' , Yii :: t ( $ this -> tcModule , "Status didn't change." ) . ' ' . Yii :: t ( $ this -> tcModule , "Error on field: '{field}'." , [ 'field' => $ attribute ] ) . ' ' . $ errors [ 0 ] ) ; break ; } } } return $ this -> redirect ( [ 'index' , 'id' => $ id , 'page' => empty ( $ model -> page ) ? 1 : $ model -> page , ] ) ; }
Change status of user .
47,226
public function getRelation ( $ relationName ) { $ relationInstance = null ; if ( isset ( $ this -> relations [ $ relationName ] ) ) { $ relationInstance = $ this -> relations [ $ relationName ] ; } return $ relationInstance ; }
Get a relation bby its name .
47,227
public function getFilter ( $ filtername ) { $ filter = null ; if ( ! is_null ( $ this -> filters ) && isset ( $ this -> filters [ $ filtername ] ) ) { $ filter = $ this -> filters [ $ filtername ] ; } return $ filter ; }
Return the filter or null .
47,228
public static function getEntityNameFromClassName ( string $ className ) { $ entityName = constant ( sprintf ( self :: ENTITY_NAME_CONST_FORMAT , $ className ) ) ; if ( $ entityName === AbstractEntity :: ENTITY_NAME or ! is_string ( $ entityName ) ) { throw new NoEntityNameException ( $ className ) ; } return $ entityName ; }
Gets an entity name from an entity class name if it provides an ENTITY_NAME constant
47,229
public function loadRegistries ( ) { $ registries = $ this -> registryFactory -> getDefaultRegistries ( ) ; foreach ( $ registries as $ registry ) { $ this -> addRegistry ( $ registry ) ; } }
Loads the registries
47,230
public function getEntityName ( ) { if ( is_null ( $ this -> entityName ) ) { $ this -> entityName = self :: getEntityNameFromClassName ( $ this -> getEntityClass ( ) ) ; } return $ this -> entityName ; }
Gets the entity name
47,231
public function findById ( int $ id ) { $ entity = null ; for ( $ i = 0 ; $ i < count ( $ this -> registries ) ; $ i ++ ) { $ registry = $ this -> registries [ $ i ] ; $ entity = $ registry -> findByKey ( $ id ) ; if ( $ entity instanceof AbstractEntity ) { $ this -> updateRegistries ( [ $ entity ] , $ i - 1 ) ; break ; } } return $ entity ; }
Finds an entity by its id
47,232
public function findByIds ( array $ ids ) { $ entities = [ ] ; for ( $ i = 0 ; $ i < count ( $ this -> registries ) ; $ i ++ ) { $ registry = $ this -> registries [ $ i ] ; $ found = $ registry -> findByKeys ( $ ids ) ; $ entities = array_merge ( $ entities , $ found ) ; $ this -> updateRegistries ( $ found , $ i - 1 ) ; if ( count ( $ entities ) === count ( $ ids ) ) { break ; } } return $ entities ; }
Finds a list of entities by their ids
47,233
public function findOneBy ( array $ criteria = [ ] , array $ orders = [ ] , $ offset = null ) : ? AbstractEntity { $ array = $ this -> findBy ( $ criteria , $ orders , 1 , $ offset ) ; return array_shift ( $ array ) ; }
Finds one entity from criteria
47,234
public function matching ( Criteria $ criteria ) : array { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) -> select ( 'e.id' ) -> from ( $ this -> getEntityName ( ) , 'e' ) ; $ queryBuilder -> addCriteria ( $ criteria ) ; $ ids = $ queryBuilder -> getQuery ( ) -> getResult ( ColumnHydrator :: HYDRATOR_MODE ) ; if ( count ( $ ids ) === 0 ) { return [ ] ; } return $ this -> findByIds ( $ ids ) ; }
Gets all entities matching query criteria
47,235
public function getEntityRepository ( ) { $ repository = $ this -> entityManager -> getRepository ( $ this -> getEntityName ( ) ) ; if ( ! ( $ repository instanceof EntityRepository ) ) { throw new InvalidEntityNameException ( $ this -> getEntityName ( ) , $ this -> getEntityClass ( ) ) ; } return $ repository ; }
Gets the doctrine s entity repository for the entity
47,236
private function updateRegistries ( $ entities , $ from ) { if ( count ( $ entities ) >= 0 ) { for ( $ j = $ from ; $ j >= 0 ; $ j -- ) { $ registry = $ this -> registries [ $ j ] ; foreach ( $ entities as $ entity ) { $ registry -> add ( $ entity -> getId ( ) , $ entity ) ; } } } }
Updates the registries
47,237
public function render ( ) { $ args = func_get_args ( ) ; foreach ( $ args as $ arg ) { if ( isset ( $ this -> output [ $ arg ] ) ) { return $ this -> output [ $ arg ] ; } throw new Exception ( "{$arg} is not set!" , 1 ) ; } }
Render compiled HTML
47,238
public function addMapper ( ResultMapperInterface $ mapper ) { if ( $ mapper instanceof self ) { return $ this -> addMappers ( $ mapper -> mappers ) ; } $ this -> mappers [ ] = $ mapper ; return $ this ; }
Adds a Mapper to the chain .
47,239
public function isValueChanged ( $ field ) { if ( ! $ this -> IsNullable ( $ field ) ) { return false ; } return isset ( $ this -> nullableChanged [ $ field ] ) ; }
Check if the given field is nullable and if it should be included in the request
47,240
protected function nullableChanged ( $ field = null ) { if ( ! $ field ) { $ function = debug_backtrace ( ) [ 1 ] [ 'function' ] ; $ field = lcfirst ( substr ( $ function , 3 ) ) ; } $ this -> nullableChanged [ $ field ] = true ; }
Trigger the fact the nullable changed
47,241
public function newConnection ( $ host , $ database , $ user , $ password ) { return self :: $ driver -> connect ( $ host , $ database , $ user , $ password ) ; }
Connect to another driver database server .
47,242
public function persist ( ) { $ parts = explode ( '/' , $ this -> file ) ; array_pop ( $ parts ) ; $ dir = implode ( '/' , $ parts ) ; if ( ! is_dir ( $ dir ) ) { mkdir ( $ dir , 493 , true ) ; } return file_put_contents ( $ this -> file , serialize ( $ this -> data ) ) ; }
Persist the cache data
47,243
public function rebuild ( ) { if ( file_exists ( $ this -> file ) ) { try { $ this -> data = unserialize ( file_get_contents ( $ this -> file ) ) ; return true ; } catch ( \ Exception $ e ) { } } $ this -> data = [ ] ; $ this -> persist ( ) ; return false ; }
Try to unserialize the existing cache if it s corrupted it s lost let it go .
47,244
public function build ( $ basePath ) { $ cache = new PuliResourceCollectionCache ( $ this -> cacheDir . 'gui-icons.css' , $ this -> debug ) ; $ resources = $ this -> resourceFinder -> findByType ( 'phlexible/icons' ) ; if ( ! $ cache -> isFresh ( $ resources ) ) { $ content = $ this -> buildIcons ( $ resources , $ basePath ) ; $ cache -> write ( $ content ) ; if ( ! $ this -> debug ) { $ this -> compressor -> compressFile ( ( string ) $ cache ) ; } } return new Asset ( ( string ) $ cache ) ; }
Get all Stylesheets for the given section .
47,245
public function getParameterListAsObject ( $ name , $ delimiter = ";" ) { $ parameter = $ this -> getValidParameterOfType ( $ name , "string" ) ; $ list = preg_split ( '/\s*(?:,*("[^"]+"),*|,*(\'[^\']+\'),*|,+)\s*/' , $ parameter , null , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ) ; $ parameters = [ ] ; $ values = [ ] ; foreach ( $ list as $ itemValue ) { $ bits = preg_split ( '/\s*(?:;*("[^"]+");*|;*(\'[^\']+\');*|;+)\s*/' , $ itemValue , 0 , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ) ; $ value = array_shift ( $ bits ) ; $ attributes = [ ] ; $ lastNullAttribute = null ; foreach ( $ bits as $ bit ) { if ( ( $ start = substr ( $ bit , 0 , 1 ) ) === ( $ end = substr ( $ bit , - 1 ) ) && ( $ start === '"' || $ start === '\'' ) ) { $ attributes [ $ lastNullAttribute ] = substr ( $ bit , 1 , - 1 ) ; } elseif ( '=' === $ end ) { $ lastNullAttribute = $ bit = substr ( $ bit , 0 , - 1 ) ; $ attributes [ $ bit ] = null ; } else { $ parts = explode ( '=' , $ bit ) ; $ attributes [ $ parts [ 0 ] ] = isset ( $ parts [ 1 ] ) && strlen ( $ parts [ 1 ] ) > 0 ? $ parts [ 1 ] : '' ; } } $ parameters [ ( $ start = substr ( $ value , 0 , 1 ) ) === ( $ end = substr ( $ value , - 1 ) ) && ( $ start === '"' || $ start === '\'' ) ? substr ( $ value , 1 , - 1 ) : $ value ] = $ attributes ; } return new Factory ( $ name , $ parameters , static :: $ sanitizer , static :: $ validator , false ) ; }
Get a comma seperated list of params as a Parameter object ;
47,246
public function removeExtension ( $ name ) { if ( isset ( $ this -> extensions [ $ name ] ) ) { unset ( $ this -> extensions [ $ name ] ) ; } return $ this ; }
Remove an extension .
47,247
public static function javascriptRedirectUser ( $ url , $ numSeconds = 0 ) { $ htmlString = '' ; $ htmlString .= "<script type='text/javascript'>" . "var redirectTime=" . $ numSeconds * 1000 . ";" . PHP_EOL . "var redirectURL='" . $ url . "';" . PHP_EOL . 'setTimeout("location.href = redirectURL;", redirectTime);' . PHP_EOL . "</script>" ; return $ htmlString ; }
Allows us to re - direct the user using javascript when headers have already been submitted .
47,248
public static function setCliTitle ( $ nameingPrefix ) { $ succeeded = false ; $ num_running = self :: getNumProcRunning ( $ nameingPrefix ) ; if ( function_exists ( 'cli_set_process_title' ) ) { cli_set_process_title ( $ nameingPrefix . $ num_running ) ; $ succeeded = true ; } return $ succeeded ; }
Sets the title of the process and will append the appropriate number of already existing processes with the same title . WARNING - this will fail and return FALSE if you are on Windows
47,249
public static function sendApiRequest ( $ url , array $ parameters , $ requestType = "POST" , $ headers = array ( ) ) { $ allowedRequestTypes = array ( "GET" , "POST" , "PUT" , "PATCH" , "DELETE" ) ; $ requestTypeUpper = strtoupper ( $ requestType ) ; if ( ! in_array ( $ requestTypeUpper , $ allowedRequestTypes ) ) { throw new \ Exception ( "API request needs to be one of GET, POST, PUT, PATCH, or DELETE." ) ; } if ( $ requestType === "GET" ) { $ ret = self :: sendGetRequest ( $ url , $ parameters ) ; } else { $ query_string = http_build_query ( $ parameters , '' , '&' ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; switch ( $ requestTypeUpper ) { case "POST" : { curl_setopt ( $ ch , CURLOPT_POST , 1 ) ; } break ; case "PUT" : case "PATCH" : case "DELETE" : { curl_setopt ( $ this -> m_ch , CURLOPT_CUSTOMREQUEST , $ requestTypeUpper ) ; } break ; default : { throw new \ Exception ( "Unrecognized request type." ) ; } } curl_setopt ( $ ch , CURLOPT_TIMEOUT , 30 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ query_string ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYHOST , 0 ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , 0 ) ; if ( count ( $ headers ) > 0 ) { $ headersStrings = array ( ) ; foreach ( $ headers as $ key => $ value ) { $ headersStrings [ ] = "{$key}: {$value}" ; } curl_setopt ( $ this -> m_ch , CURLOPT_HTTPHEADER , $ this -> m_headers ) ; } $ jsondata = curl_exec ( $ ch ) ; if ( curl_error ( $ ch ) ) { $ errMsg = "Connection Error: " . curl_errno ( $ ch ) . ' - ' . curl_error ( $ ch ) ; throw new \ Exception ( $ errMsg ) ; } curl_close ( $ ch ) ; $ ret = json_decode ( $ jsondata ) ; if ( $ ret == null ) { $ errMsg = 'Recieved a non json response from API: ' . $ jsondata ; throw new \ Exception ( $ errMsg ) ; } } return $ ret ; }
Sends an api request through the use of CURL
47,250
public static function sendGetRequest ( $ url , array $ parameters = array ( ) , $ arrayForm = false ) { if ( count ( $ parameters ) > 0 ) { $ query_string = http_build_query ( $ parameters , '' , '&' ) ; $ url .= $ query_string ; } $ curl = curl_init ( ) ; $ curlOptions = array ( CURLOPT_RETURNTRANSFER => 1 , CURLOPT_URL => $ url , ) ; curl_setopt_array ( $ curl , $ curlOptions ) ; $ rawResponse = curl_exec ( $ curl ) ; curl_close ( $ curl ) ; $ responseObj = json_decode ( $ rawResponse , $ arrayForm ) ; if ( $ responseObj == null ) { $ errMsg = 'Recieved a non json response from API: ' . $ rawResponse ; throw new \ Exception ( $ errMsg ) ; } return $ responseObj ; }
Sends a GET request to a RESTful API through cURL .
47,251
public static function fetchArgs ( array $ reqArgs , array $ optionalArgs ) { $ values = self :: fetchReqArgs ( $ reqArgs ) ; $ values = array_merge ( $ values , self :: fetchOptionalArgs ( $ optionalArgs ) ) ; return $ values ; }
Retrieves the specified arguments from REQUEST . This will throw an exception if a required argument is not present but not if an optional argument is not .
47,252
public static function getCurrentUrl ( ) { $ pageURL = 'http' ; if ( isset ( $ _SERVER [ "HTTPS" ] ) ) { $ pageURL .= "s" ; } $ pageURL .= "://" ; if ( $ _SERVER [ "SERVER_PORT" ] != "80" ) { $ pageURL .= $ _SERVER [ "SERVER_NAME" ] . ":" . $ _SERVER [ "SERVER_PORT" ] . $ _SERVER [ "REQUEST_URI" ] ; } else { $ pageURL .= $ _SERVER [ "SERVER_NAME" ] . $ _SERVER [ "REQUEST_URI" ] ; } return $ pageURL ; }
Builds url of the current page excluding any ? = &stuff
47,253
public static function versionGuard ( $ reqVersion , $ errMsg = '' ) { if ( version_compare ( PHP_VERSION , $ reqVersion ) == - 1 ) { if ( $ errMsg == '' ) { $ errMsg = 'Required PHP version: ' . $ reqVersion . ', current Version: ' . PHP_VERSION ; } die ( $ errMsg ) ; } }
Implement a version guard . This will throw an exception if we do not have the required version of PHP that is specified .
47,254
public static function isPortOpen ( $ host , $ port , $ protocol ) { $ protocol = strtolower ( $ protocol ) ; if ( $ protocol != 'tcp' && $ protocol != 'udp' ) { $ errMsg = 'Unrecognized protocol [' . $ protocol . '] ' . 'please specify [tcp] or [udp]' ; throw new \ Exception ( $ errMsg ) ; } if ( empty ( $ host ) ) { $ host = self :: getPublicIp ( ) ; } foreach ( $ ports as $ port ) { $ connection = @ fsockopen ( $ host , $ port ) ; if ( is_resource ( $ connection ) ) { $ isOpen = true ; fclose ( $ connection ) ; } else { $ isOpen = false ; } } return $ isOpen ; }
Checks to see if the specified port is open .
47,255
public static function generateConfig ( $ settings , $ variableName , $ filePath ) { $ varStr = var_export ( $ settings , true ) ; $ output = '<?php' . PHP_EOL . '$' . $ variableName . ' = ' . $ varStr . ';' ; $ wroteFile = file_put_contents ( $ filePath , $ output ) ; if ( $ wroteFile === FALSE ) { $ msg = "Failed to generate config file. Check permissions!" ; throw new \ Exception ( $ msg ) ; } }
Generate a php config file to have the setting provided . This is useful if we want to be able to update our config file through code such as a web ui to upadate settings . Platforms like wordpress allow updating the settings but do this through a database .
47,256
public static function generatePasswordHash ( $ rawPassword , $ cost = 11 ) { $ cost = intval ( $ cost ) ; $ cost = self :: clampValue ( $ cost , $ max = 31 , $ min = 4 ) ; if ( $ cost < 10 ) { $ cost = "0" . $ cost ; } $ options = array ( 'cost' => $ cost ) ; $ hash = password_hash ( $ rawPassword , PASSWORD_BCRYPT , $ options ) ; return $ hash ; }
Converts a raw password into a hash using PHP 5 . 5 s new hashing method
47,257
public static function isValidSignedRequest ( array $ data , string $ signature ) { $ generated_signature = SiteSpecific :: generateSignature ( $ data ) ; return ( $ generated_signature == $ signature ) ; }
Check if the provided data has the correct signature .
47,258
public function button ( $ label = null , $ url = null , $ status = null , $ icon = null , $ block = false , $ disabled = false , $ flat = false , $ size = Button :: SIZE_NORMAL ) { $ button = new Button ( $ label , $ url , $ status , $ icon , $ block , $ disabled , $ flat , $ size ) ; return $ this -> addButton ( $ button ) ; }
Create a new button
47,259
public function logOut ( $ type , $ source , $ message , $ logKey = null , $ printOut = true ) { $ log = [ "time" => date ( "Y-m-d H:i:s" , time ( ) ) , "source" => $ source , "type" => $ type , "message" => $ message ] ; if ( $ printOut ) $ this -> printOut = $ printOut ; if ( $ logKey ) $ log [ "logKey" ] = $ logKey ; $ file = $ this -> activityName ; $ this -> filePath = $ this -> logPath . "/" . $ file . ".log" ; if ( ! openlog ( __FILE__ , LOG_CONS | LOG_PID , LOG_LOCAL1 ) ) throw new CpeException ( "Unable to connect to Syslog!" , OPENLOG_ERROR ) ; switch ( $ type ) { case "INFO" : $ priority = LOG_INFO ; break ; case "ERROR" : $ priority = LOG_ERR ; break ; case "FATAL" : $ priority = LOG_ALERT ; break ; case "WARNING" : $ priority = LOG_WARNING ; break ; case "DEBUG" : $ priority = LOG_DEBUG ; break ; default : throw new CpeException ( "Unknown log Type!" , LOG_TYPE_ERROR ) ; } $ this -> printToFile ( $ log ) ; $ out = json_encode ( $ log ) ; syslog ( $ priority , $ out ) ; }
Log message to syslog and log file . Will print
47,260
private function printToFile ( $ log ) { if ( ! is_string ( $ log [ 'message' ] ) ) $ log [ 'message' ] = json_encode ( $ log [ 'message' ] ) ; $ toPrint = $ log [ 'time' ] . " [" . $ log [ 'type' ] . "] [" . $ log [ 'source' ] . "] " ; if ( isset ( $ log [ 'logKey' ] ) && $ log [ 'logKey' ] ) $ toPrint .= "[" . $ log [ 'logKey' ] . "] " ; $ toPrint .= $ log [ 'message' ] . "\n" ; if ( $ this -> printout ) print $ toPrint ; if ( file_put_contents ( $ this -> filePath , $ toPrint , FILE_APPEND ) === false ) { throw new CpeException ( "Can't write into log file: $this->logPath" , LOGFILE_ERROR ) ; } }
Write log in file
47,261
final public static function fromString ( string $ string ) : Enum { $ parts = explode ( '::' , $ string ) ; return self :: fromName ( end ( $ parts ) ) ; }
Creates instance from a string representation
47,262
final public static function fromName ( string $ name ) : Enum { $ constName = sprintf ( '%s::%s' , static :: class , $ name ) ; if ( ! defined ( $ constName ) ) { $ message = sprintf ( '%s is not a member constant of enum %s' , $ name , static :: class ) ; throw new DomainException ( $ message ) ; } return new static ( constant ( $ constName ) ) ; }
Creates instance from an enum constant name
47,263
final public static function fromOrdinal ( int $ ordinal ) : Enum { $ constants = self :: getMembers ( ) ; $ item = array_slice ( $ constants , $ ordinal , 1 , true ) ; if ( ! $ item ) { $ end = count ( $ constants ) - 1 ; $ message = sprintf ( 'Enum ordinal (%d) out of range [0, %d]' , $ ordinal , $ end ) ; throw new DomainException ( $ message ) ; } return new static ( current ( $ item ) ) ; }
Creates instance from an enum ordinal position
47,264
final public static function getMembers ( ) : array { if ( ! isset ( self :: $ constants [ static :: class ] ) ) { $ reflection = new ReflectionClass ( static :: class ) ; $ constants = self :: sortConstants ( $ reflection ) ; self :: guardConstants ( $ constants ) ; self :: $ constants [ static :: class ] = $ constants ; } return self :: $ constants [ static :: class ] ; }
Retrieves enum member names and values
47,265
final public function name ( ) : string { if ( $ this -> name === null ) { $ constants = self :: getMembers ( ) ; $ this -> name = array_search ( $ this -> value , $ constants , true ) ; } return $ this -> name ; }
Retrieves the enum constant name
47,266
final public function ordinal ( ) : int { if ( $ this -> ordinal === null ) { $ ordinal = 0 ; foreach ( self :: getMembers ( ) as $ constValue ) { if ( $ this -> value === $ constValue ) { break ; } $ ordinal ++ ; } $ this -> ordinal = $ ordinal ; } return $ this -> ordinal ; }
Retrieves the enum ordinal position
47,267
final private static function guardConstants ( array $ constants ) : void { $ duplicates = [ ] ; foreach ( $ constants as $ value ) { $ names = array_keys ( $ constants , $ value , $ strict = true ) ; if ( count ( $ names ) > 1 ) { $ duplicates [ VarPrinter :: toString ( $ value ) ] = $ names ; } } if ( ! empty ( $ duplicates ) ) { $ list = array_map ( function ( $ names ) use ( $ constants ) { return sprintf ( '(%s)=%s' , implode ( '|' , $ names ) , VarPrinter :: toString ( $ constants [ $ names [ 0 ] ] ) ) ; } , $ duplicates ) ; $ message = sprintf ( 'Duplicate enum values: %s' , implode ( ', ' , $ list ) ) ; throw new DomainException ( $ message ) ; } }
Validates enum constants
47,268
final private static function sortConstants ( ReflectionClass $ reflection ) : array { $ constants = [ ] ; while ( $ reflection && __CLASS__ !== $ reflection -> getName ( ) ) { $ scope = [ ] ; foreach ( $ reflection -> getReflectionConstants ( ) as $ const ) { if ( $ const -> isPublic ( ) ) { $ scope [ $ const -> getName ( ) ] = $ const -> getValue ( ) ; } } $ constants = $ scope + $ constants ; $ reflection = $ reflection -> getParentClass ( ) ; } return $ constants ; }
Sorts member constants
47,269
private function getValidation ( string $ name ) : validator \ Validation { if ( ! isset ( $ this -> validations [ $ name ] ) ) { if ( isset ( $ this -> validationRegister [ $ name ] ) ) { $ class = $ this -> validationRegister [ $ name ] ; } else { throw new exceptions \ ValidatorException ( "Validator [$name] not found" ) ; } $ params = isset ( $ this -> validationData [ $ name ] ) ? $ this -> validationData [ $ name ] : null ; $ this -> validations [ $ name ] = new $ class ( $ params ) ; } return $ this -> validations [ $ name ] ; }
Get an instance of a validation class .
47,270
protected function registerValidation ( string $ name , string $ class , $ data = null ) { $ this -> validationRegister [ $ name ] = $ class ; $ this -> validationData [ $ name ] = $ data ; }
Register a validation type .
47,271
private function getFieldInfo ( $ key , $ value ) : array { $ name = null ; $ options = [ ] ; if ( is_numeric ( $ key ) && is_string ( $ value ) ) { $ name = $ value ; } else if ( is_numeric ( $ key ) && is_array ( $ value ) ) { $ name = array_shift ( $ value ) ; $ options = $ value ; } else if ( is_string ( $ key ) ) { $ name = $ key ; $ options = $ value ; } return [ 'name' => $ name , 'options' => $ options ] ; }
Build a uniform field info array for various types of validations .
47,272
public function validate ( array $ data ) : bool { $ passed = true ; $ this -> invalidFields = [ ] ; $ rules = $ this -> getRules ( ) ; foreach ( $ rules as $ validation => $ fields ) { foreach ( $ fields as $ key => $ value ) { $ field = $ this -> getFieldInfo ( $ key , $ value ) ; $ validationInstance = $ this -> getValidation ( $ validation ) ; $ validationStatus = $ validationInstance -> run ( $ field , $ data ) ; $ passed = $ passed && $ validationStatus ; $ this -> invalidFields = array_merge_recursive ( $ this -> invalidFields , $ validationInstance -> getMessages ( ) ) ; } } return $ passed ; }
Validate data according to validation rules that have been set into this validator .
47,273
protected function universalCreate ( ) { $ bean = \ R :: dispense ( $ this -> type ) ; $ bean -> created = \ R :: isoDateTime ( ) ; return $ bean ; }
Dispenses a Redbean bean ans sets it s creation date .
47,274
public function set ( $ data , $ bean ) { foreach ( $ this -> properties as $ property ) { $ value = false ; $ c = new $ property [ 'type' ] ; if ( isset ( $ data [ $ property [ 'name' ] ] ) || ( isset ( $ _FILES [ $ property [ 'name' ] ] ) && $ _FILES [ $ property [ 'name' ] ] [ 'size' ] > 0 ) || $ property [ 'autovalue' ] == true ) { if ( method_exists ( $ c , 'set' ) ) { $ value = $ c -> set ( $ bean , $ property , $ data [ $ property [ 'name' ] ] ) ; } else { $ value = $ data [ $ property [ 'name' ] ] ; } if ( $ value ) { $ hasvalue = true ; } else { $ hasvalue = false ; } } else { if ( isset ( $ property [ 'required' ] ) ) { if ( method_exists ( $ c , 'read' ) && $ c -> read ( $ bean , $ property ) ) { $ hasvalue = true ; } else if ( $ bean -> { $ property [ 'name' ] } ) { $ hasvalue = true ; } else { $ hasvalue = false ; } } } if ( isset ( $ property [ 'required' ] ) ) { if ( $ property [ 'required' ] && ! $ hasvalue ) { throw new \ Exception ( 'Validation error. ' . $ property [ 'description' ] . ' is required.' ) ; } } if ( ! is_bool ( $ value ) ) { if ( isset ( $ property [ 'unique' ] ) ) { $ duplicate = \ R :: findOne ( $ this -> type , $ property [ 'name' ] . ' = :val ' , [ ':val' => $ value ] ) ; if ( $ duplicate && $ duplicate -> id != $ bean -> id ) { throw new \ Exception ( 'Validation error. ' . $ property [ 'description' ] . ' should be unique.' ) ; } } $ bean -> { $ property [ 'name' ] } = $ value ; } } $ bean -> modified = \ R :: isoDateTime ( ) ; \ R :: store ( $ bean ) ; return $ bean ; }
Set values for a bean . Used by Create and Update . Checks for each property if a set method exists for it s type . If so it executes it .
47,275
protected static function tryGetValue ( $ provider , $ object , $ propertyName , & $ error ) { try { return call_user_func ( array ( $ provider , 'getValue' ) , $ object , $ propertyName ) ; } catch ( \ InvalidArgumentException $ e ) { $ error = $ e ; return null ; } }
Try to get the value of an object property with a specific provider
47,276
protected static function trySetValue ( $ provider , & $ object , $ propertyName , $ value , & $ error ) { try { return call_user_func ( array ( $ provider , 'setValue' ) , $ object , $ propertyName , $ value ) ; } catch ( \ InvalidArgumentException $ e ) { $ error = $ e ; return null ; } }
Try to set the value of an object property with a specific provider
47,277
public function canGetProperty ( $ name , $ checkVars = true ) { if ( ! in_array ( $ name , $ this -> attrs ) ) { return parent :: canGetProperty ( $ name , $ checkVars ) ; } return true ; }
Indicates whether a property can be read .
47,278
public function events ( ) { return [ \ yii \ db \ ActiveRecord :: EVENT_BEFORE_VALIDATE => 'handleValidate' , \ yii \ db \ ActiveRecord :: EVENT_AFTER_INSERT => 'handleAfterSave' , \ yii \ db \ ActiveRecord :: EVENT_AFTER_UPDATE => 'handleAfterSave' , ] ; }
Validates interpreter together with owner
47,279
public function interpreter ( array $ restriction = [ ] ) { if ( null === $ this -> _interpreter ) { $ this -> _interpreter = new Interpreter ( $ this -> owner , $ this -> config , $ this -> allowCache , $ this -> attrActive ) ; } $ this -> _interpreter -> setRestriction ( $ restriction ) ; return $ this -> _interpreter ; }
Retrieves instance to multilang interperter
47,280
public function getUserFeed ( $ userName = null , $ location = null ) { if ( $ location instanceof Zend_Gdata_Photos_UserQuery ) { $ location -> setType ( 'feed' ) ; if ( $ userName !== null ) { $ location -> setUser ( $ userName ) ; } $ uri = $ location -> getQueryUrl ( ) ; } else if ( $ location instanceof Zend_Gdata_Query ) { if ( $ userName !== null ) { $ location -> setUser ( $ userName ) ; } $ uri = $ location -> getQueryUrl ( ) ; } else if ( $ location !== null ) { $ uri = $ location ; } else if ( $ userName !== null ) { $ uri = self :: PICASA_BASE_FEED_URI . '/' . self :: DEFAULT_PROJECTION . '/' . self :: USER_PATH . '/' . $ userName ; } else { $ uri = self :: PICASA_BASE_FEED_URI . '/' . self :: DEFAULT_PROJECTION . '/' . self :: USER_PATH . '/' . self :: DEFAULT_USER ; } return parent :: getFeed ( $ uri , 'Zend_Gdata_Photos_UserFeed' ) ; }
Retrieve a UserFeed containing AlbumEntries PhotoEntries and TagEntries associated with a given user .
47,281
public function getAlbumFeed ( $ location = null ) { if ( $ location === null ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'Location must not be null' ) ; } else if ( $ location instanceof Zend_Gdata_Photos_UserQuery ) { $ location -> setType ( 'feed' ) ; $ uri = $ location -> getQueryUrl ( ) ; } else if ( $ location instanceof Zend_Gdata_Query ) { $ uri = $ location -> getQueryUrl ( ) ; } else { $ uri = $ location ; } return parent :: getFeed ( $ uri , 'Zend_Gdata_Photos_AlbumFeed' ) ; }
Retreive AlbumFeed object containing multiple PhotoEntry or TagEntry objects .
47,282
public function getPhotoFeed ( $ location = null ) { if ( $ location === null ) { $ uri = self :: PICASA_BASE_FEED_URI . '/' . self :: DEFAULT_PROJECTION . '/' . self :: COMMUNITY_SEARCH_PATH ; } else if ( $ location instanceof Zend_Gdata_Photos_UserQuery ) { $ location -> setType ( 'feed' ) ; $ uri = $ location -> getQueryUrl ( ) ; } else if ( $ location instanceof Zend_Gdata_Query ) { $ uri = $ location -> getQueryUrl ( ) ; } else { $ uri = $ location ; } return parent :: getFeed ( $ uri , 'Zend_Gdata_Photos_PhotoFeed' ) ; }
Retreive PhotoFeed object containing comments and tags associated with a given photo .
47,283
public function getUserEntry ( $ location ) { if ( $ location === null ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'Location must not be null' ) ; } else if ( $ location instanceof Zend_Gdata_Photos_UserQuery ) { $ location -> setType ( 'entry' ) ; $ uri = $ location -> getQueryUrl ( ) ; } else if ( $ location instanceof Zend_Gdata_Query ) { $ uri = $ location -> getQueryUrl ( ) ; } else { $ uri = $ location ; } return parent :: getEntry ( $ uri , 'Zend_Gdata_Photos_UserEntry' ) ; }
Retreive a single UserEntry object .
47,284
public function insertAlbumEntry ( $ album , $ uri = null ) { if ( $ uri === null ) { $ uri = self :: PICASA_BASE_FEED_URI . '/' . self :: DEFAULT_PROJECTION . '/' . self :: USER_PATH . '/' . self :: DEFAULT_USER ; } $ newEntry = $ this -> insertEntry ( $ album , $ uri , 'Zend_Gdata_Photos_AlbumEntry' ) ; return $ newEntry ; }
Create a new album from a AlbumEntry .
47,285
public function insertPhotoEntry ( $ photo , $ uri = null ) { if ( $ uri instanceof Zend_Gdata_Photos_AlbumEntry ) { $ uri = $ uri -> getLink ( self :: FEED_LINK_PATH ) -> href ; } if ( $ uri === null ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'URI must not be null' ) ; } $ newEntry = $ this -> insertEntry ( $ photo , $ uri , 'Zend_Gdata_Photos_PhotoEntry' ) ; return $ newEntry ; }
Create a new photo from a PhotoEntry .
47,286
public function insertTagEntry ( $ tag , $ uri = null ) { if ( $ uri instanceof Zend_Gdata_Photos_PhotoEntry ) { $ uri = $ uri -> getLink ( self :: FEED_LINK_PATH ) -> href ; } if ( $ uri === null ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'URI must not be null' ) ; } $ newEntry = $ this -> insertEntry ( $ tag , $ uri , 'Zend_Gdata_Photos_TagEntry' ) ; return $ newEntry ; }
Create a new tag from a TagEntry .
47,287
public function insertCommentEntry ( $ comment , $ uri = null ) { if ( $ uri instanceof Zend_Gdata_Photos_PhotoEntry ) { $ uri = $ uri -> getLink ( self :: FEED_LINK_PATH ) -> href ; } if ( $ uri === null ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'URI must not be null' ) ; } $ newEntry = $ this -> insertEntry ( $ comment , $ uri , 'Zend_Gdata_Photos_CommentEntry' ) ; return $ newEntry ; }
Create a new comment from a CommentEntry .
47,288
public function deleteAlbumEntry ( $ album , $ catch ) { if ( $ catch ) { try { $ this -> delete ( $ album ) ; } catch ( Zend_Gdata_App_HttpException $ e ) { if ( $ e -> getResponse ( ) -> getStatus ( ) === 409 ) { $ entry = new Zend_Gdata_Photos_AlbumEntry ( $ e -> getResponse ( ) -> getBody ( ) ) ; $ this -> delete ( $ entry -> getLink ( 'edit' ) -> href ) ; } else { throw $ e ; } } } else { $ this -> delete ( $ album ) ; } }
Delete an AlbumEntry .
47,289
public function deletePhotoEntry ( $ photo , $ catch ) { if ( $ catch ) { try { $ this -> delete ( $ photo ) ; } catch ( Zend_Gdata_App_HttpException $ e ) { if ( $ e -> getResponse ( ) -> getStatus ( ) === 409 ) { $ entry = new Zend_Gdata_Photos_PhotoEntry ( $ e -> getResponse ( ) -> getBody ( ) ) ; $ this -> delete ( $ entry -> getLink ( 'edit' ) -> href ) ; } else { throw $ e ; } } } else { $ this -> delete ( $ photo ) ; } }
Delete a PhotoEntry .
47,290
public function deleteCommentEntry ( $ comment , $ catch ) { if ( $ catch ) { try { $ this -> delete ( $ comment ) ; } catch ( Zend_Gdata_App_HttpException $ e ) { if ( $ e -> getResponse ( ) -> getStatus ( ) === 409 ) { $ entry = new Zend_Gdata_Photos_CommentEntry ( $ e -> getResponse ( ) -> getBody ( ) ) ; $ this -> delete ( $ entry -> getLink ( 'edit' ) -> href ) ; } else { throw $ e ; } } } else { $ this -> delete ( $ comment ) ; } }
Delete a CommentEntry .
47,291
public function deleteTagEntry ( $ tag , $ catch ) { if ( $ catch ) { try { $ this -> delete ( $ tag ) ; } catch ( Zend_Gdata_App_HttpException $ e ) { if ( $ e -> getResponse ( ) -> getStatus ( ) === 409 ) { $ entry = new Zend_Gdata_Photos_TagEntry ( $ e -> getResponse ( ) -> getBody ( ) ) ; $ this -> delete ( $ entry -> getLink ( 'edit' ) -> href ) ; } else { throw $ e ; } } } else { $ this -> delete ( $ tag ) ; } }
Delete a TagEntry .
47,292
public function getParam ( $ index ) { if ( isset ( $ this -> params [ $ index ] ) ) { return $ this -> params [ $ index ] ; } else { return NULL ; } }
Devuelve un parametro en base a un indice - solo parametros no utilizados por el framework
47,293
public function getParamClean ( $ index ) { if ( isset ( $ this -> params [ $ index ] ) ) { return $ this -> params [ $ index ] ; } else { return NULL ; } }
Devuelve un parametro limpiado en base a un indice - solo parametros no utilizados por el framework
47,294
public function getParamAll ( $ index ) { if ( isset ( $ this -> allParams [ $ index ] ) ) { return Security :: clean_vars ( $ this -> allParams [ $ index ] ) ; } else { return NULL ; } }
Devuelve un parametro en base a un indice - incluye todos los parametros
47,295
public function getParamAllClean ( $ index ) { if ( isset ( $ this -> allParams [ $ index ] ) ) { return Security :: clean_vars ( $ this -> allParams [ $ index ] ) ; } else { return NULL ; } }
Devuelve un parametro limpiado en base a un indice - incluye todos los parametros
47,296
protected function build ( $ m ) { $ string = $ m [ 1 ] ; if ( substr ( $ string , 0 , 1 ) != '<' ) { return '&gt;' ; } elseif ( strlen ( $ string ) == 1 ) { return '&lt;' ; } if ( ! preg_match ( '%^<\s*(/\s*)?([a-zA-Z0-9\-]+)([^>]*)>?|(<!--.*? , $ string , $ matches ) ) { return '' ; } $ slash = trim ( $ matches [ 1 ] ) ; $ elem = & $ matches [ 2 ] ; $ attrlist = & $ matches [ 3 ] ; $ comment = & $ matches [ 4 ] ; if ( $ comment ) { $ elem = '!--' ; } if ( ! in_array ( strtolower ( $ elem ) , $ this -> tags , true ) ) { return '' ; } if ( $ comment ) { return $ comment ; } if ( $ slash != '' ) { return "</$elem>" ; } $ attrlist = preg_replace ( '%(\s?)/\s*$%' , '\1' , $ attrlist , - 1 , $ count ) ; $ xhtml_slash = $ count ? ' /' : '' ; $ attr2 = implode ( ' ' , $ this -> explodeAttributes ( $ attrlist ) ) ; $ attr2 = preg_replace ( '/[<>]/' , '' , $ attr2 ) ; $ attr2 = strlen ( $ attr2 ) ? ' ' . $ attr2 : '' ; return "<$elem$attr2$xhtml_slash>" ; }
Build a filtered tag
47,297
public function match ( $ var ) { $ ret = false ; foreach ( $ this -> _types as $ type ) { if ( array_search ( $ type , array ( "*" , "mixed" ) ) !== false ) { $ ret = true ; } elseif ( array_search ( $ type , array ( "number" , "numeric" ) ) !== false ) { $ ret = is_numeric ( $ var ) ; } elseif ( array_search ( $ type , array ( "bool" , "boolean" ) ) !== false ) { $ ret = is_bool ( $ var ) ; } elseif ( $ type == "string" ) { $ ret = is_string ( $ var ) ; } elseif ( $ type == "array" ) { $ ret = is_array ( $ var ) ; } elseif ( $ type == "object" ) { $ ret = is_object ( $ var ) ; } elseif ( $ type == "resource" ) { $ ret = is_resource ( $ var ) ; } elseif ( $ type == "function" ) { $ ret = is_callable ( $ var ) ; } elseif ( $ type == "scalar" ) { $ ret = is_scalar ( $ var ) ; } else { $ ret = is_a ( $ var , $ type ) ; } if ( $ ret ) { break ; } } return $ ret ; }
Does the variable match with this descriptor?
47,298
public function execute ( ) { if ( is_string ( $ this -> callback ) ) { $ parts = explode ( '::' , $ this -> callback ) ; $ className = $ parts [ 0 ] ; $ classMethod = $ parts [ 1 ] ; if ( ! class_exists ( $ className ) ) { throw new RouterException ( "The callback class declared in your middleware is not found: '{$className}'" ) ; } $ class = new $ className ( ) ; if ( ! $ class instanceof BaseMiddleware ) { throw new RouterException ( "The class in your middleware route doesn't extend the BaseMiddleware: '{$className}'" ) ; } if ( ! method_exists ( $ class , $ classMethod ) ) { throw new RouterException ( "The class in your middleware route doesn't have the method you provided: '{$className}' method: {$classMethod}" ) ; } $ result = call_user_func ( array ( $ class , $ classMethod ) ) ; } elseif ( is_callable ( $ this -> callback ) ) { $ result = call_user_func ( $ this -> callback ) ; } else { throw new RouterException ( "Middleware callback is not a class or callable!" ) ; } if ( $ result === false && $ this -> position === 'before' ) { return false ; } return true ; }
Execute Callback in middleware capture the output of it .
47,299
public function prepare ( ) { $ class = get_class ( $ this ) ; if ( ! isset ( $ this -> dbTable ) ) { return e ( 'Cannot load "' . $ class . '" module - no $dbTable is configured' ) ; } if ( $ class != __CLASS__ ) { db ( ) -> createField ( $ this , $ this -> dbTable , 'dbIdField' , 'VARCHAR(50)' ) ; } db ( ) -> createField ( $ this , $ this -> dbTable , 'dbNameField' , 'VARCHAR(50)' ) ; db ( ) -> createField ( $ this , $ this -> dbTable , 'dbSurnameField' , 'VARCHAR(50)' ) ; db ( ) -> createField ( $ this , $ this -> dbTable , 'dbEmailField' , 'VARCHAR(50)' ) ; db ( ) -> createField ( $ this , $ this -> dbTable , 'dbGenderField' , 'VARCHAR(10)' ) ; db ( ) -> createField ( $ this , $ this -> dbTable , 'dbBirthdayField' , 'DATE' ) ; db ( ) -> createField ( $ this , $ this -> dbTable , 'dbPhotoField' , 'VARCHAR(125)' ) ; return parent :: prepare ( ) ; }
Prepare module data