/** * Load Function */ function data_toc($pData, $pParams) { include_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; global $gStructure, $gContent, $gBitSmarty; if (is_object($gStructure) && $gStructure->isValid()) { $struct =& $gStructure; } elseif (@BitBase::verifyId($pParams['structure_id'])) { $struct = new LibertyStructure($pParams['structure_id']); $struct->load(); } elseif (is_object($gContent)) { $structures = $gContent->getStructures(); // We take the first structure. not good, but works for now - spiderr if (!empty($structures[0])) { require_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; $struct = new LibertyStructure($structures[0]['structure_id']); $struct->load(); } } $repl = ' '; if (!empty($struct) && is_object($struct) && $struct->isValid()) { if (@BitBase::verifyId($structure_id)) { $get_structure = $structure_id; } else { $get_structure = $struct->mStructureId; } $tree = $struct->getSubTree($get_structure, !empty($pParams['display']) && $pParams['display'] == 'full_toc'); $gBitSmarty->assign("subtree", $tree); $repl = $gBitSmarty->fetch("bitpackage:liberty/plugins/data_toc.tpl"); } return $repl; }
/** * Get the path of the gallery * * @param numeric $pStructureId ID of the gallery we want to find the path to * @access public * @return Gallery path on success, FALSE on failure - mErrors will contain reason for failure */ function getGalleryPath($pStructureId = NULL) { if (!@BitBase::verifyId($pStructureId)) { $pStructureId = $this->mStructureId; } if (@BitBase::verifyId($pStructureId)) { global $gStructure; // create new object if needed if (empty($gStructure)) { $gStructure = new LibertyStructure(); } // get the structure path $ret = $gStructure->getPath($pStructureId); } return !empty($ret) ? $ret : FALSE; }
$gStructure->loadPath(); $gBitSmarty->assign('structureInfo', $gStructure->mInfo); } } } if ($gStructure and !empty($gStructure->mInfo['structure_path'])) { $secondbox = 0; $tree = 1; $gStructure->mInfo['structure_path'][0]['structure_id']; if ($gStructure->mInfo['parent']['structure_id'] == 4) { $sidebox = $gStructure->mInfo['content_id'] - 3; } elseif ($gStructure->mInfo['parent']['content_id'] > 4) { $sidebox = $gStructure->mInfo['parent']['content_id'] - 3; } else { $sidebox = 1; } if ($gStructure->mInfo['content_id'] != 4) { $menu = $gStructure->buildTreeToc($tree); $gBitSmarty->assignByRef('menu', $menu[0]['sub']); $gBitSmarty->assign('sidebox', $sidebox); if ($secondbox) { $secondmenu = $gStructure->buildTreeToc($secondbox); $gBitSmarty->assignByRef('secondmenu', $secondmenu[0]['sub']); } } } else { require_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; $gStructure = new LibertyStructure(1); $menu = $gStructure->buildTreeToc(1); $gBitSmarty->assignByRef('menu', $menu[0]['sub']); }
function getList(&$pListHash) { $struct = new LibertyStructure(); $pListHash['content_type_guid'] = $this->mContentTypeGuid; return $struct->getList($pListHash); }
require_once '../kernel/setup_inc.php'; include_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; if (!@BitBase::verifyId($_REQUEST["structure_id"])) { $gBitSystem->fatalError(tra("No structure indicated")); } else { global $gStructure; $gStructure = new LibertyStructure($_REQUEST["structure_id"]); $gStructure->load(); // order matters for these conditionals if (empty($gStructure) || !$gStructure->isValid()) { $gBitSystem->fatalError(tra('Invalid structure')); } if ($gStructure->mInfo['root_structure_id'] == $gStructure->mInfo['structure_id']) { $rootStructure =& $gStructure; } else { $rootStructure = new LibertyStructure($gStructure->mInfo['root_structure_id']); $rootStructure->load(); $rootStructure->loadNavigation(); $rootStructure->loadPath(); } if (empty($gContent)) { $gContent = LibertyContent::getLibertyObject($gStructure->getField('content_id')); $gContent->verifyUpdatePermission(); } $gBitSmarty->assign_by_ref('gStructure', $gStructure); $gBitSmarty->assign('editingStructure', TRUE); $gBitSmarty->assign('structureInfo', $gStructure->mInfo); // Store the actively stored structure name $gBitUser->storePreference('edit_structure_name', $rootStructure->mInfo['title']); $gBitUser->storePreference('edit_structure_id', $rootStructure->mStructureId); if (isset($_REQUEST["action"]) && $_REQUEST["action"] == 'remove' || !empty($_REQUEST["confirm"])) {
* $Id$ * @package pigeonholes * @subpackage modules */ /** * Initial Setup */ global $gBitSmarty, $gQueryUserId, $gBitThemes, $module_rows, $moduleParams, $gBitSystem, $module_params; $module_rows = $moduleParams['module_rows']; $module_params = $moduleParams['module_params']; $_template->tpl_vars['moduleTitle'] = new Smarty_variable(isset($moduleParams['title'])); $ns = array(); if ($gBitSystem->isPackageActive('pigeonholes')) { require_once PIGEONHOLES_PKG_PATH . 'Pigeonholes.php'; $p = new Pigeonholes(); $s = new LibertyStructure(); // Prep get list screws with us. $listHash = array('load_only_root' => TRUE, 'sort_mode' => 'lc.title_asc', 'offset' => 0, 'max_records' => '999999', 'find' => ''); if (!empty($module_params['root_structure_id'])) { $listHash['root_structure_id'] = $module_params['root_structure_id']; } if (!empty($module_params['structure_id'])) { $l = array(array('structure_id' => $module_params['structure_id'])); } else { $l = $p->getList($listHash); } foreach ($l as $e) { $d = $s->getSubTree($e['structure_id']); $d_o = array(); foreach ($d as $c) { $pos_var =& $d_o;
} } if (!empty($loadContentId)) { $gContent = BitPage::getLibertyObject($loadContentId); } if (empty($gContent) || !is_object($gContent)) { $gContent = new BitPage(); } } // we weren't passed a structure, but maybe this page belongs to one. let's check... if ($gContent->isValid() && empty($gStructure)) { //Get the structures this page is a member of if (!empty($lookupHash['structure'])) { $structure = $lookupHash['structure']; } else { $structure = ''; } $structs = $gContent->getStructures(); if (count($structs) == 1) { $gStructure = new LibertyStructure($structs[0]['structure_id']); if ($gStructure->load()) { $gStructure->loadNavigation(); $gStructure->loadPath(); $gBitSmarty->assign('structureInfo', $gStructure->mInfo); } } else { $gBitSmarty->assign('showstructs', $structs); } } $gBitSmarty->clearAssign('gContent'); $gBitSmarty->assignByRef('gContent', $gContent);
} $gBitSmarty->assign('contentTypes', $contentTypes); $gBitSmarty->assign('contentSelect', $contentSelect = !isset($_REQUEST['content_type']) ? NULL : $_REQUEST['content_type']); $listHash = array('find' => empty($_REQUEST['find']) ? NULL : $_REQUEST['find'], 'sort_mode' => empty($_REQUEST['sort_mode']) ? NULL : $_REQUEST['sort_mode'], 'max_records' => @BitBase::verifyId($_REQUEST['max_records']) ? $_REQUEST['max_records'] : 10, 'include_members' => !empty($_REQUEST['include']) && $_REQUEST['include'] == 'members' ? TRUE : FALSE, 'content_type' => $contentSelect); // We need to handle insert and next where we are NOT actually doing an insert if (!empty($_REQUEST['insert_content']) || !empty($_REQUEST['insert_content_and_next'])) { $listHash['list_page'] = empty($_REQUEST['list_page']) ? 2 : $_REQUEST['list_page'] + 1; } else { $listHash['list_page'] = empty($_REQUEST['list_page']) ? NULL : $_REQUEST['list_page']; } $assignableContent = $gContent->getAssignableContent($listHash); if (!empty($_REQUEST['insert_content']) || !empty($_REQUEST['insert_content_and_next'])) { // here we need to limit all killing to the selected structure $deletableParentIds = array(); if (empty($gStructure) && @BitBase::verifyId($_REQUEST['root_structure_id'])) { $gStructure = new LibertyStructure(); $struct = $gStructure->getStructure($_REQUEST); foreach ($struct as $node) { $deletableParentIds[] = $node['content_id']; } } // make an array that can be stored foreach ($assignableContent as $item) { if (!empty($_REQUEST['pigeonhole'][$item['content_id']])) { foreach ($_REQUEST['pigeonhole'][$item['content_id']] as $parent_id) { $memberHash[$parent_id][] = array('parent_id' => $parent_id, 'content_id' => $item['content_id']); } } if (!empty($_REQUEST['include']) && $_REQUEST['include'] == 'members') { if (!empty($item['content_id']) && !$gContent->expungePigeonholeMember(array('member_id' => $item['content_id'], 'deletables' => $deletableParentIds))) { $feedback['error'] = 'The content could not be deleted before insertion.';
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details * * @package wiki * @subpackage functions */ /** * required setup */ require_once '../kernel/setup_inc.php'; require_once WIKI_PKG_PATH . 'BitBook.php'; $book = new BitBook(); $gSiteMapHash = array(); $listHash = array(); if ($bookList = $book->getList($listHash)) { foreach ($bookList['data'] as $bookHash) { $bookStructure = new LibertyStructure($bookHash['structure_id']); $listBook = $bookStructure->buildTreeToc($bookHash['structure_id']); process_book_list($listBook); } } function process_book_list($pList, $pDepth = 1) { global $gSiteMapHash; foreach (array_keys($pList) as $key) { if (!empty($pList[$key]['display_url'])) { $hash = array(); $hash['loc'] = BIT_BASE_URI . $pList[$key]['display_url']; $hash['lastmod'] = date('Y-m-d', $pList[$key]['last_modified']); if (time() - $pList[$key]['last_modified'] < 86400) { $freq = 'daily'; } elseif (time() - $pList[$key]['last_modified'] < 86400 * 7) {
$gBitSystem->confirmDialog($formHash, $msgHash); } } // used to display the newly updated version of an image if (!empty($_REQUEST['refresh'])) { $gBitSmarty->assign('refresh', '?refresh=' . time()); } // services $displayHash = array('perm_name' => 'p_treasury_view_gallery'); $gContent->invokeServices('content_display_function', $displayHash); // set up structure related stuff global $gStructure; if (empty($gContent->mInfo['root_structure_id']) || !@BitBase::verifyId($gContent->mInfo['root_structure_id'])) { bit_redirect(TREASURY_PKG_URL . "index.php"); } $gStructure = new LibertyStructure($gContent->mInfo['root_structure_id']); $gStructure->load(); // confirm that structure is valid if (empty($gStructure) || !$gStructure->isValid()) { $gBitSystem->fatalError(tra('Invalid structure')); } $gBitSmarty->assignByRef('gStructure', $gStructure); $gBitSmarty->assign('structureInfo', $gStructure->mInfo); $gBitSmarty->assign('subtree', $gStructure->getSubTree($gStructure->mStructureId)); $listHash = $_REQUEST; $listHash['root_structure_id'] = $gContent->mInfo['root_structure_id']; $listHash['structure_id'] = $gContent->mInfo['structure_id']; $listHash['sort_mode'] = !empty($_REQUEST['sort_mode']) ? $_REQUEST['sort_mode'] : 'created_desc'; $gContent->loadItems($listHash); // pagination related settings $listHash['listInfo']['parameters']['structure_id'] = $gContent->mStructureId;
/** * Imports a structure from liberty_structures to nexus including hierarchy * @return number of errors encountered */ function importStructure($pStructureId = NULL) { if ($pStructureId || !is_numeric($pStructureId)) { include_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; $structure = new LibertyStructure($pStructureId); $structure->load(); // order matters for these conditionals if (empty($structure) || !$structure->isValid()) { $this->mErrors['structure'] = tra('Invalid structure'); } if ($structure->mInfo['root_structure_id'] == $structure->mInfo['structure_id']) { $rootStructure =& $structure; } else { $rootStructure = new LibertyStructure($structure->mInfo['root_structure_id']); $rootStructure->load(); } $structureList = $rootStructure->getSubTree($rootStructure->mInfo['structure_id']); $menuHash['title'] = $rootStructure->mInfo['title']; if ($menu_id = $this->storeMenu($menuHash)) { // we need to insert the structure title manually, as this is not part of the structure $itemHash = array('menu_id' => $menu_id, 'title' => $rootStructure->mInfo['title'], 'pos' => 1, 'parent_id' => 0, 'rsrc' => $rootStructure->mInfo['structure_id'], 'rsrc_type' => 'structure_id'); $storedItem = $this->storeItem($itemHash); // insert all nodes in structure as menu items foreach ($structureList as $structureItem) { if ($structureItem['first']) { // get id of the current item $query = "SELECT MAX(`item_id`) FROM `" . BIT_DB_PREFIX . "nexus_menu_items`"; $parentPath[] = $this->mDb->getOne($query, array()); $parent_id = end($parentPath); } if ($structureItem['last']) { // move up one step in the structure parentPath array_pop($parentPath); $parent_id = end($parentPath); } else { // save the item in the menu $tmpItem = $rootStructure->getNode($structureItem['structure_id']); $itemHash = array('menu_id' => $menu_id, 'title' => $structureItem['title'], 'pos' => $tmpItem['pos'], 'parent_id' => $parent_id, 'rsrc' => isset($structureItem['structure_id']) ? $structureItem['structure_id'] : NULL, 'rsrc_type' => 'structure_id'); $storedItem = $this->storeItem($itemHash); } } } else { $this->mErrors['store_menu'] = tra('The menu could not be stored.'); } } else { $this->mErrors['structure_id'] = tra('No valid structure id was given.'); } return count($this->mErrors) == 0; }
* @TODO would be nice if packages provided this as service **/ //get pigeonholes list if ($gBitSystem->isPackageActive('pigeonholes')) { //this is just like pigeonholes:list.php without the tpl call $gBitSystem->verifyPermission('p_pigeonholes_view'); include_once PIGEONHOLES_PKG_PATH . 'lookup_pigeonholes_inc.php'; $listHash =& $_REQUEST; $listHash['load_only_root'] = TRUE; $listHash['sort_mode'] = !empty($listHash['sort_mode']) ? $listHash['sort_mode'] : 'title_asc'; $pigeonList = $gContent->getList($listHash); // set up structure related stuff if (!empty($pigeonList)) { foreach ($pigeonList as $key => $pigeonhole) { if (empty($gStructure)) { $gStructure = new LibertyStructure(); } $pigeonList[$key]['subtree'] = $gStructure->getSubTree($pigeonhole['root_structure_id']); // add permissions to all so we know if we can display pages within category // foreach( $pigeonList[$key]['subtree'] as $k => $node ) { // $pigeonList[$key]['subtree'][$k]['preferences'] = $gContent->loadPreferences( $node['content_id'] ); // } } $gBitSmarty->assign('pigeonList', $pigeonList); } $gBitSmarty->assign('listInfo', $listHash['listInfo']); } if ($gBitSystem->isPackageActive('stars')) { //php is annoying, so 0 would be interpretted as null and not trigger the tpl this relates too. $GeoStars = array('stars_pixels' => 1, 'stars_version_pixels' => 1, 'stars_load' => 1); $gBitSmarty->assign('loadStars', TRUE);
* @version $Header$ * * @package liberty * @subpackage modules */ /** * Initial Setup */ global $gStructure, $gContent, $moduleParams, $gBitSmarty; require_once LIBERTY_PKG_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']); $struct->load(); } elseif (is_object($gContent) && $gContent->hasViewPermission(FALSE)) { $structures = $gContent->getStructures(); // We take the first structure. not good, but works for now - spiderr if (!empty($structures[0])) { require_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; $struct = new LibertyStructure($structures[0]['structure_id']); $struct->load(); } } if (is_object($struct) && count($struct->isValid())) { $_template->tpl_vars['moduleTitle'] = new Smarty_variable($moduleParams['title']); $toc = $struct->getToc($struct->mInfo['root_structure_id'], 'asc', FALSE, 2); $_template->tpl_vars['modStructureTOC'] = new Smarty_variable($struct->getToc($struct->mInfo['root_structure_id'], 'asc', FALSE, 2)); }
$gBitSystem->display('error.tpl', NULL, array('display_mode' => 'edit')); die; } //try to add a new structure $gContent = new BitBook(); $pageId = $gContent->findByPageName($_REQUEST['name']); if ($pageId) { $gContent->mPageId = $pageId; $gContent->load(); } else { $params['title'] = $_REQUEST['name']; $params['edit'] = '{toc}'; $gContent->store($params); } if ($gContent->isValid()) { $gStructure = new LibertyStructure(); // alias => '' is a temporary setting until alias stuff has been removed $structureHash = array('content_id' => $gContent->mContentId, 'alias' => ''); $structure_id = $gStructure->storeNode($structureHash); //Cannot create a structure if a structure already exists if (!isset($structure_id)) { $gBitSmarty->assign('msg', $_REQUEST['name'] . " " . tra("page not added (Exists)")); $gBitSystem->display('error.tpl', NULL, array('display_mode' => 'edit')); die; } $chapters = explode("\n", $_REQUEST["chapters"]); foreach ($chapters as $chapter) { $chapterName = trim($chapter); if (!empty($chapterName)) { unset($params); unset($nodeHash);
/** * Get all child pigeonholes starting from any parent * * @param array $pContentId of the pigoenhole * @param array $pStructureId of the pigeonhole * @access public * @return array of child pigeonholes on success, empty array on failure */ function getSubPigeonholes($pContentId = NULL, $pStructureId = NULL) { global $gStructure; $ret = array(); if (empty($gStructure)) { $struct = new LibertyStructure(); } else { $struct =& $gStructure; } if (@BitBase::verifyId($pContentId) && !@BitBase::verifyId($pStructureId)) { $pigeon = $struct->getNode(NULL, $pContentId); $pStructureId = $pigeon['structure_id']; } if (@BitBase::verifyId($pStructureId)) { $tree = $struct->getSubTree($pStructureId); // weed out duplicates foreach ($tree as $pigeon) { if (!in_array($pigeon['content_id'], array_keys($ret))) { $ret[$pigeon['content_id']] = $pigeon; } } } return $ret; }
/** * cleans up and reorganises data in nested array where keys are structure_id * @param $pParamHash contains a nested set of arrays with structure_id as key * @return reorganised array */ function embellishStructureHash(&$pParamHash) { $pos = 1; foreach ($pParamHash as $structure_id => $node) { if (!empty($node)) { LibertyStructure::embellishStructureHash($node); } $node['pos'] = $pos++; $node['structure_id'] = $structure_id; $pParamHash[$structure_id] = $node; } }
/** * expunge a gallery * * @param array $pParamHash * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function expunge($pForceDeleteItems = FALSE) { $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); // get all items that are part of the sub tree require_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; $struct = new LibertyStructure(); $tree = $struct->getSubTree($this->mStructureId); // include the current id as well - needed when there are no sub-galleries $galleryContentIds[] = $this->mContentId; foreach ($tree as $node) { $galleryContentIds[] = $node['content_id']; } $galleryContentIds = array_unique($galleryContentIds); // Create Item Object require_once TREASURY_PKG_PATH . 'TreasuryItem.php'; $itemObject = new TreasuryItem(); // Go through all galleries we want to remove foreach ($galleryContentIds as $gid) { // make sure the gallery is fully loaded $this->mContentId = $gid; $this->load(); $itemContentIds = $this->mDb->getCol("SELECT `item_content_id` FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `gallery_content_id`=?", array($gid)); $itemContentIds = array_unique($itemContentIds); // Delete items in galleries foreach ($itemContentIds as $iid) { if ($pForceDeleteItems) { // Remove item even if it exists in other galleries $count = 1; } else { // Only delete item if it doesn't exist in other galleries $count = $this->mDb->getOne("SELECT COUNT( `item_content_id` ) FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `item_content_id`=?", array($iid)); } // Only delete item if it doesn't exist in other galleries if ($count == 1) { $itemObject->mContentId = $iid; $itemObject->load(); if (!$itemObject->expunge()) { $this->mErrors['expunge'][] = $itemObject->mErrors; } } } // Next, we remove any icons if they exist if ($thumbdir = $this->getGalleryThumbBaseUrl()) { @unlink_r(BIT_ROOT_PATH . $thumbdir); } // Now that all the items are gone, we can start nuking gallery entries // remove gallery preferences $query = "DELETE FROM `" . BIT_DB_PREFIX . "liberty_content_prefs` WHERE `content_id`=?"; $result = $this->mDb->query($query, array($this->mContentId)); // Remove map entries $sql = "DELETE FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `gallery_content_id`=?"; $rs = $this->mDb->query($sql, array($gid)); // Remove gallery entry $sql = "DELETE FROM `" . BIT_DB_PREFIX . "treasury_gallery` WHERE `content_id`=?"; $rs = $this->mDb->query($sql, array($gid)); // Let liberty remove all the content entries for this gallery if (!LibertyContent::expunge()) { $errors = TRUE; } // Finally nuke the structure in liberty_structures $struct->removeStructureNode($this->mStructureId, FALSE); } if (empty($errors)) { $this->mDb->CompleteTrans(); $ret = TRUE; } else { $this->mDb->RollbackTrans(); $ret = FALSE; } } return $ret; }