idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
45,600 | public function index ( Service $ service , MediaDataTable $ mediaDataTable ) { return $ mediaDataTable -> with ( [ 'resource' => $ service , 'tabs' => 'adminarea.services.tabs' , 'id' => "adminarea-services-{$service->getRouteKey()}-media-table" , 'url' => route ( 'adminarea.services.media.store' , [ 'service' => $ se... | List service media . |
45,601 | public function store ( ImageFormRequest $ request , Service $ service ) : void { $ service -> addMediaFromRequest ( 'file' ) -> sanitizingFileName ( function ( $ fileName ) { return md5 ( $ fileName ) . '.' . pathinfo ( $ fileName , PATHINFO_EXTENSION ) ; } ) -> toMediaCollection ( 'default' , config ( 'cortex.booking... | Store new service media . |
45,602 | public function destroy ( Service $ service , Media $ media ) { $ service -> media ( ) -> where ( $ media -> getKeyName ( ) , $ media -> getKey ( ) ) -> first ( ) -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.services.media.index' , [ 'service' => $ service ] ) , 'with' => [ 'warning' => trans ( 'cortex... | Destroy given service media . |
45,603 | public function export ( ) { if ( Cache :: has ( config ( 'laravel-localization.caches.key' ) ) ) { $ this -> strings = Cache :: get ( config ( 'laravel-localization.caches.key' ) ) ; return $ this ; } foreach ( config ( 'laravel-localization.paths.lang_dirs' ) as $ dir ) { try { $ files = $ this -> findLanguageFiles (... | Method to return generate array with contents of parsed language files . |
45,604 | protected function findLanguageFiles ( $ path ) { $ dirIterator = new \ RecursiveDirectoryIterator ( $ path , \ RecursiveDirectoryIterator :: SKIP_DOTS ) ; $ recIterator = new \ RecursiveIteratorIterator ( $ dirIterator ) ; $ phpFiles = array_values ( array_map ( 'current' , iterator_to_array ( new \ RegexIterator ( $ ... | Find available language files and parse them to array . |
45,605 | protected function parseLangFiles ( $ file , $ key , $ dir ) { $ packageName = basename ( $ file , '.php' ) ; $ language = explode ( DIRECTORY_SEPARATOR , $ file ) [ 1 ] ; $ fileContents = require $ dir . DIRECTORY_SEPARATOR . $ file ; if ( array_key_exists ( $ language , $ this -> strings ) ) { if ( array_key_exists (... | Method to parse language files . |
45,606 | protected function parseVendorFiles ( $ file , $ key , $ dir ) { $ packageName = basename ( $ file , '.php' ) ; $ package = explode ( DIRECTORY_SEPARATOR , $ file ) [ 2 ] ; $ language = explode ( DIRECTORY_SEPARATOR , $ file ) [ 3 ] ; $ fileContents = require $ dir . DIRECTORY_SEPARATOR . $ file ; if ( array_key_exists... | Method to parse language files from vendor folder . |
45,607 | public function getFullUrl ( ) { $ parts = $ this -> toArray ( ) ; unset ( $ parts [ 'full_url' ] , $ parts [ 'pass' ] ) ; foreach ( $ parts as $ method => $ param ) { if ( $ param ) { $ method = 'add' . ucfirst ( $ method ) ; $ this -> $ method ( $ param ) ; } } return ltrim ( implode ( $ this -> fullUrl ) , '/' ) ; } | Build the final url based on the structure defined |
45,608 | public function addUser ( $ user ) { if ( $ user && $ this -> getPass ( ) ) { $ this -> fullUrl [ 'credentials' ] = $ user . ':' . $ this -> getPass ( ) . '@' ; } return $ this ; } | Add the credentials to the final url both username and password are added in this stage |
45,609 | public function addQuery ( array $ query ) { $ queryParts = [ ] ; foreach ( $ query as $ key => $ value ) { $ queryParts [ ] = "{$key}={$value}" ; } $ this -> fullUrl [ 'query' ] = '?' . implode ( '&' , $ queryParts ) ; return $ this ; } | Add query string to the final url |
45,610 | public static function getDynamicMetadataClassName ( $ name ) { $ camelCasedName = preg_replace_callback ( '/(^|_|\.)+(.)/' , function ( $ match ) { return ( '.' === $ match [ 1 ] ? '_' : '' ) . strtoupper ( $ match [ 2 ] ) ; } , $ name ) ; return 'Rokka\Client\Core\DynamicMetadata\\' . $ camelCasedName ; } | Returns the Dynamic Metadata class name from the API name . |
45,611 | private function getAllows ( array $ methods ) { $ allows = [ ] ; foreach ( $ methods as $ method ) { if ( in_array ( $ method -> name , [ 'onGet' , 'onPost' , 'onPut' , 'onPatch' , 'onDelete' , 'onHead' ] , true ) ) { $ allows [ ] = strtoupper ( substr ( $ method -> name , 2 ) ) ; } } return $ allows ; } | Return allowed methods |
45,612 | private function getEntityBody ( ResourceObject $ ro , array $ allows ) : array { $ mehtodList = [ ] ; foreach ( $ allows as $ method ) { $ mehtodList [ $ method ] = ( $ this -> optionsMethod ) ( $ ro , $ method ) ; } return $ mehtodList ; } | Return OPTIONS entity body |
45,613 | public function getNext ( $ min = null , $ max = null ) { if ( ( $ min === null && $ max !== null ) || ( $ min !== null && $ max === null ) ) throw new Exception ( 'Invalid arguments' ) ; if ( $ this -> index === 0 ) { $ this -> generateTwister ( ) ; } $ y = $ this -> state [ $ this -> index ] ; $ y = ( $ y ^ ( $ y >> ... | Get the next pseudo - random number in the sequence |
45,614 | public function getHashMaybeUpload ( AbstractLocalImage $ image ) { if ( $ hash = $ image -> getRokkaHash ( ) ) { return $ hash ; } if ( ! $ hash = $ this -> callbacks -> getHash ( $ image ) ) { if ( ! $ this -> isImage ( $ image ) ) { return null ; } $ sourceImage = $ this -> imageUpload ( $ image ) ; if ( null !== $ ... | Returns the hash of an image . If we don t have an image stored locally it uploads it to rokka . |
45,615 | public function getStackUrl ( $ image , $ stack , $ format = 'jpg' , $ seo = null , $ seoLanguage = 'de' ) { if ( null == $ image ) { return '' ; } $ image = $ this -> getImageObject ( $ image ) ; if ( ! $ hash = self :: getHashMaybeUpload ( $ image ) ) { return '' ; } if ( null === $ seo ) { return $ this -> generateR... | Gets the rokka URL for an image Uploads it if we don t have a hash locally . |
45,616 | public function getResizeUrl ( $ image , $ width , $ height = null , $ format = 'jpg' , $ seo = null , $ seoLanguage = 'de' ) { $ imageObject = $ this -> getImageObject ( $ image ) ; if ( null !== $ height ) { $ heightString = "-height-$height" ; } else { $ heightString = '' ; } $ stack = "dynamic/resize-width-$width$h... | Return the rokka URL for getting a resized image . |
45,617 | public function getOriginalSizeUrl ( $ image , $ format = 'jpg' , $ seo = null , $ seoLanguage = '' ) { $ imageObject = $ this -> getImageObject ( $ image ) ; $ stack = 'dynamic/noop--options-autoformat-true-jpg.transparency.autoformat-true' ; return $ this -> getStackUrl ( $ imageObject , $ stack , $ format , $ seo , ... | Return the rokka URL for getting the image in it s original size . |
45,618 | public function getImagename ( AbstractLocalImage $ image = null ) { if ( null === $ image ) { return '' ; } if ( null === $ image -> getFilename ( ) ) { return '' ; } return pathinfo ( $ image -> getFilename ( ) , PATHINFO_FILENAME ) ; } | Returns the filename of the image without extension . |
45,619 | public function generateRokkaUrl ( $ hash , $ stack , $ format = 'jpg' , $ seo = null , $ seoLanguage = 'de' ) { if ( null === $ format ) { $ format = 'jpg' ; } $ slug = null ; if ( ! empty ( $ seo ) && null !== $ seo ) { if ( null === $ seoLanguage ) { $ seoLanguage = 'de' ; } $ slug = self :: slugify ( $ seo , $ seoL... | Gets the rokka URL for an image hash and stack with optional seo filename in the URL . Doesn t upload it if we don t have a local hash for it . Use getStackUrl for that . |
45,620 | public function getRokkaClient ( ) { if ( null === $ this -> imageClient ) { $ this -> imageClient = Factory :: getImageClient ( $ this -> rokkaOrg , $ this -> rokkaApiKey , $ this -> rokkaClientOptions ) ; } return $ this -> imageClient ; } | Gets the rokka image client used by this class . |
45,621 | public function getImageObject ( $ input , $ identifier = null , $ context = null ) { if ( $ input instanceof AbstractLocalImage ) { if ( null !== $ identifier ) { $ input -> setIdentifier ( $ identifier ) ; } if ( null !== $ context ) { $ input -> setContext ( $ context ) ; } return $ input ; } if ( $ input instanceof... | Returns a LocalImage object depending on the input . |
45,622 | function queryReturnError ( $ sql , $ arr = FALSE , $ error_log = TRUE ) { $ errormode = $ this -> getAttribute ( \ PDO :: ATTR_ERRMODE ) ; if ( $ errormode != \ PDO :: ERRMODE_EXCEPTION ) { $ this -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; } $ q = FALSE ; $ success = FALSE ; $ message = '... | Prepare and execute an SQL query with lots of error checking . |
45,623 | function rowDie ( $ sql , $ arr = FALSE , $ error_log = TRUE ) { $ stmt = self :: queryDie ( $ sql , $ arr , $ error_log ) ; $ row = $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ; return $ row ; } | Prepare and execute an SQL query and retrieve a single row . |
45,624 | function allRowsDie ( $ sql , $ arr = FALSE , $ error_log = TRUE ) { $ stmt = self :: queryDie ( $ sql , $ arr , $ error_log ) ; $ rows = array ( ) ; while ( $ row = $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ) { array_push ( $ rows , $ row ) ; } return $ rows ; } | Prepare and execute an SQL query and retrieve all the rows as an array |
45,625 | function metadata ( $ tablename ) { $ sql = "SHOW COLUMNS FROM " . $ tablename ; $ q = self :: queryReturnError ( $ sql ) ; if ( $ q -> success ) { return $ q -> fetchAll ( ) ; } else { return false ; } } | Retrieve the metadata for a table . |
45,626 | function describeColumn ( $ fieldname , $ source ) { if ( ! is_array ( $ source ) ) { if ( ! is_string ( $ source ) ) { throw new \ Exception ( 'Source must be an array of metadata or a table name' ) ; } $ source = self :: describe ( $ source ) ; if ( ! is_array ( $ source ) ) return null ; } foreach ( $ source as $ co... | Retrieve the metadata for a column in a table . |
45,627 | function columnIsNull ( $ fieldname , $ source ) { $ column = self :: describeColumn ( $ fieldname , $ source ) ; if ( ! $ column ) throw new \ Exception ( "Could not find $fieldname" ) ; return U :: get ( $ column , "Null" ) == "YES" ; } | Check if a column is null |
45,628 | function columnType ( $ fieldname , $ source ) { $ column = self :: describeColumn ( $ fieldname , $ source ) ; if ( ! $ column ) throw new \ Exception ( "Could not find $fieldname" ) ; $ type = U :: get ( $ column , "Type" ) ; if ( ! $ type ) return null ; if ( strpos ( $ type , '(' ) === false ) return $ type ; $ mat... | Get the column type |
45,629 | function getContentItemSelection ( ) { $ this -> json -> { self :: CONTENT_ITEMS } = $ this -> items ; unset ( $ this -> json -> { self :: DATA_CLAIM } ) ; if ( isset ( $ this -> claim -> data ) ) { $ this -> json -> { self :: DATA_CLAIM } = $ this -> claim -> data ; } return $ this -> json ; } | Return the claims array to send back to the LMS |
45,630 | public function addContentItem ( $ url , $ title = false , $ text = false , $ icon = false , $ fa_icon = false , $ additionalParams = array ( ) ) { $ params = array ( 'url' => $ url , 'title' => $ title , 'text' => $ text , 'icon' => $ icon , 'fa_icon' => $ fa_icon , ) ; if ( ! empty ( $ additionalParams [ 'placementTa... | addContentItem - Add an Content Item |
45,631 | public function addContentItemExtended ( $ params = array ( ) ) { if ( empty ( $ params [ 'title' ] ) ) $ params [ 'title' ] = false ; if ( empty ( $ params [ 'text' ] ) ) $ params [ 'text' ] = false ; if ( empty ( $ params [ 'icon' ] ) ) $ params [ 'icon' ] = false ; if ( empty ( $ params [ 'fa_icon' ] ) ) $ params [ ... | addContentItemExtended - Add an Content Item |
45,632 | public function addFileItem ( $ url , $ title = false , $ additionalParams = array ( ) ) { $ item = '{ "@type" : "FileItem", "url" : "http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1.xsd", "copyAdvice" : "true", "expiresAt" : "2014-03-05T00:00:00Z", "mediaType" : "application/xml", "title" : "Imported from Ts... | addFileItem - Add an File Item |
45,633 | public function setHome ( $ link , $ href ) { $ this -> home = new \ Tsugi \ UI \ MenuEntry ( $ link , $ href ) ; return $ this ; } | Set the Home Menu |
45,634 | public function addLeft ( $ link , $ href , $ push = false ) { if ( $ this -> left == false ) $ this -> left = new Menu ( ) ; $ x = new \ Tsugi \ UI \ MenuEntry ( $ link , $ href , $ push ) ; $ this -> left -> add ( $ x , $ push ) ; return $ this ; } | Add an entty to the Left Menu |
45,635 | public function addRight ( $ link , $ href , $ push = true ) { if ( $ this -> right == false ) $ this -> right = new Menu ( ) ; $ x = new \ Tsugi \ UI \ MenuEntry ( $ link , $ href , $ push ) ; $ this -> right -> add ( $ x , $ push ) ; return $ this ; } | Add an entty to the Right Menu |
45,636 | public function export ( $ pretty = false ) { $ tmp = new \ stdClass ( ) ; if ( $ this -> home != false ) $ tmp -> home = $ this -> home ; if ( $ this -> left != false ) $ tmp -> left = $ this -> left -> menu ; if ( $ this -> right != false ) $ tmp -> right = $ this -> right -> menu ; if ( $ pretty ) { return json_enco... | Export a menu to JSON |
45,637 | public static function import ( $ json_str ) { try { $ json = json_decode ( $ json_str ) ; $ retval = new MenuSet ( ) ; $ retval -> home = new \ Tsugi \ UI \ MenuEntry ( $ json -> home -> link , $ json -> home -> href ) ; if ( isset ( $ json -> left ) ) $ retval -> left = self :: importRecurse ( $ json -> left , 0 ) ; ... | Import a menu from JSON |
45,638 | private static function importRecurse ( $ entry , $ depth ) { if ( isset ( $ entry -> menu ) ) $ entry = $ entry -> menu ; if ( ! is_array ( $ entry ) ) { $ link = $ entry -> link ; $ href = $ entry -> href ; if ( is_string ( $ href ) ) { return new \ Tsugi \ UI \ MenuEntry ( $ link , $ href ) ; } $ submenu = self :: i... | Walk a JSON tree to import a hierarchy of menus |
45,639 | protected function call ( $ method , $ path , array $ options = [ ] , $ needsCredentials = true ) { $ options [ 'headers' ] [ self :: API_VERSION_HEADER ] = $ this -> apiVersion ; if ( $ needsCredentials ) { $ options [ 'headers' ] [ self :: API_KEY_HEADER ] = $ this -> credentials [ 'key' ] ; } return $ this -> client... | Call the API rokka endpoint . |
45,640 | protected function getOrganizationName ( $ organization = null ) { $ org = ( empty ( $ organization ) ) ? $ this -> defaultOrganization : $ organization ; if ( null === $ org ) { throw new \ RuntimeException ( 'Organization is empty' ) ; } return $ org ; } | Return the organization or the default if empty . |
45,641 | public static function lookupResultBypass ( $ user_id ) { global $ CFG , $ PDOX , $ CONTEXT , $ LINK ; $ stmt = $ PDOX -> queryDie ( "SELECT result_id, R.link_id AS link_id, R.user_id AS user_id, sourcedid, service_id, grade, note, R.json AS json, R.note AS note FROM {$CFG->dbprefix}lti_result... | hence the complex query to make sure we don t cross silos |
45,642 | public static function gradeGet ( $ row = false , & $ debug_log = false ) { global $ CFG ; $ PDOX = LTIX :: getConnection ( ) ; $ key_key = LTIX :: ltiParameter ( 'key_key' ) ; $ secret = LTIX :: decrypt_secret ( LTIX :: ltiParameter ( 'secret' ) ) ; if ( $ row !== false ) { $ sourcedid = isset ( $ row [ 'sourcedid' ] ... | Load the grade for a particular row and update our local copy |
45,643 | public function gradeSendDueDate ( $ gradetosend , $ oldgrade = false , $ dueDate = false ) { if ( $ gradetosend == 1.0 ) { $ scorestr = "Your answer is correct, score saved." ; } else { $ scorestr = "Your score of " . ( $ gradetosend * 100.0 ) . "% has been saved." ; } if ( $ dueDate && $ dueDate -> penalty > 0 ) { $ ... | Send a grade applying the due date logic and only increasing grades |
45,644 | public function getJSON ( ) { global $ CFG ; $ PDOX = $ this -> launch -> pdox ; $ stmt = $ PDOX -> queryDie ( "SELECT json FROM {$CFG->dbprefix}lti_result WHERE result_id = :RID" , array ( ':RID' => $ this -> id ) ) ; $ row = $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ; return $ row [ 'json' ] ; } | Get the JSON for this result |
45,645 | public function setJSON ( $ json ) { global $ CFG ; $ PDOX = $ this -> launch -> pdox ; $ stmt = $ PDOX -> queryDie ( "UPDATE {$CFG->dbprefix}lti_result SET json = :json, updated_at = NOW() WHERE result_id = :RID" , array ( ':json' => $ json , ':RID' => $ this -> id ) ) ; } | Set the JSON for this result |
45,646 | public function setNote ( $ note ) { global $ CFG ; $ PDOX = $ this -> launch -> pdox ; $ stmt = $ PDOX -> queryDie ( "UPDATE {$CFG->dbprefix}lti_result SET note = :note, updated_at = NOW() WHERE result_id = :RID" , array ( ':note' => $ note , ':RID' => $ this -> id ) ) ; } | Set the Note for this result |
45,647 | function bodyStart ( $ checkpost = true ) { global $ CFG ; ob_start ( ) ; ?> </head><body prefix="oer: http://oerschema.org"><div id="body_container"><script>if (window!=window.top) { document.getElementById("body_container").className = "container_iframe";} else { document.getElementById("body_container").classN... | Finish the head and start the body of a Tsugi HTML page . |
45,648 | public static function getUtilUrl ( $ path ) { global $ CFG ; if ( isset ( $ CFG -> utilroot ) ) { return $ CFG -> utilroot . $ path ; } $ path = str_replace ( '.php' , '' , $ path ) ; $ retval = $ CFG -> wwwroot . '/util' . $ path ; return $ retval ; } | getUtilUrl - Get a URL in the utility script space - does not add session |
45,649 | public static function handleHeartBeat ( $ cookie ) { global $ CFG ; self :: headerJson ( ) ; session_start ( ) ; $ session_object = null ; $ now = time ( ) ; $ seconds = $ now - LTIX :: wrapped_session_get ( $ session_object , 'LAST_ACTIVITY' , $ now ) ; LTIX :: wrapped_session_put ( $ session_object , 'LAST_ACTIVITY'... | Handle the heartbeat calls . This is UI code basically . |
45,650 | function welcomeUserCourse ( ) { global $ USER , $ CONTEXT ; if ( isset ( $ USER -> displayname ) ) { if ( isset ( $ CONTEXT -> title ) ) { printf ( _m ( "<p>Welcome %s from %s" ) , htmlent_utf8 ( $ USER -> displayname ) , htmlent_utf8 ( $ CONTEXT -> title ) ) ; } else { printf ( _m ( "<p>Welcome %s" ) , htmlent_utf8 (... | Welcome the user to the course |
45,651 | function closeButton ( $ text = false ) { if ( $ text === false ) $ text = _m ( "Exit" ) ; $ button = "btn-success" ; if ( $ text == "Cancel" || $ text == _m ( "Cancel" ) ) $ button = "btn-warning" ; echo ( "<a href=\"#\" onclick=\"window_close();\" class=\"btn " . $ button . "\">" . $ text . "</a>\n" ) ; } | Emit a properly styled close button for use in own popup |
45,652 | function topNavSession ( $ menuset ) { global $ CFG ; $ export = $ menuset -> export ( ) ; $ sess_key = 'tsugi_top_nav_' . $ CFG -> wwwroot ; if ( $ this -> session_get ( $ sess_key ) !== $ export ) { $ this -> session_put ( $ sess_key , $ export ) ; } } | Store the top navigation in the session |
45,653 | function topNav ( $ menu_set = false ) { global $ CFG , $ LAUNCH ; $ sess_key = 'tsugi_top_nav_' . $ CFG -> wwwroot ; $ launch_return_url = $ LAUNCH -> ltiRawParameter ( 'launch_presentation_return_url' , false ) ; $ same_host = false ; if ( $ CFG -> apphome && startsWith ( $ launch_return_url , $ CFG -> apphome ) ) $ ... | Emit the top navigation block |
45,654 | public static function embeddedMenu ( $ url , $ profile_email , $ user_email ) { global $ CFG ; if ( ! $ CFG -> unify ) return '' ; if ( isset ( $ _COOKIE [ 'TSUGILINKDISMISS' ] ) ) return '' ; $ message = htmlentities ( $ profile_email ) ; return <<< EOF<div id="tsugi-link-dialog" title="Read Only Dialog" style="disp... | The embedded menu - for now just one button ... |
45,655 | function dumpDebugArray ( $ debug_log ) { if ( ! is_array ( $ debug_log ) ) return ; foreach ( $ debug_log as $ k => $ v ) { if ( count ( $ v ) > 1 ) { $ this -> togglePre ( $ v [ 0 ] , $ v [ 1 ] ) ; } else if ( is_array ( $ v ) ) { line_out ( $ v [ 0 ] ) ; } else if ( is_string ( $ v ) ) { line_out ( $ v ) ; } } } | Dump a debug array with messages and optional detail |
45,656 | public static function doRedirect ( $ location ) { if ( headers_sent ( ) ) { if ( PHP_VERSION_ID >= 70000 ) { $ location = U :: addSession ( $ location ) ; } echo ( '<a href="' . $ location . '">Continue</a>' . "\n" ) ; } else { if ( ini_get ( 'session.use_cookies' ) == 0 ) { $ location = U :: addSession ( $ location )... | Redirect to a local URL adding session if necessary |
45,657 | public function add_module ( $ title ) { $ this -> resource_count ++ ; $ resource_str = str_pad ( $ this -> resource_count . '' , 6 , '0' , STR_PAD_LEFT ) ; $ identifier = 'T_' . $ resource_str ; $ xpath = new \ DOMXpath ( $ this ) ; $ items = $ xpath -> query ( CC :: item_xpath ) -> item ( 0 ) ; $ module = $ this -> a... | Adds a module to the manifest |
45,658 | public function add_sub_module ( $ module , $ title ) { $ this -> resource_count ++ ; $ resource_str = str_pad ( $ this -> resource_count . '' , 6 , '0' , STR_PAD_LEFT ) ; $ identifier = 'T_' . $ resource_str ; $ sub_module = $ this -> add_child_ns ( CC :: CC_1_1_CP , $ module , 'item' , null , array ( 'identifier' => ... | Adds a sub module to a module |
45,659 | public function add_resource_item ( $ module , $ title = null , $ type , $ identifier , $ file ) { $ identifier_ref = $ identifier . "_R" ; $ xpath = new \ DOMXpath ( $ this ) ; $ new_item = $ this -> add_child_ns ( CC :: CC_1_1_CP , $ module , 'item' , null , array ( 'identifier' => $ identifier , "identifierref" => $... | Add a resource to the manifest . |
45,660 | public function status ( $ html = false ) { $ msg = $ this -> run ( "status" ) ; if ( $ html == true ) { $ msg = str_replace ( "\n" , "<br />" , $ msg ) ; } return $ msg ; } | Runs a git status call |
45,661 | public function rm ( $ files = "*" , $ cached = false ) { if ( is_array ( $ files ) ) { $ files = '"' . implode ( '" "' , $ files ) . '"' ; } return $ this -> run ( "rm " . ( $ cached ? '--cached ' : '' ) . $ files ) ; } | Runs a git rm call |
45,662 | public function commit ( $ message = "" , $ commit_all = true ) { $ flags = $ commit_all ? '-av' : '-v' ; return $ this -> run ( "commit " . $ flags . " -m " . escapeshellarg ( $ message ) ) ; } | Runs a git commit call |
45,663 | public function list_tags ( $ pattern = null ) { $ tagArray = explode ( "\n" , $ this -> run ( "tag -l $pattern" ) ) ; foreach ( $ tagArray as $ i => & $ tag ) { $ tag = trim ( $ tag ) ; if ( $ tag == '' ) { unset ( $ tagArray [ $ i ] ) ; } } return $ tagArray ; } | List all the available repository tags . |
45,664 | public function log ( $ format = null ) { if ( $ format === null ) return $ this -> run ( 'log' ) ; else return $ this -> run ( 'log --pretty=format:"' . $ format . '"' ) ; } | List log entries . |
45,665 | public static function decomposeUri ( UriInterface $ uri ) { $ stackPattern = '(?<stack>.*([^-]|--)|-*)' ; $ hashPattern = '(?<hash>[0-9a-f]{6,40})' ; $ filenamePattern = '(?<filename>[A-Za-z\-\0-\9]+)' ; $ formatPattern = '(?<format>.{3,4})' ; $ pathPattern = '(?<hash>-.+-)' ; $ path = $ uri -> getPath ( ) ; if ( preg... | Return components of a rokka URL . |
45,666 | public static function getSrcSetUrl ( UriInterface $ url , $ size , $ custom = null , $ setWidthInUrl = true ) { $ identifier = substr ( $ size , - 1 , 1 ) ; $ size = substr ( $ size , 0 , - 1 ) ; switch ( $ identifier ) { case 'x' : $ uri = self :: addOptionsToUri ( $ url , 'options-dpr-' . $ size ) ; break ; case 'w'... | Returns a rokka URL to be used in srcset style attributes . |
45,667 | private static function getSrcSetUrlCustom ( $ size , $ custom , $ setWidthInUrl , UriInterface $ uri ) { if ( preg_match ( '#^([0-9]+)x$#' , $ custom , $ matches ) ) { $ uri = self :: addOptionsToUri ( $ uri , 'options-dpr-' . $ matches [ 1 ] . ( $ setWidthInUrl ? '--resize-width-' . ( int ) ceil ( $ size / $ matches ... | Adds custom options to the URL . |
45,668 | public static function getConnection ( ) { global $ PDOX , $ CFG ; if ( isset ( $ PDOX ) && is_object ( $ PDOX ) && get_class ( $ PDOX ) == 'Tsugi\Util\PDOX' ) { return $ PDOX ; } if ( defined ( 'PDO_WILL_CATCH' ) ) { $ PDOX = new \ Tsugi \ Util \ PDOX ( $ CFG -> pdo , $ CFG -> dbuser , $ CFG -> dbpass ) ; $ PDOX -> se... | Get a singleton global connection or set it up if not already set up . |
45,669 | public static function launchCheck ( $ needed = self :: ALL , $ session_object = null , $ request_data = false ) { global $ TSUGI_LAUNCH , $ CFG ; $ needed = self :: patchNeeded ( $ needed ) ; $ LTI11 = false ; $ LTI13 = false ; $ detail = LTI13 :: isRequestDetail ( $ request_data ) ; if ( $ detail === true ) { $ LTI13... | Silently check if this is a launch and if so handle it and redirect back to ourselves |
45,670 | 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 |
45,671 | 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 |
45,672 | 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 |
45,673 | 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 |
45,674 | 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 |
45,675 | 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 |
45,676 | 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 |
45,677 | 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 |
45,678 | 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 |
45,679 | 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 |
45,680 | 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 |
45,681 | 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 |
45,682 | 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 . |
45,683 | 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 |
45,684 | 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 |
45,685 | 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 |
45,686 | 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 |
45,687 | 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 |
45,688 | 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 |
45,689 | 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 |
45,690 | 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 |
45,691 | 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 |
45,692 | 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 |
45,693 | 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 |
45,694 | 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 |
45,695 | 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 |
45,696 | 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 |
45,697 | 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 |
45,698 | 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 |
45,699 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.