idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
43,600
public function importePagado ( $ id = null ) { $ importePagado = 0 ; if ( empty ( $ id ) ) { $ id = $ this -> id ; } $ fieldContain [ 'recursive' ] = - 1 ; $ fieldContain [ 'contain' ] = 'Egreso' ; $ fieldContain [ 'conditions' ] = array ( 'Gasto.id' => $ id ) ; $ coso = parent :: find ( 'first' , $ fieldContain ) ; if ( ! empty ( $ coso [ 'Egreso' ] ) ) { foreach ( $ coso [ 'Egreso' ] as $ eg ) { if ( $ eg [ 'AccountEgresosGasto' ] [ 'gasto_id' ] == $ id ) { $ importePagado += $ eg [ 'AccountEgresosGasto' ] [ 'importe' ] ; } } } return $ importePagado ; }
Indica la sumatoria de todos los pagos realizados para ese gasto
43,601
protected function extractHeaders ( $ data ) { $ headers = array_keys ( $ data [ 0 ] ) ; foreach ( $ this -> options [ 'hiddenFields' ] as $ hiddenField ) { if ( in_array ( $ hiddenField , $ headers ) ) { array_splice ( $ headers , array_search ( $ hiddenField , $ headers ) , 1 ) ; } } if ( ! empty ( $ this -> options [ 'actions' ] ) ) { $ headers [ ] = 'Actions' ; } return $ headers ; }
Get Table headers from data
43,602
public function getGrandTotalAttribute ( ) { if ( ! $ this -> deliveryOption ) return $ this -> total ; return ( float ) round ( $ this -> total + $ this -> deliveryOption -> price , 2 ) ; }
Calculate grand total in respect to quantity and delivery .
43,603
public function useAddress ( PostalAddress $ postalAddress ) { $ this -> name = $ postalAddress -> name ; $ this -> street1 = $ postalAddress -> street1 ; $ this -> street2 = $ postalAddress -> street2 ; $ this -> city = $ postalAddress -> city ; $ this -> county = $ postalAddress -> county ; $ this -> postcode = $ postalAddress -> postcode ; $ this -> country = $ postalAddress -> country ; }
Mass - assignment method for using a postal address .
43,604
public static function averageAmount ( $ since = 0 , $ until = null ) { $ until = $ until ? : time ( ) ; return ( int ) self :: where ( 'created' , '>=' , $ since ) -> where ( 'created' , '<=' , $ until ) -> avg ( 'total' ) ; }
Return the average amount of purchases .
43,605
protected function convert ( $ data ) { if ( $ data instanceof DateTime ) { $ data = clone $ data ; return $ data -> setTimezone ( $ this -> timezone ) -> format ( 'Y-m-d\TG:i:s\Z' ) ; } if ( is_object ( $ data ) && ! method_exists ( $ data , '__toString' ) ) { return null ; } if ( is_array ( $ data ) ) { return null ; } if ( is_bool ( $ data ) ) { return $ data ? '1' : '0' ; } return $ data !== null ? ( string ) $ data : null ; }
Convert the data to a string .
43,606
protected function combine ( array $ data , $ separator ) { $ results = array_shift ( $ data ) ; $ results = is_array ( $ results ) ? $ results : [ $ results ] ; while ( $ value = array_shift ( $ data ) ) { if ( is_array ( $ value ) ) { $ replacement = [ ] ; foreach ( $ value as $ array_value ) { foreach ( $ results as $ result_value ) { $ replacement [ ] = $ result_value . $ separator . $ array_value ; } } $ results = $ replacement ; } else { foreach ( $ results as $ key => $ result_value ) { $ results [ $ key ] = $ result_value . $ separator . $ value ; } } } return array_filter ( $ results ) ; }
Combine all the data into strings .
43,607
public function activateUser ( $ key ) { $ tokenhandler = new ActivationToken ( $ this -> db ) ; $ tokenhandler -> setSelectorTokenString ( $ key ) ; $ token_from_key = $ tokenhandler -> getToken ( ) ; $ tokenhandler -> loadTokenData ( ) ; $ id_user = $ tokenhandler -> getUserId ( ) ; if ( empty ( $ id_user ) ) { return false ; } $ token_from_db = $ tokenhandler -> getToken ( ) ; if ( ! hash_equals ( $ token_from_key , $ token_from_db ) ) { return false ; } $ this -> db -> qb ( [ 'table' => 'core_users' , 'method' => 'UPDATE' , 'fields' => 'state' , 'filter' => 'id_user=:id_user' , 'params' => [ ':state' => 0 , ':id_user' => $ id_user ] ] , true ) ; $ tokenhandler -> deleteActivationTokenByUserId ( $ id_user ) ; return $ id_user ; }
Actives user by using a key
43,608
public static function redirect ( $ url , $ permanent = false , $ timer = 0 , $ die = true , $ noForceJsRedirect = false ) { if ( headers_sent ( ) ) { if ( $ noForceJsRedirect ) { echo '<script language="javascript" type="text/javascript">window.setTimeout("location=(\'' . $ url . '\');", ' . $ timer . '*1000);</script>' ; echo '<noscript><meta http-equiv="refresh" content="' . $ timer . ';url=' . $ url . '" /></noscript>' ; } } else { if ( $ timer != 0 ) header ( 'refresh: ' . $ timer . ';location=' . $ url ) ; else header ( 'location:' . $ url ) ; if ( $ permanent ) header ( 'Status: 301 Moved Permanently' , false , 301 ) ; } if ( $ die ) exit ( ) ; }
Redirection to another url . With Javascript if header was alreadry send
43,609
protected static function _getDataFromArray ( & $ array , $ key = false , $ default = null , $ allowHtmlTags = false ) { if ( $ key === null ) return ! $ allowHtmlTags ? self :: _secure ( $ array , $ allowHtmlTags ) : $ array ; else { if ( ! array_key_exists ( $ key , $ array ) ) return $ default ; return ! $ allowHtmlTags ? self :: _secure ( $ array [ $ key ] , $ allowHtmlTags ) : $ array [ $ key ] ; } }
Get a data from a reference array
43,610
protected static function _secure ( $ value , $ allowHtmlTags ) { if ( is_array ( $ value ) ) { foreach ( $ value as & $ v ) $ v = self :: _secure ( $ v , $ allowHtmlTags ) ; } elseif ( is_string ( $ value ) ) $ value = htmlspecialchars ( strip_tags ( $ value , ( ( is_string ( $ allowHtmlTags ) && ! empty ( $ allowHtmlTags ) ) ? $ allowHtmlTags : null ) ) , ENT_QUOTES ) ; return $ value ; }
Secure a value remove all or allow html tags
43,611
public function add_pickup_windowAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ hub = $ this -> getRepo ( 'Profile' ) -> find ( $ id ) ; $ seller = $ this -> getUser ( ) -> getCurrentProfile ( ) ; if ( ! $ hub ) { throw $ this -> createNotFoundException ( 'No hub found for id ' . $ id ) ; } $ sellerHubRef = $ this -> getRepo ( 'SellerHubRef' ) -> findOneBySellerAndHub ( $ seller , $ hub ) ; if ( ! $ sellerHubRef ) { throw $ this -> createNotFoundException ( 'No SellerHubRef found for Seller/Hub combination' ) ; } $ pickupWindow = new SellerHubPickupWindow ( ) ; $ pickupWindow -> setSellerHubRef ( $ sellerHubRef ) ; $ form = $ this -> createForm ( new SellerHubPickupWindowType ( ) , $ pickupWindow ) ; if ( $ request -> getMethod ( ) == 'POST' ) { $ form -> bindRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getEntityManager ( ) ; $ em -> persist ( $ pickupWindow ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'Seller_hub_show' , array ( 'id' => $ hub -> getId ( ) , ) ) ) ; } } return $ this -> render ( 'HarvestCloudCoreBundle:Seller/SellerHubRef:add_pickup_window.html.twig' , array ( 'hub' => $ hub , 'form' => $ form -> createView ( ) , ) ) ; }
add pickup window
43,612
final public function get ( string $ type ) : object { if ( $ this -> supports ( $ type ) ) { $ ret = $ this -> getObject ( $ type ) ; if ( $ ret instanceof $ type ) { return $ ret ; } throw new TypeError ; } throw new UnavailableTypeException ; }
Get an object of the type .
43,613
public function headers ( ) { $ headers = [ ] ; foreach ( $ this -> headers as $ header ) { $ headers [ $ header -> name ( ) ] = $ header -> value ( ) ; } return $ headers ; }
Get header values
43,614
public function onFlush ( OnFlushEventArgs $ eventArgs ) { $ em = $ eventArgs -> getEntityManager ( ) ; $ uow = $ em -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityInsertions ( ) as $ entity ) { $ this -> debug ( 'Inserting entity ' . get_class ( $ entity ) . '. Fields: ' . json_encode ( $ uow -> getEntityChangeSet ( $ entity ) ) ) ; } foreach ( $ uow -> getScheduledEntityUpdates ( ) as $ entity ) { $ add = '' ; if ( method_exists ( $ entity , '__toString' ) ) { $ add = ' ' . $ entity -> __toString ( ) ; } elseif ( method_exists ( $ entity , 'getId' ) ) { $ add = ' with id ' . $ entity -> getId ( ) ; } $ this -> debug ( 'Updating entity ' . get_class ( $ entity ) . $ add . '. Data: ' . json_encode ( $ uow -> getEntityChangeSet ( $ entity ) ) ) ; } foreach ( $ uow -> getScheduledEntityDeletions ( ) as $ entity ) { $ add = '' ; if ( method_exists ( $ entity , '__toString' ) ) { $ add = ' ' . $ entity -> __toString ( ) ; } elseif ( method_exists ( $ entity , 'getId' ) ) { $ add = ' with id ' . $ entity -> getId ( ) ; } $ this -> debug ( 'Deleting entity ' . get_class ( $ entity ) . $ add . '.' ) ; } }
Logs the entity changes
43,615
public function setLimit ( $ limit ) { if ( ! isset ( $ this -> _persistence ) || ! ( $ this -> _persistence instanceof IPersistance ) ) { throw new Exception ( "Repository Exception : No existe la interfaz de la persistencia o no implementa la interfaz IPersistance." ) ; } $ this -> _persistence -> setLimit ( $ limit ) ; return $ this ; }
Setea el limite para efectuar en las operaciones de lectura
43,616
public function setPage ( PageDataModel $ pageModel ) { $ pageModel -> setModified ( new \ DateTime ( ) ) -> setEntityManager ( $ this ) -> save ( ) ; return true ; }
Set Page .
43,617
public function getPage ( $ stub ) { $ this -> logger -> addNotice ( print_r ( $ this -> cfg -> getAll ( ) , 1 ) ) ; $ stmtManager = $ this -> getStatementManager ( Simple :: class ) ; $ stmtBuilder = $ stmtManager -> getStatementBuilder ( Select :: class ) ; $ collection = $ stmtManager -> setStatement ( $ stmtBuilder -> setWhere ( [ 'stub = :stub' ] ) ) -> setArguments ( [ 'stub' => $ stub ] ) -> execute ( ) ; $ c = $ collection -> current ( ) ; return $ c ; }
Get Page .
43,618
public function getPages ( ECParams $ params ) { $ stmtManager = $ this -> getStatementManager ( Simple :: class ) ; $ stmtBuilder = $ stmtManager -> getStatementBuilder ( Select :: class ) ; $ collection = $ stmtManager -> setStatement ( $ stmtBuilder -> setColumns ( [ 'stub' ] ) ) -> execute ( ) ; return $ collection -> setEcParams ( $ params ) ; }
Get all Pages .
43,619
public function output ( ) { $ data = [ 'classes' => [ ] , 'files' => [ ] , ] ; foreach ( $ this -> processed as $ type => $ classes ) { foreach ( $ classes as $ name => $ values ) { $ covered = $ values [ 'covered' ] ; $ total = $ values [ 'total' ] ; $ pct = ( ( ( int ) $ covered / ( int ) $ total ) * 100 ) ; $ covered = str_pad ( ( string ) $ covered , 7 , ' ' , STR_PAD_LEFT ) ; $ total = str_pad ( ( string ) $ total , 5 , ' ' , STR_PAD_LEFT ) ; $ percentage = number_format ( $ pct , 2 ) . '%' ; $ percentage = str_pad ( ( string ) $ percentage , 10 , ' ' , STR_PAD_LEFT ) ; if ( $ pct < 25 ) { $ covered = $ this -> output -> red ( $ covered ) ; $ total = $ this -> output -> red ( $ total ) ; $ percentage = $ this -> output -> red ( $ percentage ) ; } if ( $ pct < 75 ) { $ covered = $ this -> output -> black -> yellow ( $ covered ) ; $ total = $ this -> output -> black -> yellow ( $ total ) ; $ percentage = $ this -> output -> black -> yellow ( $ percentage ) ; } if ( $ pct >= 75 ) { $ covered = $ this -> output -> green ( $ covered ) ; $ total = $ this -> output -> green ( $ total ) ; $ percentage = $ this -> output -> green ( $ percentage ) ; } $ data [ $ type ] [ ] = [ $ name , $ covered , $ total , $ percentage ] ; } } $ out = [ ] ; if ( count ( $ data [ 'classes' ] ) > 0 ) { array_unshift ( $ data [ 'classes' ] , [ 'Class' , 'Covered' , 'Lines' , 'Percentage' ] ) ; $ out [ ] = new Table ( $ data [ 'classes' ] , [ 'headerColor' => Graphite :: YELLOW , 'columnSeparator' => '' , 'headerSeparator' => '' , 'cellPadding' => 1 , ] ) ; } if ( count ( $ data [ 'files' ] ) > 0 ) { array_unshift ( $ data [ 'files' ] , [ 'File' , 'Covered' , 'Lines' , 'Percentage' ] ) ; $ out [ ] = new Table ( $ data [ 'files' ] , [ 'headerColor' => Graphite :: YELLOW , 'columnSeparator' => '' , 'headerSeparator' => '' , 'cellPadding' => 1 , ] ) ; } return $ this -> output -> render ( implode ( "\n\n" , $ out ) ) ; }
Output the coverage tables .
43,620
private function isCovered ( $ file ) { return in_array ( $ file , $ this -> includedFiles ) && ! in_array ( $ file , $ this -> excludedFiles ) && isset ( $ this -> covered [ $ file ] ) ; }
Check if a file should be included in coverage calculations .
43,621
private function processRawData ( ) { $ data = xdebug_get_code_coverage ( ) ; $ processed = [ 'classes' => [ ] , 'files' => [ ] , ] ; foreach ( $ data as $ file => $ lines ) { if ( $ this -> isCovered ( $ file ) ) { $ filter = function ( $ value , $ line = null ) { return $ value !== self :: DEAD ; } ; $ executable = array_filter ( $ lines , $ filter ) ; $ object = $ this ; $ filter = function ( $ value , $ line ) use ( $ object , $ file ) { if ( in_array ( $ line , $ object -> covered [ $ file ] ) ) { return $ value === 1 ; } } ; $ covered = array_filter ( $ lines , $ filter , ARRAY_FILTER_USE_BOTH ) ; $ coverage = [ 'covered' => count ( $ covered ) , 'total' => count ( $ executable ) , ] ; if ( $ class = $ this -> getClassForFile ( $ file ) ) { $ processed [ 'classes' ] [ $ class ] = $ coverage ; continue ; } $ name = str_replace ( $ this -> runner -> pwd . '/' , '' , $ file ) ; $ processed [ 'files' ] [ $ name ] = $ coverage ; } } return $ this -> processed = $ processed ; }
Process the raw coverage data .
43,622
public static function createUOID ( $ gid = NULL , $ id = NULL ) { if ( $ gid == NULL ) $ gid = Sonic :: getContextGlobalID ( ) ; if ( $ id == NULL ) $ id = Random :: getUniqueRandom ( ) ; $ uoid = $ gid . UOID :: SEPARATOR . $ id ; return $ uoid ; }
Creates a new UOID for the current Sonic context
43,623
public static function isValid ( $ uoid ) { $ uoid = explode ( UOID :: SEPARATOR , $ uoid ) ; if ( count ( $ uoid ) != 2 ) return false ; if ( ! GID :: isValid ( $ uoid [ 0 ] ) ) return false ; if ( ! preg_match ( "/^[a-zA-Z0-9]+$/" , $ uoid [ 1 ] ) || strlen ( $ uoid [ 1 ] ) != 16 ) { return false ; } return true ; }
Verifies if a given UOID is valid
43,624
private function AddArticlePageSelector ( ) { $ name = 'ArticlePage' ; $ this -> articlePageSelector = new PageSelector ( $ name , Trans ( $ this -> Label ( $ name ) ) , $ this -> articleList -> GetArticlePage ( ) ) ; $ this -> articlePageSelector -> SetSite ( $ this -> Page ( ) -> GetSite ( ) ) ; $ this -> Elements ( ) -> AddElement ( $ name , $ this -> articlePageSelector ) ; }
Adds the article page selector element
43,625
protected function SaveElement ( ) { $ this -> articleList -> SetArticlePage ( $ this -> articlePageSelector -> GetPage ( ) ) ; $ archiveCat = explode ( '-' , $ this -> Value ( 'ArchiveCategory' ) ) ; $ this -> CleanPageArticleLists ( ) ; if ( count ( $ archiveCat ) == 1 ) { $ this -> SaveArchivePage ( $ archiveCat [ 0 ] ) ; } else if ( count ( $ archiveCat ) == 2 ) { $ this -> SaveCategoryPage ( $ archiveCat [ 1 ] ) ; } return $ this -> articleList ; }
Saves article list and attaches current page to chosen archive or category
43,626
private function SaveArchivePage ( $ archiveID ) { $ archive = Archive :: Schema ( ) -> ByID ( $ archiveID ) ; if ( $ archive ) { $ archive -> SetPage ( $ this -> Page ( ) ) ; $ archive -> Save ( ) ; } }
Sets the current page to the chosen archive if no category chosen
43,627
private function SaveCategoryPage ( $ categoryID ) { $ category = Category :: Schema ( ) -> ByID ( $ categoryID ) ; if ( $ category ) { $ category -> SetPage ( $ this -> Page ( ) ) ; $ category -> Save ( ) ; } }
Sets the current page tor the chosen category if no archive chosen
43,628
public static function inProperty ( string $ name , DeserializesCollections $ collection , Deserializes $ item , string $ key = 'key' ) : MapsProperty { return new self ( $ name , $ collection , $ item , $ key ) ; }
Creates a new embedded has - many mapping .
43,629
protected function _configure ( ) { $ this -> config = new Core \ Configuration ( ) ; define ( "CHICKENWIRE_PATH" , dirname ( __FILE__ ) ) ; define ( "APP_PATH" , APP_ROOT . "/Application" ) ; define ( "CONFIG_PATH" , APP_PATH . "/Config" ) ; define ( "CONTROLLER_PATH" , APP_PATH . "/Controllers" ) ; define ( "LAYOUT_PATH" , APP_PATH . "/Layouts" ) ; define ( "MODEL_PATH" , APP_PATH . "/Models" ) ; define ( "VIEW_PATH" , APP_PATH . "/Views" ) ; define ( "PUBLIC_PATH" , APP_PATH . "/Public" ) ; define ( "MODULE_PATH" , APP_ROOT . "/Modules" ) ; define ( "MODEL_NS" , $ this -> config -> applicationNamespace . "\\Models" ) ; $ dh = opendir ( CONFIG_PATH ) ; $ configFiles = scandir ( CONFIG_PATH , SCANDIR_SORT_ASCENDING ) ; foreach ( $ configFiles as $ file ) { if ( preg_match ( "/\.php$/" , $ file ) ) { $ this -> config -> load ( CONFIG_PATH . '/' . $ file ) ; } } $ dbConnections = $ this -> config -> allFor ( "database" ) ; $ environment = $ this -> config -> environment ; \ ActiveRecord \ Config :: initialize ( function ( $ config ) use ( $ dbConnections , $ environment ) { $ config -> setModelDirectory ( MODEL_PATH ) ; $ config -> setConnections ( $ dbConnections ) ; $ config -> setDefaultConnection ( $ environment ) ; } ) ; if ( $ this -> config -> timezone == '' ) { throw new \ Exception ( "You need to specify the timezone in the Application configuration." , 1 ) ; } date_default_timezone_set ( $ this -> config -> timezone ) ; \ HtmlObject \ Traits \ Tag :: $ useSelfClosingSlash = $ this -> config -> htmlSelfClosingSlash ; $ this -> config -> webPath = rtrim ( $ this -> config -> webPath , ' /' ) ; }
Load and apply configuration files
43,630
protected function _loadModules ( ) { $ dh = opendir ( MODULE_PATH ) ; while ( false !== ( $ filename = readdir ( $ dh ) ) ) { if ( is_dir ( MODULE_PATH . "/" . $ filename ) && ! preg_match ( '/^\./' , $ filename ) ) { Module :: load ( $ filename ) ; } } }
Load all modules in the Modules directory
43,631
public function set ( $ path = null , $ value = null ) { if ( $ path === null ) { $ this -> data = $ value ; return $ this ; } $ at = & $ this -> data ; $ keys = explode ( "." , $ path ) ; $ keyCount = count ( $ keys ) ; for ( $ i = 0 ; $ i < $ keyCount ; $ i ++ ) { if ( ( $ keyCount - 1 ) === $ i ) { if ( is_array ( $ at ) ) { $ at [ $ keys [ $ i ] ] = $ value ; } else { throw new \ RuntimeException ( "Can not set value at this path ($path) because is not array." ) ; } } else { $ key = $ keys [ $ i ] ; if ( ! isset ( $ at [ $ key ] ) ) { $ at [ $ key ] = [ ] ; } $ at = & $ at [ $ key ] ; } } return $ this ; }
Set new key for data this can also ovewrite existing data
43,632
public function get ( $ key = null , $ default = null ) { $ return = $ this -> data ; if ( $ key !== null ) { $ keys = explode ( '.' , $ key ) ; foreach ( $ keys as $ key ) { if ( isset ( $ return [ ( string ) $ key ] ) ) { $ return = $ return [ $ key ] ; } else { $ return = $ default ; break ; } } } return $ return ; }
Get value assigned for key
43,633
protected function makePhar ( ) { $ phar = new Phar ( $ this -> filePhar , 0 , $ this -> alias ) ; $ phar -> setSignatureAlgorithm ( \ Phar :: SHA1 ) ; $ phar -> startBuffering ( ) ; $ this -> addFiles ( $ phar ) ; $ this -> addBinFile ( $ phar ) ; $ this -> addStub ( $ phar ) ; $ this -> addLicence ( $ phar ) ; $ phar -> stopBuffering ( ) ; unset ( $ phar ) ; }
Gerar arquivo PHAR .
43,634
protected function makeBat ( ) { $ content = $ this -> files -> get ( __DIR__ . '/../stubs/bat.stub' ) ; $ content = str_replace ( 'DubbyAlias' , $ this -> alias , $ content ) ; $ this -> files -> put ( $ this -> fileBat , $ content ) ; }
Gerar arquivo BAT .
43,635
protected function resetPhar ( ) { if ( $ this -> files -> exists ( $ this -> filePhar ) ) { $ this -> files -> delete ( $ this -> filePhar ) ; } if ( $ this -> files -> exists ( $ this -> fileBat ) ) { $ this -> files -> delete ( $ this -> fileBat ) ; } }
Reiniciar arquivos compilados .
43,636
public function setName ( $ name ) { $ this -> name = $ name ; $ this -> alias = $ name . '.phar' ; $ this -> filePhar = $ this -> files -> combine ( $ this -> pathBase , $ this -> alias ) ; $ this -> fileBat = $ this -> files -> combine ( $ this -> pathBase , $ name . '.bat' ) ; }
Set name app .
43,637
public function addFiles ( Phar $ phar ) { $ finder = new Finder ( ) ; $ finder -> files ( ) -> ignoreVCS ( true ) -> name ( '*.php' ) -> name ( '*.stub' ) -> exclude ( 'Tests' ) -> exclude ( 'tests' ) -> exclude ( '/storage' ) -> exclude ( '/config' ) -> exclude ( '/build' ) -> in ( $ this -> pathBase ) ; foreach ( $ finder as $ file ) { $ this -> addFile ( $ phar , $ file ) ; } }
Adicionar arquivos .
43,638
private function addFile ( Phar $ phar , SplFileInfo $ file , $ strip = false ) { $ strip = ( $ file -> getExtension ( ) == 'php' ) ? true : $ strip ; $ this -> fireEvent ( $ file -> getRealPath ( ) ) ; $ path = str_replace ( $ this -> pathBase , '' , $ file -> getRealPath ( ) ) ; $ content = $ this -> files -> get ( $ file ) ; if ( $ strip ) { $ content = $ this -> stripWhitespace ( $ content ) ; } if ( 'LICENSE' === basename ( $ file ) ) { $ content = "\n" . $ content . "\n" ; } foreach ( $ this -> params as $ pk => $ pv ) { $ pk = sprintf ( '@%s@' , $ pk ) ; $ content = str_replace ( $ pk , $ pv , $ content ) ; } $ phar -> addFromString ( $ path , $ content ) ; }
Adicionar arquivo tratado no phar .
43,639
protected function addBinFile ( Phar $ phar ) { $ fileBin = $ this -> files -> combine ( $ this -> pathBase , $ this -> fileNameBin ) ; if ( ! $ this -> files -> exists ( $ fileBin ) ) { return ; } $ this -> fireEvent ( 'BIN: file main' ) ; $ content = $ this -> files -> get ( $ fileBin ) ; $ content = preg_replace ( '{^#!/usr/bin/env php\s*}' , '' , $ content ) ; $ phar -> addFromString ( 'artisan' , $ content ) ; }
Adicionar arquivo BIN .
43,640
protected function addStub ( Phar $ phar ) { $ this -> fireEvent ( 'STUB' ) ; $ defineTime = '' ; if ( array_key_exists ( 'package_version' , $ this -> params ) ) { $ warningTime = time ( ) + 30 * 86400 ; $ defineTime = "define('PHAR_DEV_WARNING_TIME', $warningTime);\n" ; } $ content = $ this -> files -> get ( __DIR__ . '/../stubs/compile.stub' ) ; $ content = str_replace ( 'DubbyAlias' , $ this -> alias , $ content ) ; $ content = str_replace ( 'DubbyDefineDateTime' , $ defineTime , $ content ) ; $ phar -> setStub ( $ content ) ; }
Adicionar Stub .
43,641
protected function addLicence ( Phar $ phar ) { $ file = $ this -> files -> combine ( $ this -> pathBase , 'LICENSE' ) ; if ( ! $ this -> files -> exists ( $ file ) ) { return ; } $ this -> fireEvent ( 'LICENCE' ) ; $ this -> addFile ( $ phar , new SplFileInfo ( $ file ) , false ) ; }
Adicionar arquivo de licenca .
43,642
protected function addUpdateFile ( Phar $ phar ) { $ file = $ this -> files -> combine ( $ this -> pathBase , 'update.json' ) ; if ( $ this -> files -> exists ( $ file ) ) { $ this -> addFile ( $ phar , new SplFileInfo ( $ file ) , false ) ; } }
Adicionar arquivo para update .
43,643
private function stripWhitespace ( $ source ) { if ( ! function_exists ( 'token_get_all' ) ) { return $ source ; } $ output = '' ; foreach ( token_get_all ( $ source ) as $ token ) { if ( is_string ( $ token ) ) { $ output .= $ token ; } elseif ( in_array ( $ token [ 0 ] , [ T_COMMENT , T_DOC_COMMENT ] ) ) { $ output .= str_repeat ( "\n" , substr_count ( $ token [ 1 ] , "\n" ) ) ; } elseif ( T_WHITESPACE === $ token [ 0 ] ) { $ whitespace = preg_replace ( '{[ \t]+}' , ' ' , $ token [ 1 ] ) ; $ whitespace = preg_replace ( '{(?:\r\n|\r|\n)}' , "\n" , $ whitespace ) ; $ whitespace = preg_replace ( '{\n +}' , "\n" , $ whitespace ) ; $ output .= $ whitespace ; } else { $ output .= $ token [ 1 ] ; } } return $ output ; }
Removes whitespace from a PHP source string while preserving line numbers .
43,644
public function findFilterDataBySlug ( Query $ query , array $ options ) { if ( ! isset ( $ options [ 'request' ] ) || get_class ( $ options [ 'request' ] ) !== ServerRequest :: class ) { user_error ( 'The request query option must exist and must be of type Cake\Http\ServerRequest.' ) ; } $ encryptedFilterData = $ this -> _findEncryptedFilterData ( $ query , $ options [ 'request' ] ) -> first ( ) ; if ( $ encryptedFilterData ) { $ encryptedFilterData = $ encryptedFilterData -> toArray ( ) ; return $ this -> _decodeFilterData ( $ encryptedFilterData [ 'filter_data' ] ) ; } return [ ] ; }
Find stored filter data for a given slug .
43,645
public function createFilterForFilterData ( ServerRequest $ request , array $ filterData ) { $ charlist = 'abcdefghikmnopqrstuvwxyz' ; do { $ slug = '' ; for ( $ i = 0 ; $ i < 14 ; $ i ++ ) { $ slug .= substr ( $ charlist , rand ( 0 , 31 ) , 1 ) ; } } while ( $ this -> _slugExists ( $ slug , $ request ) ) ; $ this -> save ( new Filter ( [ 'plugin' => $ request -> getParam ( 'plugin' ) , 'controller' => $ request -> getParam ( 'controller' ) , 'action' => $ request -> getParam ( 'action' ) , 'slug' => $ slug , 'filter_data' => $ this -> _encodeFilterData ( $ filterData ) ] ) ) ; return $ slug ; }
Create a new filter entry for the given request and filter data .
43,646
protected function _pluginCondition ( ServerRequest $ request ) { if ( $ request -> getParam ( 'plugin' ) !== null ) { return [ $ this -> getAlias ( ) . '.plugin' => $ request -> getParam ( 'plugin' ) ] ; } return [ $ this -> getAlias ( ) . '.plugin IS NULL' ] ; }
Get the plugin query condition for a given request .
43,647
protected function _slugExists ( $ slug , ServerRequest $ request ) { $ existingSlug = $ this -> find ( 'all' ) -> select ( $ this -> getAlias ( ) . '.slug' ) -> where ( [ $ this -> getAlias ( ) . '.slug' => $ slug , $ this -> getAlias ( ) . '.controller' => $ request -> getParam ( 'controller' ) , $ this -> getAlias ( ) . '.action' => $ request -> getParam ( 'action' ) ] ) -> where ( $ this -> _pluginCondition ( $ request ) ) -> enableHydration ( false ) -> first ( ) ; return $ existingSlug !== null ; }
Check if a slug for the given request params already exists .
43,648
protected function _findEncryptedFilterData ( Query $ query , ServerRequest $ request ) { return $ query -> select ( $ this -> getAlias ( ) . '.filter_data' ) -> where ( [ $ this -> getAlias ( ) . '.controller' => $ request -> getParam ( 'controller' ) , $ this -> getAlias ( ) . '.action' => $ request -> getParam ( 'action' ) , $ this -> getAlias ( ) . '.slug' => $ request -> getParam ( 'sluggedFilter' ) ] ) -> where ( $ this -> _pluginCondition ( $ request ) ) ; }
Find encrypted filter data for the given request and the provided sluggedFilter .
43,649
private function determineMethod ( array $ server ) : string { $ mapping = [ 'GET' => self :: METHOD_GET , 'POST' => self :: METHOD_POST , 'PUT' => self :: METHOD_PUT , 'PATCH' => self :: METHOD_PATCH , 'DELETE' => self :: METHOD_DELETE , 'HEAD' => self :: METHOD_HEAD , 'OPTIONS' => self :: METHOD_OPTIONS , 'CONNECT' => self :: METHOD_CONNECT , 'TRACE' => self :: METHOD_TRACE ] ; $ method = $ server [ 'REQUEST_METHOD' ] ; if ( array_key_exists ( $ method , $ mapping ) ) { return $ mapping [ $ method ] ; } return self :: METHOD_GET ; }
Determines the used method by using passed server configuration .
43,650
private function determineHeader ( array $ server ) : MapInterface { $ header = new Map ( ) ; foreach ( $ server as $ name => $ value ) { if ( strpos ( $ name , 'HTTP_' ) === 0 ) { $ name = substr ( $ name , 5 ) ; $ name = explode ( '_' , $ name ) ; $ name = array_map ( 'strtolower' , $ name ) ; $ name = array_map ( 'ucfirst' , $ name ) ; $ name = implode ( '-' , $ name ) ; $ header -> set ( $ name , $ value ) ; } } return new ReadOnlyMap ( $ header ) ; }
Determines the header by using passed server configuration .
43,651
private function determinePath ( array $ server ) : string { $ path = '' ; if ( strpos ( $ server [ 'SCRIPT_NAME' ] , 'index.php' ) !== false ) { $ path = str_replace ( 'index.php' , '' , $ server [ 'SCRIPT_NAME' ] ) ; } $ parts = explode ( '?' , $ server [ 'REQUEST_URI' ] ) ; $ length = 0 ; if ( $ path !== '' && strpos ( $ parts [ 0 ] , $ path ) === 0 ) { $ length = strlen ( $ path ) ; } return '/' . ltrim ( substr ( $ parts [ 0 ] , $ length ) , '/' ) ; }
Determines the used path by using passed server configuration .
43,652
private function determineRemoteIpAddress ( array $ server ) : string { if ( array_key_exists ( 'HTTP_X_FORWARDED_FOR' , $ server ) && filter_var ( $ server [ 'HTTP_X_FORWARDED_FOR' ] , FILTER_VALIDATE_IP ) ) { return $ server [ 'HTTP_X_FORWARDED_FOR' ] ; } elseif ( array_key_exists ( 'HTTP_CLIENT_IP' , $ server ) && filter_var ( $ server [ 'HTTP_CLIENT_IP' ] , FILTER_VALIDATE_IP ) ) { return $ server [ 'HTTP_CLIENT_IP' ] ; } elseif ( array_key_exists ( 'HTTP_TRUE_CLIENT_IP' , $ server ) && filter_var ( $ server [ 'HTTP_TRUE_CLIENT_IP' ] , FILTER_VALIDATE_IP ) ) { return $ server [ 'HTTP_TRUE_CLIENT_IP' ] ; } return $ server [ 'REMOTE_ADDR' ] ; }
Determines the remote ip address by using passed server configuration .
43,653
private function narrowArray ( array $ array , string $ key = null ) { if ( $ key ) { $ key .= '--' ; } $ result = [ ] ; foreach ( $ array as $ index => $ value ) { if ( is_array ( $ value ) ) { $ result = array_merge ( $ result , $ this -> narrowArray ( $ value , $ key . $ index ) ) ; } else { $ result [ $ key . $ index ] = $ value ; } } return $ result ; }
Narrows PHP s native nested map into a non - nested map .
43,654
public function Index ( $ Module , $ AppFolder = '' , $ DeliveryType = '' ) { if ( ! $ DeliveryType ) $ this -> DeliveryType ( DELIVERY_TYPE_VIEW ) ; $ ModuleClassExists = class_exists ( $ Module ) ; if ( $ ModuleClassExists ) { $ ReflectionClass = new ReflectionClass ( $ Module ) ; if ( $ ReflectionClass -> implementsInterface ( "Gdn_IModule" ) ) { if ( $ AppFolder ) { $ this -> ApplicationFolder = $ AppFolder ; } else { $ Filename = str_replace ( '\\' , '/' , substr ( $ ReflectionClass -> getFileName ( ) , strlen ( PATH_ROOT ) ) ) ; $ Parts = explode ( '/' , trim ( $ Filename , '/' ) ) ; if ( $ Parts [ 0 ] == 'applications' ) { $ this -> ApplicationFolder = $ Parts [ 1 ] ; } } $ ModuleInstance = new $ Module ( $ this ) ; $ ModuleInstance -> Visible = TRUE ; $ WhiteList = array ( 'Limit' , 'Help' ) ; foreach ( $ this -> Request -> Get ( ) as $ Key => $ Value ) { if ( in_array ( $ Key , $ WhiteList ) ) { $ ModuleInstance -> $ Key = $ Value ; } } $ this -> SetData ( '_Module' , $ ModuleInstance ) ; $ this -> Render ( 'Index' , FALSE , 'dashboard' ) ; return ; } } throw NotFoundException ( $ Module ) ; }
Creates and renders an instance of a module .
43,655
public function replace ( $ patternName , Siteroot $ siteroot , ElementVersion $ elementVersion , $ language ) { if ( ! isset ( $ this -> patterns [ $ patternName ] ) ) { $ pattern = '%p' ; } else { $ pattern = $ this -> patterns [ $ patternName ] ; } return $ this -> replacePattern ( $ pattern , $ siteroot , $ elementVersion , $ language ) ; }
Resolved page title by configured pattern .
43,656
public function replacePattern ( $ pattern , Siteroot $ siteroot , ElementVersion $ elementVersion , $ language ) { $ replace = [ '%s' => $ siteroot -> getTitle ( ) , '%b' => $ elementVersion -> getBackendTitle ( $ language ) , '%p' => $ elementVersion -> getPageTitle ( $ language ) , '%n' => $ elementVersion -> getNavigationTitle ( $ language ) , '%r' => $ this -> projectTitle , ] ; return str_replace ( array_keys ( $ replace ) , array_values ( $ replace ) , $ pattern ) ; }
Resolve page title by pattern .
43,657
public function handle ( Client $ client , $ index , $ alias , $ replace = false ) { $ client -> getIndex ( $ index ) -> addAlias ( $ alias , $ replace ) ; }
Handle add alias command
43,658
private function getModuleSortCallback ( ) { return function ( ModuleInterface $ left , ModuleInterface $ right ) { return strcmp ( $ left -> getName ( ) , $ right -> getName ( ) ) ; } ; }
Callback to sort the Modules by name .
43,659
protected function validate ( ) { $ this -> isValid = true ; foreach ( $ this -> getWritableBearer ( ) -> getWritables ( ) as $ name => $ writable ) { if ( $ writable instanceof FieldInterface ) { $ writable -> validate ( ) ; } } foreach ( $ this -> getWritableBearer ( ) -> getWritables ( ) as $ name => $ writable ) { if ( array_key_exists ( $ name , $ this -> validators ) === true ) { foreach ( $ this -> validators [ $ name ] as $ validator ) { call_user_func_array ( $ validator , [ $ writable , $ this ] ) ; } } } foreach ( $ this -> getWritableBearer ( ) -> getWritables ( ) as $ name => $ writable ) { if ( $ writable instanceof FieldInterface && $ writable -> isValid ( ) === false ) { $ this -> isValid = false ; $ this -> addError ( "Please correct the indicated errors and resubmit the form." ) ; break ; } } foreach ( $ this -> getWritableBearer ( ) -> getWritables ( ) as $ writable ) { if ( $ writable instanceof FormInterface ) { if ( $ writable -> isValid ( ) === false && $ this -> isValid === true ) { $ this -> isValid = false ; $ this -> addError ( "Please correct the indicated errors and resubmit the form." ) ; } } } if ( $ this -> errors !== [ ] ) { $ this -> isValid = false ; } }
Determine whether the form is valid .
43,660
public static function create ( array $ data ) : League { $ league = new League ( ) ; parent :: fill ( $ data , $ league ) ; return $ league ; }
Creates a league object with the given data
43,661
public function field_count ( ) { if ( $ this -> statement ) { return $ this -> statement -> field_count ; } if ( ! $ this -> mysqli_result ) { return false ; } return $ this -> mysqli_result -> field_count ; }
Returns the number of the fields in the result of the last retrieving query .
43,662
public function hasPermissionForId ( $ id ) { try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ permission = $ em -> getRepository ( '\\Zepi\\Core\\AccessControl\\Entity\\Permission' ) -> find ( $ id ) ; if ( $ permission !== null ) { return true ; } return false ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot check if there is a permission for the given id "' . $ id . '".' , 0 , $ e ) ; } }
Returns true if there is a permission for the given id
43,663
public function hasAccess ( $ accessEntityUuid , $ accessLevel ) { if ( $ accessEntityUuid == '' || $ accessLevel == '' ) { return false ; } try { $ queryBuilder = $ this -> entityManager -> getQueryBuilder ( ) ; $ queryBuilder -> select ( $ queryBuilder -> expr ( ) -> count ( 'p.id' ) ) -> from ( '\\Zepi\\Core\\AccessControl\\Entity\\Permission' , 'p' ) -> where ( 'p.accessEntityUuid = :accessEntityUuid' ) -> andWhere ( 'p.accessLevelKey = :accessLevel' ) -> setParameter ( 'accessEntityUuid' , $ accessEntityUuid ) -> setParameter ( 'accessLevel' , $ accessLevel ) ; $ data = $ queryBuilder -> getQuery ( ) ; if ( $ data === false ) { return false ; } return ( $ data -> getSingleScalarResult ( ) > 0 ) ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot verify the permission for uuid "' . $ accessEntityUuid . '" and access level "' . $ accessLevel . '".' , 0 , $ e ) ; } }
Returns true if the given access entity uuid has already access to the access level
43,664
public function getPermissionsRawForUuid ( $ accessEntityUuid ) { if ( $ accessEntityUuid == '' ) { return array ( ) ; } try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ permissions = $ em -> getRepository ( '\\Zepi\\Core\\AccessControl\\Entity\\Permission' ) -> findBy ( array ( 'accessEntityUuid' => $ accessEntityUuid ) ) ; $ accessLevels = array ( ) ; foreach ( $ permissions as $ permission ) { $ accessLevels [ ] = $ permission -> getAccessLevelKey ( ) ; } return $ accessLevels ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot load the permission for the given uuid "' . $ accessEntityUuid . '".' , 0 , $ e ) ; } }
Returns an array with all granted access levels for the given access entity uuid whithout resolving the group access levels .
43,665
public function getPermissionsForUuid ( $ accessEntityUuid ) { if ( $ accessEntityUuid == '' ) { return array ( ) ; } try { $ accessLevels = $ this -> getPermissionsRawForUuid ( $ accessEntityUuid ) ; $ accessLevels = $ this -> runtimeManager -> executeFilter ( '\\Zepi\\Core\\AccessControl\\Filter\\PermissionsBackend\\ResolvePermissions' , $ accessLevels ) ; return $ accessLevels ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot load the permission for the given uuid "' . $ accessEntityUuid . '".' , 0 , $ e ) ; } }
Returns an array with all granted access levels for the given access entity uuid
43,666
public function revokePermissions ( $ accessLevel ) { if ( $ accessLevel == '' ) { return false ; } try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ permissions = $ em -> getRepository ( '\\Zepi\\Core\\AccessControl\\Entity\\Permission' ) -> findBy ( array ( 'accessLevelKey' => $ accessLevel ) ) ; foreach ( $ permissions as $ permission ) { $ em -> remove ( $ permission ) ; } $ em -> flush ( ) ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot revoke the access levels "' . $ accessLevel . '".' , 0 , $ e ) ; } }
Revokes the permission for the given access level .
43,667
protected function prepare ( ) { $ active = app ( 'antares.memory' ) -> get ( "extensions.active" ) ; $ memory = app ( 'antares.memory' ) -> make ( 'tests' ) ; $ tests = $ memory -> all ( ) ; $ return = [ ] ; foreach ( $ tests as $ index => $ data ) { if ( ! isset ( $ data [ 'executor' ] ) ) { $ memory -> forget ( $ index ) ; continue ; } try { $ reflection = new ReflectionClass ( $ data [ 'executor' ] ) ; if ( ! $ reflection -> hasMethod ( 'addTestButton' ) ) { throw new Exception ( 'Form Configuration is invalid. Form with test must contains Testable Trait.' ) ; } } catch ( Exception $ e ) { Log :: emergency ( $ e ) ; $ memory -> forget ( $ index ) ; continue ; } $ name = $ data [ 'component' ] ; $ fullName = isset ( $ active [ $ name ] ) ? $ active [ $ name ] [ 'full_name' ] : 'Foundation' ; $ return [ $ fullName ] [ $ data [ 'name' ] ] [ $ index ] = $ data ; } $ memory -> finish ( ) ; return $ return ; }
script prepare before round robin launch
43,668
protected function removeHeader ( $ name ) { if ( ! $ this -> hasHeader ( $ name ) ) { return false ; } $ value = $ this -> getHeader ( $ name ) ; unset ( $ this -> headers [ $ name ] ) ; return $ value ; }
Remove a item of header
43,669
public function add ( $ query , $ resource , array $ meta = [ ] ) { $ query = static :: clean ( $ query ) ; list ( $ method , $ uri ) = explode ( ' ' , $ query ) ; $ this -> routes [ $ query ] = new Route ( $ method , $ uri , $ resource , $ meta ) ; return $ this ; }
Add route definition
43,670
public function parse ( $ class , array $ meta = [ ] ) { $ methods = get_class_methods ( $ class ) ; foreach ( $ methods as $ method ) { $ query = Annotation :: ofMethod ( $ class , $ method , 'uri' ) ; if ( $ query ) { $ this -> add ( $ query , [ $ class , $ method ] , $ meta ) ; } } return $ this ; }
Parse class methods annotation and add route
43,671
public function mount ( $ prefix , RouterInterface $ router , array $ meta = [ ] ) { $ prefix = '/' . trim ( $ prefix , '/' ) ; foreach ( $ router -> routes ( ) as $ route ) { $ route -> uri = $ prefix . $ route -> uri ; $ route -> meta = array_merge ( $ route -> meta , $ meta ) ; $ query = static :: clean ( $ route -> method . ' ' . $ route -> uri ) ; $ this -> routes [ $ query ] = $ route ; } return $ this ; }
Mount router under prefix query
43,672
public function reverse ( $ resource , array $ params = [ ] ) { if ( $ key = array_search ( $ resource , $ this -> routes ) ) { $ route = $ this -> routes [ $ key ] ; $ route -> params = $ params ; return $ route ; } }
Reverse finding by resource
43,673
public function textDomain ( $ textDomain = self :: DEFAULT_TEXT_DOMAIN , $ locale = null ) { $ translator = $ this -> getTranslator ( ) ; $ locale = $ locale ? : $ translator -> getLocale ( ) ; if ( ! isset ( $ translator -> myMessages [ $ textDomain ] [ $ locale ] ) ) { $ translator -> loadMyMessages ( $ textDomain , $ locale ) ; } if ( ! isset ( $ translator -> messages [ $ textDomain ] [ $ locale ] ) ) { $ translator -> loadMessages ( $ textDomain , $ locale ) ; } $ my = $ translator -> myMessages [ $ textDomain ] [ $ locale ] ; $ global = $ translator -> messages [ $ textDomain ] [ $ locale ] ; if ( $ my instanceof TextDomain ) { $ my = $ my -> getArrayCopy ( ) ; } else if ( empty ( $ my ) ) { $ my = array ( ) ; } if ( $ global instanceof TextDomain ) { $ global = $ global -> getArrayCopy ( ) ; } else if ( empty ( $ global ) ) { $ global = array ( ) ; } return array_replace ( $ global , $ my ) ; }
Get a whole text - domain
43,674
public function searchAll ( $ filter , array $ attributes = [ ] ) { $ ldap = $ this -> getResource ( ) ; ldap_set_option ( $ ldap , LDAP_OPT_PROTOCOL_VERSION , 3 ) ; $ cookie = '' ; $ result = [ ] ; do { ldap_control_paged_result ( $ ldap , self :: PAGE_SIZE , true , $ cookie ) ; Stdlib \ ErrorHandler :: start ( E_WARNING ) ; $ search = ldap_search ( $ ldap , $ this -> getBaseDn ( ) , $ filter , $ attributes ) ; Stdlib \ ErrorHandler :: stop ( ) ; if ( $ search === false ) { throw new Lp \ Exception \ LdapException ( $ this , 'searching: ' . $ filter ) ; } $ entries = $ this -> createCollection ( new Lp \ Collection \ DefaultIterator ( $ this , $ search ) , null ) ; foreach ( $ entries as $ es ) { $ result [ ] = $ es ; } ldap_control_paged_result_response ( $ ldap , $ search , $ cookie ) ; } while ( $ cookie !== null && $ cookie != '' ) ; return $ result ; }
Search LDAP registry for entries matching filter and optional attributes and return ALL values including those beyond the usual 1000 entries as an array .
43,675
public function appendCollectionAttributes ( array $ data , ErrorCollection $ error , string $ format , array $ context ) : array { $ innerError = new ErrorResource ( $ error -> getMessage ( ) , $ error -> getReason ( ) , $ error -> getPath ( ) , $ error -> getAttributes ( ) , $ error -> getIdentifier ( ) ) ; foreach ( $ error -> getRelations ( ) as $ relation ) { $ innerError -> addRelation ( $ relation ) ; } $ normalizedInnerError = $ this -> normalizer -> normalize ( $ innerError , $ format , $ context ) ; return array_merge ( $ normalizedInnerError , $ data ) ; }
Append collection attributes to
43,676
public function addSingleton ( string $ name , $ singleton ) : self { $ name = Str :: studly ( $ name ) ; if ( isset ( $ this -> ci [ $ name ] ) ) { throw new \ InvalidArgumentException ( "Duplicated class name '{$name}' for singleton instance object" ) ; } $ this -> ci [ $ name ] = $ singleton ; return $ this ; }
Add new singleton
43,677
public function get ( bool $ isRawUrl = false ) : string { if ( $ this -> sourceChanged ) { return $ this -> getAbsolute ( $ isRawUrl ) ; } return $ this -> getRelative ( $ isRawUrl ) ; }
Get the URL contained in this object . May return a relative or absolute URL depending on whether the absolute part has changed .
43,678
public function getConfigurationSources ( ConfigInterface $ conf ) { if ( $ conf -> hasOption ( 'config-file' ) ) { $ file = $ conf -> getOption ( 'config-file' ) ; if ( isset ( $ file ) ) { if ( ! strstr ( $ file , '/' ) ) { $ file = $ conf -> getOption ( 'config-dir' ) . $ file ; } return array ( $ file ) ; } } $ dir = $ conf -> getOption ( 'config-dir' ) ; $ list = glob ( "{$dir}*.xml" , GLOB_ERR ) ; if ( $ list === false ) { throw new IOException ( $ dir , null , "config-dir '$dir' is not readable" , IOException :: FAILURE_NOT_READABLE ) ; } return $ list ; }
Finds the configured configuration sources .
43,679
public function triggerEvent ( $ event , Payload $ payload ) : string { return $ this -> state ( $ payload -> state ( ) ) -> triggerEvent ( $ event , $ payload ) ; }
Trigger event for payload Return next state name
43,680
public function setAttribute ( $ key , $ value ) { $ key = strtolower ( $ key ) ; if ( ! is_array ( $ value ) ) { $ value = [ 'value' => $ value , 'doubleQuote' => true , ] ; } $ this -> attr [ $ key ] = $ value ; return $ this ; }
Set an attribute for this tag .
43,681
public function getAttribute ( $ key ) { if ( ! isset ( $ this -> attr [ $ key ] ) ) { return null ; } $ value = $ this -> attr [ $ key ] [ 'value' ] ; if ( is_string ( $ value ) && ! is_null ( $ this -> encode ) ) { $ this -> attr [ $ key ] [ 'value' ] = $ this -> encode -> convert ( $ value ) ; } return $ this -> attr [ $ key ] ; }
Returns an attribute by the key
43,682
private static function setDefaults ( ) { if ( ! self :: $ defaults ) { self :: $ defaults = [ self :: CFG_CSS_PATH => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'error.min.css' , self :: CFG_TRACE_MAX_DEPTH => 50 , self :: CFG_BACKGROUND => 'default' , self :: CFG_FOREGROUND_NOTICE => 'cyan' , self :: CFG_FOREGROUND_WARNING => 'yellow' , self :: CFG_FOREGROUND_ERROR => 'red' , self :: CFG_FORCE_HTML => false ] ; } }
Sets default config
43,683
function mountById ( $ id ) { $ db = new Db ( ) ; if ( $ this -> where != false || $ this -> where != '' ) { $ where = ' AND ' . $ this -> where ; } $ res = $ db -> query ( 'SELECT * FROM ' . $ this -> table . ' WHERE id = :id ' . $ where , [ ':id' => 0 + $ id ] ) ; if ( isset ( $ res [ 0 ] ) ) { $ this -> load ( $ res [ 0 ] -> getAll ( ) ) ; $ db -> query ( 'UPDATE article SET access = access + 1 WHERE id = ' . $ this -> id ) ; return $ this ; } return false ; }
Mount from DataBase - search by ID
43,684
function requestNew ( ) { $ db = new Db ; $ result = $ db -> query ( 'SELECT MIN(id)id, (SELECT MAX(id+1) FROM article)nid FROM article WHERE status = 6 OR (status = 5 AND editdate <= STR_TO_DATE(\'' . date ( 'Y-m-d H:i:s' , time ( ) - 86400 ) . '\', \'%Y-%m-%d %H:%i:%s\'))' ) ; if ( isset ( $ result [ 0 ] ) ) { $ this -> editdate = date ( 'Y-m-d H:i:s' ) ; $ this -> pubdate = $ this -> editdate ; if ( $ result [ 0 ] -> get ( 'id' ) == null ) { $ this -> id = $ result [ 0 ] -> get ( 'nid' ) ; $ db -> query ( 'INSERT INTO articlecontent SET article = ' . $ this -> id . ', content = "", editdate = "' . $ this -> editdate . '"' ) ; $ db -> query ( 'INSERT INTO article SET id = ' . $ this -> id . ', status = 5, editdate = \'' . $ this -> editdate . '\'' ) ; } else { $ this -> id = $ result [ 0 ] -> get ( 'id' ) ; $ db -> query ( 'UPDATE article SET status = 5, pubdate = \'' . $ this -> pubdate . '\', editdate = \'' . $ this -> editdate . '\', rateup = 0, ratedown = 0, access = 0, link = "", tags = "", title = "", media = "{}", resume = "" WHERE id = ' . $ this -> id . '' ) ; $ db -> query ( 'UPDATE articlecontent SET content = "", editdate = \'' . $ this -> editdate . '\' WHERE article = ' . $ this -> id . '' ) ; } $ this -> clearDir ( ) ; return $ this ; } return false ; }
Get Row in DB
43,685
function getAll ( ) { foreach ( $ this as $ k => $ v ) { if ( $ k == 'table' || $ k == 'where' ) { continue ; } $ data [ $ k ] = $ v ; } return $ data ; }
Get All data
43,686
function save ( ) { if ( $ this -> id != false || $ this -> id != 0 ) { return $ this -> update ( ) ; } else { return $ this -> insert ( ) ; } }
SAVE a new or UPDATE this
43,687
function clearDir ( ) { $ dir = _WWW . $ this -> patch . $ this -> id . '/' ; foreach ( scandir ( $ dir ) as $ file ) { if ( $ file == '.' || $ file == '..' ) { continue ; } unlink ( $ dir . $ file ) ; } }
Delete all files in article directory
43,688
public function driver_name ( ) { $ this -> _connection or $ this -> connect ( ) ; return $ this -> _connection -> getAttribute ( \ PDO :: ATTR_DRIVER_NAME ) ; }
Get the current PDO Driver name
43,689
public function set_charset ( $ charset ) { $ this -> _connection or $ this -> connect ( ) ; if ( strtolower ( $ this -> driver_name ( ) ) == 'sqlsrv' ) { $ this -> _connection -> setAttribute ( \ PDO :: SQLSRV_ATTR_ENCODING , \ PDO :: SQLSRV_ENCODING_SYSTEM ) ; } elseif ( strtolower ( $ this -> driver_name ( ) ) == 'sqlite' ) { $ this -> _connection -> exec ( 'PRAGMA encoding = ' . $ this -> quote ( $ charset ) ) ; } elseif ( strtolower ( $ this -> driver_name ( ) ) != 'odbc' ) { $ this -> _connection -> exec ( 'SET NAMES ' . $ this -> quote ( $ charset ) ) ; } }
Set the charset
43,690
public function escape ( $ value ) { $ this -> _connection or $ this -> connect ( ) ; $ result = $ this -> _connection -> quote ( $ value ) ; if ( empty ( $ result ) ) { $ result = "'" . str_replace ( "'" , "''" , $ value ) . "'" ; } return $ result ; }
Escape a value
43,691
public function init ( ? string $ configuration = 'stylesheets' ) : void { $ config = Core :: i ( ) -> config -> getConfiguration ( $ configuration ) ; foreach ( $ config as $ script ) { $ this -> append ( $ script ) ; } }
Get the stylesheets that are defined in the configuration .
43,692
public function prepend ( ) : void { $ script = $ this -> parseArgs ( func_get_args ( ) ) ; if ( $ script !== false ) { array_unshift ( $ this -> members , $ script ) ; } }
Add a new stylesheet to the beginning of the list
43,693
public function append ( ) : void { $ script = $ this -> parseArgs ( func_get_args ( ) ) ; if ( $ script !== false ) { array_push ( $ this -> members , $ script ) ; } }
Add a new stylesheet to the end of the list
43,694
private function makeLink ( $ args ) { if ( ! isset ( $ args [ 'href' ] ) ) { Core :: i ( ) -> log -> warning ( 'Unable to add stylesheet, no href attribute.' ) ; return false ; } if ( ! isset ( $ args [ 'rel' ] ) ) { $ args [ 'rel' ] = 'stylesheet' ; } if ( ! isset ( $ args [ 'type' ] ) && $ args [ 'rel' ] == 'stylesheet' ) { $ args [ 'type' ] = 'text/css' ; } $ link = '<link' ; foreach ( $ args as $ key => $ value ) { $ link .= ' ' . $ key . '="' . $ value . '"' ; } $ link .= ' />' ; return $ link ; }
Generate a link to the stylesheet based on the passed parameters .
43,695
public function build ( $ name = null ) { $ caching = new Caching ( ) ; $ caching -> setStack ( new DebugStack ( ) ) ; if ( $ this -> debug && isset ( $ this -> debugDriver ) ) { $ caching -> setDriver ( $ this -> resolveDriver ( $ this -> debugDriver ) ) ; return $ caching ; } if ( null === $ name ) { $ name = $ this -> configuration -> get ( 'caching.default' , 'null' ) ; } $ driver = $ this -> resolveDriver ( $ name ) ; $ caching -> setDriver ( $ driver ) ; return $ caching ; }
Build cache driver .
43,696
protected function resolveDriver ( $ name ) { if ( ! isset ( $ this -> drivers [ $ name ] ) || ! $ this -> container -> has ( $ this -> drivers [ $ name ] ) ) { throw new \ RuntimeException ( sprintf ( 'Caching driver "%s" does not exist or is not registered as a service.' , $ name ) ) ; } $ driver = $ this -> container -> get ( $ this -> drivers [ $ name ] ) ; if ( ! $ driver instanceof DriverInterface ) { throw new \ RuntimeException ( sprintf ( 'Service "%s" is not a valid caching driver.' , $ this -> drivers [ $ name ] ) ) ; } return $ driver ; }
Resolve caching driver from name .
43,697
private function convertField ( $ array ) { $ result = [ ] ; foreach ( static :: $ convertFields as $ key ) { if ( isset ( $ array [ $ key ] ) ) { $ result [ $ key ] = $ array [ $ key ] ; } } if ( isset ( $ array [ 'dataType' ] ) ) { $ result [ 'dataType' ] = $ this -> inferType ( $ array [ 'dataType' ] ) ; } else { $ result [ 'dataType' ] = isset ( $ array [ 'children' ] ) ? 'object' : DataTypes :: STRING ; } $ result [ 'required' ] = isset ( $ array [ 'required' ] ) && ( bool ) $ array [ 'required' ] ; $ result [ 'readonly' ] = isset ( $ array [ 'readonly' ] ) && ( bool ) $ array [ 'readonly' ] ; $ result = $ this -> convertChildren ( $ array , $ result ) ; return $ result ; }
Convert the annotation for a field .
43,698
private function convertChildren ( $ array , $ result ) { if ( isset ( $ array [ 'children' ] ) ) { foreach ( $ array [ 'children' ] as $ key => $ value ) { $ result [ 'children' ] [ $ key ] = $ this -> convertField ( $ value ) ; if ( isset ( $ result [ 'children' ] [ $ key ] [ 'required' ] ) ) { $ result [ 'required' ] = $ result [ 'required' ] || ( bool ) $ result [ 'children' ] [ $ key ] [ 'required' ] ; } } return $ result ; } return $ result ; }
Convert the children key of an array .
43,699
public function inferType ( $ type ) { if ( DataTypes :: isPrimitive ( $ type ) ) { return $ type ; } elseif ( DataTypes :: COLLECTION === strtolower ( $ type ) ) { return $ type ; } return DataTypes :: STRING ; }
Convert the type .