blob: 6d69da3a92b20fd35088e92b199ebc8b9c5c8ec5 (
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
51
52
|
<?php
/**
* @version $Header$
*
* @package liberty
* @subpackage modules
*/
/**
* Initial Setup
*/
use Bitweaver\BitBase;
use Bitweaver\Liberty\LibertyStructure;
global $gStructure, $gContent, $moduleParams, $gBitSmarty;
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'] ) ) {
$gBitSmarty->assign( 'moduleTitle', $moduleParams['title'] );
}
$toc = $struct->getToc( $struct->mInfo['root_structure_id'], 'asc', false, 2 );
$root = $struct->getRootObject( $struct->mInfo['root_structure_id'] );
$gBitSmarty->assign( 'rootTitle', $root->getDisplayLink() );
$gBitSmarty->assign( 'modStructureTOC', $struct->getToc( $struct->mInfo['root_structure_id'], 'asc', false, 2 ) );
}
|