TYPO3  7.6
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
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 = array('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 = array()
 
 $ids_hierarchy = array()
 
 $orig_ids_hierarchy = array()
 
 $buffer_idH = array()
 
 $specUIDmap = array()
 
 $data = false
 
 $dataLookup = false
 
 $tree = array()
 
 $stored = array()
 
 $bank = 0
 
 $recs = array()
 

Protected Member Functions

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

Detailed Description

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

Definition at line 30 of file AbstractTreeView.php.

Constructor & Destructor Documentation

__construct ( )

Constructor

Definition at line 273 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 339 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 559 of file AbstractTreeView.php.

determineScriptUrl ( )
protected

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

Definition at line 281 of file AbstractTreeView.php.

References GeneralUtility\_GP(), elseif, 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 595 of file AbstractTreeView.php.

References AbstractTreeView\$bank.

Referenced by AbstractTreeView\getTree().

getBackendUser ( )
protected
Returns
BackendUserAuthentication

Definition at line 1009 of file AbstractTreeView.php.

References $GLOBALS.

Referenced by AbstractTreeView\getTree().

getBrowsableTree ( )

Will create and return the HTML code for a browsable tree Is based on the mounts found in the internal array ->MOUNTS (set in the constructor)

Returns
string HTML code for the browsable tree

Definition at line 371 of file AbstractTreeView.php.

References AbstractTreeView\$expandFirst, AbstractTreeView\$ids, AbstractTreeView\getIcon(), AbstractTreeView\getRecord(), AbstractTreeView\getRootIcon(), AbstractTreeView\getRootRecord(), AbstractTreeView\getTree(), AbstractTreeView\initializePositionSaving(), AbstractTreeView\PM_ATagWrap(), AbstractTreeView\printTree(), and AbstractTreeView\reset().

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 829 of file AbstractTreeView.php.

References AbstractTreeView\$clause, BackendUtility\deleteClause(), AbstractTreeView\getDatabaseConnection(), AbstractTreeView\getDataCount(), AbstractTreeView\getDataInit(), and BackendUtility\versioningPlaceholderClause().

Referenced by AbstractTreeView\getTree().

getDatabaseConnection ( )
protected
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 902 of file AbstractTreeView.php.

References AbstractTreeView\getDatabaseConnection().

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 947 of file AbstractTreeView.php.

References AbstractTreeView\getDatabaseConnection().

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 878 of file AbstractTreeView.php.

References AbstractTreeView\$clause, BackendUtility\deleteClause(), AbstractTreeView\getDatabaseConnection(), AbstractTreeView\reset(), and BackendUtility\versioningPlaceholderClause().

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 920 of file AbstractTreeView.php.

References AbstractTreeView\getDatabaseConnection(), and 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 709 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 720 of file AbstractTreeView.php.

References AbstractTreeView\getId().

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

getLanguageService ( )
protected
Returns
LanguageService

Definition at line 1001 of file AbstractTreeView.php.

References $GLOBALS.

Referenced by 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 859 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 653 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 846 of file AbstractTreeView.php.

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

getThisScript ( )
protected
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 698 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 684 of file AbstractTreeView.php.

References AbstractTreeView\$title, GeneralUtility\fixed_lgd_cs(), 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 739 of file AbstractTreeView.php.

References 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 310 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 606 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 512 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 491 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 425 of file AbstractTreeView.php.

References AbstractTreeView\$tree, AbstractTreeView\getId(), AbstractTreeView\getTitleStr(), if, 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 351 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 636 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 966 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 992 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 547 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 572 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 533 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 68 of file AbstractTreeView.php.

$bank = 0
$BE_USER = ''

Definition at line 90 of file AbstractTreeView.php.

$buffer_idH = array()

Definition at line 223 of file AbstractTreeView.php.

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

$clause = ''
$data = false

Definition at line 237 of file AbstractTreeView.php.

$dataLookup = false

Definition at line 243 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 151 of file AbstractTreeView.php.

$domIdPrefix = 'row'

Definition at line 172 of file AbstractTreeView.php.

$expandAll = 0

Definition at line 43 of file AbstractTreeView.php.

$expandFirst = 0
$ext_IconMode = false

Definition at line 62 of file AbstractTreeView.php.

$fieldArray = array('uid', 'pid', 'title')

Definition at line 143 of file AbstractTreeView.php.

$ids = array()
$ids_hierarchy = array()

Definition at line 211 of file AbstractTreeView.php.

$makeHTML = 1

Definition at line 180 of file AbstractTreeView.php.

$MOUNTS = null

Definition at line 101 of file AbstractTreeView.php.

$orderByFields = ''

Definition at line 134 of file AbstractTreeView.php.

Referenced by AbstractTreeView\init().

$orig_ids_hierarchy = array()

Definition at line 217 of file AbstractTreeView.php.

$parentField = 'pid'

Definition at line 116 of file AbstractTreeView.php.

$recs = array()

Definition at line 268 of file AbstractTreeView.php.

$setRecs = 0

Definition at line 187 of file AbstractTreeView.php.

$showDefaultTitleAttribute = false

Definition at line 82 of file AbstractTreeView.php.

$specUIDmap = array()

Definition at line 230 of file AbstractTreeView.php.

$stored = array()

Definition at line 256 of file AbstractTreeView.php.

$subLevelID = '_SUB_LEVEL'

Definition at line 195 of file AbstractTreeView.php.

Referenced by AbstractTreeView\setDataFromArray().

$table = ''

Definition at line 109 of file AbstractTreeView.php.

$thisScript = ''

Definition at line 49 of file AbstractTreeView.php.

$title = 'no title'
$titleAttrib = 'title'

Definition at line 55 of file AbstractTreeView.php.

$tree = array()
$treeName = ''

Definition at line 162 of file AbstractTreeView.php.

Referenced by AbstractTreeView\savePosition().