idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
28,300
public static function fromAttributeValues ( AttributeValue ... $ values ) : self { if ( ! count ( $ values ) ) { throw new \ LogicException ( "No values." ) ; } $ oid = reset ( $ values ) -> oid ( ) ; return new self ( new AttributeType ( $ oid ) , ... $ values ) ; }
Convenience method to initialize from attribute values .
28,301
public function castValues ( string $ cls ) : self { $ refl = new \ ReflectionClass ( $ cls ) ; if ( ! $ refl -> isSubclassOf ( AttributeValue :: class ) ) { throw new \ LogicException ( "$cls must be derived from " . AttributeValue :: class . "." ) ; } $ oid = $ this -> oid ( ) ; $ values = array_map ( function ( AttributeValue $ value ) use ( $ cls , $ oid ) { $ value = $ cls :: fromSelf ( $ value ) ; if ( $ value -> oid ( ) != $ oid ) { throw new \ LogicException ( "Attribute OID mismatch." ) ; } return $ value ; } , $ this -> _values ) ; return self :: fromAttributeValues ( ... $ values ) ; }
Cast attribute values to another AttributeValue class .
28,302
public static function getMongoDate ( $ time = null ) { if ( is_null ( $ time ) ) { $ time = floor ( microtime ( true ) * 1000 ) ; } return new UTCDateTime ( $ time ) ; }
Return a UTCDateTime object If you pass in your own time it will use that to construct the object otherwise it will create an object based on the current time .
28,303
private function getField ( $ fieldname ) { if ( array_key_exists ( $ fieldname , $ this -> colmodel ) ) { return $ this -> colmodel [ $ fieldname ] ; } else { return false ; } }
Generic getter for any jqgrid column model attribute
28,304
public function getColModelJson ( $ prefix = '' ) { $ model = $ this -> colmodel ; $ dp = '' ; if ( array_key_exists ( 'datepicker' , $ model ) && $ model [ 'datepicker' ] ) { $ dp = ' ,"searchoptions" : {dataInit : datePick, "attr" : { "title": "Choisir une date" }}' ; } if ( array_key_exists ( 'autocomplete' , $ model ) ) { $ route = $ this -> router -> generate ( $ model [ 'autocomplete' ] ) ; $ dp = ' ,"searchoptions" : {dataInit : function(elem) { $(elem).autocomplete({source:\'' . $ route . '\',minLength:2}) }}' ; } unset ( $ model [ 'twig' ] ) ; unset ( $ model [ 'having' ] ) ; unset ( $ model [ 'value' ] ) ; unset ( $ model [ 'datepicker' ] ) ; unset ( $ model [ 'autocomplete' ] ) ; if ( array_key_exists ( 'name' , $ model ) ) { $ model [ 'name' ] = $ prefix . $ model [ 'name' ] ; } $ models = $ this -> encode ( $ model ) ; $ models = substr ( $ models , 0 , strlen ( $ models ) - 1 ) . $ dp . '}' ; return $ models ; }
Decorate specific column model attributes with values expected to build the view
28,305
private function validatePaymentMethodSpecific ( ) { $ this -> validate ( 'paymentMethod' ) ; switch ( $ this -> getPaymentMethod ( ) ) { case 'ideal' : $ this -> validate ( 'issuer' ) ; if ( $ this -> getCurrency ( ) != 'EUR' ) throw new InvalidRequestException ( "Cardgate : iDeal only accepts EUR" ) ; break ; case 'mistercash' : if ( $ this -> getCurrency ( ) != 'EUR' ) throw new InvalidRequestException ( "Cardgate : Bancontact/Mistercash only accepts EUR" ) ; break ; } }
Some PaymentMethod specific validation checks .
28,306
public function getAssetType ( string $ assetType ) : AssetTypeInterface { if ( ! isset ( $ this -> assetTypes [ $ assetType ] ) ) { if ( isset ( $ this -> assetTypesArray [ $ assetType ] ) ) { $ this -> assetTypes [ $ assetType ] = ImmutableAssetType :: fromArray ( $ assetType , $ this -> assetTypesArray [ $ assetType ] ) ; } else { $ this -> assetTypes [ $ assetType ] = ImmutableAssetType :: fromArray ( $ assetType , [ ] ) ; } } return $ this -> assetTypes [ $ assetType ] ; }
Returns an asset type object for the requested type .
28,307
private function getData ( Reader $ reader ) { $ size = $ this -> getSize ( $ reader ) ; $ reader -> seek ( 0 ) ; return $ reader -> read ( $ reader -> getSize ( ) - 12 - $ size ) ; }
Reads the contents of the archive file without the signature .
28,308
private function getSize ( Reader $ reader ) { $ reader -> seek ( - 12 , SEEK_END ) ; $ size = unpack ( 'V' , $ reader -> read ( 4 ) ) ; $ size = ( int ) $ size [ 1 ] ; return $ size ; }
Returns the size of the signature hash .
28,309
private function readPublicKey ( Reader $ reader ) { $ file = $ reader -> getFile ( ) . '.pubkey' ; if ( ! file_exists ( $ file ) ) { throw FileException :: createUsingFormat ( 'The path "%s" is not a file or does not exist.' , $ file ) ; } if ( false === ( $ key = @ file_get_contents ( $ file ) ) ) { throw FileException :: createUsingLastError ( ) ; } return $ key ; }
Returns the public key for the archive file .
28,310
public function run ( ) { Config :: $ in_stream = $ this -> stdin ; Config :: $ out_stream = $ this -> stdout ; Config :: $ delay = 0.6 ; $ this -> parse_options ( ) ; $ this -> load_translation ( ) ; $ this -> game -> start ( ) ; }
Run the level .
28,311
public function parse_options ( ) { $ getopt = new Getopt ( [ [ 'd' , 'directory' , Getopt :: REQUIRED_ARGUMENT , 'Run under given directory' ] , [ 'l' , 'level' , Getopt :: REQUIRED_ARGUMENT , 'Practice level on epic' ] , [ 's' , 'skip' , Getopt :: NO_ARGUMENT , 'Skip user input' ] , [ 't' , 'time' , Getopt :: REQUIRED_ARGUMENT , 'Delay each turn by seconds' ] , [ 'L' , 'locale' , Getopt :: REQUIRED_ARGUMENT , 'Specify locale like en_US' ] , [ 'h' , 'help' , Getopt :: NO_ARGUMENT , 'Show this message' ] , ] ) ; try { $ getopt -> parse ( ) ; } catch ( \ Exception $ e ) { echo $ e -> getMessage ( ) . "\n" ; exit ; } if ( $ getopt -> getOption ( 'h' ) ) { echo $ getopt -> getHelpText ( ) ; exit ; } if ( $ getopt -> getOption ( 'd' ) ) { Config :: $ path_prefix = $ getopt -> getOption ( 'd' ) ; } if ( $ getopt -> getOption ( 'l' ) ) { Config :: $ practice_level = $ getopt -> getOption ( 'l' ) ; } if ( $ getopt -> getOption ( 's' ) ) { Config :: $ skip_input = true ; } if ( ! is_null ( $ getopt -> getOption ( 't' ) ) ) { Config :: $ delay = $ getopt -> getOption ( 't' ) ; } list ( Config :: $ locale ) = explode ( '.' , getenv ( 'LANG' ) ) ; if ( $ getopt -> getOption ( 'L' ) ) { Config :: $ locale = $ getopt -> getOption ( 'L' ) ; } }
Parse the options .
28,312
public function load_translation ( ) { $ translator = new \ Gettext \ Translator ( ) ; $ i18n_path = realpath ( __DIR__ . '/../../i18n/' . Config :: $ locale . '.po' ) ; if ( file_exists ( $ i18n_path ) ) { $ translations = \ Gettext \ Translations :: fromPoFile ( $ i18n_path ) ; $ translator -> loadTranslations ( $ translations ) ; } Translator :: initGettextFunctions ( $ translator ) ; }
Load the i12n translation file .
28,313
public function getCheckinData ( $ startTime , $ endTime , $ userIdList , $ openCheckinDataType = 3 ) { $ params = [ 'opencheckindatatype' => $ openCheckinDataType , 'starttime' => $ startTime , 'endtime' => $ endTime , 'useridlist' => ( array ) $ userIdList , ] ; return $ this -> parseJSON ( 'json' , [ self :: API_CHECKIN_DATA , $ params ] ) ; }
Get checkin data .
28,314
public function getApprovalData ( $ startTime , $ endTime , $ nextSpNum = null ) { $ params = [ 'starttime' => $ startTime , 'endtime' => $ endTime , 'next_spnum' => $ nextSpNum , ] ; return $ this -> parseJSON ( 'json' , [ self :: API_APPROVAL_DATA , $ params ] ) ; }
Get approval data .
28,315
public function createImage ( $ seed = '' , $ file = '' ) { if ( ! $ seed ) { $ seed = mt_rand ( ) . time ( ) ; } $ this -> seed = $ seed ; if ( $ this -> ismono ) { $ this -> generateMonoColor ( ) ; } $ image = $ this -> createTransparentImage ( $ this -> fullsize , $ this -> fullsize ) ; $ arcwidth = $ this -> fullsize ; for ( $ i = $ this -> rings ; $ i > 0 ; $ i -- ) { $ this -> drawRing ( $ image , $ arcwidth ) ; $ arcwidth -= $ this -> ringwidth ; } $ out = $ this -> createTransparentImage ( $ this -> size , $ this -> size ) ; imagecopyresampled ( $ out , $ image , 0 , 0 , 0 , 0 , $ this -> size , $ this -> size , $ this -> fullsize , $ this -> fullsize ) ; if ( $ file ) { imagepng ( $ out , $ file ) ; } else { header ( "Content-type: image/png" ) ; imagepng ( $ out ) ; } imagedestroy ( $ out ) ; imagedestroy ( $ image ) ; }
Generates an ring image
28,316
protected function drawRing ( $ image , $ arcwidth ) { $ color = $ this -> randomColor ( $ image ) ; $ transparency = $ this -> transparentColor ( $ image ) ; $ start = $ this -> rand ( 20 , 360 ) ; $ stop = $ this -> rand ( 20 , 360 ) ; if ( $ stop < $ start ) list ( $ start , $ stop ) = array ( $ stop , $ start ) ; imagefilledarc ( $ image , $ this -> center , $ this -> center , $ arcwidth , $ arcwidth , $ stop , $ start , $ color , IMG_ARC_PIE ) ; imagefilledellipse ( $ image , $ this -> center , $ this -> center , $ arcwidth - $ this -> ringwidth , $ arcwidth - $ this -> ringwidth , $ transparency ) ; imagecolordeallocate ( $ image , $ color ) ; imagecolordeallocate ( $ image , $ transparency ) ; }
Drawas a single ring
28,317
protected function randomColor ( $ image ) { if ( $ this -> ismono ) { return imagecolorallocatealpha ( $ image , $ this -> monocolor [ 0 ] , $ this -> monocolor [ 1 ] , $ this -> monocolor [ 2 ] , $ this -> rand ( 0 , 96 ) ) ; } return imagecolorallocate ( $ image , $ this -> rand ( 0 , 255 ) , $ this -> rand ( 0 , 255 ) , $ this -> rand ( 0 , 255 ) ) ; }
Allocate a random color
28,318
protected function createTransparentImage ( $ width , $ height ) { $ image = @ imagecreatetruecolor ( $ width , $ height ) ; if ( ! $ image ) { throw new \ Exception ( 'Missing libgd support' ) ; } imagealphablending ( $ image , false ) ; $ transparency = $ this -> transparentColor ( $ image ) ; imagefill ( $ image , 0 , 0 , $ transparency ) ; imagecolordeallocate ( $ image , $ transparency ) ; imagesavealpha ( $ image , true ) ; return $ image ; }
Create a transparent image
28,319
public function redirect ( $ url ) { return new RedirectResponse ( sprintf ( self :: PRE_AUTH_LINK , $ this -> getSuiteId ( ) , $ this -> getCode ( ) , urlencode ( $ url ) ) ) ; }
Redirect to WeChat PreAuthorization page .
28,320
public function getCode ( ) { $ data = [ 'suite_id' => $ this -> getSuiteId ( ) , ] ; $ result = $ this -> parseJSON ( 'json' , [ self :: GET_PRE_AUTH_CODE , $ data ] ) ; if ( empty ( $ result [ 'pre_auth_code' ] ) ) { throw new InvalidArgumentException ( 'Invalid response.' ) ; } return $ result [ 'pre_auth_code' ] ; }
Get pre auth code .
28,321
public static function install_mock_files ( ) { $ sample_path = Director :: baseFolder ( ) . '/' . MOCK_DATAOBJECTS_DIR . '/lib' ; $ sample_files = glob ( $ sample_path . '/*.jpeg' ) ; $ folder = self :: get_mock_folder ( ) ; $ installed_sample_files = self :: get_mock_files ( ) ; if ( sizeof ( $ sample_files ) <= $ installed_sample_files -> count ( ) ) { return ; } foreach ( $ sample_files as $ file ) { copy ( $ file , $ folder -> getFullPath ( ) . basename ( $ file ) ) ; } $ folder -> syncChildren ( ) ; }
Copies stock files from the module directory to the filesytem and updates the database .
28,322
public static function download_lorem_image ( ) { $ url = 'http://lorempixel.com/1024/768?t=' . uniqid ( ) ; $ img_filename = "mock-file-" . uniqid ( ) . ".jpeg" ; $ img = self :: get_mock_folder ( ) -> getFullPath ( ) . $ img_filename ; if ( ini_get ( 'allow_url_fopen' ) ) { file_put_contents ( $ img , file_get_contents ( $ url ) ) ; } else { $ ch = curl_init ( $ url ) ; $ fp = fopen ( $ img , 'wb' ) ; curl_setopt ( $ ch , CURLOPT_FILE , $ fp ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_exec ( $ ch ) ; curl_close ( $ ch ) ; fclose ( $ fp ) ; } if ( ! file_exists ( $ img ) || ! filesize ( $ img ) ) { return false ; } $ i = Image :: create ( ) ; $ i -> Filename = self :: get_mock_folder ( ) -> Filename . $ img_filename ; $ i -> Title = $ img_filename ; $ i -> Name = $ img_filename ; $ i -> ParentID = self :: get_mock_folder ( ) -> ID ; $ i -> write ( ) ; return $ i ; }
Downloads a random image from a public website and installs it into the filesystem
28,323
public static function get_random_local_image ( ) { self :: install_mock_files ( ) ; return self :: get_mock_files ( ) -> sort ( DB :: get_conn ( ) -> random ( ) ) -> first ( ) ; }
Gets a random image that already exists in the filesystem
28,324
protected function setSslVerification ( ) { if ( $ this -> getTestMode ( ) ) $ this -> httpClient -> setSslVerification ( false , false , 0 ) ; else $ this -> httpClient -> setSslVerification ( ) ; }
We need this because the hostname does not match the cert ...
28,325
public function getCacheKey ( ) { if ( is_null ( $ this -> cacheKey ) ) { return $ this -> prefix . $ this -> suiteId ; } return $ this -> cacheKey ; }
Get component verify ticket cache key .
28,326
public function getHTMLFragments ( $ gridField ) { Requirements :: javascript ( MOCK_DATAOBJECTS_DIR . '/javascript/mock_dataobjects.js' ) ; Requirements :: css ( MOCK_DATAOBJECTS_DIR . '/css/mock_dataobjects.css' ) ; $ forTemplate = new ArrayData ( array ( ) ) ; $ forTemplate -> Colspan = count ( $ gridField -> getColumns ( ) ) ; $ forTemplate -> CountField = TextField :: create ( 'mockdata[Count]' , '' , '10' ) -> setAttribute ( 'maxlength' , 2 ) -> setAttribute ( 'size' , 2 ) ; $ forTemplate -> RelationsField = new CheckboxField ( 'mockdata[IncludeRelations]' , '' , false ) ; $ forTemplate -> DownloadsField = new CheckboxField ( 'mockdata[DownloadImages]' , '' , false ) ; $ forTemplate -> Cancel = GridField_FormAction :: create ( $ gridField , 'cancel' , _t ( 'MockData.CANCEL' , 'Cancel' ) , 'cancel' , null ) -> setAttribute ( 'id' , 'action_mockdata_cancel' . $ gridField -> getModelClass ( ) ) -> addExtraClass ( 'mock-data-generator-btn cancel' ) ; $ forTemplate -> Action = GridField_FormAction :: create ( $ gridField , 'mockdata' , _t ( 'MockData.CREATE' , 'Create' ) , 'mockdata' , null ) -> addExtraClass ( 'mock-data-generator-btn create ss-ui-action-constructive' ) -> setAttribute ( 'id' , 'action_mockdata_' . $ gridField -> getModelClass ( ) ) ; return array ( 'before' => $ forTemplate -> renderWith ( 'MockDataGenerator' ) ) ; }
Adds the HTML to the GridField that includes options for the mock data as well as the action button
28,327
public function activate ( Composer $ composer , IOInterface $ io ) { $ this -> composer = $ composer ; $ this -> io = $ io ; }
The activation method is called when the plugin is activated .
28,328
public function callback ( ) { $ generator = $ this -> getGenerator ( ) ; try { $ this -> io -> write ( '<info>Generating OXID eShop unified namespace classes ... </info>' , false ) ; $ generator -> cleanupOutputDirectory ( ) ; $ generator -> generate ( ) ; $ this -> io -> write ( '<info>Done</info>' ) ; } catch ( \ Exception $ exception ) { $ this -> io -> writeError ( '<error>Failed</error>' ) ; $ this -> io -> writeError ( '<error>Error: ' . $ exception -> getMessage ( ) . '</error>' ) ; $ this -> io -> writeError ( '<error>Code: ' . $ exception -> getCode ( ) . '</error>' ) ; $ this -> io -> writeError ( '<error>Stacktrace: ' . PHP_EOL . $ exception -> getTraceAsString ( ) . '</error>' ) ; } }
This callback is called when the wished composer events are fired .
28,329
protected function getGenerator ( ) { $ facts = new \ OxidEsales \ Facts \ Facts ( ) ; $ unifiedNameSpaceClassMapProvider = new \ OxidEsales \ UnifiedNameSpaceGenerator \ UnifiedNameSpaceClassMapProvider ( $ facts ) ; return new \ OxidEsales \ UnifiedNameSpaceGenerator \ Generator ( $ facts , $ unifiedNameSpaceClassMapProvider ) ; }
Create the Unified Namespace Generator object .
28,330
public function convertToPlaceholder ( ) { $ bucket = $ this -> getCloudBucket ( ) ; if ( $ bucket && ! $ bucket -> isLocalCopyEnabled ( ) ) { $ path = $ this -> owner -> getFullPath ( ) ; CloudAssets :: inst ( ) -> getLogger ( ) -> debug ( "CloudAssets: converting $path to placeholder" ) ; Filesystem :: makeFolder ( dirname ( $ path ) ) ; file_put_contents ( $ path , Config :: inst ( ) -> get ( 'CloudAssets' , 'file_placeholder' ) ) ; clearstatcache ( ) ; } return $ this -> owner ; }
Wipes out the contents of this file and replaces with placeholder text
28,331
public function downloadFromCloud ( ) { if ( $ this -> owner -> CloudStatus === 'Live' ) { $ bucket = $ this -> owner -> getCloudBucket ( ) ; if ( $ bucket ) { $ contents = $ bucket -> getContents ( $ this -> owner ) ; $ path = $ this -> owner -> getFullPath ( ) ; Filesystem :: makeFolder ( dirname ( $ path ) ) ; CloudAssets :: inst ( ) -> getLogger ( ) -> debug ( "CloudAssets: downloading $path from cloud (size=" . strlen ( $ contents ) . ")" ) ; if ( ! empty ( $ contents ) ) { file_put_contents ( $ path , $ contents ) ; } } } }
If this file is stored in the cloud downloads the cloud copy and replaces whatever is local .
28,332
public function createLocalIfNeeded ( ) { if ( $ this -> owner -> CloudStatus === 'Live' ) { $ bucket = $ this -> getCloudBucket ( ) ; if ( $ bucket && $ bucket -> isLocalCopyEnabled ( ) ) { if ( ! file_exists ( $ this -> owner -> getFullPath ( ) ) || $ this -> containsPlaceholder ( ) ) { try { $ this -> downloadFromCloud ( ) ; } catch ( Exception $ e ) { CloudAssets :: inst ( ) -> getLogger ( ) -> error ( "CloudAssets: Failed bucket download: " . $ e -> getMessage ( ) . " for " . $ this -> owner -> getFullPath ( ) ) ; } } } else { if ( ! file_exists ( $ this -> owner -> getFullPath ( ) ) ) { $ this -> convertToPlaceholder ( ) ; } } } }
If the file is present in the database and the cloud but not locally create a placeholder for it . This can happen in a lot of cases such as load balanced servers and local development .
28,333
public function getTableRows ( $ tableSpecId , array $ filter = [ ] , array $ sortBy = [ ] , $ offset = 0 , $ limit = 10 , array $ options = [ ] ) { $ t = new \ Tripod \ Timer ( ) ; $ t -> start ( ) ; $ options = array_merge ( [ 'returnCursor' => false , 'includeCount' => true , 'documentType' => '\Tripod\Mongo\Documents\Tables' ] , $ options ) ; $ filter [ '_id.' . _ID_TYPE ] = $ tableSpecId ; $ collection = $ this -> getConfigInstance ( ) -> getCollectionForTable ( $ this -> storeName , $ tableSpecId , $ this -> readPreference ) ; $ findOptions = [ ] ; if ( ! empty ( $ limit ) ) { $ findOptions [ 'skip' ] = ( int ) $ offset ; $ findOptions [ 'limit' ] = ( int ) $ limit ; } if ( isset ( $ sortBy ) ) { $ findOptions [ 'sort' ] = $ sortBy ; } $ results = $ collection -> find ( $ filter , $ findOptions ) ; if ( $ options [ 'includeCount' ] ) { $ count = $ collection -> count ( $ filter ) ; } else { $ count = - 1 ; } $ results -> setTypeMap ( [ 'root' => $ options [ 'documentType' ] , 'document' => 'array' , 'array' => 'array' ] ) ; $ t -> stop ( ) ; $ this -> timingLog ( MONGO_TABLE_ROWS , [ 'duration' => $ t -> result ( ) , 'query' => $ filter , 'collection' => TABLE_ROWS_COLLECTION ] ) ; $ this -> getStat ( ) -> timer ( MONGO_TABLE_ROWS . ".$tableSpecId" , $ t -> result ( ) ) ; return [ 'head' => [ 'count' => $ count , 'offset' => $ offset , 'limit' => $ limit ] , 'results' => $ options [ 'returnCursor' ] ? $ results : $ results -> toArray ( ) ] ; }
Query the tables collection and return the results
28,334
public function distinct ( $ tableSpecId , $ fieldName , array $ filter = [ ] ) { $ t = new \ Tripod \ Timer ( ) ; $ t -> start ( ) ; $ filter [ '_id.' . _ID_TYPE ] = $ tableSpecId ; $ collection = $ this -> config -> getCollectionForTable ( $ this -> storeName , $ tableSpecId , $ this -> readPreference ) ; $ results = $ collection -> distinct ( $ fieldName , $ filter ) ; $ t -> stop ( ) ; $ query = array ( 'distinct' => $ fieldName , 'filter' => $ filter ) ; $ this -> timingLog ( MONGO_TABLE_ROWS_DISTINCT , array ( 'duration' => $ t -> result ( ) , 'query' => $ query , 'collection' => TABLE_ROWS_COLLECTION ) ) ; $ this -> getStat ( ) -> timer ( MONGO_TABLE_ROWS_DISTINCT . ".$tableSpecId" , $ t -> result ( ) ) ; return array ( "head" => array ( "count" => count ( $ results ) ) , "results" => $ results ) ; }
Returns the distinct values for a table column optionally filtered by query
28,335
protected function truncatingSave ( Collection $ collection , array $ generatedRow ) { try { $ collection -> updateOne ( array ( '_id' => $ generatedRow [ '_id' ] ) , array ( '$set' => $ generatedRow ) , array ( 'upsert' => true ) ) ; } catch ( \ Exception $ e ) { if ( strpos ( $ e -> getMessage ( ) , "Btree::insert: key too large to index" ) !== FALSE ) { $ this -> truncateFields ( $ collection , $ generatedRow ) ; $ collection -> updateOne ( array ( '_id' => $ generatedRow [ '_id' ] ) , array ( '$set' => $ generatedRow ) , array ( 'upsert' => true ) ) ; } else { throw $ e ; } } }
Save the generated rows to the given collection .
28,336
protected function truncateFields ( Collection $ collection , array & $ generatedRow ) { $ indexedFields = [ ] ; $ indexesGroupedByCollection = $ this -> config -> getIndexesGroupedByCollection ( $ this -> storeName ) ; if ( isset ( $ indexesGroupedByCollection ) && isset ( $ indexesGroupedByCollection [ $ collection -> getCollectionName ( ) ] ) ) { $ indexes = $ indexesGroupedByCollection [ $ collection -> getCollectionName ( ) ] ; if ( isset ( $ indexes ) ) { foreach ( $ indexes as $ repset ) { foreach ( $ repset as $ index ) { foreach ( $ index as $ indexedFieldname => $ v ) { if ( strpos ( $ indexedFieldname , "value." ) === 0 ) { $ indexedFields [ ] = substr ( $ indexedFieldname , strlen ( 'value.' ) ) ; } } } } } } if ( count ( $ indexedFields ) > 0 && isset ( $ generatedRow [ 'value' ] ) && is_array ( $ generatedRow [ 'value' ] ) ) { foreach ( $ generatedRow as & $ field ) { foreach ( $ indexedFields as $ indexedFieldname ) { $ maxKeySize = 1020 - strlen ( "value_" . $ indexedFieldname . "_1" ) ; if ( array_key_exists ( $ indexedFieldname , $ field ) ) { if ( is_string ( $ field [ $ indexedFieldname ] ) && strlen ( $ field [ $ indexedFieldname ] ) > $ maxKeySize ) { $ field [ $ indexedFieldname ] = substr ( $ field [ $ indexedFieldname ] , 0 , $ maxKeySize ) ; } } } } } }
Truncate any indexed fields in the generated rows which are too large to index
28,337
protected function addFields ( $ source , $ spec , & $ dest ) { if ( isset ( $ spec [ 'fields' ] ) ) { foreach ( $ spec [ 'fields' ] as $ f ) { if ( isset ( $ f [ 'temporary' ] ) && $ f [ 'temporary' ] === true ) { if ( ! in_array ( $ f [ 'fieldName' ] , $ this -> temporaryFields ) ) { $ this -> temporaryFields [ ] = $ f [ 'fieldName' ] ; } } if ( isset ( $ f [ 'predicates' ] ) ) { foreach ( $ f [ 'predicates' ] as $ p ) { if ( is_string ( $ p ) && isset ( $ source [ $ p ] ) ) { $ this -> generateValues ( $ source , $ f , $ p , $ dest ) ; } else { $ predicateFunctions = $ this -> getPredicateFunctions ( $ p ) ; $ predicateFunctions = array_reverse ( $ predicateFunctions ) ; foreach ( $ predicateFunctions as $ function => $ functionOptions ) { if ( $ function == 'predicates' ) { foreach ( $ functionOptions as $ v ) { $ v = trim ( $ v ) ; if ( isset ( $ source [ $ v ] ) ) { $ this -> generateValues ( $ source , $ f , $ v , $ dest ) ; } } } else { if ( isset ( $ dest [ $ f [ 'fieldName' ] ] ) ) { $ dest [ $ f [ 'fieldName' ] ] = $ this -> applyModifier ( $ function , $ dest [ $ f [ 'fieldName' ] ] , $ functionOptions ) ; } } } } } } if ( isset ( $ f [ 'value' ] ) ) { if ( $ f [ 'value' ] == '_link_' || $ f [ 'value' ] == 'link' ) { if ( $ f [ 'value' ] == '_link_' ) { $ this -> warningLog ( "Table spec value '_link_' is deprecated" , $ f ) ; } if ( isset ( $ dest [ $ f [ 'fieldName' ] ] ) ) { if ( ! is_array ( $ dest [ $ f [ 'fieldName' ] ] ) ) { $ dest [ $ f [ 'fieldName' ] ] = array ( $ dest [ $ f [ 'fieldName' ] ] ) ; } $ dest [ $ f [ 'fieldName' ] ] [ ] = $ this -> labeller -> qname_to_alias ( $ source [ '_id' ] [ 'r' ] ) ; } else { $ dest [ $ f [ 'fieldName' ] ] = $ this -> labeller -> qname_to_alias ( $ source [ '_id' ] [ 'r' ] ) ; } } } } } }
Add fields to a table row
28,338
protected function generateValues ( $ source , $ f , $ predicate , & $ dest ) { $ values = [ ] ; if ( isset ( $ source [ $ predicate ] [ VALUE_URI ] ) && ! empty ( $ source [ $ predicate ] [ VALUE_URI ] ) ) { $ values [ ] = $ source [ $ predicate ] [ VALUE_URI ] ; } else if ( isset ( $ source [ $ predicate ] [ VALUE_LITERAL ] ) && ! empty ( $ source [ $ predicate ] [ VALUE_LITERAL ] ) ) { $ values [ ] = $ source [ $ predicate ] [ VALUE_LITERAL ] ; } else if ( isset ( $ source [ $ predicate ] [ _ID_RESOURCE ] ) ) { $ values [ ] = $ source [ $ predicate ] [ _ID_RESOURCE ] ; } else { foreach ( $ source [ $ predicate ] as $ v ) { if ( isset ( $ v [ VALUE_LITERAL ] ) && ! empty ( $ v [ VALUE_LITERAL ] ) ) { $ values [ ] = $ v [ VALUE_LITERAL ] ; } else if ( isset ( $ v [ VALUE_URI ] ) && ! empty ( $ v [ VALUE_URI ] ) ) { $ values [ ] = $ v [ VALUE_URI ] ; } } } foreach ( $ values as $ v ) { if ( ! isset ( $ dest [ $ f [ 'fieldName' ] ] ) ) { $ dest [ $ f [ 'fieldName' ] ] = $ v ; } else if ( is_array ( $ dest [ $ f [ 'fieldName' ] ] ) ) { $ dest [ $ f [ 'fieldName' ] ] [ ] = $ v ; } else { $ existingVal = $ dest [ $ f [ 'fieldName' ] ] ; $ dest [ $ f [ 'fieldName' ] ] = [ ] ; $ dest [ $ f [ 'fieldName' ] ] [ ] = $ existingVal ; $ dest [ $ f [ 'fieldName' ] ] [ ] = $ v ; } } }
Generate values for a given predicate
28,339
protected function getPredicateFunctions ( $ array ) { $ predicateFunctions = [ ] ; if ( is_array ( $ array ) ) { if ( isset ( $ array [ 'predicates' ] ) ) { $ predicateFunctions [ 'predicates' ] = $ array [ 'predicates' ] ; } else { $ predicateFunctions [ key ( $ array ) ] = $ array [ key ( $ array ) ] ; $ predicateFunctions = array_merge ( $ predicateFunctions , $ this -> getPredicateFunctions ( $ array [ key ( $ array ) ] ) ) ; } } return $ predicateFunctions ; }
Recursively get functions that can modify a predicate
28,340
protected function getPredicateAliasesFromPredicateProperty ( $ predicate ) { $ predicates = [ ] ; if ( is_string ( $ predicate ) && ! empty ( $ predicate ) ) { $ predicates [ ] = $ this -> getLabeller ( ) -> uri_to_alias ( $ predicate ) ; } elseif ( is_array ( $ predicate ) ) { foreach ( $ this -> getPredicatesFromPredicateFunctions ( $ predicate ) as $ p ) { $ predicates [ ] = $ this -> getLabeller ( ) -> uri_to_alias ( $ p ) ; } } return $ predicates ; }
Rewrites any predicate uris to alias curies
28,341
protected function getPredicatesFromPredicateFunctions ( $ array ) { $ predicates = [ ] ; if ( is_array ( $ array ) ) { if ( isset ( $ array [ 'predicates' ] ) ) { $ predicates = $ array [ 'predicates' ] ; } else { $ predicates = array_merge ( $ predicates , $ this -> getPredicatesFromPredicateFunctions ( $ array [ key ( $ array ) ] ) ) ; } } return $ predicates ; }
When given an array as input will traverse any predicate functions and return the predicate strings
28,342
protected function getPredicatesFromFilterCondition ( $ filter ) { $ predicates = [ ] ; $ regex = "/(^|\b)(\w+\:\w+)\.(l|u)(\b|$)/" ; foreach ( $ filter as $ key => $ condition ) { if ( is_string ( $ key ) ) { $ numMatches = preg_match_all ( $ regex , $ key , $ matches ) ; for ( $ i = 0 ; $ i < $ numMatches ; $ i ++ ) { if ( isset ( $ matches [ 2 ] [ $ i ] ) ) { $ predicates [ ] = $ matches [ 2 ] [ $ i ] ; } } } if ( is_string ( $ condition ) ) { $ numMatches = preg_match_all ( $ regex , $ condition , $ matches ) ; for ( $ i = 0 ; $ i < $ numMatches ; $ i ++ ) { if ( isset ( $ matches [ 2 ] [ $ i ] ) ) { $ predicates [ ] = $ matches [ 2 ] [ $ i ] ; } } } elseif ( is_array ( $ condition ) ) { array_merge ( $ predicates , $ this -> getPredicatesFromFilterCondition ( $ condition ) ) ; } } return $ predicates ; }
Parses a specDocument s filter parameter for any predicates
28,343
public function checkModifierFunctions ( array $ array , $ parent , $ parentKey = null ) { foreach ( $ array as $ k => $ v ) { if ( is_array ( $ v ) ) { if ( ! array_key_exists ( $ k , $ parent ) && ! array_key_exists ( $ k , \ Tripod \ Mongo \ Composites \ Tables :: $ predicateModifiers ) ) { throw new \ Tripod \ Exceptions \ ConfigException ( "Invalid modifier: '" . $ k . "' in key '" . $ parentKey . "'" ) ; } if ( array_key_exists ( $ k , \ Tripod \ Mongo \ Composites \ Tables :: $ predicateModifiers ) ) { $ this -> checkModifierFunctions ( $ v , \ Tripod \ Mongo \ Composites \ Tables :: $ predicateModifiers [ $ k ] , $ k ) ; } else { $ this -> checkModifierFunctions ( $ v , $ parent [ $ k ] , $ k ) ; } } else if ( is_string ( $ k ) ) { if ( ! array_key_exists ( $ k , $ parent ) ) { throw new \ Tripod \ Exceptions \ ConfigException ( "Invalid modifier: '" . $ k . "' in key '" . $ parentKey . "'" ) ; } } } }
Check modifier functions against fields
28,344
public function getIndexesGroupedByCollection ( $ storeName ) { $ indexes = $ this -> indexes [ $ storeName ] ; foreach ( $ indexes as $ collection => $ indices ) { $ indexes [ $ collection ] [ _LOCKED_FOR_TRANS_INDEX ] = array ( _ID_KEY => 1 , _LOCKED_FOR_TRANS => 1 ) ; $ indexes [ $ collection ] [ _UPDATED_TS_INDEX ] = array ( _ID_KEY => 1 , _UPDATED_TS => 1 ) ; $ indexes [ $ collection ] [ _CREATED_TS_INDEX ] = array ( _ID_KEY => 1 , _CREATED_TS => 1 ) ; } $ tableIndexes = [ ] ; foreach ( $ this -> getTableSpecifications ( $ storeName ) as $ tspec ) { if ( array_key_exists ( "ensureIndexes" , $ tspec ) ) { if ( ! isset ( $ tableIndexes [ $ tspec [ 'to_data_source' ] ] ) ) { $ tableIndexes [ $ tspec [ 'to_data_source' ] ] = [ ] ; } foreach ( $ tspec [ "ensureIndexes" ] as $ index ) { $ tableIndexes [ $ tspec [ 'to_data_source' ] ] [ ] = $ index ; } } } $ indexes [ TABLE_ROWS_COLLECTION ] = $ tableIndexes ; $ viewIndexes = [ ] ; foreach ( $ this -> getViewSpecifications ( $ storeName ) as $ vspec ) { if ( array_key_exists ( "ensureIndexes" , $ vspec ) ) { if ( ! isset ( $ viewIndexes [ $ vspec [ 'to_data_source' ] ] ) ) { $ viewIndexes [ $ vspec [ 'to_data_source' ] ] = [ ] ; } foreach ( $ vspec [ "ensureIndexes" ] as $ index ) { $ viewIndexes [ $ vspec [ 'to_data_source' ] ] [ ] = $ index ; } } } $ indexes [ VIEWS_COLLECTION ] = $ viewIndexes ; return $ indexes ; }
Returns a list of the configured indexes grouped by collection
28,345
public function isPodWithinStore ( $ storeName , $ pod ) { return ( array_key_exists ( $ storeName , $ this -> podConnections ) ) ? array_key_exists ( $ pod , $ this -> podConnections [ $ storeName ] ) : false ; }
Returns a boolean reflecting whether or not the database and collection are defined in the config
28,346
public function getPods ( $ storeName ) { return ( array_key_exists ( $ storeName , $ this -> podConnections ) ) ? array_keys ( $ this -> podConnections [ $ storeName ] ) : [ ] ; }
Returns an array of collection configurations for the supplied database name
28,347
public function getDataSourceForPod ( $ storeName , $ podName ) { if ( isset ( $ this -> podConnections [ $ storeName ] ) && isset ( $ this -> podConnections [ $ storeName ] [ $ podName ] ) ) { return $ this -> podConnections [ $ storeName ] [ $ podName ] ; } throw new \ Tripod \ Exceptions \ ConfigException ( "'{$podName}' not configured for store '{$storeName}'" ) ; }
Returns the name of the data source for the request pod . This may be the default for the store or the pod may have overridden it in the config .
28,348
public function getConnStr ( $ storeName , $ podName = null ) { if ( array_key_exists ( $ storeName , $ this -> dbConfig ) ) { if ( ! $ podName ) { return $ this -> getConnStrForDataSource ( $ this -> dbConfig [ $ storeName ] [ 'data_source' ] ) ; } $ pods = $ this -> getPods ( $ storeName ) ; if ( array_key_exists ( $ podName , $ pods ) ) { return $ this -> getConnStrForDataSource ( $ pods [ $ podName ] [ 'data_source' ] ) ; } throw new \ Tripod \ Exceptions \ ConfigException ( "Collection $podName does not exist for database $storeName" ) ; } else { throw new \ Tripod \ Exceptions \ ConfigException ( "Database $storeName does not exist in configuration" ) ; } }
Returns the connection string for the supplied database name
28,349
public function isReplicaSet ( $ datasource ) { if ( array_key_exists ( $ datasource , $ this -> dataSources ) ) { if ( array_key_exists ( "replicaSet" , $ this -> dataSources [ $ datasource ] ) && ! empty ( $ this -> dataSources [ $ datasource ] [ "replicaSet" ] ) ) { return true ; } } return false ; }
Returns a boolean reflecting whether or not a replica set has been defined for the supplied database name
28,350
public function getViewSpecification ( $ storeName , $ vid ) { if ( isset ( $ this -> viewSpecs [ $ storeName ] ) && isset ( $ this -> viewSpecs [ $ storeName ] [ $ vid ] ) ) { return $ this -> viewSpecs [ $ storeName ] [ $ vid ] ; } else { return null ; } }
Return the view specification document for the supplied id if it exists
28,351
public function getSearchDocumentSpecification ( $ storeName , $ sid ) { if ( array_key_exists ( $ storeName , $ this -> searchDocSpecs ) && array_key_exists ( $ sid , $ this -> searchDocSpecs [ $ storeName ] ) ) { return $ this -> searchDocSpecs [ $ storeName ] [ $ sid ] ; } return null ; }
Returns the search document specification for the supplied id if it exists
28,352
public function getSearchDocumentSpecifications ( $ storeName , $ type = null , $ justReturnSpecId = false ) { if ( ! isset ( $ this -> searchDocSpecs [ $ storeName ] ) || empty ( $ this -> searchDocSpecs [ $ storeName ] ) ) { return [ ] ; } $ specs = [ ] ; if ( empty ( $ type ) ) { if ( $ justReturnSpecId ) { $ specIds = [ ] ; foreach ( $ this -> searchDocSpecs [ $ storeName ] as $ specId => $ spec ) { $ specIds [ ] = $ specId ; } return $ specIds ; } else { return $ this -> searchDocSpecs [ $ storeName ] ; } } $ labeller = $ this -> getLabeller ( ) ; $ typeAsUri = $ labeller -> uri_to_alias ( $ type ) ; $ typeAsQName = $ labeller -> qname_to_alias ( $ type ) ; foreach ( $ this -> searchDocSpecs [ $ storeName ] as $ spec ) { if ( is_array ( $ spec [ _ID_TYPE ] ) ) { if ( in_array ( $ typeAsUri , $ spec [ _ID_TYPE ] ) || in_array ( $ typeAsQName , $ spec [ _ID_TYPE ] ) ) { if ( $ justReturnSpecId ) { $ specs [ ] = $ spec [ _ID_KEY ] ; } else { $ specs [ ] = $ spec ; } } } else { if ( $ spec [ _ID_TYPE ] == $ typeAsUri || $ spec [ _ID_TYPE ] == $ typeAsQName ) { if ( $ justReturnSpecId ) { $ specs [ ] = $ spec [ _ID_KEY ] ; } else { $ specs [ ] = $ spec ; } } } } return $ specs ; }
Returns an array of all search document specifications or specification ids
28,353
public function getTableSpecification ( $ storeName , $ tid ) { if ( isset ( $ this -> tableSpecs [ $ storeName ] ) && isset ( $ this -> tableSpecs [ $ storeName ] [ $ tid ] ) ) { return $ this -> tableSpecs [ $ storeName ] [ $ tid ] ; } else { return null ; } }
Returns the requested table specification if it exists
28,354
private function getMandatoryKey ( $ key , Array $ a , $ configName = 'config' ) { if ( ! array_key_exists ( $ key , $ a ) ) { throw new \ Tripod \ Exceptions \ ConfigException ( "Mandatory config key [$key] is missing from $configName" ) ; } return $ a [ $ key ] ; }
Returns the value of the supplied key or throws an error if missing
28,355
private function findFieldsInTableSpec ( $ fieldName , $ spec ) { $ fields = [ ] ; if ( is_array ( $ spec ) && ! empty ( $ spec ) ) { if ( array_key_exists ( $ fieldName , $ spec ) ) { $ fields = $ spec [ $ fieldName ] ; } if ( isset ( $ spec [ 'joins' ] ) ) { foreach ( $ spec [ 'joins' ] as $ join ) { $ fields = array_merge ( $ fields , $ this -> findFieldsInTableSpec ( $ fieldName , $ join ) ) ; } } } return $ fields ; }
Finds fields in a table specification
28,356
public static function deserialize ( array $ config ) { if ( isset ( $ config [ 'class' ] ) && isset ( $ config [ 'config' ] ) ) { $ config = $ config [ 'config' ] ; } $ instance = new self ( ) ; $ instance -> loadConfig ( $ config ) ; return $ instance ; }
Sets the Tripod config
28,357
public static function getSource ( ) { if ( false === ( $ code = @ file ( __FILE__ ) ) ) { $ error = error_get_last ( ) ; throw new RuntimeException ( $ error [ 'message' ] ) ; } $ code = array_slice ( $ code , 6 ) ; foreach ( $ code as $ i => $ line ) { if ( '' === trim ( $ line ) ) { unset ( $ code [ $ i ] ) ; continue ; } if ( preg_match ( '{^\s*(/\*+|\*+)}' , $ line ) ) { unset ( $ code [ $ i ] ) ; } } return join ( '' , $ code ) ; }
Returns the embeddable source for this class .
28,358
private function extractFile ( array $ file ) { $ this -> seek ( $ file [ 'offset' ] ) ; $ contents = $ this -> read ( $ file [ 'size' ] [ 'compressed' ] ) ; if ( $ file [ 'flags' ] & self :: BZ2 ) { if ( ! $ this -> compression [ 'bzip2' ] ) { throw new RuntimeException ( "The \"bz2\" extension is required to decompress \"{$file['name']['data']}\"." ) ; } $ contents = bzdecompress ( $ contents ) ; } elseif ( $ file [ 'flags' ] & self :: GZ ) { if ( ! $ this -> compression [ 'gzip' ] ) { throw new RuntimeException ( "The \"zlib\" extension is required to decompress \"{$file['name']['data']}\"." ) ; } $ contents = gzinflate ( $ contents ) ; } return $ contents ; }
Returns the contents of a file from the archive .
28,359
private function findOffset ( ) { $ this -> seek ( 0 ) ; $ offset = 0 ; while ( ! $ this -> isEndOfFile ( ) ) { if ( strtolower ( $ this -> read ( 1 ) ) === self :: $ sequence [ $ offset ] ) { $ offset ++ ; } else { $ offset = 0 ; } if ( ! isset ( self :: $ sequence [ $ offset + 1 ] ) ) { break ; } } $ this -> seek ( 1 , SEEK_CUR ) ; if ( $ offset === ( count ( self :: $ sequence ) - 1 ) ) { $ position = $ this -> getPosition ( ) ; if ( "\r\n" === $ this -> read ( 2 ) ) { return $ position + 2 ; } return $ position ; } return null ; }
Finds the archive offset of an archive .
28,360
private function getFileList ( ) { $ count = $ this -> getFileCount ( ) ; $ size = $ this -> getSize ( ) + 4 ; $ this -> seek ( $ this -> offset + 18 + $ this -> getAliasSize ( ) + 4 + $ this -> getMetadataSize ( ) ) ; return $ this -> readFileList ( $ count , $ size ) ; }
Returns the list of files in the archive .
28,361
private function getPosition ( ) { if ( false === ( $ position = @ ftell ( $ this -> getHandle ( ) ) ) ) { $ error = error_get_last ( ) ; throw new RuntimeException ( $ error [ 'message' ] ) ; } return $ position ; }
Returns the current position of the file pointer .
28,362
public function set ( $ agentId , array $ agentInfo = [ ] ) { $ params = array_merge ( $ agentInfo , [ 'agentid' => $ agentId , ] ) ; return $ this -> parseJSON ( 'json' , [ self :: API_SET , $ params ] ) ; }
Set an agent by agent id .
28,363
public function getFakeData ( Generator $ faker ) { $ paragraphs = rand ( 1 , 5 ) ; $ i = 0 ; $ ret = "" ; while ( $ i < $ paragraphs ) { $ ret .= "<p>" . $ faker -> paragraph ( rand ( 2 , 6 ) ) . "</p>" ; $ i ++ ; } return $ ret ; }
Gets a random set of paragraphs
28,364
private static function waitChildProcess ( string $ name , $ boot ) { $ processObject = App :: getBean ( $ name ) ; if ( ( $ hasWait = method_exists ( $ processObject , 'wait' ) ) || $ boot ) { Process :: signal ( SIGCHLD , function ( $ sig ) use ( $ name , $ processObject , $ hasWait ) { while ( $ ret = Process :: wait ( false ) ) { if ( $ hasWait ) { $ processObject -> wait ( $ ret ) ; } unset ( self :: $ processes [ $ name ] ) ; } } ) ; } }
Wait child process
28,365
protected function initEditor ( ) : void { $ view = $ this -> getView ( ) ; CKEditorAsset :: register ( $ view ) ; CKEditorAssetAddition :: register ( $ view ) ; $ id = $ this -> options [ 'id' ] ; $ clientOptions = ! empty ( $ this -> clientOptions ) ? Json :: encode ( $ this -> clientOptions ) : '{}' ; $ js = [ ] ; $ js [ ] = "CKEDITOR.replace('$id', $clientOptions);" ; $ js [ ] = "initItstructureOnChangeHandler('$id');" ; if ( array_key_exists ( 'filebrowserUploadUrl' , $ this -> clientOptions ) || array_key_exists ( 'filebrowserImageUploadUrl' , $ this -> clientOptions ) ) { $ js [ ] = "initItstructureCsrfHandler();" ; } $ view -> registerJs ( implode ( "\n" , $ js ) ) ; }
Initialize CKEditor in textarea field with asset .
28,366
protected function getActiveTextarea ( ) : string { return Html :: activeTextarea ( $ this -> model , $ this -> attribute , $ this -> options ) ; }
Get active textarea field with model .
28,367
protected function getTextarea ( ) : string { return Html :: textarea ( $ this -> name , $ this -> value , $ this -> options ) ; }
Get textarea field without model and with name and value .
28,368
public function createAuthorizerApplication ( $ authorizerCorpId , $ permanentCode ) { $ this -> fetch ( 'authorization' ) -> setAuthorizerCorpId ( $ authorizerCorpId ) -> setAuthorizerPermanentCode ( $ permanentCode ) ; $ application = $ this -> fetch ( 'app' ) ; $ application [ 'access_token' ] = $ this -> fetch ( 'authorizer_access_token' ) ; $ application [ 'oauth' ] = $ this -> fetch ( 'oauth' ) ; return $ application ; }
Create an instance of the EntWeChat for the given authorizer .
28,369
public function asClass ( $ soapResult , array $ resultClassMap = array ( ) , $ resultClassNamespace = '' ) { if ( ! is_object ( $ soapResult ) ) { throw new InvalidParameterException ( 'Soap Result is not an object' ) ; } $ objVarsNames = array_keys ( get_object_vars ( $ soapResult ) ) ; $ rootClassName = reset ( $ objVarsNames ) ; $ soapResultObj = $ this -> mapObject ( $ soapResult -> $ rootClassName , $ rootClassName , $ resultClassMap , $ resultClassNamespace ) ; return $ soapResultObj ; }
Maps Result XML Elements to Classes
28,370
protected function mapArray ( $ data , $ className , $ classMap , $ classNamespace = '' ) { $ className = 'array|' . $ className ; if ( ! array_key_exists ( $ className , $ classMap ) ) { return $ data ; } $ returnArray = [ ] ; foreach ( $ data as $ key => $ val ) { $ returnArray [ $ key ] = $ this -> mapObject ( $ val , $ className , $ classMap , $ classNamespace ) ; } return $ returnArray ; }
Map Remote SOAP response to local classes if response is array
28,371
protected function getMappedClassName ( $ className , $ classMap ) { if ( array_key_exists ( $ className , $ classMap ) ) { $ mappedClassName = $ classMap [ $ className ] ; } else { $ mappedClassName = 'stdClass' ; } $ this -> checkClassExistence ( $ mappedClassName ) ; return $ mappedClassName ; }
Get mapped class name
28,372
protected function mapPropertyWithSetter ( $ object , $ key , $ value , $ mappedClassName ) { $ setterName = $ this -> getSetterName ( $ key ) ; $ value = $ this -> castParameter ( $ mappedClassName , $ key , $ value ) ; $ object -> $ setterName ( $ value ) ; }
Map property to object with setter
28,373
protected function castParameter ( $ mappedClassName , $ key , $ value ) { $ parameter = $ this -> getSetterParameter ( $ mappedClassName , $ key ) ; $ parameterClass = $ this -> getParameterClass ( $ parameter ) ; if ( $ parameterClass ) { $ paramClassName = $ parameterClass -> getNamespaceName ( ) . '\\' . $ parameterClass -> getName ( ) ; if ( $ paramClassName === '\DateTime' ) { $ value = new \ DateTime ( $ value ) ; } } return $ value ; }
Cast the value if parameter is typehinted
28,374
public function editTemplate ( ) { $ this -> defaultData ( ) ; $ clazz = $ this -> getCurrentClass ( ) ; $ delivery = $ this -> getCurrentInstance ( ) ; $ formContainer = new DeliveryForm ( $ clazz , $ delivery ) ; $ myForm = $ formContainer -> getForm ( ) ; $ myForm -> evaluate ( ) ; if ( $ myForm -> isSubmited ( ) ) { if ( $ myForm -> isValid ( ) ) { $ propertyValues = $ myForm -> getValues ( ) ; $ binder = new tao_models_classes_dataBinding_GenerisFormDataBinder ( $ delivery ) ; $ delivery = $ binder -> bind ( $ propertyValues ) ; $ this -> getClassService ( ) -> onChangeLabel ( $ delivery ) ; $ this -> setData ( "selectNode" , tao_helpers_Uri :: encode ( $ delivery -> getUri ( ) ) ) ; $ this -> setData ( 'message' , __ ( 'Delivery saved' ) ) ; $ this -> setData ( 'reload' , true ) ; } } $ this -> setData ( 'contentForm' , $ this -> getContentForm ( ) ) ; $ this -> setData ( 'uri' , tao_helpers_Uri :: encode ( $ delivery -> getUri ( ) ) ) ; $ this -> setData ( 'classUri' , tao_helpers_Uri :: encode ( $ clazz -> getUri ( ) ) ) ; $ this -> setData ( 'hasContent' , ! is_null ( $ this -> getClassService ( ) -> getContent ( $ delivery ) ) ) ; $ this -> setData ( 'formTitle' , __ ( 'Delivery properties' ) ) ; $ this -> setData ( 'myForm' , $ myForm -> render ( ) ) ; if ( $ this -> getServiceLocator ( ) -> get ( \ common_ext_ExtensionsManager :: SERVICE_ID ) -> isEnabled ( 'taoCampaign' ) ) { $ this -> setData ( 'campaign' , \ taoCampaign_helpers_Campaign :: renderCampaignTree ( $ delivery ) ) ; } $ this -> setView ( 'DeliveryTemplate/editDelivery.tpl' ) ; }
Edit a delivery template instance
28,375
public function setContentClass ( ) { $ delivery = $ this -> getCurrentInstance ( ) ; $ contentClass = $ this -> getClass ( $ this -> getRequestParameter ( 'model' ) ) ; if ( is_null ( $ this -> getClassService ( ) -> getContent ( $ delivery ) ) ) { $ content = $ this -> getClassService ( ) -> createContent ( $ delivery , $ contentClass ) ; $ success = true ; } else { $ this -> logWarning ( 'Content already defined, cannot be replaced' ) ; $ success = false ; } $ this -> returnJson ( array ( 'success' => $ success ) ) ; }
Set the model to use for the delivery
28,376
public function delete ( ) { if ( ! $ this -> isXmlHttpRequest ( ) ) { throw new \ Exception ( "wrong request mode" ) ; } $ deleted = $ this -> getClassService ( ) -> deleteInstance ( $ this -> getCurrentInstance ( ) ) ; $ this -> returnJson ( array ( 'deleted' => $ deleted ) ) ; }
Delete a delivery template
28,377
public function initCompilation ( ) { $ this -> defaultData ( ) ; $ delivery = $ this -> getCurrentInstance ( ) ; $ deliveryData = array ( ) ; $ deliveryData [ "uri" ] = $ delivery -> getUri ( ) ; $ resultServer = $ this -> getClassService ( ) -> getResultServer ( $ delivery ) ; $ deliveryData [ 'resultServer' ] = $ resultServer ; $ deliveryData [ 'tests' ] = array ( ) ; if ( ! empty ( $ resultServer ) ) { $ tests = $ this -> getClassService ( ) -> getRelatedTests ( $ delivery ) ; foreach ( $ tests as $ test ) { $ deliveryData [ 'tests' ] [ ] = array ( "label" => $ test -> getLabel ( ) , "uri" => $ test -> getUri ( ) ) ; } } $ this -> returnJson ( $ deliveryData ) ; }
get the compilation view
28,378
public function getAllContentClasses ( ) { $ deliveryContentSuperClass = new core_kernel_classes_Class ( DeliveryContent :: CLASS_URI ) ; $ subclasses = $ deliveryContentSuperClass -> getSubClasses ( true ) ; return $ subclasses ; }
Returns all the content classes
28,379
public function createContent ( core_kernel_classes_Resource $ delivery , core_kernel_classes_Class $ contentClass ) { $ impl = $ this -> getImplementationByContentClass ( $ contentClass ) ; $ content = $ impl -> createContent ( $ delivery ) ; return $ delivery -> editPropertyValues ( new core_kernel_classes_Property ( DeliveryTemplate :: PROPERTY_CONTENT ) , $ content ) ; }
Spawns new Content for a delivery
28,380
public function getImplementationByContent ( core_kernel_classes_Resource $ content ) { foreach ( $ content -> getTypes ( ) as $ type ) { if ( $ type -> isSubClassOf ( new core_kernel_classes_Class ( DeliveryContent :: CLASS_URI ) ) ) { return $ this -> getImplementationByContentClass ( $ type ) ; } } throw new common_exception_NoImplementation ( 'No implementation found for DeliveryContent ' . $ content -> getUri ( ) ) ; }
Returns the implementation from the content
28,381
public function getImplementationByContentClass ( core_kernel_classes_Class $ contentClass ) { $ classname = ( string ) $ contentClass -> getOnePropertyValue ( new core_kernel_classes_Property ( DeliveryContent :: PROPERTY_IMPLEMENTATION ) ) ; if ( empty ( $ classname ) ) { throw new common_exception_NoImplementation ( 'No implementation found for contentClass ' . $ contentClass -> getUri ( ) ) ; } if ( ! class_exists ( $ classname ) || ! in_array ( 'oat\\taoDeliveryTemplate\\model\\ContentModel' , class_implements ( $ classname ) ) ) { throw new common_exception_Error ( 'Content implementation ' . $ classname . ' not found, or not compatible for content class ' . $ contentClass -> getUri ( ) ) ; } return new $ classname ( ) ; }
Returns the implementation from the content class
28,382
public function index ( ) { $ this -> defaultData ( ) ; $ delivery = $ this -> getCurrentInstance ( ) ; $ this -> setData ( 'uri' , $ delivery -> getUri ( ) ) ; $ this -> setData ( 'classUri' , $ this -> getCurrentClass ( ) -> getUri ( ) ) ; $ this -> setData ( "deliveryLabel" , $ delivery -> getLabel ( ) ) ; $ compiled = $ this -> getClassService ( ) -> getAssembliesByTemplate ( $ delivery , true ) ; $ this -> setData ( "isCompiled" , ! empty ( $ compiled ) ) ; $ this -> setView ( "Compilation/index.tpl" ) ; }
Render json data to populate the delivery tree modelType must be in the request parameters
28,383
public function getAssembliesByTemplate ( core_kernel_classes_Resource $ deliveryTemplate , $ activeOnly = false ) { $ searchArray = $ activeOnly ? array ( PROPERTY_COMPILEDDELIVERY_DELIVERY => $ deliveryTemplate ) : array ( PROPERTY_COMPILEDDELIVERY_DELIVERY => $ deliveryTemplate , ) ; return $ this -> getRootClass ( ) -> searchInstances ( $ searchArray , array ( 'like' => 'false' , 'recursive' => true ) ) ; }
Returns the assemblies derived from the delivery template
28,384
public function createAssemblyFromTemplate ( core_kernel_classes_Resource $ deliveryTemplate ) { $ assemblyClass = $ this -> getRootClass ( ) ; $ content = DeliveryTemplateService :: singleton ( ) -> getContent ( $ deliveryTemplate ) ; if ( is_null ( $ content ) ) { throw new EmptyDeliveryException ( 'Delivery ' . $ deliveryTemplate -> getUri ( ) . ' has no content' ) ; } $ props = $ deliveryTemplate -> getPropertiesValues ( array ( OntologyRdfs :: RDFS_LABEL , TAO_DELIVERY_RESULTSERVER_PROP , TAO_DELIVERY_MAXEXEC_PROP , TAO_DELIVERY_START_PROP , TAO_DELIVERY_END_PROP , TAO_DELIVERY_EXCLUDEDSUBJECTS_PROP ) ) ; $ props [ PROPERTY_COMPILEDDELIVERY_DELIVERY ] = array ( $ deliveryTemplate ) ; return $ this -> createAssemblyByContent ( $ assemblyClass , $ content , $ props ) ; }
Creates a new assembly from the provided template and desactivates other assemblies crearted from the same template
28,385
protected function init ( ) { if ( $ this -> file -> hasError ) { throw new CException ( sprintf ( 'File could not be uploaded: %s' , $ this -> getUploadError ( $ this -> file -> getError ( ) ) ) ) ; } }
Checks if there were any errors during file upload .
28,386
protected function getUploadError ( $ code ) { switch ( $ code ) { case UPLOAD_ERR_INI_SIZE : case UPLOAD_ERR_FORM_SIZE : return 'File too large.' ; case UPLOAD_ERR_PARTIAL : return 'File upload was not completed.' ; case UPLOAD_ERR_NO_FILE : return 'No file was uploaded.' ; case UPLOAD_ERR_NO_TMP_DIR : return 'Temporary folder missing.' ; case UPLOAD_ERR_CANT_WRITE : return 'Failed to write to disk' ; case UPLOAD_ERR_EXTENSION : return 'A PHP extension stopped the file upload.' ; case UPLOAD_ERR_OK : default : return 'OK' ; } }
Returns the upload error message for the given error code .
28,387
public static function loadConfig ( $ filename ) { self :: fireEvent ( 'Atomik::Loadconfig::Before' , array ( & $ filename ) ) ; if ( ! preg_match ( '/.+\.(php|ini|json)$/' , $ filename ) ) { $ found = false ; foreach ( array ( 'php' , 'ini' , 'json' ) as $ format ) { if ( file_exists ( "$filename.$format" ) ) { $ found = true ; break ; } } if ( ! $ found ) { throw new AtomikException ( "Configuration file '$filename' not found" ) ; } $ filename .= ".$format" ; } else { $ format = substr ( $ filename , strrpos ( $ filename , '.' ) + 1 ) ; } $ config = array ( ) ; if ( $ format === 'ini' ) { if ( ( $ data = parse_ini_file ( $ filename , true ) ) === false ) { throw new AtomikException ( 'INI configuration malformed' ) ; } $ config = self :: dimensionizeArray ( $ data , '.' ) ; } else if ( $ format === 'json' ) { if ( ( $ config = json_decode ( file_get_contents ( $ filename ) , true ) ) === null ) { throw new AtomikException ( 'JSON configuration malformed' ) ; } } else { if ( is_array ( $ return = include ( $ filename ) ) ) { $ config = $ return ; } } self :: fireEvent ( 'Atomik::Loadconfig::After' , array ( $ filename , & $ config ) ) ; return $ config ; }
Loads a configuration file
28,388
public static function uriMatch ( $ pattern , $ uri = null ) { if ( $ uri === null ) { $ uri = self :: get ( 'request_uri' ) ; } $ uri = trim ( $ uri , '/' ) ; $ pattern = trim ( $ pattern , '/' ) ; $ regexp = $ pattern ; if ( $ pattern { 0 } != '#' ) { $ regexp = '#^' . str_replace ( '*' , '(.*)' , $ pattern ) . '$#' ; } return ( bool ) preg_match ( $ regexp , $ uri ) ; }
Checks if an uri matches the pattern .
28,389
public static function setViewContext ( $ context = null ) { if ( $ context === null ) { $ context = self :: get ( self :: get ( 'app.views.context_param' , 'format' ) , self :: get ( 'app.views.default_context' , 'html' ) , self :: get ( 'request' ) ) ; } self :: set ( 'app.view_context' , $ context ) ; if ( ( $ viewContextParams = self :: get ( "app.views.contexts.$context" , false ) ) !== false ) { if ( $ viewContextParams [ 'layout' ] !== true ) { self :: set ( 'app.layout' , $ viewContextParams [ 'layout' ] ) ; } header ( 'Content-type: ' . self :: get ( 'content_type' , 'text/html' , $ viewContextParams ) ) ; } }
Sets the view context
28,390
public static function executeFile ( $ action , $ method , $ vars , $ context ) { $ methodAction = $ action . '.' . $ method ; $ actionFilename = self :: actionFilename ( $ action ) ; $ methodActionFilename = self :: actionFilename ( $ methodAction ) ; self :: fireEvent ( 'Atomik::Executefile' , array ( & $ actionFilename , & $ methodActionFilename , & $ context ) ) ; if ( $ actionFilename === false && $ methodActionFilename === false ) { return false ; } $ atomik = self :: instance ( ) ; if ( $ actionFilename !== false ) { list ( $ content , $ vars ) = $ atomik -> scoped ( $ actionFilename , $ vars ) ; echo $ content ; } if ( $ methodActionFilename !== false ) { list ( $ content , $ vars ) = $ atomik -> scoped ( $ methodActionFilename , $ vars ) ; echo $ content ; } return $ vars ; }
Executor which uses files to define actions
28,391
public static function actionFilename ( $ action , $ dirs = null , $ useNamespaces = false ) { $ dirs = self :: path ( $ dirs ? : self :: get ( 'atomik.dirs.actions' ) ) ; if ( ( $ filename = self :: findFile ( "$action.php" , $ dirs , $ useNamespaces ) ) === false ) { return $ useNamespaces ? false : self :: findFile ( "$action/index.php" , $ dirs ) ; } return $ filename ; }
Returns an action s filename
28,392
public static function noRender ( ) { if ( count ( self :: $ execContexts ) ) { self :: $ execContexts [ count ( self :: $ execContexts ) - 1 ] [ 'render' ] = false ; } }
Prevents the view of the action from which it s called to be rendered
28,393
public static function setView ( $ view ) { if ( count ( self :: $ execContexts ) ) { self :: $ execContexts [ count ( self :: $ execContexts ) - 1 ] [ 'view' ] = $ view ; } }
Modifies the view associted to the action from which it s called
28,394
public static function renderFile ( $ filename , $ vars = array ( ) ) { self :: fireEvent ( 'Atomik::Renderfile::Before' , array ( & $ filename , & $ vars ) ) ; if ( ( $ callback = self :: get ( 'app.views.engine' , false ) ) !== false ) { if ( ! is_callable ( $ callback ) ) { throw new AtomikException ( 'The specified rendering engine callback cannot be called' ) ; } $ output = $ callback ( $ filename , $ vars ) ; } else { list ( $ output , $ vars ) = self :: instance ( ) -> scoped ( $ filename , $ vars , self :: get ( 'app.views.short_tags' , true ) ) ; } self :: fireEvent ( 'Atomik::Renderfile::After' , array ( $ filename , & $ output , $ vars ) ) ; return $ output ; }
Renders a file using a filename which will not be resolved .
28,395
public static function renderLayout ( $ layout , $ content , $ vars = array ( ) , $ dirs = null ) { $ dirs = $ dirs ? : self :: get ( 'atomik.dirs.layouts' ) ; if ( is_array ( $ layout ) ) { foreach ( array_reverse ( $ layout ) as $ l ) { $ content = self :: renderLayout ( $ l , $ content , $ vars , $ dirs ) ; } return $ content ; } $ appLayout = self :: delete ( 'app.layout' ) ; self :: set ( 'app.layout' , array ( $ layout ) ) ; do { $ layout = array_shift ( self :: getRef ( 'app.layout' ) ) ; self :: fireEvent ( 'Atomik::Renderlayout' , array ( & $ layout , & $ content , & $ vars , & $ dirs ) ) ; $ vars [ 'contentForLayout' ] = $ content ; $ content = self :: render ( $ layout , $ vars , $ dirs ) ; } while ( count ( self :: get ( 'app.layout' ) ) ) ; self :: set ( 'app.layout' , $ appLayout ) ; return $ content ; }
Renders a layout
28,396
public static function viewFilename ( $ view , $ dirs = null , $ extension = null ) { $ dirs = self :: path ( $ dirs ? : self :: get ( 'atomik.dirs.views' ) ) ; $ extension = $ extension ? : ltrim ( self :: get ( 'app.views.file_extension' ) , '.' ) ; if ( ( $ filename = self :: findFile ( "$view.$extension" , $ dirs ) ) === false ) { return self :: findFile ( "$view/index.$extension" , $ dirs ) ; } return $ filename ; }
Returns a view s filename
28,397
public static function loadHelper ( $ helperName , $ dirs = null ) { if ( isset ( self :: $ loadedHelpers [ $ helperName ] ) ) { return ; } self :: fireEvent ( 'Atomik::Loadhelper::Before' , array ( & $ helperName , & $ dirs ) ) ; $ functionName = $ helperName ; $ camelizedHelperName = str_replace ( ' ' , '' , ucwords ( str_replace ( '_' , ' ' , $ helperName ) ) ) ; $ className = $ camelizedHelperName . 'Helper' ; if ( ! function_exists ( $ functionName ) && ! class_exists ( $ className ) ) { $ dirs = self :: path ( $ dirs ? : self :: get ( 'atomik.dirs.helpers' ) ) ; if ( ( $ include = self :: findFile ( "$helperName.php" , $ dirs , true ) ) === false ) { throw new AtomikException ( "Helper '$helperName' not found" ) ; } list ( $ filename , $ ns ) = $ include ; include $ filename ; $ functionName = ltrim ( "$ns\\$functionName" , '\\' ) ; $ className = ltrim ( "$ns\\$className" , '\\' ) ; } if ( function_exists ( $ functionName ) ) { self :: $ loadedHelpers [ $ helperName ] = $ functionName ; } else if ( class_exists ( $ className , false ) ) { self :: $ loadedHelpers [ $ helperName ] = array ( new $ className ( ) , $ camelizedHelperName ) ; } else { throw new AtomikException ( "Helper '$helperName' file found but no function or class matching the helper name" ) ; } self :: fireEvent ( 'Atomik::Loadhelper::After' , array ( $ helperName , $ dirs ) ) ; }
Loads an helper file
28,398
public static function helper ( $ helperName , $ args = array ( ) , $ dirs = null ) { self :: loadHelper ( $ helperName , $ dirs ) ; return call_user_func_array ( self :: $ loadedHelpers [ $ helperName ] , $ args ) ; }
Executes an helper
28,399
public static function add ( $ key , $ value = null , $ dimensionize = true , & $ array = null ) { return self :: set ( $ key , $ value , $ dimensionize , $ array , 'append' ) ; }
Adds a value to the array pointed by the key