Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Class: ReferenceHelper  - X-Ref

getInstance()   X-Ref
Get an instance of this class.

return: ReferenceHelper

__construct()   X-Ref
Create a new ReferenceHelper.


columnSort($a, $b)   X-Ref
Compare two column addresses
Intended for use as a Callback function for sorting column addresses by column.

param: string $a First column to test (e.g. 'AA')
param: string $b Second column to test (e.g. 'Z')
return: int

columnReverseSort($a, $b)   X-Ref
Compare two column addresses
Intended for use as a Callback function for reverse sorting column addresses by column.

param: string $a First column to test (e.g. 'AA')
param: string $b Second column to test (e.g. 'Z')
return: int

cellSort($a, $b)   X-Ref
Compare two cell addresses
Intended for use as a Callback function for sorting cell addresses by column and row.

param: string $a First cell to test (e.g. 'AA1')
param: string $b Second cell to test (e.g. 'Z1')
return: int

cellReverseSort($a, $b)   X-Ref
Compare two cell addresses
Intended for use as a Callback function for sorting cell addresses by column and row.

param: string $a First cell to test (e.g. 'AA1')
param: string $b Second cell to test (e.g. 'Z1')
return: int

cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)   X-Ref
Test whether a cell address falls within a defined range of cells.

param: string $cellAddress Address of the cell we're testing
param: int $beforeRow Number of the row we're inserting/deleting before
param: int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
param: int $beforeColumnIndex Index number of the column we're inserting/deleting before
param: int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
return: bool

adjustPageBreaks(Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)   X-Ref
Update page breaks when inserting/deleting rows/columns.

param: Worksheet $pSheet The worksheet that we're editing
param: string $pBefore Insert/Delete before this cell address (e.g. 'A1')
param: int $beforeColumnIndex Index number of the column we're inserting/deleting before
param: int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
param: int $beforeRow Number of the row we're inserting/deleting before
param: int $pNumRows Number of rows to insert/delete (negative values indicate deletion)

adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)   X-Ref
Update cell comments when inserting/deleting rows/columns.

param: Worksheet $pSheet The worksheet that we're editing
param: string $pBefore Insert/Delete before this cell address (e.g. 'A1')
param: int $beforeColumnIndex Index number of the column we're inserting/deleting before
param: int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
param: int $beforeRow Number of the row we're inserting/deleting before
param: int $pNumRows Number of rows to insert/delete (negative values indicate deletion)

adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)   X-Ref
Update hyperlinks when inserting/deleting rows/columns.

param: Worksheet $pSheet The worksheet that we're editing
param: string $pBefore Insert/Delete before this cell address (e.g. 'A1')
param: int $beforeColumnIndex Index number of the column we're inserting/deleting before
param: int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
param: int $beforeRow Number of the row we're inserting/deleting before
param: int $pNumRows Number of rows to insert/delete (negative values indicate deletion)

adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)   X-Ref
Update data validations when inserting/deleting rows/columns.

param: Worksheet $pSheet The worksheet that we're editing
param: string $pBefore Insert/Delete before this cell address (e.g. 'A1')
param: int $beforeColumnIndex Index number of the column we're inserting/deleting before
param: int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
param: int $beforeRow Number of the row we're inserting/deleting before
param: int $pNumRows Number of rows to insert/delete (negative values indicate deletion)

adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)   X-Ref
Update merged cells when inserting/deleting rows/columns.

param: Worksheet $pSheet The worksheet that we're editing
param: string $pBefore Insert/Delete before this cell address (e.g. 'A1')
param: int $beforeColumnIndex Index number of the column we're inserting/deleting before
param: int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
param: int $beforeRow Number of the row we're inserting/deleting before
param: int $pNumRows Number of rows to insert/delete (negative values indicate deletion)

adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)   X-Ref
Update protected cells when inserting/deleting rows/columns.

param: Worksheet $pSheet The worksheet that we're editing
param: string $pBefore Insert/Delete before this cell address (e.g. 'A1')
param: int $beforeColumnIndex Index number of the column we're inserting/deleting before
param: int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
param: int $beforeRow Number of the row we're inserting/deleting before
param: int $pNumRows Number of rows to insert/delete (negative values indicate deletion)

adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)   X-Ref
Update column dimensions when inserting/deleting rows/columns.

param: Worksheet $pSheet The worksheet that we're editing
param: string $pBefore Insert/Delete before this cell address (e.g. 'A1')
param: int $beforeColumnIndex Index number of the column we're inserting/deleting before
param: int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
param: int $beforeRow Number of the row we're inserting/deleting before
param: int $pNumRows Number of rows to insert/delete (negative values indicate deletion)

adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)   X-Ref
Update row dimensions when inserting/deleting rows/columns.

param: Worksheet $pSheet The worksheet that we're editing
param: string $pBefore Insert/Delete before this cell address (e.g. 'A1')
param: int $beforeColumnIndex Index number of the column we're inserting/deleting before
param: int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
param: int $beforeRow Number of the row we're inserting/deleting before
param: int $pNumRows Number of rows to insert/delete (negative values indicate deletion)

insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pSheet)   X-Ref
Insert a new column or row, updating all possible related data.

param: string $pBefore Insert before this cell address (e.g. 'A1')
param: int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
param: int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
param: Worksheet $pSheet The worksheet that we're editing

updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '')   X-Ref
Update references within formulas.

param: string $pFormula Formula to update
param: string $pBefore Insert before this one
param: int $pNumCols Number of columns to insert
param: int $pNumRows Number of rows to insert
param: string $sheetName Worksheet name/title
return: string Updated formula

updateFormulaReferencesAnyWorksheet(string $formula = '', int $insertColumns = 0, int $insertRows = 0)   X-Ref
Update all cell references within a formula, irrespective of worksheet.


updateCellReferencesAllWorksheets(string $formula, int $insertColumns, int $insertRows)   X-Ref
No description

updateColumnRangesAllWorksheets(string $formula, int $insertColumns)   X-Ref
No description

updateRowRangesAllWorksheets(string $formula, int $insertRows)   X-Ref
No description

updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)   X-Ref
Update cell reference.

param: string $pCellRange Cell range
param: string $pBefore Insert before this one
param: int $pNumCols Number of columns to increment
param: int $pNumRows Number of rows to increment
return: string Updated cell range

updateNamedFormulas(Spreadsheet $spreadsheet, $oldName = '', $newName = '')   X-Ref
Update named formulas (i.e. containing worksheet references / named ranges).

param: Spreadsheet $spreadsheet Object to update
param: string $oldName Old name (name to replace)
param: string $newName New name

updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)   X-Ref
Update cell range.

param: string $pCellRange Cell range    (e.g. 'B2:D4', 'B:C' or '2:3')
param: string $pBefore Insert before this one
param: int $pNumCols Number of columns to increment
param: int $pNumRows Number of rows to increment
return: string Updated cell range

updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)   X-Ref
Update single cell reference.

param: string $pCellReference Single cell reference
param: string $pBefore Insert before this one
param: int $pNumCols Number of columns to increment
param: int $pNumRows Number of rows to increment
return: string Updated cell reference

__clone()   X-Ref
__clone implementation. Cloning should not be allowed in a Singleton!