idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
226,600 | public static function encrypt_secret ( $ secret ) { global $ CFG ; if ( startsWith ( $ secret , 'AES::' ) ) return $ secret ; $ encr = AesCtr :: encrypt ( $ secret , $ CFG -> cookiesecret , 256 ) ; return 'AES::' . $ encr ; } | Encrypt a secret to put into the session |
226,601 | public static function decrypt_secret ( $ secret ) { global $ CFG ; if ( $ secret === null || $ secret === false ) return $ secret ; if ( ! startsWith ( $ secret , 'AES::' ) ) return $ secret ; $ secret = substr ( $ secret , 5 ) ; $ decr = AesCtr :: decrypt ( $ secret , $ CFG -> cookiesecret , 256 ) ; return $ decr ; } | Decrypt a secret from the session |
226,602 | public static function wrapped_session_get ( $ session_object , $ key , $ default = null ) { global $ TSUGI_SESSION_OBJECT ; if ( $ session_object === null && isset ( $ TSUGI_SESSION_OBJECT ) ) $ session_object = $ TSUGI_SESSION_OBJECT ; if ( is_object ( $ session_object ) ) { return $ session_object -> get ( $ key , $... | Wrap getting a key from the session |
226,603 | public static function wrapped_session_all ( $ session_object ) { global $ TSUGI_SESSION_OBJECT ; if ( $ session_object === null && isset ( $ TSUGI_SESSION_OBJECT ) ) $ session_object = $ TSUGI_SESSION_OBJECT ; if ( is_object ( $ session_object ) ) { return $ session_object -> all ( ) ; } if ( is_array ( $ session_obje... | Get all session values |
226,604 | public static function wrapped_session_put ( & $ session_object , $ key , $ value ) { global $ TSUGI_SESSION_OBJECT ; if ( $ session_object === null && isset ( $ TSUGI_SESSION_OBJECT ) ) $ session_object = $ TSUGI_SESSION_OBJECT ; if ( is_object ( $ session_object ) ) { $ session_object -> put ( $ key , $ value ) ; ret... | Wrap setting a key from the session |
226,605 | public static function wrapped_session_forget ( & $ session_object , $ key ) { global $ TSUGI_SESSION_OBJECT ; if ( $ session_object === null && isset ( $ TSUGI_SESSION_OBJECT ) ) $ session_object = $ TSUGI_SESSION_OBJECT ; if ( is_object ( $ session_object ) ) { $ session_object -> forget ( $ key ) ; return ; } if ( i... | Wrap forgetting a key from the session |
226,606 | public static function wrapped_session_flush ( & $ session_object ) { global $ TSUGI_SESSION_OBJECT ; if ( $ session_object === null && isset ( $ TSUGI_SESSION_OBJECT ) ) $ session_object = $ TSUGI_SESSION_OBJECT ; if ( is_object ( $ session_object ) ) { $ session_object -> flush ( ) ; return ; } if ( is_array ( $ sess... | Wrap flushing the session |
226,607 | public static function oauth_parameters ( ) { $ request_headers = OAuthUtil :: get_headers ( ) ; if ( isset ( $ _SERVER [ 'QUERY_STRING' ] ) ) { $ parameters = OAuthUtil :: parse_parameters ( $ _SERVER [ 'QUERY_STRING' ] ) ; } else { $ parameters = array ( ) ; } $ parameters = array_merge ( $ parameters , $ _POST ) ; i... | The LTI parameter data |
226,608 | public static function getCompositeKey ( $ post , $ session_secret ) { $ comp = $ session_secret . '::' . $ post [ 'key' ] . '::' . $ post [ 'context_id' ] . '::' . U :: get ( $ post , 'link_id' ) . '::' . $ post [ 'user_id' ] . '::' . intval ( time ( ) / 1800 ) . $ _SERVER [ 'HTTP_USER_AGENT' ] . '::' . __FILE__ ; ret... | session secret . Also make these change every 30 minutes |
226,609 | private static function patchNeeded ( $ needed ) { if ( $ needed == self :: NONE ) $ needed = array ( ) ; if ( $ needed == self :: ALL ) { $ needed = array ( self :: CONTEXT , self :: LINK , self :: USER ) ; } if ( is_string ( $ needed ) ) $ needed = array ( $ needed ) ; return $ needed ; } | Patch the value for the list of needed features |
226,610 | public static function requireDataOverride ( $ needed , $ pdox , $ session_object , $ current_url , $ request_data ) { return self :: requireDataPrivate ( $ needed , $ pdox , $ session_object , $ current_url , $ request_data ) ; } | Handle the launch but with the caller given the chance to override defaults |
226,611 | public static function launchAuthorizationFlow ( $ request_data ) { global $ CFG , $ PDOX ; $ key = U :: get ( $ request_data , 'oauth_consumer_key' ) ; if ( ! $ key ) return false ; if ( U :: get ( $ request_data , 'oauth_signature_method' ) && U :: get ( $ request_data , 'oauth_timestamp' ) && U :: get ( $ request_da... | Handle the optional LTI pre 1 . 3 Launch Authorization flow |
226,612 | public static function var_dump ( ) { global $ USER , $ CONTEXT , $ LINK , $ RESULT ; echo ( '$USER:' . "\n" ) ; if ( ! isset ( $ USER ) ) { echo ( "Not set\n" ) ; } else { var_dump ( $ USER ) ; } echo ( '$CONTEXT:' . "\n" ) ; if ( ! isset ( $ CONTEXT ) ) { echo ( "Not set\n" ) ; } else { var_dump ( $ CONTEXT ) ; } ech... | Dump out the internal data structures adssociated with the current launch . Best if used within a pre tag . |
226,613 | public static function signParameters ( $ oldparms , $ endpoint , $ method , $ submit_text = false , $ org_id = false , $ org_desc = false ) { $ oauth_consumer_key = self :: ltiParameter ( 'key_key' ) ; $ oauth_consumer_secret = self :: decrypt_secret ( self :: ltiParameter ( 'secret' ) ) ; return LTI :: signParameters... | signParameters - Look up the key and secret and call the underlying code in LTI |
226,614 | public static function settingsSend ( $ settings , $ settings_url , & $ debug_log = false ) { $ key_key = self :: ltiParameter ( 'key_key' ) ; $ secret = self :: decrypt_secret ( self :: ltiParameter ( 'secret' ) ) ; $ retval = LTI :: sendJSONSettings ( $ settings , $ settings_url , $ key_key , $ secret , $ debug_log )... | Send settings to the LMS using the simple JSON approach |
226,615 | public static function caliperSend ( $ caliperBody , $ content_type = 'application/json' , & $ debug_log = false ) { $ caliperURL = LTIX :: ltiRawParameter ( 'custom_sub_canvas_xapi_url' ) ; if ( strlen ( $ caliperURL ) == 0 ) { if ( is_array ( $ debug_log ) ) $ debug_log [ ] = array ( 'custom_sub_canvas_xapi_url not f... | Send a Caliper Body to the correct URL using the key and secret |
226,616 | public static function jsonSend ( $ method , $ postBody , $ content_type , $ service_url , & $ debug_log = false ) { $ key_key = self :: ltiParameter ( 'key_key' ) ; $ secret = self :: decrypt_secret ( self :: ltiParameter ( 'secret' ) ) ; $ retval = LTI :: sendJSONBody ( $ method , $ postBody , $ content_type , $ serv... | Send a JSON Body to a URL after looking up the key and secret |
226,617 | public static function removeQueryString ( $ url ) { $ pos = strpos ( $ url , '?' ) ; if ( $ pos === false ) return $ url ; $ url = substr ( $ url , 0 , $ pos ) ; return $ url ; } | removeQueryString - Drop a query string from a url |
226,618 | public static function curPageUrlFolder ( ) { $ folder = self :: curPageUrlBase ( ) . $ _SERVER [ 'REQUEST_URI' ] ; $ folder = self :: removeQueryString ( $ folder ) ; if ( preg_match ( '/\/$/' , $ folder ) ) return $ folder ; return dirname ( $ folder ) ; } | curPageUrlFolder - Returns the URL to the folder currently executing |
226,619 | public static function curPageUrlBase ( ) { global $ CFG ; $ pieces = parse_url ( $ CFG -> wwwroot ) ; if ( isset ( $ pieces [ 'scheme' ] ) ) { $ scheme = $ pieces [ 'scheme' ] ; } else { $ scheme = ( ! isset ( $ _SERVER [ 'HTTPS' ] ) || $ _SERVER [ 'HTTPS' ] != "on" ) ? 'http' : 'https' ; } if ( isset ( $ pieces [ 'po... | curPageUrlBase - Returns the protocol host and port for the current URL |
226,620 | private static function checkCSRF ( $ session_object = null ) { global $ CFG ; $ token = self :: wrapped_session_get ( $ session_object , 'CSRF_TOKEN' ) ; if ( ! $ token ) return false ; if ( isset ( $ _POST [ 'CSRF_TOKEN' ] ) && $ token == $ _POST [ 'CSRF_TOKEN' ] ) return true ; $ headers = array_change_key_case ( ap... | Returns true for a good CSRF and false if we could not verify it |
226,621 | public static function getCoreLaunchData ( ) { global $ CFG , $ CONTEXT , $ USER , $ CONTEXT , $ LINK ; $ ltiProps = array ( ) ; $ ltiProps [ LTIConstants :: LTI_VERSION ] = LTIConstants :: LTI_VERSION_1 ; $ ltiProps [ LTIConstants :: CONTEXT_ID ] = $ CONTEXT -> id ; $ ltiProps [ LTIConstants :: ROLES ] = $ USER -> ins... | getCoreLaunchData - Get the launch data common across launch types |
226,622 | public static function getLaunchData ( ) { global $ CFG , $ CONTEXT , $ USER , $ CONTEXT , $ LINK ; $ ltiProps = self :: getCoreLaunchData ( ) ; $ ltiProps [ LTIConstants :: LTI_MESSAGE_TYPE ] = LTIConstants :: LTI_MESSAGE_TYPE_BASICLTILAUNCHREQUEST ; $ ltiProps [ LTIConstants :: RESOURCE_LINK_ID ] = $ LINK -> id ; $ l... | getLaunchData - Get the launch data for a normal LTI 1 . x launch |
226,623 | public static function getLaunchContent ( $ endpoint , $ debug = false ) { $ info = LTIX :: getKeySecretForLaunch ( $ endpoint ) ; if ( $ info === false ) { return '<p style="color:red">Unable to load key/secret for ' . htmlentities ( $ endpoint ) . "</p>\n" ; } $ key = $ info [ 'key' ] ; $ secret = self :: decrypt_sec... | getLaunchContent - Get the launch data for am LTI ContentItem launch |
226,624 | private static function abort_with_error_log ( $ msg , $ extra = false , $ prefix = "DIE:" ) { $ return_url = isset ( $ _POST [ 'launch_presentation_return_url' ] ) ? $ _POST [ 'launch_presentation_return_url' ] : null ; if ( is_array ( $ extra ) ) $ extra = Output :: safe_var_dump ( $ extra ) ; if ( $ return_url === n... | We are aborting this request . If this is a launch redirect back |
226,625 | public static function noteLoggedIn ( $ row ) { global $ CFG , $ PDOX ; if ( ! isset ( $ row [ 'user_id' ] ) ) return ; if ( ! isset ( $ PDOX ) || ! $ PDOX ) return ; if ( Net :: getIP ( ) !== NULL ) { $ sql = "UPDATE {$CFG->dbprefix}lti_user SET login_at=NOW(), login_count=login_count+1, ipaddr=:IP WHER... | Update the login_at fields as appropriate |
226,626 | public static function header ( $ buffer = false ) { global $ CFG ; ob_start ( ) ; ?> <style> .card { display: inline-block; padding: 0.5em; margin: 12px; border: 1px solid black; height: 9em; overflow-y: hidden;} .card div { height: 8em; overflow-y: hidden; text-overflow: ellipsis;}#loade... | emit the header material |
226,627 | public static function adjustArray ( & $ entry ) { global $ CFG ; if ( isset ( $ entry ) && ! is_array ( $ entry ) ) { $ entry = array ( $ entry ) ; } for ( $ i = 0 ; $ i < count ( $ entry ) ; $ i ++ ) { if ( is_string ( $ entry [ $ i ] ) ) U :: absolute_url_ref ( $ entry [ $ i ] ) ; if ( isset ( $ entry [ $ i ] -> hre... | Make non - array into an array and adjust paths |
226,628 | public function getModuleByAnchor ( $ anchor ) { foreach ( $ this -> lessons -> modules as $ mod ) { if ( $ mod -> anchor == $ anchor ) return $ mod ; } return null ; } | Get a module associated with an anchor |
226,629 | public function getLtiByRlid ( $ resource_link_id ) { foreach ( $ this -> lessons -> modules as $ mod ) { if ( ! isset ( $ mod -> lti ) ) continue ; foreach ( $ mod -> lti as $ lti ) { if ( $ lti -> resource_link_id == $ resource_link_id ) return $ lti ; } } return null ; } | Get an LTI associated with a resource link ID |
226,630 | 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 |
226,631 | 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 |
226,632 | 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 |
226,633 | 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 . |
226,634 | 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 . |
226,635 | 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 . |
226,636 | 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 |
226,637 | 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 |
226,638 | 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 |
226,639 | 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 |
226,640 | 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 |
226,641 | 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 . |
226,642 | 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 . |
226,643 | 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 . |
226,644 | 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 . |
226,645 | public function getIterator ( ) { $ isTraversal = ( is_array ( $ this -> body ) || $ this -> body instanceof \ Traversable ) ; return $ isTraversal ? new \ ArrayIterator ( $ this -> body ) : new \ ArrayIterator ( [ ] ) ; } | Get array iterator |
226,646 | 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 |
226,647 | 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 |
226,648 | public function addLink ( $ link , $ href , $ push = false ) { $ entry = new MenuEntry ( $ link , $ href ) ; return $ this -> add ( $ entry , $ push ) ; } | Add an link to the menu |
226,649 | public function addSeparator ( $ push = false ) { $ entry = MenuEntry :: separator ( ) ; return $ this -> add ( $ entry , $ push ) ; } | Add a separator to the menu |
226,650 | 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 |
226,651 | 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 |
226,652 | 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 . |
226,653 | 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 |
226,654 | 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 ... |
226,655 | 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 . |
226,656 | 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 . |
226,657 | 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 |
226,658 | 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 |
226,659 | 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 |
226,660 | 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 |
226,661 | 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 |
226,662 | 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 |
226,663 | 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 |
226,664 | 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 . |
226,665 | 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 . |
226,666 | 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 . |
226,667 | 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 . |
226,668 | 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 . |
226,669 | public function listSourceImages ( $ limit = null , $ offset = null , $ organization = '' ) { return $ this -> searchSourceImages ( [ ] , [ ] , $ limit , $ offset , $ organization ) ; } | List source images . |
226,670 | 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 . |
226,671 | 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 . |
226,672 | 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 . |
226,673 | public function listOperations ( ) { $ contents = $ this -> call ( 'GET' , self :: OPERATIONS_RESOURCE ) -> getBody ( ) -> getContents ( ) ; return OperationCollection :: createFromJsonResponse ( $ contents ) ; } | List operations . |
226,674 | 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 . |
226,675 | 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 . |
226,676 | 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 . |
226,677 | 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 . |
226,678 | public function deleteStack ( $ stackName , $ organization = '' ) { $ response = $ this -> call ( 'DELETE' , implode ( '/' , [ self :: STACK_RESOURCE , $ this -> getOrganizationName ( $ organization ) , $ stackName ] ) ) ; return '204' == $ response -> getStatusCode ( ) ; } | Delete a stack . |
226,679 | 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 . |
226,680 | 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 . |
226,681 | 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 . |
226,682 | 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 . |
226,683 | 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 . |
226,684 | 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 . |
226,685 | 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 . |
226,686 | 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 |
226,687 | 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 |
226,688 | 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 . |
226,689 | 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 . |
226,690 | 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 . |
226,691 | 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 . |
226,692 | 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 |
226,693 | 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 . |
226,694 | public function settingsSet ( $ key , $ value ) { $ allSettings = $ this -> settingsGetAll ( ) ; $ allSettings [ $ key ] = $ value ; $ this -> settingsSetAll ( $ allSettings ) ; } | Update a single key in settings |
226,695 | 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 . |
226,696 | 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 |
226,697 | 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 |
226,698 | 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 |
226,699 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.