本文整理汇总了PHP中WikiPage::makeRevision方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiPage::makeRevision方法的具体用法?PHP WikiPage::makeRevision怎么用?PHP WikiPage::makeRevision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiPage
的用法示例。
在下文中一共展示了WikiPage::makeRevision方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Add a wiki page
*
* @return void
*/
function add()
{
if (!WikiPage::canAdd(logged_user(), active_project())) {
flash_error(lang('no access permissions'));
$this->redirectTo('wiki');
}
//if
if (false !== ($data = array_var($_POST, 'wiki', false))) {
//Make a new wiki page
$page = new WikiPage();
//Set the Id for this project
$page->setProjectId(active_project()->getId());
$page->setProjectIndex(logged_user()->isMemberOfOwnerCompany() ? $data['project_index'] : 0);
$page->setProjectSidebar(logged_user()->isMemberOfOwnerCompany() ? $data['project_sidebar'] : 0);
//Make a new revision of this page
$revision = $page->makeRevision();
//Set attributes from form
$revision->setFromAttributes($data);
//Set user ID and project ID
$revision->setCreatedbyId(logged_user()->getId());
try {
//Start the db transaction
DB::beginWork();
//Save the page
$page->save();
//Make a log entry
ApplicationLogs::createLog($page, active_project(), ApplicationLogs::ACTION_ADD);
if (plugin_active('tags')) {
//Add page tags
$page->setTagsFromCSV($data['tags']);
}
//Commit changed
DB::commit();
//Tell the user they made a page
flash_success(lang('success add wiki page'));
//Redirect
$this->redirectToUrl($page->getViewUrl());
} catch (Exception $e) {
DB::rollback();
tpl_assign('error', $e);
}
//try
}
// if
if (!isset($page) || !instance_of($page, 'WikiPage')) {
$page = new WikiPage();
$page->setProjectId(active_project()->getId());
}
// if
tpl_assign('page', $page);
tpl_assign('revision', new Revision());
$this->setTemplate('edit');
}
示例2: WikiPage
/**
* View all wiki pages
*
* @return void
*/
function all_pages()
{
// There isn't a wiki page for all pages
// So prepare a dummy page
$page = new WikiPage();
// Make a revision for the page
$revision = $page->makeRevision();
$revision->setName(lang('wiki all pages'));
$all_pages = Wiki::getAllProjectPages(active_project());
tpl_assign('all_pages', $all_pages);
tpl_assign('page', $page);
tpl_assign('revision', $revision);
$this->_load_sidebar();
}
示例3: copy
//.........这里部分代码省略.........
$file->save();
$source_revision = $source_file->getLastRevision();
if ($source_revision instanceof ProjectFileRevision) {
$revision = new ProjectFileRevision();
$revision->setFileId($file->getId());
$revision->setRevisionNumber($source_revision->getRevisionNumber());
$revision->setRepositoryId($source_revision->getRepositoryId());
$revision->setFilesize($source_revision->getFilesize());
$revision->setFilename($source_revision->getFileName());
$revision->setTypeString($source_revision->getTypeString());
$revision->setThumbFilename($source_revision->getThumbFilename());
$revision->setFileTypeId($source_revision->getFileTypeId());
$revision->setComment($source_revision->getComment());
$revision->save();
}
}
// foreach
}
// if
}
// if
if ($copy_pages) {
$source_pages = Wiki::getAllProjectPages($source);
if (is_array($source_pages)) {
foreach ($source_pages as $source_page) {
$page = new WikiPage();
$page->setProjectId($project_id);
$page->setProjectIndex($source_page->getProjectIndex());
$page->setProjectSidebar($source_page->getProjectSidebar());
if (plugin_active('tags')) {
//$page->setTags($source_page->getTagNames());
}
//Make a new revision of this page
$revision = $page->makeRevision();
$source_revision = $source_page->getLatestRevision();
//Set attributes
$revision->setName($source_revision->getName());
$revision->setContent($source_revision->getContent());
$revision->setLogMessage($source_revision->getLogMessage());
//Save the page
$page->save();
}
// foreach
}
// if
}
// if
if ($copy_users) {
$source_companies = ProjectCompanies::instance()->getCompaniesByProject($source);
if (is_array($source_companies)) {
foreach ($source_companies as $source_company) {
$project_company = new ProjectCompany();
$project_company->setCompanyId($source_company->getId());
$project_company->setProjectId($project_id);
$project_company->save();
}
// foreach
}
$source_users = ProjectUsers::instance()->getUsersByProject($source);
if (is_array($source_users)) {
foreach ($source_users as $source_user) {
$project_user = new ProjectUser();
$project_user->setUserId($source_user->getId());
$project_user->setProjectId($project_id);
$project_user->save();
}