PHP Класс Tools\View\Helper\TreeHelper

Автор: Andy Dawson
Автор: Mark Scherer
Наследование: extends Cake\View\Helper
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$_config array Config settings property
$_defaultConfig array Default settings
$_itemAttributes array ItemAttributes property
$_typeAttributes array TypeAttributes property
$_typeAttributesNext array TypeAttributesNext property

Открытые методы

Метод Описание
addItemAttribute ( string $id = '', string $key = '', mixed $value = null ) : void AddItemAttribute function
addTypeAttribute ( string $id = '', string $key = '', mixed | null $value = null, string $previousOrNext = 'next' ) : void AddTypeAttribute function
generate ( array | Query $data, array $config = [] ) : string Tree generation method.

Защищенные методы

Метод Описание
_attributes ( string $rType, array $elementData = [], boolean $clear = true ) : string Attributes function.
_markUnrelatedAsHidden ( array &$tree, array $path, integer $level ) : void Mark unrelated records as hidden using 'hide' => 1.
_suffix ( boolean $reset = false ) : string Suffix method.

Описание методов

_attributes() защищенный Метод

Logic to apply styles to tags.
protected _attributes ( string $rType, array $elementData = [], boolean $clear = true ) : string
$rType string
$elementData array
$clear boolean
Результат string

_markUnrelatedAsHidden() защищенный Метод

In the callback or element you can then return early in this case.
protected _markUnrelatedAsHidden ( array &$tree, array $path, integer $level ) : void
$tree array Tree
$path array Tree path
$level integer
Результат void

_suffix() защищенный Метод

Used to close and reopen a ul/ol to allow easier listings
protected _suffix ( boolean $reset = false ) : string
$reset boolean
Результат string

addItemAttribute() публичный Метод

Called to modify the attributes of the next to be processed Note that the content of a 'node' is processed before generating its wrapping tag
public addItemAttribute ( string $id = '', string $key = '', mixed $value = null ) : void
$id string
$key string
$value mixed
Результат void

addTypeAttribute() публичный Метод

Called to modify the attributes of the next to be processed Note that the content of a 'node' is processed before generating its wrapping tag (if appropriate) An 'interesting' case is that of a first child with children. To generate the output
    (1)
  • XYZ (3)
      (2)
    • ABC... ...
    ... The processing order is indicated by the numbers in brackets. attributes are allways applied to the next type (2) to be generated to set properties of the holding type - pass 'previous' for the 4th param i.e. Hide children (2) $tree->addTypeAttribute('style', 'display', 'hidden'); give top level type (1) a class $tree->addTypeAttribute('class', 'hasHiddenGrandChildren', null, 'previous');
public addTypeAttribute ( string $id = '', string $key = '', mixed | null $value = null, string $previousOrNext = 'next' ) : void
$id string
$key string
$value mixed | null
$previousOrNext string
Результат void

generate() публичный Метод

Accepts the results of find('all', array('fields' => array('lft', 'rght', 'whatever'), 'order' => 'lft ASC')); children(); // if you have the tree behavior of course! or find('threaded'); and generates a tree structure of the data. Settings (2nd parameter): 'model' => name of the model (key) to look for in the data array. defaults to the first model for the current controller. If set to false 2d arrays will be allowed/expected. 'alias' => the array key to output for a simple ul (not used if element or callback is specified) 'type' => type of output defaults to ul 'itemType => type of item output default to li 'id' => id for top level 'type' 'class' => class for top level 'type' 'element' => path to an element to render to get node contents. 'callback' => callback to use to get node contents. e.g. array(&$anObject, 'methodName') or 'floatingMethod' 'autoPath' => array($left, $right [$classToAdd = 'active']) if set any item in the path will have the class $classToAdd added. MPTT only. 'hideUnrelated' => if unrelated (not children, not siblings) should be hidden, needs 'treePath', true/false or array/string for callback 'treePath' => treePath to insert into callback/element 'left' => name of the 'lft' field if not lft. only applies to MPTT data 'right' => name of the 'rght' field if not rght. only applies to MPTT data 'depth' => used internally when running recursively, can be used to override the depth in either mode. 'maxDepth' => used to control the depth upto which to generate tree 'firstChild' => used internally when running recursively. 'splitDepth' => if multiple "parallel" types are required, instead of one big type, nominate the depth to do so here example: useful if you have 30 items to display, and you'd prefer they appeared in the source as 3 lists of 10 to be able to style/float them. 'splitCount' => the number of "parallel" types. defaults to null (disabled) set the splitCount, and optionally set the splitDepth to get parallel lists
public generate ( array | Query $data, array $config = [] ) : string
$data array | Cake\ORM\Query Data to loop over
$config array Config
Результат string HTML representation of the passed data

Описание свойств

$_config защищенное свойство

Config settings property
protected array $_config
Результат array

$_defaultConfig защищенное свойство

Default settings
protected array $_defaultConfig
Результат array

$_itemAttributes защищенное свойство

ItemAttributes property
protected array $_itemAttributes
Результат array

$_typeAttributes защищенное свойство

TypeAttributes property
protected array $_typeAttributes
Результат array

$_typeAttributesNext защищенное свойство

TypeAttributesNext property
protected array $_typeAttributesNext
Результат array