idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
45,700
public function renderAll ( $ buffer = false ) { ob_start ( ) ; echo ( '<div typeof="Course">' . "\n" ) ; echo ( '<h1>' . $ this -> lessons -> title . "</h1>\n" ) ; echo ( '<p property="description">' . $ this -> lessons -> description . "</p>\n" ) ; echo ( '<div id="box">' . "\n" ) ; $ count = 0 ; foreach ( $ this -> ...
End of renderSingle
45,701
public function getCustomWithInherit ( $ key , $ rlid = false ) { global $ CFG ; $ custom = LTIX :: ltiCustomGet ( $ key ) ; if ( strlen ( $ custom ) > 0 ) return $ custom ; if ( $ rlid === false ) return false ; $ lti = $ this -> getLtiByRlid ( $ rlid ) ; if ( isset ( $ lti -> custom ) ) foreach ( $ lti -> custom as $...
Check if a setting value is in a resource in a Lesson
45,702
public static function parseHeaders ( $ headerstr = false ) { if ( $ headerstr === false ) $ headerstr = self :: getLastHeadersReceived ( ) ; $ lines = explode ( "\n" , $ headerstr ) ; $ headermap = array ( ) ; foreach ( $ lines as $ line ) { $ pos = strpos ( $ line , ':' ) ; if ( $ pos < 1 ) continue ; $ key = substr ...
Extract a set of header lines into an array
45,703
public static function getIP ( ) { if ( function_exists ( 'apache_request_headers' ) ) { $ headers = apache_request_headers ( ) ; } else { $ headers = $ _SERVER ; } $ filter_option = 0 ; $ the_ip = false ; if ( $ the_ip === false && array_key_exists ( 'HTTP_CF_CONNECTING_IP' , $ headers ) ) { $ pieces = explode ( ',' ,...
Get the actual IP address of the incoming request .
45,704
protected function compile ( ) : void { $ metaModel = $ this -> factory -> translateIdToMetaModelName ( $ this -> metamodel ) ; try { $ this -> Template -> editor = $ this -> editor -> editFor ( $ metaModel , 'create' ) ; } catch ( NotEditableException $ exception ) { throw new AccessDeniedException ( $ exception -> ge...
Compile the content element .
45,705
public static function enabled ( ) { global $ CFG ; $ config = isset ( $ CFG -> websocket_url ) && isset ( $ CFG -> websocket_secret ) ; if ( ! $ config ) return false ; $ pieces = parse_url ( $ CFG -> websocket_url ) ; $ port = U :: get ( $ pieces , 'port' ) ; $ host = U :: get ( $ pieces , 'host' ) ; if ( ! $ port ) ...
Determine if this server is configured for web sockets .
45,706
public static function getPort ( ) { global $ CFG ; if ( ! self :: enabled ( ) ) return null ; $ pieces = parse_url ( $ CFG -> websocket_url ) ; return U :: get ( $ pieces , 'port' ) ; }
Returns the port that the configured web socket server
45,707
public static function makeToken ( $ launch ) { global $ CFG ; if ( ! isset ( $ launch -> link -> id ) ) return false ; $ token = $ CFG -> wwwroot . '::' . $ launch -> link -> id . '::' ; $ token .= isset ( $ launch -> context -> id ) ? $ launch -> context -> id : 'no_context' ; $ token .= '::' ; $ token .= isset ( $ l...
Build a plaintext token for a particular link_id
45,708
public static function getToken ( $ launch ) { global $ CFG ; if ( ! isset ( $ CFG -> websocket_secret ) || strlen ( $ CFG -> websocket_secret ) < 1 ) return false ; $ plain = self :: makeToken ( $ launch ) ; if ( ! $ plain ) return $ plain ; $ encrypted = AesCtr :: encrypt ( $ plain , $ CFG -> websocket_secret , 256 )...
Build and sign a token for a particular link_id
45,709
public static function decodeToken ( $ token ) { global $ CFG ; $ plain = AesCtr :: decrypt ( $ token , $ CFG -> websocket_secret , 256 ) ; $ pieces = explode ( '::' , $ plain ) ; if ( count ( $ pieces ) != 4 ) return false ; return $ plain ; }
Decode and parse a token to make sure it is valid
45,710
public static function getSpaceFromToken ( $ token ) { $ pieces = explode ( '::' , $ token ) ; if ( count ( $ pieces ) != 4 ) return false ; $ space = implode ( '::' , array_slice ( $ pieces , 0 , 2 ) ) ; return $ space ; }
Pull out the host and link_id so as to create the space
45,711
public static function insertForm ( $ fields , $ from_location , $ titles = false ) { echo ( '<form method="post">' . "\n" ) ; for ( $ i = 0 ; $ i < count ( $ fields ) ; $ i ++ ) { $ field = $ fields [ $ i ] ; if ( strpos ( $ field , "_at" ) > 0 ) continue ; if ( strpos ( $ field , "_sha256" ) > 0 ) continue ; echo ( '...
Generate the HTML for an insert form .
45,712
public static function fieldToTitle ( $ name , $ titles = false ) { if ( is_array ( $ titles ) && U :: get ( $ titles , $ name ) ) return U :: get ( $ titles , $ name ) ; return ucwords ( str_replace ( '_' , ' ' , $ name ) ) ; }
Maps a field name to a presentable title .
45,713
public static function selectSql ( $ tablename , $ fields , $ where_clause = false ) { $ sql = "SELECT " ; $ first = true ; foreach ( $ fields as $ field ) { if ( ! $ first ) $ sql .= ', ' ; $ sql .= $ field ; $ first = false ; } $ sql .= "\n FROM " . $ tablename ; if ( $ where_clause && strlen ( $ where_clause ) > 0 )...
Produce the SELECT statement for a table set of fields and where clause .
45,714
public function getRecursiveFolders ( $ folders ) { if ( ! is_array ( $ folders ) ) { $ folders = [ $ folders ] ; } $ paths = [ ] ; foreach ( $ folders as $ folder ) { $ iter = new Iterator ( new DirectoryIterator ( $ folder , DirectoryIterator :: SKIP_DOTS ) , Iterator :: SELF_FIRST , Iterator :: CATCH_GET_CHILD ) ; $...
Get all subdirectories located in an array of folders .
45,715
public function getIterator ( ) { $ isTraversal = ( is_array ( $ this -> body ) || $ this -> body instanceof \ Traversable ) ; return $ isTraversal ? new \ ArrayIterator ( $ this -> body ) : new \ ArrayIterator ( [ ] ) ; }
Get array iterator
45,716
public static function removeTextChunks ( $ key , $ png ) { $ retval = substr ( $ png , 0 , 8 ) ; $ ipos = 8 ; if ( $ retval != "\x89PNG\x0d\x0a\x1a\x0a" ) throw new Exception ( 'Is not a valid PNG image' ) ; $ chunkHeader = substr ( $ png , $ ipos , 8 ) ; $ ipos = $ ipos + 8 ; while ( $ chunkHeader ) { $ chunk = @ unp...
Strip out any existing text chunks with a particular key
45,717
public function add ( $ entry , $ push = false ) { if ( $ push ) { array_unshift ( $ this -> menu , $ entry ) ; } else { $ this -> menu [ ] = $ entry ; } return $ this ; }
Add an entry to the menu
45,718
public function addLink ( $ link , $ href , $ push = false ) { $ entry = new MenuEntry ( $ link , $ href ) ; return $ this -> add ( $ entry , $ push ) ; }
Add an link to the menu
45,719
public function addSeparator ( $ push = false ) { $ entry = MenuEntry :: separator ( ) ; return $ this -> add ( $ entry , $ push ) ; }
Add a separator to the menu
45,720
function getFirstName ( $ displayname = null ) { if ( $ displayname === null ) $ displayname = $ this -> getNameAndEmail ( ) ; if ( $ displayname === null ) return null ; $ pieces = explode ( ' ' , $ displayname ) ; if ( count ( $ pieces ) > 0 ) return $ pieces [ 0 ] ; return null ; }
Get the user s first name falling back to email
45,721
public static function loadUserInfoBypass ( $ user_id ) { global $ CFG , $ PDOX , $ CONTEXT ; $ cacheloc = 'lti_user' ; $ row = Cache :: check ( $ cacheloc , $ user_id ) ; if ( $ row != false ) return $ row ; $ stmt = $ PDOX -> queryDie ( "SELECT displayname, email, user_key FROM {$CFG->dbprefix}lti_user AS U ...
Load a user s info from the user_id
45,722
public static function create ( $ id , $ guid , $ context_id , $ debug = false ) { global $ CFG ; $ pt = $ CFG -> cookiepad . '::' . $ id . '::' . $ guid . '::' . $ context_id ; if ( $ debug ) echo ( "PT1: $pt\n" ) ; $ ct = \ Tsugi \ Crypt \ AesCtr :: encrypt ( $ pt , $ CFG -> cookiesecret , 256 ) ; return $ ct ; }
Utility code to deal with Secure Cookies .
45,723
public static function set ( $ user_id , $ userEmail , $ context_id ) { global $ CFG ; $ ct = self :: create ( $ user_id , $ userEmail , $ context_id ) ; setcookie ( $ CFG -> cookiename , $ ct , time ( ) + ( 86400 * 45 ) , '/' ) ; }
We have a user - set their secure cookie
45,724
public static function dump ( ) { global $ DEBUG_STRING ; $ retval = '' ; $ sess = ( strlen ( session_id ( ) ) > 0 ) ; if ( $ sess ) { if ( strlen ( $ _SESSION [ '__zzz_debug' ] ) > 0 ) { $ retval = $ _SESSION [ '__zzz_debug' ] ; unset ( $ _SESSION [ '__zzz_debug' ] ) ; } } if ( strlen ( $ retval ) > 0 && strlen ( $ DE...
Calling this clears debug buffer ...
45,725
public static function set ( $ cacheloc , $ cachekey , $ cacheval , $ expiresec = false ) { $ cacheloc = "cache_" . $ cacheloc ; if ( $ cacheval === null || $ cacheval === false ) { unset ( $ _SESSION [ $ cacheloc ] ) ; return ; } if ( $ expiresec !== false ) $ expiresec = time ( ) + $ expiresec ; $ _SESSION [ $ cachel...
Place an entry in the cache .
45,726
public static function check ( $ cacheloc , $ cachekey ) { $ cacheloc = "cache_" . $ cacheloc ; if ( isset ( $ _SESSION [ $ cacheloc ] ) ) { $ cache_row = $ _SESSION [ $ cacheloc ] ; if ( time ( ) >= $ cache_row [ 2 ] ) { unset ( $ _SESSION [ $ cacheloc ] ) ; return false ; } if ( $ cache_row [ 0 ] == $ cachekey ) { re...
Check and return a value from the cache .
45,727
public static function expires ( $ cacheloc , $ cachekey ) { $ cacheloc = "cache_" . $ cacheloc ; if ( isset ( $ _SESSION [ $ cacheloc ] ) ) { $ cache_row = $ _SESSION [ $ cacheloc ] ; if ( time ( ) >= $ cache_row [ 2 ] ) { unset ( $ _SESSION [ $ cacheloc ] ) ; return false ; } if ( $ cache_row [ 0 ] != $ cachekey ) re...
Check when value in the cache expires
45,728
public static function handleSettingsPost ( ) { global $ USER ; if ( ! $ USER ) return false ; if ( isset ( $ _POST [ 'settings_internal_post' ] ) && $ USER -> instructor ) { $ newsettings = array ( ) ; foreach ( $ _POST as $ k => $ v ) { if ( $ k == session_name ( ) ) continue ; if ( $ k == 'settings_internal_post' ) ...
Handle incoming settings post data
45,729
public static function select ( $ name , $ default = false , $ fields ) { global $ USER ; if ( ! $ USER ) return ; $ oldsettings = Settings :: linkGetAll ( ) ; if ( ! $ USER -> instructor ) { $ configured = false ; foreach ( $ fields as $ k => $ v ) { $ index = $ k ; $ display = $ v ; if ( is_int ( $ index ) ) $ index ...
Handle a settings selector box
45,730
public static function text ( $ name , $ title = false ) { global $ USER ; if ( ! $ USER ) return false ; $ oldsettings = Settings :: linkGetAll ( ) ; $ configured = isset ( $ oldsettings [ $ name ] ) ? $ oldsettings [ $ name ] : false ; if ( $ title === false ) $ title = $ name ; if ( ! $ USER -> instructor ) { if ( $...
Handle a settings text box
45,731
public static function getDueDate ( ) { $ retval = new \ stdClass ( ) ; $ retval -> penaltyinfo = false ; $ retval -> message = false ; $ retval -> penalty = 0 ; $ retval -> dayspastdue = 0 ; $ retval -> percent = 0 ; $ retval -> duedate = false ; $ retval -> duedatestr = false ; $ duedatestr = Settings :: linkGet ( 'd...
Get the due data data in an object
45,732
public static function getDueDateDelta ( $ time ) { if ( $ time < 600 ) { $ delta = $ time . ' seconds' ; } else if ( $ time < 3600 ) { $ delta = sprintf ( "%0.0f" , ( $ time / 60.0 ) ) . ' ' . _m ( 'minutes' ) ; } else if ( $ time <= 86400 ) { $ delta = sprintf ( "%0.2f" , ( $ time / 3600.0 ) ) . ' ' . _m ( 'hours' ) ...
Show a due date delta in reasonable units
45,733
public static function dueDate ( ) { global $ USER ; if ( ! $ USER ) return false ; $ due = Settings :: linkGet ( 'due' , '' ) ; $ timezone = Settings :: linkGet ( 'timezone' , 'Pacific/Honolulu' ) ; $ time = Settings :: linkGet ( 'penalty_time' , 86400 ) ; $ cost = Settings :: linkGet ( 'penalty_cost' , 0.2 ) ; if ( !...
Emit the text and form fields to support due dates
45,734
public function deleteSourceImage ( $ hash , $ organization = '' ) { try { $ response = $ this -> call ( 'DELETE' , implode ( '/' , [ self :: SOURCEIMAGE_RESOURCE , $ this -> getOrganizationName ( $ organization ) , $ hash ] ) ) ; } catch ( GuzzleException $ e ) { if ( 404 == $ e -> getCode ( ) ) { return false ; } thr...
Delete a source image .
45,735
public function copySourceImage ( $ hash , $ destinationOrg , $ overwrite = true , $ sourceOrg = '' ) { try { $ headers = [ 'Destination' => $ destinationOrg ] ; if ( false === $ overwrite ) { $ headers [ 'Overwrite' ] = 'F' ; } $ response = $ this -> call ( 'COPY' , implode ( '/' , [ self :: SOURCEIMAGE_RESOURCE , $ t...
Copy a source image to another org .
45,736
public function copySourceImages ( $ hashes , $ destinationOrg , $ overwrite = true , $ sourceOrg = '' ) { try { $ headers = [ 'Destination' => $ destinationOrg ] ; if ( false === $ overwrite ) { $ headers [ 'Overwrite' ] = 'F' ; } $ response = $ this -> call ( 'POST' , implode ( '/' , [ self :: SOURCEIMAGE_RESOURCE , ...
Copy multiple sources image to another org .
45,737
public function deleteSourceImagesWithBinaryHash ( $ binaryHash , $ organization = '' ) { try { $ response = $ this -> call ( 'DELETE' , implode ( '/' , [ self :: SOURCEIMAGE_RESOURCE , $ this -> getOrganizationName ( $ organization ) ] ) , [ 'query' => [ 'binaryHash' => $ binaryHash ] ] ) ; } catch ( GuzzleException $...
Delete source images by binaryhash .
45,738
public function searchSourceImages ( $ search = [ ] , $ sorts = [ ] , $ limit = null , $ offset = null , $ organization = '' ) { $ options = [ 'query' => [ ] ] ; $ sort = SearchHelper :: buildSearchSortParameter ( $ sorts ) ; if ( ! empty ( $ sort ) ) { $ options [ 'query' ] [ 'sort' ] = $ sort ; } if ( \ is_array ( $ ...
Search and list source images .
45,739
public function listSourceImages ( $ limit = null , $ offset = null , $ organization = '' ) { return $ this -> searchSourceImages ( [ ] , [ ] , $ limit , $ offset , $ organization ) ; }
List source images .
45,740
public function getSourceImage ( $ hash , $ organization = '' ) { $ path = self :: SOURCEIMAGE_RESOURCE . '/' . $ this -> getOrganizationName ( $ organization ) ; $ path .= '/' . $ hash ; $ contents = $ this -> call ( 'GET' , $ path ) -> getBody ( ) -> getContents ( ) ; return SourceImage :: createFromJsonResponse ( $ ...
Load a source image s metadata from Rokka .
45,741
public function getSourceImagesWithBinaryHash ( $ binaryHash , $ organization = '' ) { $ path = self :: SOURCEIMAGE_RESOURCE . '/' . $ this -> getOrganizationName ( $ organization ) ; $ options [ 'query' ] = [ 'binaryHash' => $ binaryHash ] ; $ contents = $ this -> call ( 'GET' , $ path , $ options ) -> getBody ( ) -> ...
Loads source images metadata from Rokka by binaryhash .
45,742
public function getSourceImageContents ( $ hash , $ organization = '' ) { $ path = implode ( '/' , [ self :: SOURCEIMAGE_RESOURCE , $ this -> getOrganizationName ( $ organization ) , $ hash , 'download' , ] ) ; return $ this -> call ( 'GET' , $ path ) -> getBody ( ) -> getContents ( ) ; }
Get a source image s binary contents from Rokka .
45,743
public function listOperations ( ) { $ contents = $ this -> call ( 'GET' , self :: OPERATIONS_RESOURCE ) -> getBody ( ) -> getContents ( ) ; return OperationCollection :: createFromJsonResponse ( $ contents ) ; }
List operations .
45,744
public function createStack ( $ stackName , array $ stackOperations , $ organization = '' , array $ stackOptions = [ ] , $ overwrite = false ) { $ stackData = [ 'operations' => $ stackOperations , 'options' => $ stackOptions , ] ; $ stack = Stack :: createFromConfig ( $ stackName , $ stackData , $ organization ) ; retu...
Create a stack .
45,745
public function saveStack ( Stack $ stack , array $ requestConfig = [ ] ) { if ( empty ( $ stack -> getName ( ) ) ) { throw new \ LogicException ( 'Stack has no name, please set one.' ) ; } if ( empty ( $ stack -> getOrganization ( ) ) ) { $ stack -> setOrganization ( $ this -> defaultOrganization ) ; } $ queryString =...
Save a stack on rokka .
45,746
public function listStacks ( $ limit = null , $ offset = null , $ organization = '' ) { $ options = [ ] ; if ( $ limit || $ offset ) { $ options = [ 'query' => [ 'limit' => $ limit , 'offset' => $ offset ] ] ; } $ contents = $ this -> call ( 'GET' , self :: STACK_RESOURCE . '/' . $ this -> getOrganizationName ( $ organ...
List stacks .
45,747
public function getStack ( $ stackName , $ organization = '' ) { $ contents = $ this -> call ( 'GET' , implode ( '/' , [ self :: STACK_RESOURCE , $ this -> getOrganizationName ( $ organization ) , $ stackName ] ) ) -> getBody ( ) -> getContents ( ) ; return Stack :: createFromJsonResponse ( $ contents ) ; }
Return a stack .
45,748
public function deleteStack ( $ stackName , $ organization = '' ) { $ response = $ this -> call ( 'DELETE' , implode ( '/' , [ self :: STACK_RESOURCE , $ this -> getOrganizationName ( $ organization ) , $ stackName ] ) ) ; return '204' == $ response -> getStatusCode ( ) ; }
Delete a stack .
45,749
public function setDynamicMetadata ( $ dynamicMetadata , $ hash , $ organization = '' , $ options = [ ] ) { if ( ! \ is_array ( $ dynamicMetadata ) ) { $ dynamicMetadata = [ $ dynamicMetadata ] ; } $ count = 0 ; $ response = null ; foreach ( $ dynamicMetadata as $ value => $ data ) { $ callOptions = [ ] ; if ( $ data i...
Add the given DynamicMetadata to a SourceImage . Returns the new Hash for the SourceImage it could be the same as the input one if the operation did not change it .
45,750
public function deleteDynamicMetadata ( $ dynamicMetadataName , $ hash , $ organization = '' , $ options = [ ] ) { if ( empty ( $ hash ) ) { throw new \ LogicException ( 'Missing image Hash.' ) ; } if ( empty ( $ dynamicMetadataName ) ) { throw new \ LogicException ( 'Missing DynamicMetadata name.' ) ; } $ path = implo...
Delete the given DynamicMetadata from a SourceImage . Returns the new Hash for the SourceImage it could be the same as the input one if the operation did not change it .
45,751
public function deleteUserMetadataField ( $ field , $ hash , $ organization = '' ) { return $ this -> doUserMetadataRequest ( [ $ field => null ] , $ hash , 'PATCH' , $ organization ) ; }
Delete the given field from the user - metadata of the image .
45,752
public function deleteUserMetadataFields ( $ fields , $ hash , $ organization = '' ) { $ data = [ ] ; foreach ( $ fields as $ value ) { $ data [ $ value ] = null ; } return $ this -> doUserMetadataRequest ( $ data , $ hash , 'PATCH' , $ organization ) ; }
Delete the given fields from the user - metadata of the image .
45,753
public function getSourceImageUri ( $ hash , $ stack , $ format = 'jpg' , $ name = null , $ organization = null ) { $ apiUri = new Uri ( $ this -> client -> getConfig ( 'base_uri' ) ) ; $ format = strtolower ( $ format ) ; $ parts = explode ( '.' , $ apiUri -> getHost ( ) , 2 ) ; $ baseHost = array_pop ( $ parts ) ; $ ...
Returns url for accessing the image .
45,754
protected function extractHashFromLocationHeader ( array $ headers ) { $ location = reset ( $ headers ) ; if ( empty ( $ location ) ) { return false ; } $ uri = new Uri ( $ location ) ; $ parts = explode ( '/' , $ uri -> getPath ( ) ) ; $ return = array_pop ( $ parts ) ; if ( null === $ return ) { return false ; } retu...
Helper function to extract from a Location header the image hash only the first Location is used .
45,755
public function addOverridingOptions ( $ options ) { $ part = 0 ; if ( \ count ( $ this -> getStackOperations ( ) ) > 0 ) { ++ $ part ; } foreach ( explode ( '/' , $ options ) as $ option ) { ++ $ part ; foreach ( explode ( '--' , $ option ) as $ stringOperation ) { $ stringOperationWithOptions = explode ( '-' , $ stri...
For overwriting stack operation options or adding stack options .
45,756
public static function validate ( $ data ) { if ( ! is_array ( $ data ) ) return '$data must be an array' ; $ id = U :: get ( $ data , 'id' ) ; if ( $ id ) { if ( ! is_int ( $ id ) ) return "id must be an an integer" ; } $ uk1 = U :: get ( $ data , 'uk1' ) ; if ( $ uk1 ) { if ( ! is_string ( $ uk1 ) ) return "uk1 must ...
Validate a kvs record
45,757
private function getOptions ( string $ class ) : Options { $ ref = new \ ReflectionClass ( $ class ) ; $ allows = $ this -> getAllows ( $ ref -> getMethods ( ) ) ; $ params = [ ] ; foreach ( $ allows as $ method ) { $ params [ ] = $ this -> getParams ( $ class , $ method ) ; } return new Options ( $ allows , $ params )...
Return available resource request method
45,758
public function handleForItemRendering ( ParseItemEvent $ event ) : void { $ settings = $ event -> getRenderSettings ( ) ; if ( ! $ settings -> get ( self :: FRONTEND_EDITING_ENABLED_FLAG ) ) { return ; } $ parsed = $ event -> getResult ( ) ; $ item = $ event -> getItem ( ) ; $ tableName = $ item -> getMetaModel ( ) ->...
Handle the url injection for item rendering .
45,759
private function generateAddUrl ( array $ page ) : string { $ event = new GenerateFrontendUrlEvent ( $ page , null , $ page [ 'language' ] ) ; $ this -> dispatcher -> dispatch ( ContaoEvents :: CONTROLLER_GENERATE_FRONTEND_URL , $ event ) ; $ url = UrlBuilder :: fromUrl ( $ event -> getUrl ( ) . '?' ) -> setQueryParame...
Generate the url to add an item .
45,760
private function getPageDetails ( $ pageId ) : ? array { if ( empty ( $ pageId ) ) { return null ; } $ event = new GetPageDetailsEvent ( $ pageId ) ; $ this -> dispatcher -> dispatch ( ContaoEvents :: CONTROLLER_GET_PAGE_DETAILS , $ event ) ; return $ event -> getPageDetails ( ) ; }
Retrieve the details for the page with the given id .
45,761
private function translateLabel ( $ transString , $ definitionName , array $ parameters = [ ] ) : string { $ translator = $ this -> translator ; $ label = $ translator -> trans ( $ definitionName . '.' . $ transString , $ parameters , 'contao_' . $ definitionName ) ; if ( $ label !== $ definitionName . '.' . $ transStr...
Get a translated label from the translator .
45,762
public function settingsGetAll ( ) { global $ CFG ; $ name = $ this -> ENTITY_NAME ; $ retval = $ this -> ltiParameter ( $ name . "_settings" , false ) ; if ( $ retval === null || ( is_string ( $ retval ) && strlen ( $ retval ) < 1 ) ) { $ retval = array ( ) ; } else if ( strlen ( $ retval ) > 0 ) { try { $ retval = js...
Retrieve an array of all of the settings
45,763
public function settingsGet ( $ key , $ default = false ) { $ allSettings = $ this -> settingsGetAll ( ) ; if ( array_key_exists ( $ key , $ allSettings ) ) { return $ allSettings [ $ key ] ; } else { return $ default ; } }
Retrieve a particular key from the settings .
45,764
public function settingsSet ( $ key , $ value ) { $ allSettings = $ this -> settingsGetAll ( ) ; $ allSettings [ $ key ] = $ value ; $ this -> settingsSetAll ( $ allSettings ) ; }
Update a single key in settings
45,765
public function settingsUpdate ( $ keyvals ) { $ allSettings = $ this -> settingsGetAll ( ) ; $ different = false ; foreach ( $ keyvals as $ k => $ v ) { if ( array_key_exists ( $ k , $ allSettings ) ) { if ( $ v != $ allSettings [ $ k ] ) { $ different = true ; break ; } } else { $ different = true ; break ; } } if ( ...
Set or update a number of keys to new values in link settings .
45,766
public static function __ ( $ message , $ textdomain = false ) { global $ CFG , $ PDOX , $ TSUGI_LOCALE , $ TSUGI_LOCALE_RELOAD , $ TSUGI_TRANSLATE ; if ( isset ( $ CFG -> checktranslation ) && $ CFG -> checktranslation && isset ( $ PDOX ) ) { $ string_sha = U :: lti_sha256 ( $ message ) ; $ domain = $ textdomain ; if ...
Translate a messege from the master domain
45,767
public static function setLocale ( $ locale = null ) { global $ CFG , $ TSUGI_LOCALE , $ TSUGI_LOCALE_RELOAD ; if ( isset ( $ CFG -> legacytranslation ) ) { if ( ! function_exists ( 'bindtextdomain' ) ) return ; if ( ! function_exists ( 'textdomain' ) ) return ; } if ( isset ( $ CFG -> legacytranslation ) && $ locale &...
Set the LOCAL for the current user
45,768
public static function setupTextDomain ( ) { global $ CFG , $ TSUGI_LOCALE , $ TSUGI_LOCALE_RELOAD , $ TSUGI_TRANSLATE ; $ domain = $ CFG -> getScriptFolder ( ) ; $ folder = $ CFG -> getScriptPathFull ( ) . "/locale" ; $ TSUGI_LOCALE_RELOAD = false ; $ TSUGI_TRANSLATE = false ; if ( isset ( $ CFG -> legacytranslation )...
Set up the translation entities
45,769
public function addLtiLinkItem ( $ url , $ title = false , $ text = false , $ icon = false , $ fa_icon = false , $ custom = false , $ points = false , $ activityId = false , $ additionalParams = array ( ) ) { global $ CFG ; $ params = array ( 'url' => $ url , 'title' => $ title , 'text' => $ text , 'icon' => $ icon , '...
addLtiLinkItem - Add an LTI Link Content Item
45,770
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 .
45,771
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
45,772
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
45,773
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
45,774
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
45,775
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
45,776
public function getCurrentUserId ( ) { $ contents = $ this -> call ( 'GET' , self :: USER_RESOURCE ) -> getBody ( ) -> getContents ( ) ; $ json = json_decode ( $ contents , true ) ; return $ json [ 'user_id' ] ; }
Get current user .
45,777
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 .
45,778
public function getOrganization ( $ organization = '' ) { $ contents = $ this -> call ( 'GET' , self :: ORGANIZATION_RESOURCE . '/' . $ this -> getOrganizationName ( $ organization ) ) -> getBody ( ) -> getContents ( ) ; return Organization :: createFromJsonResponse ( $ contents ) ; }
Return an organization .
45,779
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 .
45,780
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 .
45,781
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 .
45,782
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 .
45,783
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 .
45,784
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
45,785
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
45,786
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
45,787
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 .
45,788
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 .
45,789
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 .
45,790
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 .
45,791
public static function returnUrl ( $ postdata = false ) { if ( ! $ postdata ) $ postdata = LTIX :: ltiRawPostArray ( ) ; return parent :: returnUrl ( $ postdata ) ; }
returnUrl - Returns the content_item_return_url
45,792
public static function allowImportItem ( $ postdata = false ) { if ( ! $ postdata ) $ postdata = LTIX :: ltiRawPostArray ( ) ; return parent :: allowImportItem ( $ postdata ) ; }
allowImportItem - Returns true if we can return Common Cartridges
45,793
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
45,794
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
45,795
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
45,796
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
45,797
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
45,798
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
45,799
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