idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
226,700
public function getContent ( ) { if ( null === $ this -> templateHelper ) { throw new \ RuntimeException ( 'Rokka TemplateHelper is not set in RokkaHash. Needed for downloading images.' ) ; } if ( null === $ this -> content ) { $ rokkaHash = $ this -> getRokkaHash ( ) ; if ( null !== $ rokkaHash ) { $ this -> content =...
Returns the actual content of an image .
226,701
public function ltiParameterUpdate ( $ varname , $ value ) { $ lti = $ this -> session_get ( 'lti' , false ) ; if ( ! $ lti ) $ lti = array ( ) ; if ( is_array ( $ lti ) ) $ lti [ $ varname ] = $ value ; $ lti = $ this -> session_put ( 'lti' , $ lti ) ; }
Update a keyed variable from the LTI data in the current session with default
226,702
public function isSakai ( ) { $ ext_lms = $ this -> ltiRawParameter ( 'ext_lms' , false ) ; $ ext_lms = strtolower ( $ ext_lms ) ; return strpos ( $ ext_lms , 'sakai' ) === 0 ; }
Indicate if this launch came from Sakai
226,703
public function isMoodle ( ) { $ ext_lms = $ this -> ltiRawParameter ( 'ext_lms' , false ) ; $ ext_lms = strtolower ( $ ext_lms ) ; return strpos ( $ ext_lms , 'moodle' ) === 0 ; }
Indicate if this launch came from Moodle
226,704
public function isCoursera ( ) { $ product = $ this -> ltiRawParameter ( 'tool_consumer_info_product_family_code' , false ) ; $ tci_description = $ this -> ltiRawParameter ( 'tool_consumer_instance_description' , false ) ; return ( $ product == 'ims' && $ tci_description == 'Coursera' ) ; }
Indicate if this launch came from Coursera
226,705
public function newLaunch ( $ send_name = true , $ send_email = true ) { $ parms = array ( 'lti_message_type' => 'basic-lti-launch-request' , 'tool_consumer_info_product_family_code' => 'tsugi' , 'tool_consumer_info_version' => '1.1' , ) ; $ form_id = "tsugi_form_id_" . bin2Hex ( openssl_random_pseudo_bytes ( 4 ) ) ; $...
set up parameters for an outbound launch from this launch
226,706
public function getCurrentUserId ( ) { $ contents = $ this -> call ( 'GET' , self :: USER_RESOURCE ) -> getBody ( ) -> getContents ( ) ; $ json = json_decode ( $ contents , true ) ; return $ json [ 'user_id' ] ; }
Get current user .
226,707
public function createOrganization ( $ name , $ billingMail , $ displayName = '' ) { $ options = [ 'json' => [ 'billing_email' => $ billingMail , ] ] ; if ( ! empty ( $ displayName ) ) { $ options [ 'json' ] [ 'display_name' ] = $ displayName ; } $ contents = $ this -> call ( 'PUT' , self :: ORGANIZATION_RESOURCE . '/'...
Create an organization .
226,708
public function getOrganization ( $ organization = '' ) { $ contents = $ this -> call ( 'GET' , self :: ORGANIZATION_RESOURCE . '/' . $ this -> getOrganizationName ( $ organization ) ) -> getBody ( ) -> getContents ( ) ; return Organization :: createFromJsonResponse ( $ contents ) ; }
Return an organization .
226,709
public function createMembership ( $ userId , $ roles = [ Membership :: ROLE_READ ] , $ organization = '' ) { if ( \ is_string ( $ roles ) ) { $ roles = [ $ roles ] ; } $ roles = array_map ( function ( $ role ) { return strtolower ( $ role ) ; } , $ roles ) ; $ contents = $ this -> call ( 'PUT' , implode ( '/' , [ self...
Create a membership .
226,710
public function createUserAndMembership ( $ roles = [ Membership :: ROLE_READ ] , $ organization = '' ) { if ( \ is_string ( $ roles ) ) { $ roles = [ $ roles ] ; } $ roles = array_map ( function ( $ role ) { return strtolower ( $ role ) ; } , $ roles ) ; $ contents = $ this -> call ( 'POST' , implode ( '/' , [ self ::...
Create a user and membership associated to this organization .
226,711
public function getMembership ( $ userId , $ organization = '' ) { $ contents = $ this -> call ( 'GET' , implode ( '/' , [ self :: ORGANIZATION_RESOURCE , $ this -> getOrganizationName ( $ organization ) , 'memberships' , $ userId ] ) ) -> getBody ( ) -> getContents ( ) ; return $ this -> getSingleMemberShipFromJsonRes...
Get the membership metadata for the given organization and user s ID .
226,712
public function deleteMembership ( $ userId , $ organization = '' ) { try { $ response = $ this -> call ( 'DELETE' , implode ( '/' , [ self :: ORGANIZATION_RESOURCE , $ this -> getOrganizationName ( $ organization ) , 'memberships' , $ userId ] ) ) ; } catch ( GuzzleException $ e ) { if ( 404 == $ e -> getCode ( ) ) { ...
Deletes a membership for the given organization and user s ID .
226,713
public function listMemberships ( $ organization = '' ) { $ contents = $ this -> call ( 'GET' , implode ( '/' , [ self :: ORGANIZATION_RESOURCE , $ this -> getOrganizationName ( $ organization ) , 'memberships' ] ) ) -> getBody ( ) -> getContents ( ) ; $ membership = Membership :: createFromJsonResponse ( $ contents ) ...
List the membership metadata for the given organization .
226,714
public function getJson ( ) { global $ CFG , $ PDOX ; $ row = $ PDOX -> rowDie ( "SELECT json FROM {$CFG->dbprefix}{$this->TABLE_NAME} WHERE $this->PRIMARY_KEY = :PK" , array ( ":PK" => $ this -> id ) ) ; if ( $ row === false ) return false ; $ json = $ row [ 'json' ] ; if ( $ json === null ) return fals...
Load the json field for this entity
226,715
public function getJsonKey ( $ key , $ default = false ) { global $ CFG , $ PDOX ; $ jsonStr = $ this -> getJson ( ) ; if ( ! $ jsonStr ) return $ default ; $ json = json_decode ( $ jsonStr , true ) ; if ( ! $ json ) return $ default ; return U :: get ( $ json , $ key , $ default ) ; }
Get a JSON key for this entity
226,716
public function setJson ( $ json ) { global $ CFG , $ PDOX ; $ q = $ PDOX -> queryDie ( "UPDATE {$CFG->dbprefix}{$this->TABLE_NAME} SET json = :SET WHERE $this->PRIMARY_KEY = :PK" , array ( ":SET" => $ json , ":PK" => $ this -> id ) ) ; }
Set the JSON entry for this entity
226,717
public static function getImageClient ( $ organization , $ apiKey , $ options = [ ] ) { $ baseUrl = BaseClient :: DEFAULT_API_BASE_URL ; if ( ! \ is_array ( $ options ) ) { if ( \ func_num_args ( ) > 3 ) { $ baseUrl = func_get_arg ( 3 ) ; } elseif ( 3 === \ func_num_args ( ) ) { if ( 'http' !== substr ( $ options , 0 ,...
Return an image client .
226,718
public static function getUserClient ( $ organization = null , $ apiKey = null , $ options = [ ] ) { $ baseUrl = BaseClient :: DEFAULT_API_BASE_URL ; if ( \ is_array ( $ organization ) ) { $ options = $ organization ; $ organization = null ; $ apiKey = null ; } if ( isset ( $ options [ self :: API_BASE_URL ] ) ) { $ ba...
Return a user client .
226,719
private static function getGuzzleClient ( $ baseUrl , $ options = [ ] ) { $ guzzleOptions = [ ] ; if ( isset ( $ options [ self :: PROXY ] ) ) { $ guzzleOptions [ self :: PROXY ] = $ options [ self :: PROXY ] ; } if ( isset ( $ options [ self :: GUZZLE_OPTIONS ] ) ) { $ guzzleOptions = array_merge ( $ guzzleOptions , $...
Returns a Guzzle client with a retry middleware .
226,720
private static function retryDecider ( ) { return function ( $ retries , Request $ request , Response $ response = null , RequestException $ exception = null ) { if ( $ retries >= 10 ) { return false ; } if ( $ exception instanceof ConnectException ) { return true ; } if ( $ response ) { $ statusCode = $ response -> ge...
Returns a Closure for the Retry Middleware to decide if it should retry the request when it failed .
226,721
public static function returnUrl ( $ postdata = false ) { if ( ! $ postdata ) $ postdata = LTIX :: ltiRawPostArray ( ) ; return parent :: returnUrl ( $ postdata ) ; }
returnUrl - Returns the content_item_return_url
226,722
public static function allowImportItem ( $ postdata = false ) { if ( ! $ postdata ) $ postdata = LTIX :: ltiRawPostArray ( ) ; return parent :: allowImportItem ( $ postdata ) ; }
allowImportItem - Returns true if we can return Common Cartridges
226,723
function prepareResponse ( $ endform = false ) { $ return_url = $ this -> returnUrl ( ) ; $ parms = $ this -> getContentItemSelection ( ) ; $ parms = LTIX :: signParameters ( $ parms , $ return_url , "POST" , "Install Content" ) ; $ endform = '<a href="index.php" class="btn btn-warning">Back to Store</a>' ; $ content =...
Make up a response
226,724
public static function button ( $ right = false ) { global $ LINK ; if ( $ right ) echo ( '<span style="position: fixed; right: 10px; top: 5px;">' ) ; echo ( '<button onclick="showModal(\'' . __ ( 'Analytics' ) . ' ' . htmlentities ( $ LINK -> title ) . '\',\'analytics_div\'); return false;" type="button" class="btn bt...
Emit a properly styled settings button
226,725
public static function templateInclude ( $ name ) { if ( is_array ( $ name ) ) { foreach ( $ name as $ n ) { self :: templateInclude ( $ n ) ; } return ; } echo ( '<script id="script-template-' . $ name . '" type="text/x-handlebars-template">' . "\n" ) ; $ template = file_get_contents ( 'templates/' . $ name . '.hbs' )...
templateInclude - Include a handlebars template dealing with i18n
226,726
public static function templateProcess ( $ template ) { $ new = preg_replace_callback ( '|{{__ *\'([^\']*)\' *}}|' , function ( $ matches ) { return __ ( htmlent_utf8 ( trim ( $ matches [ 1 ] ) ) ) ; } , $ template ) ; $ new = preg_replace_callback ( '|{{__ *"([^"]*)" *}}|' , function ( $ matches ) { return __ ( htmlen...
templateProcess - Process a handlebars template dealing with i18n
226,727
public static function isRequestCheck ( $ request_data = false ) { if ( $ request_data === false ) $ request_data = $ _REQUEST ; if ( ! isset ( $ request_data [ "lti_message_type" ] ) ) return false ; if ( ! isset ( $ request_data [ "lti_version" ] ) ) return false ; $ good_lti_version = self :: isValidVersion ( $ requ...
Determines if this is a valid Basic LTI message
226,728
public static function verifyKeyAndSecret ( $ key , $ secret , $ http_url = NULL , $ parameters = null , $ http_method = NULL ) { global $ LastOAuthBodyBaseString ; if ( ! ( $ key && $ secret ) ) return array ( "Missing key or secret" , "" ) ; $ store = new TrivialOAuthDataStore ( ) ; $ store -> add_consumer ( $ key , ...
Verify the message signature for this request
226,729
public static function sendJSONGrade ( $ grade , $ comment , $ result_url , $ key_key , $ secret , & $ debug_log = false , $ signature = false ) { global $ LastJSONGradeResponse ; $ LastJSONGradeResponse = false ; $ content_type = "application/vnd.ims.lis.v2.result+json" ; if ( is_array ( $ debug_log ) ) $ debug_log [ ...
Send a grade using the JSON protocol from IMS LTI 2 . x
226,730
public static function sendJSONSettings ( $ settings , $ settings_url , $ key_key , $ secret , & $ debug_log = false , $ signature = false ) { $ content_type = "application/vnd.ims.lti.v2.toolsettings.simple+json" ; if ( is_array ( $ debug_log ) ) $ debug_log [ ] = array ( 'Sending ' . count ( $ settings ) . ' settings...
Send setings data using the JSON protocol from IMS LTI 2 . x
226,731
public static function sendJSONBody ( $ method , $ postBody , $ content_type , $ rest_url , $ key_key , $ secret , & $ debug_log = false , $ signature = false ) { if ( is_array ( $ debug_log ) ) $ debug_log [ ] = array ( 'Sending ' . strlen ( $ postBody ) . ' bytes to rest_url=' . $ rest_url ) ; $ more_headers = false ...
Send a JSON body LTI 2 . x Style
226,732
public static function ltiLinkUrl ( $ postdata = false ) { if ( $ postdata === false ) $ postData = $ _POST ; if ( ! isset ( $ postdata [ 'content_item_return_url' ] ) ) return false ; if ( isset ( $ postdata [ 'accept_media_types' ] ) ) { $ ltilink_mimetype = 'application/vnd.ims.lti.v1.ltilink' ; $ m = new Mimeparse ...
ltiLinkUrl - Returns true if we can return LTI Links for this launch
226,733
public static function getLtiLinkJSON ( $ url , $ title = false , $ text = false , $ icon = false , $ fa_icon = false , $ custom = false ) { $ return = '{ "@context" : "http://purl.imsglobal.org/ctx/lti/v1/ContentItem", "@graph" : [ { "@type" : "LtiLinkItem", ...
getLtiLinkJson - Get a JSON object for an LTI Link Content Item Return
226,734
public static function validateUpload ( $ FILE_DESCRIPTOR , $ SAFETY_CHECK = true ) { $ retval = true ; $ filename = isset ( $ FILE_DESCRIPTOR [ 'name' ] ) ? basename ( $ FILE_DESCRIPTOR [ 'name' ] ) : false ; if ( $ FILE_DESCRIPTOR [ 'error' ] == 1 ) { $ retval = _m ( "General upload failure" ) ; } else if ( $ FILE_DE...
Returns true if this is a good upload an error string if not
226,735
public static function isPngOrJpeg ( $ FILE_DESCRIPTOR ) { if ( ! isset ( $ FILE_DESCRIPTOR [ 'name' ] ) ) return false ; if ( ! isset ( $ FILE_DESCRIPTOR [ 'tmp_name' ] ) ) return false ; $ info = getimagesize ( $ FILE_DESCRIPTOR [ 'tmp_name' ] ) ; if ( ! is_array ( $ info ) ) return false ; $ image_type = $ info [ 2 ...
Make sure the contents of this file are a PNG or JPEG
226,736
public static function uploadToBlob ( $ FILE_DESCRIPTOR , $ SAFETY_CHECK = true ) { $ retval = self :: uploadFileToBlob ( $ FILE_DESCRIPTOR , $ SAFETY_CHECK ) ; if ( is_array ( $ retval ) ) $ retval = $ retval [ 0 ] ; return $ retval ; }
uploadToBlob - returns blob_id or false
226,737
public static function migrate ( $ file_id , $ test_key = false ) { global $ CFG , $ PDOX ; $ retval = false ; if ( isset ( $ CFG -> dataroot ) && strlen ( $ CFG -> dataroot ) > 0 ) { if ( ! $ test_key ) { $ retval = self :: blob2file ( $ file_id ) ; } } else { $ retval = self :: blob2blob ( $ file_id ) ; } return $ re...
Check and migrate a blob from an old place to the right new place
226,738
public static function blob2file ( $ file_id ) { global $ CFG , $ PDOX ; if ( ! isset ( $ CFG -> dataroot ) || strlen ( $ CFG -> dataroot ) < 1 ) return ; $ stmt = $ PDOX -> prepare ( "SELECT file_sha256, blob_id FROM {$CFG->dbprefix}blob_file WHERE path IS NULL AND file_id = :ID" ) ; $ stmt -> ex...
Check and migrate a blob to its corresponding file
226,739
public static function pushCaliperEvents ( $ seconds = 3 , $ max = 100 , $ debug = false ) { $ purged = self :: purgeCaliperEvents ( ) ; $ start = time ( ) ; $ count = 0 ; $ now = $ start ; $ end = $ start + $ seconds ; $ failure = 0 ; $ failure_code = false ; $ retval = array ( ) ; if ( U :: apcAvailable ( ) ) { $ fou...
Send the backlog of caliper events but don t overrun
226,740
public static function purgeCaliperEvents ( ) { global $ CFG ; if ( U :: apcAvailable ( ) ) { $ push_found = false ; $ last_push = apc_fetch ( 'last_event_push_time' , $ push_found ) ; $ push_diff = time ( ) - $ last_push ; $ purge_found = false ; $ last_purge = apc_fetch ( 'last_event_purge_time' , $ purge_found ) ; $...
Periodic cleanup of broken Caliper events
226,741
protected function heartbeat ( ) : DisposableInterface { return $ this -> readBuffer -> timeout ( $ this -> heartBeatRate ) -> filter ( function ( SocketMessage $ message ) { return $ message -> getMessageType ( ) -> getType ( ) === MessageType :: HEARTBEAT_REQUEST_COMMAND ; } ) -> subscribe ( new CallbackObserver ( fu...
Intercept heartbeat message and answer automatically
226,742
public function catchUpSubscription ( string $ streamId , int $ startFrom = self :: POSITION_START , bool $ resolveLink = false ) : Observable { return $ this -> readEventsForward ( $ streamId , $ startFrom , self :: DEFAULT_MAX_EVENTS , $ resolveLink ) -> concat ( $ this -> volatileSubscription ( $ streamId , $ resolv...
This kind of subscription specifies a starting point in the form of an event number or transaction file position . The given function will be called for events from the starting point until the end of the stream and then for subsequently written events .
226,743
public function volatileSubscription ( string $ streamId , bool $ resolveLink = false ) : Observable { $ event = new SubscribeToStream ( ) ; $ event -> setEventStreamId ( $ streamId ) ; $ event -> setResolveLinkTos ( $ resolveLink ) ; return Observable :: create ( function ( ObserverInterface $ observer ) use ( $ event...
This kind of subscription calls a given function for events written after the subscription is established .
226,744
public function getAreasByName ( $ name ) { if ( ! isset ( $ this -> areas [ $ name ] ) ) { return null ; } return $ this -> areas [ $ name ] ; }
Gets an array of Areas with a specific name .
226,745
public static function createFromDecodedJsonResponse ( $ data ) { $ areas = [ ] ; foreach ( $ data as $ name => $ area ) { $ areas [ $ name ] = [ ] ; foreach ( $ area as $ class => $ data ) { $ metaClass = DynamicMetadataHelper :: getDynamicMetadataClassName ( $ class ) ; $ areas [ $ name ] [ ] = $ metaClass :: createF...
Create a DynamicMetadata from the decoded JSON data .
226,746
public static function loadLinkInfo ( $ link_id ) { global $ CFG , $ PDOX , $ CONTEXT ; $ cacheloc = 'lti_link' ; $ row = Cache :: check ( $ cacheloc , $ link_id ) ; if ( $ row != false ) return $ row ; $ stmt = $ PDOX -> queryDie ( "SELECT title FROM {$CFG->dbprefix}lti_link WHERE link_id = :LID AND con...
Load link information for a different link than current
226,747
public function getPlacementSecret ( ) { global $ CFG ; $ PDOX = $ this -> launch -> pdox ; $ stmt = $ PDOX -> queryDie ( "SELECT placementsecret FROM {$CFG->dbprefix}lti_link WHERE link_id = :LID" , array ( ':LID' => $ this -> id ) ) ; $ row = $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ; $ placementsecret...
Get the placement secret for this Link
226,748
public function returnUrl ( ) { if ( ! isset ( $ this -> claim ) ) return false ; return isset ( $ this -> claim -> deep_link_return_url ) ? $ this -> claim -> deep_link_return_url : false ; }
returnUrl - Returns the deep_link_return_url
226,749
public function allowMimetype ( $ Mimetype ) { if ( ! $ this -> returnUrl ( ) ) return false ; if ( isset ( $ this -> claim -> accept_media_types ) ) { $ ma = $ Mimetype ; if ( ! is_array ( $ ma ) ) $ ma = array ( $ Mimetype ) ; $ m = new Mimeparse ; $ allowed = $ m -> best_match ( $ ma , $ this -> claim -> accept_medi...
allowMimetype - Returns true if we can return LTI Link Items
226,750
public function acceptType ( $ type ) { if ( ! isset ( $ this -> claim -> accept_types ) ) return false ; if ( ! is_array ( $ this -> claim -> accept_types ) ) return false ; return in_array ( $ type , $ this -> claim -> accept_types ) ; }
acceptType - Returns true if the string is in the accept_types
226,751
function getScriptFolder ( ) { $ path = self :: getScriptPathFull ( ) ; if ( $ path === false ) return false ; $ pieces = explode ( '/' , $ path ) ; if ( count ( $ pieces ) < 1 ) return false ; return $ pieces [ count ( $ pieces ) - 1 ] ; }
This function will return attend
226,752
function getPwd ( $ file ) { $ root = $ this -> dirroot ; $ path = realpath ( dirname ( $ file ) ) ; $ root .= '/' ; if ( strlen ( $ path ) < strlen ( $ root ) ) return false ; if ( strpos ( $ path , $ root ) !== 0 ) return false ; $ retval = substr ( $ path , strlen ( $ root ) ) ; return $ retval ; }
Get the current working directory of a file
226,753
public function getCurrentUrl ( ) { $ script = self :: getScriptName ( ) ; if ( $ script === false ) return false ; $ pieces = $ this -> apphome ; if ( $ this -> apphome ) { $ pieces = parse_url ( $ this -> apphome ) ; } if ( ! isset ( $ pieces [ 'scheme' ] ) ) return false ; $ retval = $ pieces [ 'scheme' ] . '://' . ...
Get the current URL we are executing - no query parameters
226,754
public function getCurrentUrlFolder ( ) { $ url = self :: getCurrentUrl ( ) ; $ pieces = explode ( '/' , $ url ) ; array_pop ( $ pieces ) ; $ retval = implode ( '/' , $ pieces ) ; return $ retval ; }
Get the current folder of the URL we are executing - no trailing slash
226,755
public function localhost ( ) { if ( strpos ( $ this -> wwwroot , '://localhost' ) !== false ) return true ; if ( strpos ( $ this -> wwwroot , '://127.0.0.1' ) !== false ) return true ; return false ; }
Are we on localhost?
226,756
public static function createFromDecodedJsonResponse ( $ data ) { if ( ! isset ( $ data [ 'user_metadata' ] ) ) { $ data [ 'user_metadata' ] = [ ] ; } else { foreach ( $ data [ 'user_metadata' ] as $ key => $ value ) { if ( 0 === strpos ( $ key , 'date:' ) ) { $ data [ 'user_metadata' ] [ $ key ] = new \ DateTime ( $ v...
Create a source image from the decoded JSON data .
226,757
public static function & clone_remote ( $ repo_path , $ remote , $ reference = null ) { return GitRepo :: create_new ( $ repo_path , $ remote , true , $ reference ) ; }
Clones a remote repo into a directory and then returns a GitRepo object for the newly created local repo
226,758
public static function buildSearchSortParameter ( array $ sorts ) { if ( empty ( $ sorts ) ) { return '' ; } $ sorting = [ ] ; foreach ( $ sorts as $ sortField => $ direction ) { if ( ! self :: validateFieldName ( ( string ) $ sortField ) ) { throw new \ LogicException ( sprintf ( 'Invalid field name "%s" for sorting f...
Builds the sort parameter for the source image listing API endpoint .
226,759
public static function isRequestDetail ( $ request_data = false ) { $ raw_jwt = self :: raw_jwt ( $ request_data ) ; if ( ! $ raw_jwt ) return false ; $ jwt = self :: parse_jwt ( $ raw_jwt ) ; if ( is_string ( $ jwt ) ) { return $ jwt ; } return is_object ( $ jwt ) ; }
Returns true false or a string
226,760
public static function isRequest ( $ request_data = false ) { $ retval = self :: isRequestDetail ( $ request_data ) ; if ( is_string ( $ retval ) ) { error_log ( "Bad launch " . $ retval ) ; return false ; } return is_object ( $ retval ) ; }
Returns true or false
226,761
public static function verifyPublicKey ( $ raw_jwt , $ public_key , $ algs ) { try { $ decoded = JWT :: decode ( $ raw_jwt , $ public_key , $ algs ) ; return true ; } catch ( \ Exception $ e ) { return $ e ; } }
Verify the Public Key for this request
226,762
public static function jonPostel ( $ body , & $ failures ) { if ( isset ( $ CFG -> jon_postel ) ) return ; $ version = false ; if ( isset ( $ body -> { self :: VERSION_CLAIM } ) ) $ version = $ body -> { self :: VERSION_CLAIM } ; if ( strpos ( $ version , '1.3' ) !== 0 ) $ failures [ ] = "Bad LTI version: " . $ version...
Apply Jon Postel s Law as appropriate
226,763
public static function loadRoster ( $ membership_url , $ access_token , & $ debug_log = false ) { $ ch = curl_init ( ) ; $ membership_url = trim ( $ membership_url ) ; $ headers = [ 'Authorization: Bearer ' . $ access_token , 'Accept: ' . self :: MEDIA_TYPE_MEMBERSHIPS , 'Content-Type: ' . self :: MEDIA_TYPE_MEMBERSHIP...
Call memberships and roles
226,764
public static function loadLineItem ( $ lineitem_url , $ access_token , & $ debug_log = false ) { $ lineitem_url = trim ( $ lineitem_url ) ; $ ch = curl_init ( ) ; $ headers = [ 'Authorization: Bearer ' . $ access_token , 'Accept: ' . self :: MEDIA_TYPE_LINEITEM , ] ; curl_setopt ( $ ch , CURLOPT_URL , $ lineitem_url )...
Load A LineItem
226,765
public static function loadResults ( $ lineitem_url , $ access_token , & $ debug_log = false ) { $ lineitem_url = trim ( $ lineitem_url ) ; $ ch = curl_init ( ) ; $ headers = [ 'Authorization: Bearer ' . $ access_token , 'Content-Type: ' . self :: RESULTS_TYPE , 'Accept: ' . self :: RESULTS_TYPE ] ; $ actual_url = $ li...
Load results for a LineItem
226,766
public static function deleteLineItem ( $ lineitem_url , $ access_token , & $ debug_log = false ) { $ lineitem_url = trim ( $ lineitem_url ) ; $ ch = curl_init ( ) ; $ headers = [ 'Authorization: Bearer ' . $ access_token ] ; curl_setopt ( $ ch , CURLOPT_URL , $ lineitem_url ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER ...
Delete A LineItem
226,767
public static function getISO8601 ( $ timestamp = false ) { if ( $ timestamp === false ) { $ dt = new \ DateTime ( ) ; } else { $ format = 'Y-m-d H:i:s' ; $ dt = \ DateTime :: createFromFormat ( $ format , $ timestamp ) ; } $ iso8601 = $ dt -> format ( \ DateTime :: ISO8601 ) ; $ iso8601 = str_replace ( '-1000' , '.000...
Get Caliper - style ISO8601 Datetime from unix timestamp
226,768
public static function sensorCanvasPageView ( $ user , $ application , $ page , $ timestamp = false , $ name , $ duration = 'PT5M30S' ) { $ caliper = json_decode ( '{ "@context" : "http://purl.imsglobal.org/ctx/caliper/v1/ViewEvent", "@type" : "http://purl.imsglobal.org/caliper/v1/ViewEvent", ...
This is just a test method to return properly formatted JSON for the Canvas prototype Caliper
226,769
public function cleanup ( ) { if ( $ this -> option ( 'force' ) ) { $ this -> deleteDirs ( ) ; } elseif ( $ this -> confirm ( 'Delete all subdirectories in migrations folder?' , true ) ) { $ this -> deleteDirs ( ) ; } }
Decide whether or not to delete directories .
226,770
public function deleteDirs ( ) { $ dirs = $ this -> files -> directories ( $ this -> basePath ) ; foreach ( $ dirs as $ dir ) { $ this -> files -> deleteDirectory ( $ dir ) ; } $ this -> info ( 'Subdirectories deleted' ) ; }
Delete subdirectories in the migrations folder .
226,771
public static function createFromDecodedJsonResponse ( $ data ) { $ stack_operations = [ ] ; if ( isset ( $ data [ 'stack_operations' ] ) && \ is_array ( $ data [ 'stack_operations' ] ) ) { foreach ( $ data [ 'stack_operations' ] as $ operation ) { $ stack_operations [ ] = StackOperation :: createFromDecodedJsonRespons...
Create a stack from a decoded JSON data returned by the rokka . io API .
226,772
public static function createFromConfig ( $ stackName , array $ config , $ organization = null ) { $ stack = new static ( $ organization , $ stackName ) ; if ( isset ( $ config [ 'operations' ] ) ) { $ stack -> setStackOperations ( $ config [ 'operations' ] ) ; } if ( isset ( $ config [ 'options' ] ) ) { $ stack -> set...
Creates a Stack object from an array .
226,773
public function getDynamicUriString ( ) { $ stack = new StackUri ( 'dynamic' , $ this -> getStackOperations ( ) , $ this -> getStackOptions ( ) , $ this -> getStackVariables ( ) ) ; return $ stack -> getStackUriString ( ) ; }
Returns the stack url part as a dynamic stack for previewing .
226,774
public static function createFromJsonResponse ( $ data ) { $ data = json_decode ( $ data , true ) ; $ stacks = array_map ( function ( $ stack ) { return Stack :: createFromDecodedJsonResponse ( $ stack ) ; } , $ data [ 'items' ] ) ; return new self ( $ stacks ) ; }
Create a stack from the JSON data returned by the rokka . io API .
226,775
public function click ( $ time = null ) { $ this -> total ++ ; if ( ! $ this -> timestart ) { $ this -> timestart = ( int ) ( time ( ) / $ this -> scale ) ; } if ( ! $ time ) $ time = time ( ) ; $ time = ( int ) ( $ time / $ this -> scale ) ; $ delta = $ time - $ this -> timestart ; if ( $ delta < 0 ) $ delta = 0 ; if ...
Record a click ...
226,776
public function reconstruct ( ) { $ retval = array ( ) ; foreach ( $ this -> buckets as $ k => $ v ) { $ t = ( $ this -> timestart + $ k ) * $ this -> scale ; $ retval [ $ t ] = $ v ; } return $ retval ; }
Reconstruct to the actual times
226,777
public function viewModel ( ) { $ retval = new \ stdClass ( ) ; $ buckets = $ this -> reconstruct ( ) ; $ retval -> timestart = $ this -> timestart * $ this -> scale ; $ retval -> width = $ this -> scale ; $ max = false ; $ maxt = false ; $ min = false ; $ rows = array ( ) ; foreach ( $ buckets as $ k => $ v ) { if ( $...
Produce an view model of the entire object
226,778
public static function uncompressEntry ( $ text ) { if ( $ text === null | $ text === false ) return $ text ; $ needed = false ; for ( $ i = 0 ; $ i < strlen ( $ text ) ; $ i ++ ) { $ ch = $ text [ $ i ] ; if ( $ ch >= '0' && $ ch <= '9' ) continue ; if ( $ ch == ':' || $ ch == ',' || $ ch == '=' ) continue ; $ needed ...
Optionally uncompress a serialized entry if it is compressed
226,779
public function serialize ( $ maxlength = null , $ compress = false ) { if ( ! $ maxlength ) $ maxlength = $ this -> maxlen ; $ retval = $ this -> scale . ':' . $ this -> timestart . ':' . U :: array_Integer_Serialize ( $ this -> buckets ) ; if ( strlen ( $ retval ) <= $ maxlength ) return $ retval ; $ allowCompress = ...
Serialize to a key = value pair
226,780
function getLoginUrl ( $ state ) { $ loginUrl = "https://accounts.google.com/o/oauth2/auth?" . "client_id=" . $ this -> client_id . "&redirect_uri=" . $ this -> redirect . "&state=" . $ state . "&response_type=code" . "&scope=email%20profile" . "&include_granted_scopes=true" ; if ( $ this -> openid_realm ) { $ loginUrl...
Get the login url
226,781
public static function route_get_local_path ( $ dir ) { $ uri = $ _SERVER [ 'REQUEST_URI' ] ; $ root = $ _SERVER [ 'DOCUMENT_ROOT' ] ; $ cwd = $ dir ; if ( strlen ( $ cwd ) < strlen ( $ root ) + 1 ) return false ; $ lwd = substr ( $ cwd , strlen ( $ root ) ) ; if ( strlen ( $ uri ) < strlen ( $ lwd ) + 2 ) return false...
Convienence method to get the local path if we are doing
226,782
public static function get_request_document ( ) { $ uri = $ _SERVER [ 'REQUEST_URI' ] ; $ pieces = explode ( '/' , $ uri ) ; if ( count ( $ pieces ) > 1 ) { $ local_path = $ pieces [ count ( $ pieces ) - 1 ] ; $ pos = strpos ( $ local_path , '?' ) ; if ( $ pos > 0 ) $ local_path = substr ( $ local_path , 0 , $ pos ) ; ...
Get the last bit of the path
226,783
public static function get_base_url ( $ url ) { $ pieces = parse_url ( $ url ) ; $ retval = $ pieces [ 'scheme' ] . '://' . $ pieces [ 'host' ] ; $ port = self :: get ( $ pieces , 'port' ) ; if ( $ port && $ port != 80 && $ port != 443 ) $ retval .= ':' . $ port ; return $ retval ; }
Get the protocol host and port from an absolute URL
226,784
public static function parse_rest_path ( $ uri = false , $ SERVER_SCRIPT_NAME = false ) { if ( ! $ SERVER_SCRIPT_NAME ) $ SERVER_SCRIPT_NAME = $ _SERVER [ "SCRIPT_NAME" ] ; if ( ! $ uri ) $ uri = $ _SERVER [ 'REQUEST_URI' ] ; $ pos = strpos ( $ uri , '?' ) ; if ( $ pos !== false ) $ uri = substr ( $ uri , 0 , $ pos ) ;...
Get the controller for the current request
226,785
public static function rest_path ( $ uri = false , $ SERVER_SCRIPT_NAME = false ) { global $ CFG ; $ retval = self :: parse_rest_path ( $ uri , $ SERVER_SCRIPT_NAME ) ; if ( ! is_array ( $ retval ) ) return false ; $ retobj = new \ stdClass ( ) ; if ( $ retval [ 0 ] == '/' ) { $ retobj -> parent = '' ; } else { $ retob...
Return a rest - path
226,786
public static function remove_relative_path ( $ path ) { $ pieces = explode ( '/' , $ path ) ; $ new_pieces = array ( ) ; for ( $ i = 0 ; $ i < count ( $ pieces ) ; $ i ++ ) { if ( $ pieces [ $ i ] == '.' ) continue ; if ( $ pieces [ $ i ] == '..' ) { array_pop ( $ new_pieces ) ; continue ; } $ new_pieces [ ] = $ piece...
Remove any relative elements from a path
226,787
public static function http_response_code ( $ newcode = NULL ) { static $ code = 200 ; if ( $ newcode !== NULL ) { header ( 'X-PHP-Response-Code: ' . $ newcode , true , $ newcode ) ; if ( ! headers_sent ( ) ) $ code = $ newcode ; } return $ code ; }
For 4 . 3 . 0 < = PHP < = 5 . 4 . 0
226,788
public static function array_Integer_Deserialize ( $ input ) { $ r = array ( ) ; preg_match_all ( "/([^,= ]+)=([^,= ]+)/" , $ input , $ r ) ; $ result = array ( ) ; for ( $ i = 0 ; $ i < count ( $ r [ 1 ] ) ; $ i ++ ) { $ k = $ r [ 1 ] [ $ i ] ; $ v = $ r [ 2 ] [ $ i ] ; if ( ! is_numeric ( $ k ) || ! is_numeric ( $ v ...
Deserialize an tightly serialized integer - only PHP array
226,789
public static function getCaller ( $ count = 1 ) { $ dbts = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS , 6 + $ count ) ; if ( ! is_array ( $ dbts ) || count ( $ dbts ) < 2 ) return null ; if ( ! isset ( $ dbts [ 0 ] [ 'file' ] ) ) return null ; $ myfile = $ dbts [ 0 ] [ 'file' ] ; $ retval = '' ; foreach ( $ dbts as...
Need to replicate the code or U . php will be in the traceback
226,790
private function annotationCrawl ( array $ annotations , LinkType $ link , ResourceObject $ current ) : ResourceObject { $ isList = $ this -> isList ( $ current -> body ) ; $ bodyList = $ isList ? ( array ) $ current -> body : [ $ current -> body ] ; foreach ( $ bodyList as & $ body ) { $ this -> crawl ( $ annotations ...
Link annotation crawl
226,791
public function getStackOperationsByName ( $ name ) { $ stackOperations = [ ] ; foreach ( $ this -> stackOperations as $ stackOperation ) { if ( $ stackOperation -> name === $ name ) { $ stackOperations [ ] = $ stackOperation ; } } return $ stackOperations ; }
Returns all operations matching name .
226,792
public static function get_headers ( ) { $ headers = OAuthUtil :: get_headers_internal ( ) ; if ( ! is_array ( $ headers ) ) return $ headers ; if ( ( ! isset ( $ headers [ 'Authorization' ] ) ) && isset ( $ headers [ 'X-Oauth1-Authorization' ] ) ) { $ headers [ 'Authorization' ] = $ headers [ 'X-Oauth1-Authorization' ...
header on our behalf - fall back to the alternate Authorization header .
226,793
public static function createFromArray ( $ config ) { if ( ! isset ( $ config [ 'stack' ] ) ) { throw new \ RuntimeException ( 'Stack has to be set' ) ; } $ hash = isset ( $ config [ 'hash' ] ) ? $ config [ 'hash' ] : null ; $ format = isset ( $ config [ 'format' ] ) ? $ config [ 'format' ] : null ; $ filename = isset ...
Creates a UriComponent object from an array with stack hash format filename and stack as keys .
226,794
protected function isPackageSupported ( $ package ) { $ extra = $ package -> getExtra ( ) ; if ( ! empty ( $ extra [ 'drupal' ] [ 'security-coverage' ] [ 'status' ] ) && $ extra [ 'drupal' ] [ 'security-coverage' ] [ 'status' ] == 'not-covered' ) { return false ; } return true ; }
Checks to see if this Drupal package is supported by the Drupal Security Team .
226,795
public function onPostCmdEvent ( \ Composer \ Script \ Event $ event ) { if ( ! empty ( $ this -> unsupportedPackages ) ) { $ this -> io -> write ( '<error>You are using Drupal packages that are not supported by the Drupal Security Team!</error>' ) ; foreach ( $ this -> unsupportedPackages as $ package_name => $ packag...
Execute blt update after update command has been executed if applicable .
226,796
protected function getDrupalPackage ( $ operation ) { if ( $ operation instanceof InstallOperation ) { $ package = $ operation -> getPackage ( ) ; } elseif ( $ operation instanceof UpdateOperation ) { $ package = $ operation -> getTargetPackage ( ) ; } if ( $ this -> isDrupalPackage ( $ package ) ) { return $ package ;...
Gets the package if it is a Drupal related package .
226,797
protected function isDrupalPackage ( $ package ) { if ( isset ( $ package ) && $ package instanceof PackageInterface && strstr ( $ package -> getName ( ) , 'drupal/' ) ) { return true ; } return false ; }
Checks to see if a given package is a Drupal package .
226,798
public function indexBy ( $ column ) { if ( ! $ this -> asArray ) { return parent :: indexBy ( $ column ) ; } $ modelClass = $ this -> modelClass ; $ this -> indexBy = function ( $ row ) use ( $ column , $ modelClass ) { if ( isset ( $ row [ $ column ] ) ) { return $ row [ $ column ] ; } $ dynamicColumn = $ modelClass ...
Converts the indexBy column name an anonymous function that writes rows to the result array indexed an attribute name that may be in dotted notation .
226,799
public function prepare ( $ builder ) { $ modelClass = $ this -> modelClass ; $ this -> _dynamicColumn = $ modelClass :: dynamicColumn ( ) ; if ( empty ( $ this -> _dynamicColumn ) ) { throw new \ yii \ base \ InvalidConfigException ( $ modelClass . '::dynamicColumn() must return an attribute name' ) ; } if ( empty ( $...
Maria - specific preparation for building a query that includes a dynamic column .