idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
226,500
public function loadDocument ( $ documentId , \ DmsLoaderParams $ params ) { $ objDocument = $ this -> Database -> prepare ( "SELECT d.*, CONCAT(m1.firstname, ' ', m1.lastname) AS upload_member_name, CONCAT(m2.firstname, ' ', m2.lastname) AS lastedit_member_name " . "FROM tl_dms_documents d " . "LEFT JOIN tl_member m1 ...
Load the document with the given id .
226,501
public function loadDocuments ( $ strFileName , $ strFileType , \ DmsLoaderParams $ params ) { $ arrDocuments = array ( ) ; $ objDocument = $ this -> Database -> prepare ( "SELECT d.*, CONCAT(m1.firstname, ' ', m1.lastname) AS upload_member_name, CONCAT(m2.firstname, ' ', m2.lastname) AS lastedit_member_name " . "FROM ...
Load the documents for the given file name and type .
226,502
protected function getCategoryLevel ( $ parentCategoryId , \ Category $ parentCategory = null , \ DmsLoaderParams $ params ) { $ arrCategories = array ( ) ; $ objCategory = $ this -> Database -> prepare ( "SELECT * FROM tl_dms_categories WHERE pid = ? ORDER BY sorting" ) -> execute ( $ parentCategoryId ) ; $ category =...
Recursively reading the categories
226,503
private function getAccessRights ( \ Category $ category , \ DmsLoaderParams $ params ) { $ objAccessRight = $ this -> Database -> prepare ( "SELECT * FROM tl_dms_access_rights WHERE pid = ?" ) -> execute ( $ category -> id ) ; $ arrAccessRights = array ( ) ; while ( $ objAccessRight -> next ( ) ) { $ accessRight = $ t...
Get all access rights for the given category .
226,504
private function getDocuments ( \ Category $ category , \ DmsLoaderParams $ params ) { $ whereClause = "WHERE d.pid = ? " ; $ whereParams = array ( ) ; $ whereParams [ ] = $ category -> id ; if ( $ params -> hasDocumentSearchText ( ) ) { if ( $ params -> documentSearchType == \ DmsLoaderParams :: DOCUMENT_SEARCH_LIKE )...
Get all documents for the given category .
226,505
private function buildCategory ( $ objCategory ) { $ category = new \ Category ( $ objCategory -> id , $ objCategory -> name ) ; $ category -> parentCategoryId = $ objCategory -> pid ; $ category -> description = $ objCategory -> description ; $ category -> fileTypes = $ objCategory -> file_types ; $ category -> fileTy...
Builds a category from a database result .
226,506
private function buildAccessRight ( $ objAccessRight ) { $ accessRight = new \ AccessRight ( $ objAccessRight -> id , $ objAccessRight -> member_group ) ; $ accessRight -> categoryId = $ objAccessRight -> pid ; $ strRight = \ AccessRight :: READ ; $ accessRight -> $ strRight = $ objAccessRight -> right_read ; $ strRigh...
Builds an access right from a database result .
226,507
public static function getBaseDirectory ( $ blnAppendTrailingSlash ) { $ path = \ FilesModel :: findByUuid ( $ GLOBALS [ 'TL_CONFIG' ] [ 'dmsBaseDirectory' ] ) -> path ; if ( $ blnAppendTrailingSlash ) { $ path .= "/" ; } return $ path ; }
Return base directory for the DMS documents defined in system settings .
226,508
public static function getPreviewDirectory ( $ blnAppendTrailingSlash ) { $ path = self :: getBaseDirectory ( true ) . self :: DIRECTORY_NAME_PREVIEW ; if ( $ blnAppendTrailingSlash ) { $ path .= "/" ; } return $ path ; }
Return preview directory for the DMS document preview images .
226,509
public static function getTempDirectory ( $ blnAppendTrailingSlash ) { $ path = self :: getBaseDirectory ( true ) . self :: DIRECTORY_NAME_TEMP ; if ( $ blnAppendTrailingSlash ) { $ path .= "/" ; } return $ path ; }
Return temp directory for the DMS documents .
226,510
public static function getMaxUploadFileSize ( $ strUnit , $ blnFormatted ) { $ arrValue = deserialize ( $ GLOBALS [ 'TL_CONFIG' ] [ 'dmsMaxUploadFileSize' ] ) ; $ dmsUnit = $ arrValue [ 'unit' ] ; $ dmsVal = \ Document :: convertFileSize ( ( double ) $ arrValue [ 'value' ] , $ dmsUnit , $ strUnit ) ; if ( $ blnFormatte...
Return the maximum allowed upload file size defined in system settings .
226,511
private function initDirectoryStructure ( ) { if ( ! file_exists ( TL_ROOT . '/' . $ this -> getDmsBaseDirectory ( ) ) ) { mkdir ( TL_ROOT . '/' . $ this -> getDmsBaseDirectory ( ) , 0775 , true ) ; $ objDir = \ Dbafs :: addResource ( $ this -> getDmsBaseDirectory ( ) ) ; $ objFolder = new \ Folder ( $ this -> getDmsBa...
Init the directory structure Create structure if not exists
226,512
private function initSystemSettings ( ) { if ( \ Config :: get ( self :: DMS_BASE_DIRECTORY_KEY ) && \ Config :: get ( self :: DMS_MAX_UPLOAD_FILE_SIZE_KEY ) ) { return ; } \ System :: log ( 'Running init script for setting default DMS settings, if missing.' , __METHOD__ , TL_CONFIGURATION ) ; if ( ! \ Config :: get ( ...
Init the system setting Set base directoy if not set
226,513
public function setTagMap ( int $ class , array $ map ) { if ( isset ( $ this -> tagMap [ $ class ] ) ) { $ this -> tagMap [ $ class ] = $ map ; } return $ this ; }
Map universal types to specific tag class values when decoding .
226,514
public function setOptions ( array $ options ) { if ( isset ( $ options [ 'bitstring_padding' ] ) && \ is_string ( $ options [ 'bitstring_padding' ] ) ) { $ this -> options [ 'bitstring_padding' ] = $ options [ 'bitstring_padding' ] ; } return $ this ; }
Set the options for the encoder .
226,515
protected function getVlqBytesToInt ( ) { $ value = 0 ; $ isBigInt = false ; for ( $ this -> pos ; $ this -> pos < $ this -> maxLen ; $ this -> pos ++ ) { if ( ! $ isBigInt ) { $ lshift = $ value << 7 ; if ( $ lshift < 0 ) { $ isBigInt = true ; $ this -> throwIfBigIntGmpNeeded ( true ) ; $ value = \ gmp_init ( $ value ...
Given what should be VLQ bytes represent an int get the int and the length of bytes .
226,516
protected function intToVlqBytes ( $ int ) { $ bigint = \ is_float ( $ int + 0 ) ; $ this -> throwIfBigIntGmpNeeded ( $ bigint ) ; if ( $ bigint ) { $ int = \ gmp_init ( $ int ) ; $ bytes = \ chr ( \ gmp_intval ( \ gmp_and ( \ gmp_init ( 0x7f ) , $ int ) ) ) ; $ int = \ gmp_div ( $ int , \ gmp_pow ( 2 , 7 ) ) ; $ intVa...
Get the bytes that represent variable length quantity .
226,517
public function import ( Event $ event , ImportRecordsDataTable $ importRecordsDataTable ) { return $ importRecordsDataTable -> with ( [ 'resource' => $ event , 'tabs' => 'adminarea.events.tabs' , 'url' => route ( 'adminarea.events.stash' ) , 'id' => "adminarea-events-{$event->getRouteKey()}-import-table" , ] ) -> rend...
Import events .
226,518
public function import ( Service $ service , ImportRecordsDataTable $ importRecordsDataTable ) { return $ importRecordsDataTable -> with ( [ 'resource' => $ service , 'tabs' => 'adminarea.services.tabs' , 'url' => route ( 'adminarea.services.stash' ) , 'id' => "adminarea-services-{$service->getRouteKey()}-import-table"...
Import services .
226,519
public function hoard ( ImportFormRequest $ request ) { foreach ( ( array ) $ request -> get ( 'selected_ids' ) as $ recordId ) { $ record = app ( 'cortex.foundation.import_record' ) -> find ( $ recordId ) ; try { $ fillable = collect ( $ record [ 'data' ] ) -> intersectByKeys ( array_flip ( app ( 'rinvex.bookings.serv...
Hoard services .
226,520
public function update ( BookingFormRequest $ request , ServiceBooking $ serviceBooking ) : int { return $ this -> process ( $ request , $ serviceBooking ) ; }
Update given booking .
226,521
public function destroy ( Service $ service , ServiceBooking $ serviceBooking ) { $ service -> bookings ( ) -> where ( $ serviceBooking -> getKeyName ( ) , $ serviceBooking -> getKey ( ) ) -> first ( ) -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.services.bookings.index' ) , 'with' => [ 'warning' => tr...
Destroy given booking .
226,522
public function import ( Contact $ contact , ImportRecordsDataTable $ importRecordsDataTable ) { return $ importRecordsDataTable -> with ( [ 'resource' => $ contact , 'tabs' => 'adminarea.contacts.tabs' , 'url' => route ( 'adminarea.contacts.stash' ) , 'id' => "adminarea-contacts-{$contact->getRouteKey()}-import-table"...
Import contacts .
226,523
public function stash ( ImportFormRequest $ request , DefaultImporter $ importer , Event $ event ) { $ importer -> config [ 'resource' ] = $ this -> resource ; $ importer -> handleImport ( ) ; }
Stash events .
226,524
public function index ( Event $ event , MediaDataTable $ mediaDataTable ) { return $ mediaDataTable -> with ( [ 'resource' => $ event , 'tabs' => 'adminarea.events.tabs' , 'id' => "adminarea-events-{$event->getRouteKey()}-media-table" , 'url' => route ( 'adminarea.events.media.store' , [ 'event' => $ event ] ) , ] ) ->...
List event media .
226,525
public function store ( ImageFormRequest $ request , Event $ event ) : void { $ event -> addMediaFromRequest ( 'file' ) -> sanitizingFileName ( function ( $ fileName ) { return md5 ( $ fileName ) . '.' . pathinfo ( $ fileName , PATHINFO_EXTENSION ) ; } ) -> toMediaCollection ( 'default' , config ( 'cortex.bookings.medi...
Store new event media .
226,526
public function destroy ( Event $ event , Media $ media ) { $ event -> media ( ) -> where ( $ media -> getKeyName ( ) , $ media -> getKey ( ) ) -> first ( ) -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.events.media.index' , [ 'event' => $ event ] ) , 'with' => [ 'warning' => trans ( 'cortex/foundation:...
Destroy given event media .
226,527
public function connect ( array $ config , string $ name = 'main' ) : Connection { if ( isset ( $ this -> connections [ $ name ] ) ) { throw new InvalidArgumentException ( "Connection [$name] is already configured." ) ; } $ this -> connections [ $ name ] = new Connection ( $ config ) ; return $ this -> connections [ $ ...
Connect to the given connection .
226,528
public function destroy ( Service $ service ) { $ service -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.services.index' ) , 'with' => [ 'warning' => trans ( 'cortex/foundation::messages.resource_deleted' , [ 'resource' => trans ( 'cortex/bookings::common.service' ) , 'identifier' => $ service -> name ] ...
Destroy given service .
226,529
public function api ( string $ name ) : API \ AbstractAPI { $ name = ucfirst ( $ name ) ; $ class = "ArkEcosystem\\Client\\API\\{$name}" ; if ( ! class_exists ( $ class ) ) { throw new RuntimeException ( "Class [$class] does not exist." ) ; } return new $ class ( $ this ) ; }
Make a new resource instance .
226,530
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 .
226,531
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 .
226,532
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 .
226,533
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 .
226,534
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 .
226,535
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 .
226,536
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 .
226,537
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
226,538
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
226,539
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
226,540
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 .
226,541
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
226,542
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
226,543
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
226,544
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 .
226,545
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 .
226,546
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 .
226,547
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 .
226,548
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 .
226,549
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 .
226,550
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 .
226,551
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 .
226,552
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 .
226,553
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 .
226,554
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
226,555
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 .
226,556
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 .
226,557
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
226,558
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
226,559
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
226,560
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
226,561
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
226,562
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
226,563
public function setHome ( $ link , $ href ) { $ this -> home = new \ Tsugi \ UI \ MenuEntry ( $ link , $ href ) ; return $ this ; }
Set the Home Menu
226,564
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
226,565
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
226,566
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
226,567
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
226,568
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
226,569
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 .
226,570
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 .
226,571
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
226,572
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
226,573
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
226,574
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
226,575
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
226,576
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
226,577
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 .
226,578
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
226,579
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 .
226,580
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
226,581
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
226,582
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
226,583
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
226,584
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 ...
226,585
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
226,586
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
226,587
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
226,588
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
226,589
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 .
226,590
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
226,591
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
226,592
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
226,593
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 .
226,594
public function log ( $ format = null ) { if ( $ format === null ) return $ this -> run ( 'log' ) ; else return $ this -> run ( 'log --pretty=format:"' . $ format . '"' ) ; }
List log entries .
226,595
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 .
226,596
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 .
226,597
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 .
226,598
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 .
226,599
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