function data_include($data, $params) { $ret = "<p>Please enter a valid 'page_name', 'page_id' or 'content_id' to include in this page.</p>"; // load page by page_id if (isset($params['page_id']) && is_numeric($params['page_id'])) { require_once WIKI_PKG_PATH . 'BitPage.php'; $wp = new BitPage($params['page_id']); if ($wp->load()) { $ret = $wp->parseData($wp->mInfo); } // load page by content_id } elseif (isset($params['content_id']) && is_numeric($params['content_id'])) { if ($obj = LibertyBase::getLibertyObject($params['content_id'])) { $ret = $obj->parseData(); } // load page by page_name } elseif (isset($params['page_name'])) { $ret = "page_name isn't working yet, please use page_id or content_id"; } // if $ret is empty, we need to make sure there is at least a space that we get rid of the {} if (empty($ret)) { $ret = ' '; } return $ret; }
function export_wiki_page($page_id, $nversions = 1) { global $gBitSystem; $head = ''; $head .= "Date: " . $gBitSystem->mServerTimestamp->get_rfc2822_datetime() . "\r\n"; $head .= sprintf("Mime-Version: 1.0 (Produced by Tiki)\r\n"); $iter = $this->get_page_history($page_id); $gWikiPage = new BitPage($page_id); $gWikiPage->load(); $info = $gWikiPage->mInfo; $parts = array(); $parts[] = MimeifyPageRevision($info); if ($nversions > 1 || $nversions == 0) { foreach ($iter as $revision) { $parts[] = MimeifyPageRevision($revision); if ($nversions > 0 && count($parts) >= $nversions) { break; } } } if (count($parts) > 1) { return $head . MimeMultipart($parts); } assert($parts); return $head . $parts[0]; }
function smarty_function_include_wiki_page_content($params, &$gBitSmarty) { global $debugger; // $pageName = !empty($params['page']) ? $params['page'] : (!empty($params['page_default']) ? $params['page_default'] : NULL); $transclusion_parsed = ''; include_once WIKI_PKG_PATH . 'BitPage.php'; $transclusion_bitpage = new BitPage(); if ($transclusion_page_id = $transclusion_bitpage->findByPageName($pageName)) { $transclusion_bitpage->mPageId = $transclusion_page_id; if ($transclusion_bitpage->load()) { $transclusion_full_page_data = $transclusion_bitpage->mInfo['data']; $transclusion_parsed = $transclusion_bitpage->parseData($transclusion_full_page_data, isset($transclusion_bitpage->mInfo['format_guid']) ? $transclusion_bitpage->mInfo['format_guid'] : 'tikiwiki'); } } return $transclusion_parsed; }
$formHash['delete'] = TRUE; $formHash['batch_submit'] = 'remove_pages'; foreach ($_REQUEST["checked"] as $del) { $tmpPage = new BitPage($del); if ($tmpPage->load() && !empty($tmpPage->mInfo['title'])) { $info = $tmpPage->mInfo['title']; } else { $info = $del; } $formHash['input'][] = '<input type="hidden" name="checked[]" value="' . $del . '"/>' . $info; } $gBitSystem->confirmDialog($formHash, array('warning' => tra('Are you sure you want to delete these pages?') . ' (' . tra('Count: ') . count($_REQUEST["checked"]) . ')', 'error' => tra('This cannot be undone!'))); } else { foreach ($_REQUEST["checked"] as $deletepage) { $tmpPage = new BitPage($deletepage); if (!$tmpPage->load() || !$tmpPage->expunge()) { array_merge($errors, array_values($tmpPage->mErrors)); } } if (!empty($errors)) { $gBitSmarty->assignByRef('errors', $errors); } } } $gBitSmarty->assignByRef("gContent", $gContent); if (!empty($_REQUEST['sort_mode'])) { $listHash['sort_mode'] = preg_replace('/^user_/', 'creator_user_', $_REQUEST['sort_mode']); } $listHash = $_REQUEST; $listHash['extras'] = TRUE; $listpages = $gContent->getList($listHash);
function categorize_page($pContentId, $categId) { require_once WIKI_PKG_PATH . 'BitPage.php'; // Check if we already have this object in the categories_objects page $cat_object_id = $this->is_categorized(BITPAGE_CONTENT_TYPE_GUID, $pContentId); if (!$cat_object_id) { // The page is not cateorized $catPage = new BitPage(NULL, $pContentId); if ($catPage->load()) { $cat_object_id = $this->add_categorized_object(BITPAGE_CONTENT_TYPE_GUID, $pContentId, substr($catPage->mInfo["description"], 0, 200), substr($catPage->mInfo["title"], 0, 200), $catPage->getDisplayUrl()); } } $this->categorize($cat_object_id, $categId); }
* * @package wiki * @subpackage functions */ /** * required setup */ require_once '../kernel/setup_inc.php'; require_once WIKI_PKG_PATH . 'BitPage.php'; $gBitSystem->verifyFeature('wiki_multiprint'); if (!isset($_REQUEST["printpages"])) { $gBitSystem->fatalError(tra("No pages indicated"), NULL, NULL, HttpStatusCodes::HTTP_NOT_FOUND); } else { $printpages = unserialize(urldecode($_REQUEST["printpages"])); } if (isset($_REQUEST["print"])) { // Create XMLRPC object $pages = array(); foreach ($printpages as $contentId) { $page = new BitPage(NULL, $contentId); if ($page->load()) { $page->verifyViewPermission(); $page_info = $page->mInfo; $page_info["parsed"] = $page->parseData($page_info); $pages[] = $page_info; } } } $gBitSmarty->assignByRef('pages', $pages); // Display the template $gBitSmarty->display("bitpackage:wiki/print_multi_pages.tpl");
function data_attachment($pData, $pParams, $pCommonObject, $pParseHash) { require_once LIBERTY_PKG_PATH . 'LibertyMime.php'; // at a minimum, return blank string (not empty) so we still replace the tag $ret = ' '; // The Manditory Parameter is missing. we are not gonna trow an error, and // just return empty since many sites use the old style required second // "closing" empty tag if (empty($pParams['id'])) { return $ret; } if (!($att = $pCommonObject->getAttachment($pParams['id'], $pParams))) { $ret = tra("The attachment id given is not valid."); return $ret; } global $gBitSmarty, $gLibertySystem, $gContent; // convert parameters into display properties $wrapper = liberty_plugins_wrapper_style($pParams); // work out custom display_url if there is one if (@BitBase::verifyId($pParams['page_id'])) { // link to page by page_id // avoid endless loops require_once WIKI_PKG_PATH . 'BitPage.php'; $wp = new BitPage($pParams['page_id']); if ($wp->load()) { $wrapper['display_url'] = $wp->getDisplayUrl(); } } elseif (@BitBase::verifyId($pParams['content_id'])) { // link to any content by content_id if ($obj = LibertyBase::getLibertyObject($pParams['content_id'])) { $wrapper['display_url'] = $obj->getDisplayUrl(); } } elseif (!empty($pParams['page_name'])) { // link to page by page_name require_once WIKI_PKG_PATH . 'BitPage.php'; $wp = new BitPage(); $wrapper['display_url'] = $wp->getDisplayUrl($pParams['page_name']); } elseif (!empty($pParams['link']) && $pParams['link'] == 'false') { // no link } elseif (!empty($pParams['link'])) { // Allow the use of icon, avatar, small, medium and large to link to certain size of image directly if (!empty($att['thumnail_url'][$pParams['link']])) { $pParams['link'] = $att['thumnail_url'][$pParams['link']]; // Allow the use of 'original' to link to original file directly } elseif ($pParams['link'] == 'original' && !empty($att['source_url'])) { $pParams['link'] = $att['source_url']; // Allow the use of 'download' to link to download link. this will allow us to count downloads } elseif ($pParams['link'] == 'download' && !empty($att['download_url'])) { $pParams['link'] = $att['download_url']; // Adjust class name if we are leaving this server } elseif (!strstr($pParams['link'], $_SERVER["SERVER_NAME"]) && strstr($pParams['link'], '//')) { $wrapper['href_class'] = 'class="external"'; } $wrapper['display_url'] = $pParams['link']; } elseif (!empty($att['display_url'])) { $wrapper['display_url'] = $att['display_url']; } if (!empty($wrapper['description'])) { $parseHash['content_id'] = $pParseHash['content_id']; $parseHash['user_id'] = $pParseHash['user_id']; $parseHash['no_cache'] = TRUE; $parseHash['data'] = $wrapper['description']; $wrapper['description_parsed'] = $pCommonObject->parseData($parseHash); } // pass stuff to the template $gBitSmarty->assign('attachment', $att); $gBitSmarty->assign('wrapper', $wrapper); $gBitSmarty->assign('thumbsize', !empty($pParams['size']) && ($pParams['size'] == 'original' || !empty($att['thumbnail_url'][$pParams['size']])) ? $pParams['size'] : 'medium'); //Carry only these attributes to the image tags $width = !empty($pParams['width']) ? $pParams['width'] : ''; $gBitSmarty->assign('width', $width); $height = !empty($pParams['height']) ? $pParams['height'] : ''; $gBitSmarty->assign('height', $height); $mimehandler = !empty($wrapper['output']) && $wrapper['output'] == 'thumbnail' ? LIBERTY_DEFAULT_MIME_HANDLER : $att['attachment_plugin_guid']; $ret = $gBitSmarty->fetch($gLibertySystem->getMimeTemplate('attachment', $mimehandler)); return $ret; }
} $chapters = explode("\n", $_REQUEST["chapters"]); foreach ($chapters as $chapter) { $chapterName = trim($chapter); if (!empty($chapterName)) { unset($params); unset($nodeHash); $nodeHash['parent_id'] = $structure_id; $nodeHash['root_structure_id'] = $structure_id; $nodeHash['level'] = 1; //try to add a new structure $nodePage = new BitPage(); $pageId = $nodePage->findByPageName($chapterName); if ($pageId) { $nodePage->mPageId = $pageId; $nodePage->load(); } else { $params['title'] = trim($chapterName); $params['edit'] = ''; if (!$nodePage->store($params)) { $gBitSystem->fatalError("There was an error storing the page: " . vc($gContent->mErrors)); } } $nodeHash['content_id'] = $nodePage->mContentId; $nodeHash['after_ref_id'] = $gStructure->storeNode($nodeHash); } } header("location: " . WIKI_PKG_URL . "edit_book.php?structure_id=" . $structure_id); } else { $gBitSmarty->assignByRef('errors', $gContent->mErrors); $gBitSmarty->assign('name', $_REQUEST['name']);