Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -56,7 +56,7 @@ class _Tree
|
||||
/**
|
||||
* @brief Searchable?
|
||||
*/
|
||||
protected $searchable = FALSE;
|
||||
public $searchable = FALSE;
|
||||
|
||||
/**
|
||||
* @brief If true, will prevent any item from being moved out of its current parent, only allowing them to be reordered within their current parent
|
||||
@@ -67,6 +67,16 @@ class _Tree
|
||||
* @brief If true, root cannot be turned into sub-items, and other items cannot be turned into roots
|
||||
*/
|
||||
protected $protectRoots = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Number of roots to show per page (NULL for unlimited). In most cases this doesn't make sense, since it makes re-ordering impossible. But for trees which are not orderable and which may contain a lot of roots, you can set this value
|
||||
*/
|
||||
public $rootsPerPage = NULL;
|
||||
|
||||
/**
|
||||
* @brief If using $rootsPerPage, a callback function that returns the total number of roots
|
||||
*/
|
||||
public $getTotalRoots = NULL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -80,9 +90,11 @@ class _Tree
|
||||
* @param callback $searchable Show the search bar?
|
||||
* @param bool $lockParents If true, will prevent any item from being moved out of its current parent, only allowing them to be reordered within their current parent
|
||||
* @param bool $protectRoots If true, root cannot be turned into sub-items, and other items cannot be turned into roots
|
||||
* @param int|null $rootsPerPage Number of roots to show per page (NULL for unlimited). In most cases this doesn't make sense, since it makes re-ordering impossible. But for trees which are not orderable and which may contain a lot of roots, you can set this value
|
||||
* @param callback $getTotalRoots If using $rootsPerPage, a callback function that returns the total number of roots
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $url, $title, $getRoots, $getRow, $getRowParentId, $getChildren, $getRootButtons=NULL, $searchable=FALSE, $lockParents=FALSE, $protectRoots=FALSE )
|
||||
public function __construct( $url, $title, $getRoots, $getRow, $getRowParentId, $getChildren, $getRootButtons=NULL, $searchable=FALSE, $lockParents=FALSE, $protectRoots=FALSE, $rootsPerPage = NULL, $getTotalRoots = NULL )
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->title = $title;
|
||||
@@ -94,6 +106,8 @@ class _Tree
|
||||
$this->searchable = $searchable;
|
||||
$this->lockParents = $lockParents;
|
||||
$this->protectRoots = $protectRoots;
|
||||
$this->rootsPerPage = $rootsPerPage;
|
||||
$this->getTotalRoots = $getTotalRoots;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,11 +120,12 @@ class _Tree
|
||||
try
|
||||
{
|
||||
/* Get rows */
|
||||
$page = isset( \IPS\Request::i()->page ) ? intval( \IPS\Request::i()->page ) : 1;
|
||||
$root = NULL;
|
||||
$rootParent = NULL;
|
||||
if( !\IPS\Request::i()->root )
|
||||
{
|
||||
$rows = call_user_func( $this->getRoots );
|
||||
$rows = call_user_func( $this->getRoots, $this->rootsPerPage ? array( ( $page - 1 ) * $this->rootsPerPage, $this->rootsPerPage ) : NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -124,9 +139,20 @@ class _Tree
|
||||
$root = call_user_func( $this->getRow, \IPS\Request::i()->root, TRUE );
|
||||
$rootParent = call_user_func( $this->getRowParentId, \IPS\Request::i()->root );
|
||||
}
|
||||
|
||||
/* Pagination? */
|
||||
$pagination = '';
|
||||
if ( $this->rootsPerPage )
|
||||
{
|
||||
$totalNumber = call_user_func( $this->getTotalRoots );
|
||||
if ( $totalNumber )
|
||||
{
|
||||
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $this->url, ceil( $totalNumber / $this->rootsPerPage ), $page, $this->rootsPerPage );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return \IPS\Theme::i()->getTemplate( 'trees', 'core' )->template( $this->url, $this->title, $root, $rootParent, $rows, call_user_func( $this->getRootButtons ), $this->lockParents, $this->protectRoots, $this->searchable );
|
||||
return \IPS\Theme::i()->getTemplate( 'trees', 'core' )->template( $this->url, $this->title, $root, $rootParent, $rows, call_user_func( $this->getRootButtons ), $this->lockParents, $this->protectRoots, $this->searchable, $pagination );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user