TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
AbstractTreeView Class Reference
Inheritance diagram for AbstractTreeView:
BrowseTreeView FolderTreeView PageTreeView ElementBrowserPageTreeView PageTreeView ExportPageTreeView ElementBrowserFolderTreeView FileListFolderTree NewRecordPageTreeView ElementBrowserPageTreeView

Public Member Functions

 __construct ()
 
 init ($clause= '', $orderByFields= '')
 
 addField ($field, $noCheck=false)
 
 reset ()
 
 getBrowsableTree ()
 
 printTree ($treeArr= '')
 
 PMicon ($row, $a, $c, $nextCount, $isOpen)
 
 PM_ATagWrap ($icon, $cmd, $bMark= '', $isOpen=false)
 
 wrapTitle ($title, $row, $bank=0)
 
 wrapIcon ($icon, $row)
 
 addTagAttributes ($icon, $attr)
 
 wrapStop ($str, $row)
 
 expandNext ($id)
 
 initializePositionSaving ()
 
 savePosition ()
 
 getRootIcon ($rec)
 
 getIcon ($row)
 
 getTitleStr ($row, $titleLen=30)
 
 getTitleAttrib ($row)
 
 getId ($row)
 
 getJumpToParam ($row)
 
 getTree ($uid, $depth=999, $depthData= '')
 
 getCount ($uid)
 
 getRootRecord ()
 
 getRecord ($uid)
 
 getDataInit ($parentId)
 
 getDataCount (&$res)
 
 getDataNext (&$res)
 
 getDataFree (&$res)
 
 setDataFromArray (&$dataArr, $traverse=false, $pid=0)
 
 setDataFromTreeArray (&$treeArr, &$treeLookupArr)
 

Public Attributes

 $expandFirst = 0
 
 $expandAll = 0
 
 $thisScript = ''
 
 $titleAttrib = 'title'
 
 $ext_IconMode = false
 
 $addSelfId = 0
 
 $title = 'no title'
 
 $showDefaultTitleAttribute = false
 
 $BE_USER = ''
 
 $MOUNTS = null
 
 $table = ''
 
 $parentField = 'pid'
 
 $clause = ''
 
 $orderByFields = ''
 
 $fieldArray = ['uid', 'pid', 'title']
 
 $defaultList = 'uid,pid,tstamp,sorting,deleted,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,crdate,cruser_id'
 
 $treeName = ''
 
 $domIdPrefix = 'row'
 
 $makeHTML = 1
 
 $setRecs = 0
 
 $subLevelID = '_SUB_LEVEL'
 
 $ids = []
 
 $ids_hierarchy = []
 
 $orig_ids_hierarchy = []
 
 $buffer_idH = []
 
 $specUIDmap = []
 
 $data = false
 
 $dataLookup = false
 
 $tree = []
 
 $stored = []
 
 $bank = 0
 
 $recs = []
 

Protected Member Functions

 determineScriptUrl ()
 
 getThisScript ()
 
 getLanguageService ()
 
 getBackendUser ()
 

Detailed Description

Base class for creating a browsable array/page/folder tree in HTML

Definition at line 33 of file AbstractTreeView.php.

Constructor & Destructor Documentation

__construct ( )

Constructor

Definition at line 276 of file AbstractTreeView.php.

References AbstractTreeView\determineScriptUrl().

Member Function Documentation

addField (   $field,
  $noCheck = false 
)

Adds a fieldname to the internal array ->fieldArray

Parameters
string$fieldField name to
bool$noCheckIf set, the fieldname will be set no matter what. Otherwise the field name must either be found as key in $GLOBALS['TCA'][$table]['columns'] or in the list ->defaultList
Returns
void

Definition at line 342 of file AbstractTreeView.php.

References $GLOBALS, and GeneralUtility\inList().

addTagAttributes (   $icon,
  $attr 
)

Adds attributes to image tag.

Parameters
string$iconIcon image tag
string$attrAttributes to add, eg. ' border="0"'
Returns
string Image tag, modified with $attr attributes added.

Definition at line 573 of file AbstractTreeView.php.

determineScriptUrl ( )
protected

Sets the script url depending on being a module or script request

Definition at line 284 of file AbstractTreeView.php.

References GeneralUtility\_GP(), GeneralUtility\getIndpEnv(), and GeneralUtility\makeInstance().

Referenced by AbstractTreeView\__construct().

expandNext (   $id)

Returns TRUE/FALSE if the next level for $id should be expanded - based on data in $this->stored[][] and ->expandAll flag. Extending parent function

Parameters
int$idRecord id/key
Returns
bool private
See also
::expandNext()

Definition at line 609 of file AbstractTreeView.php.

References AbstractTreeView\$bank.

Referenced by AbstractTreeView\getTree().

getBackendUser ( )
protected
Returns
BackendUserAuthentication

Definition at line 1058 of file AbstractTreeView.php.

References $GLOBALS.

Referenced by BrowseTreeView\getTitleStr(), AbstractTreeView\getTree(), and BrowseTreeView\init().

getBrowsableTree ( )
getCount (   $uid)

Returns the number of records having the parent id, $uid

Parameters
int$uidId to count subitems for
Returns
int private

Definition at line 843 of file AbstractTreeView.php.

References AbstractTreeView\getDataCount(), AbstractTreeView\getDataInit(), GeneralUtility\makeInstance(), and QueryHelper\stripLogicalOperatorPrefix().

Referenced by AbstractTreeView\getTree().

getDataCount ( $res)

Getting the tree data: Counting elements in resource

Parameters
mixed$resData handle
Returns
int number of items private
See also
getDataInit()

Definition at line 951 of file AbstractTreeView.php.

Referenced by AbstractTreeView\getCount(), and AbstractTreeView\getTree().

getDataFree ( $res)

Getting the tree data: frees data handle

Parameters
mixed$resData handle
Returns
void private

Definition at line 996 of file AbstractTreeView.php.

Referenced by AbstractTreeView\getTree().

getDataInit (   $parentId)

Getting the tree data: Selecting/Initializing data pointer to items for a certain parent id. For tables: This will make a database query to select all children to "parent" For arrays: This will return key to the ->dataLookup array

Parameters
int$parentIdparent item id
Returns
mixed Data handle (Tables: An sql-resource, arrays: A parentId integer. -1 is returned if there were NO subLevel.) private

Definition at line 908 of file AbstractTreeView.php.

References GeneralUtility\makeInstance(), QueryHelper\parseOrderBy(), AbstractTreeView\reset(), and QueryHelper\stripLogicalOperatorPrefix().

Referenced by AbstractTreeView\getCount(), and AbstractTreeView\getTree().

getDataNext ( $res)

Getting the tree data: next entry

Parameters
mixed$resData handle
Returns
array item data array OR FALSE if end of elements. private
See also
getDataInit()

Definition at line 969 of file AbstractTreeView.php.

References BackendUtility\workspaceOL().

Referenced by AbstractTreeView\getTree().

getIcon (   $row)
getId (   $row)

Returns the id from the record (typ. uid)

Parameters
array$rowRecord array
Returns
int The "uid" field value.

Definition at line 723 of file AbstractTreeView.php.

Referenced by AbstractTreeView\getJumpToParam(), PageTreeView\printTree(), AbstractTreeView\printTree(), BrowseTreeView\wrapIcon(), PageTreeView\wrapTitle(), and AbstractTreeView\wrapTitle().

getJumpToParam (   $row)

Returns jump-url parameter value.

Parameters
array$rowThe record array.
Returns
string The jump-url parameter.

Definition at line 734 of file AbstractTreeView.php.

References AbstractTreeView\getId().

Referenced by BrowseTreeView\wrapIcon(), PageTreeView\wrapTitle(), and AbstractTreeView\wrapTitle().

getLanguageService ( )
protected
Returns
LanguageService

Definition at line 1050 of file AbstractTreeView.php.

References $GLOBALS.

Referenced by PageTreeView\getTitleStr(), AbstractTreeView\getTitleStr(), and ExportPageTreeView\wrapTitle().

getRecord (   $uid)

Returns the record for a uid. For tables: Looks up the record in the database. For arrays: Returns the fake record for uid id.

Parameters
int$uidUID to look up
Returns
array The record

Definition at line 889 of file AbstractTreeView.php.

References BackendUtility\getRecordWSOL().

Referenced by PageTreeView\getBrowsableTree(), and AbstractTreeView\getBrowsableTree().

getRootIcon (   $rec)

Returns the root icon for a tree/mountpoint (defaults to the globe)

Parameters
array$recRecord for root.
Returns
string Icon image tag.

Definition at line 667 of file AbstractTreeView.php.

References GeneralUtility\makeInstance(), Icon\SIZE_SMALL, and AbstractTreeView\wrapIcon().

Referenced by ExportPageTreeView\ext_tree(), PageTreeView\getBrowsableTree(), and AbstractTreeView\getBrowsableTree().

getRootRecord ( )

Returns root record for uid (<=0)

Returns
array Array with title/uid keys with values of $this->title/0 (zero)

Definition at line 876 of file AbstractTreeView.php.

References AbstractTreeView\$title.

Referenced by PageTreeView\getBrowsableTree(), and AbstractTreeView\getBrowsableTree().

getTitleAttrib (   $row)

Returns the value for the image "title" attribute

Parameters
array$rowThe input row array (where the key "title" is used for the title)
Returns
string The attribute value (is htmlspecialchared() already)
See also
wrapIcon()

Definition at line 712 of file AbstractTreeView.php.

Referenced by AbstractTreeView\getIcon().

getTitleStr (   $row,
  $titleLen = 30 
)

Returns the title for the input record. If blank, a "no title" label (localized) will be returned. Do NOT htmlspecialchar the string from this function - has already been done.

Parameters
array$rowThe input row array (where the key "title" is used for the title)
int$titleLenTitle length (30)
Returns
string The title.

Definition at line 698 of file AbstractTreeView.php.

References AbstractTreeView\$title, and AbstractTreeView\getLanguageService().

Referenced by AbstractTreeView\printTree().

getTree (   $uid,
  $depth = 999,
  $depthData = '' 
)

Fetches the data for the tree

Parameters
int$uiditem id for which to select subitems (parent id)
int$depthMax depth (recursivity limit)
string$depthDataHTML-code prefix for recursive calls.
Returns
int The count of items on the level

Definition at line 753 of file AbstractTreeView.php.

References AbstractTreeView\$bank, AbstractTreeView\$buffer_idH, AbstractTreeView\expandNext(), AbstractTreeView\getBackendUser(), AbstractTreeView\getCount(), AbstractTreeView\getDataCount(), AbstractTreeView\getDataFree(), AbstractTreeView\getDataInit(), AbstractTreeView\getDataNext(), AbstractTreeView\getIcon(), AbstractTreeView\PMicon(), and AbstractTreeView\wrapStop().

Referenced by ExportPageTreeView\ext_tree(), PageTreeView\getBrowsableTree(), and AbstractTreeView\getBrowsableTree().

init (   $clause = '',
  $orderByFields = '' 
)

Initialize the tree class. Needs to be overwritten

Parameters
string$clauseRecord WHERE clause
string$orderByFieldsRecord ORDER BY field
Returns
void

Definition at line 313 of file AbstractTreeView.php.

References AbstractTreeView\$clause, $GLOBALS, and AbstractTreeView\$orderByFields.

Referenced by FolderTreeView\__construct().

initializePositionSaving ( )

Get stored tree structure AND updating it if needed according to incoming PM GET var.

Returns
void private

Definition at line 620 of file AbstractTreeView.php.

References GeneralUtility\_GP(), and AbstractTreeView\savePosition().

Referenced by PageTreeView\getBrowsableTree(), and AbstractTreeView\getBrowsableTree().

PM_ATagWrap (   $icon,
  $cmd,
  $bMark = '',
  $isOpen = false 
)

Wrap the plus/minus icon in a link

Parameters
string$iconHTML string to wrap, probably an image tag.
string$cmdCommand for 'PM' get var
string$bMarkIf set, the link will have an anchor point (=$bMark) and a name attribute (=$bMark)
bool$isOpen
Returns
string Link-wrapped input string private

Definition at line 526 of file AbstractTreeView.php.

References AbstractTreeView\getThisScript().

Referenced by AbstractTreeView\getBrowsableTree(), and AbstractTreeView\PMicon().

PMicon (   $row,
  $a,
  $c,
  $nextCount,
  $isOpen 
)

Generate the plus/minus icon for the browsable tree.

Parameters
array$rowRecord for the entry
int$aThe current entry number
int$cThe total number of entries. If equal to $a, a "bottom" element is returned.
int$nextCountThe number of sub-elements to the current element.
bool$isOpenThe element was expanded to render subelements if this flag is set.
Returns
string Image tag with the plus/minus icon. private
See also
::PMicon()

Definition at line 505 of file AbstractTreeView.php.

References AbstractTreeView\PM_ATagWrap().

Referenced by AbstractTreeView\getTree().

printTree (   $treeArr = '')

Compiles the HTML code for displaying the structure found inside the ->tree array

Parameters
array | string$treeArr"tree-array" - if blank string, the internal ->tree array is used.
Returns
string The HTML code for the tree

Definition at line 439 of file AbstractTreeView.php.

References AbstractTreeView\$tree, AbstractTreeView\getId(), AbstractTreeView\getTitleStr(), and AbstractTreeView\wrapTitle().

Referenced by FolderTreeView\getBrowsableTree(), and AbstractTreeView\getBrowsableTree().

reset ( )

Resets the tree, recs, ids, ids_hierarchy and orig_ids_hierarchy internal variables. Use it if you need it.

Returns
void

Definition at line 354 of file AbstractTreeView.php.

Referenced by ExportPageTreeView\ext_tree(), PageTreeView\getBrowsableTree(), AbstractTreeView\getBrowsableTree(), and AbstractTreeView\getDataInit().

savePosition ( )

Saves the content of ->stored (keeps track of expanded positions in the tree) $this->treeName will be used as key for BE_USER->uc[] to store it in

Returns
void private

Definition at line 650 of file AbstractTreeView.php.

References AbstractTreeView\$treeName.

Referenced by FolderTreeView\initializePositionSaving(), and AbstractTreeView\initializePositionSaving().

setDataFromArray ( $dataArr,
  $traverse = false,
  $pid = 0 
)

Used to initialize class with an array to browse. The array inputted will be traversed and an internal index for lookup is created. The keys of the input array are perceived as "uid"s of records which means that keys GLOBALLY must be unique like uids are. "uid" and "pid" "fakefields" are also set in each record. All other fields are optional.

Parameters
array$dataArrThe input array, see examples below in this script.
bool$traverseInternal, for recursion.
int$pidInternal, for recursion.
Returns
void

Definition at line 1015 of file AbstractTreeView.php.

References AbstractTreeView\$subLevelID.

setDataFromTreeArray ( $treeArr,
$treeLookupArr 
)

Sets the internal data arrays

Parameters
array$treeArrContent for $this->data
array$treeLookupArrContent for $this->dataLookup
Returns
void

Definition at line 1041 of file AbstractTreeView.php.

wrapIcon (   $icon,
  $row 
)

Wrapping the image tag, $icon, for the row, $row (except for mount points)

Parameters
string$iconThe image tag for the icon
array$rowThe row for the current element
Returns
string The processed icon input value. private

Definition at line 561 of file AbstractTreeView.php.

Referenced by AbstractTreeView\getIcon(), and AbstractTreeView\getRootIcon().

wrapStop (   $str,
  $row 
)

Adds a red "+" to the input string, $str, if the field "php_tree_stop" in the $row (pages) is set

Parameters
string$strInput string, like a page title for the tree
array$rowrecord row with "php_tree_stop" field
Returns
string Modified string private

Definition at line 586 of file AbstractTreeView.php.

References GeneralUtility\linkThisScript().

Referenced by AbstractTreeView\getTree().

wrapTitle (   $title,
  $row,
  $bank = 0 
)

Wrapping $title in a-tags.

Parameters
string$titleTitle string
string$rowItem record
int$bankBank pointer (which mount point number)
Returns
string private

Definition at line 547 of file AbstractTreeView.php.

References AbstractTreeView\$bank, AbstractTreeView\$title, AbstractTreeView\getId(), AbstractTreeView\getJumpToParam(), and GeneralUtility\quoteJSvalue().

Referenced by AbstractTreeView\printTree().

Member Data Documentation

$addSelfId = 0

Definition at line 71 of file AbstractTreeView.php.

$BE_USER = ''

Definition at line 93 of file AbstractTreeView.php.

$buffer_idH = []

Definition at line 226 of file AbstractTreeView.php.

Referenced by ExportPageTreeView\ext_tree(), and AbstractTreeView\getTree().

$data = false

Definition at line 240 of file AbstractTreeView.php.

$dataLookup = false

Definition at line 246 of file AbstractTreeView.php.

$defaultList = 'uid,pid,tstamp,sorting,deleted,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,crdate,cruser_id'

Definition at line 154 of file AbstractTreeView.php.

$domIdPrefix = 'row'

Definition at line 175 of file AbstractTreeView.php.

$expandAll = 0

Definition at line 46 of file AbstractTreeView.php.

$expandFirst = 0
$ext_IconMode = false

Definition at line 65 of file AbstractTreeView.php.

$fieldArray = ['uid', 'pid', 'title']

Definition at line 146 of file AbstractTreeView.php.

$ids_hierarchy = []

Definition at line 214 of file AbstractTreeView.php.

$makeHTML = 1

Definition at line 183 of file AbstractTreeView.php.

$MOUNTS = null

Definition at line 104 of file AbstractTreeView.php.

$orderByFields = ''

Definition at line 137 of file AbstractTreeView.php.

Referenced by AbstractTreeView\init().

$orig_ids_hierarchy = []

Definition at line 220 of file AbstractTreeView.php.

$parentField = 'pid'

Definition at line 119 of file AbstractTreeView.php.

$recs = []

Definition at line 271 of file AbstractTreeView.php.

$setRecs = 0

Definition at line 190 of file AbstractTreeView.php.

$showDefaultTitleAttribute = false

Definition at line 85 of file AbstractTreeView.php.

$specUIDmap = []

Definition at line 233 of file AbstractTreeView.php.

$stored = []

Definition at line 259 of file AbstractTreeView.php.

$subLevelID = '_SUB_LEVEL'

Definition at line 198 of file AbstractTreeView.php.

Referenced by AbstractTreeView\setDataFromArray().

$table = ''

Definition at line 112 of file AbstractTreeView.php.

$thisScript = ''
$titleAttrib = 'title'

Definition at line 58 of file AbstractTreeView.php.

$treeName = ''

Definition at line 165 of file AbstractTreeView.php.

Referenced by AbstractTreeView\savePosition().