blob: 3581f8a6fc931552d970a2c18c6ca74cef7e22ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
<?php
/**
* @version $Header$
*
* @package liberty
* @subpackage modules
*/
/**
* Initial Setup
*/
global $gStructure, $gContent, $moduleParams, $gBitSmarty;
require_once( LIBERTY_PKG_CLASS_PATH.'LibertyStructure.php' );
extract( $moduleParams );
$struct = NULL;
if( is_object( $gStructure ) && $gStructure->isValid() && $gStructure->hasViewPermission() ) {
$struct = &$gStructure;
} elseif( @BitBase::verifyId( $module_params['structure_id'] ) ) {
$struct = new LibertyStructure( $module_params['structure_id'] );
} elseif( is_object( $gContent ) && $gContent->hasViewPermission( FALSE ) ) {
if( $structures = $gContent->getStructures() ) {
// We take the first structure by default, perhaps there is a better choice
$structureId = $structures[0]['structure_id'];
if( count( $structures ) > 1 ) {
foreach( $structures as $structureHash ) {
if( $gContent->getTitle() == $structureHash['root_title'] ) {
$structureId = $structureHash['root_structure_id'];
break;
}
}
}
if( !empty( $structures[0] ) ) {
require_once( LIBERTY_PKG_CLASS_PATH.'LibertyStructure.php' );
$struct = new LibertyStructure( $structureId );
}
}
}
if( is_object( $struct ) && $struct->isValid() ) {
if( !empty( $moduleParams['title'] ) ) {
$_template->tpl_vars['moduleTitle'] = new Smarty_variable( $moduleParams['title'] );
}
$toc = $struct->getToc( $struct->mInfo['root_structure_id'], 'asc', FALSE, 2 );
$root = $struct->getRootObject( $struct->mInfo['root_structure_id'] );
$_template->tpl_vars['rootTitle'] = new Smarty_variable( $root->getDisplayLink() );
$_template->tpl_vars['modStructureTOC'] = new Smarty_variable( $struct->getToc( $struct->mInfo['root_structure_id'], 'asc', FALSE, 2 ) );
}
|