当前位置: 首页>>代码示例>>PHP>>正文


PHP WikiPage::save方法代码示例

本文整理汇总了PHP中WikiPage::save方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiPage::save方法的具体用法?PHP WikiPage::save怎么用?PHP WikiPage::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WikiPage的用法示例。


在下文中一共展示了WikiPage::save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wiki_install

/**
 * Wiki for phpWebSite
 *
 * See docs/CREDITS for copyright information
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @package Wiki
 * @author Greg Meiste <greg.meiste+github@gmail.com>
 */
function wiki_install(&$content)
{
    PHPWS_Core::initModClass('wiki', 'WikiManager.php');
    PHPWS_Core::initModClass('wiki', 'WikiPage.php');
    PHPWS_Core::initModClass('version', 'Version.php');
    // Adding pages that ship with the module
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/frontpage.txt')) {
        $frontpage = new WikiPage('FrontPage');
        $frontpage->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/frontpage.txt')));
        $frontpage->setOwnerId(Current_User::getId());
        $frontpage->setEditorId(Current_User::getId());
        $frontpage->setCreated(mktime());
        $frontpage->setUpdated(mktime());
        $frontpage->setComment('Provided by Wiki install');
        $frontpage->save();
        $version1 = new Version('wiki_pages');
        $version1->setSource($frontpage);
        $version1->setApproved(1);
        $version1->save();
    }
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/samplepage.txt')) {
        $samplepage = new WikiPage('SamplePage');
        $samplepage->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/samplepage.txt')));
        $samplepage->setOwnerId(Current_User::getId());
        $samplepage->setEditorId(Current_User::getId());
        $samplepage->setCreated(mktime());
        $samplepage->setUpdated(mktime());
        $samplepage->setComment('Provided by Wiki install');
        $samplepage->allow_edit = 0;
        $samplepage->save();
        $version2 = new Version('wiki_pages');
        $version2->setSource($samplepage);
        $version2->setApproved(1);
        $version2->save();
    }
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/sandbox.txt')) {
        $sandbox = new WikiPage('WikiSandBox');
        $sandbox->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/sandbox.txt')));
        $sandbox->setOwnerId(Current_User::getId());
        $sandbox->setEditorId(Current_User::getId());
        $sandbox->setCreated(mktime());
        $sandbox->setUpdated(mktime());
        $sandbox->setComment('Provided by Wiki install');
        $sandbox->save();
        $version3 = new Version('wiki_pages');
        $version3->setSource($sandbox);
        $version3->setApproved(1);
        $version3->save();
    }
    // Adding first interwiki link
    PHPWS_Core::initModClass('wiki', 'InterWiki.php');
    $interwiki = new InterWiki();
    $interwiki->setLabel('Wikipedia');
    $interwiki->setUrl('http://en.wikipedia.org/wiki/%s');
    $interwiki->save(FALSE);
    return TRUE;
}
开发者ID:Jopperi,项目名称:wiki,代码行数:79,代码来源:install.php

示例2: actionEdit

 /**
  * Handles page edit
  *
  * @param string $uid
  */
 public function actionEdit($uid)
 {
     $page = WikiPage::model()->findByWikiUid($uid);
     $comment = '';
     if (!$page) {
         $page = new WikiPage();
         $comment = Yii::t('WikiModule.wiki', 'Created new page');
     }
     $page->setWikiUid($uid);
     if (Yii::app()->getRequest()->getPost('WikiPage')) {
         $comment = Yii::app()->getRequest()->getPost('comment', '');
         $page->setAttributes(Yii::app()->getRequest()->getPost('WikiPage'));
         /** @var $auth IWikiAuth */
         $auth = $this->getModule()->getAuth();
         if (!$auth->isGuest()) {
             $page->user_id = $auth->getUserId();
         }
         $trans = $page->dbConnection->beginTransaction();
         $justCreated = false;
         if ($page->isNewRecord) {
             $justCreated = true;
             $page->save();
         }
         $revId = $this->addPageRevision($page, $comment);
         if ($revId) {
             $page->revision_id = $revId;
             if ($page->save()) {
                 if ($this->updateWikiLinks($page, $justCreated)) {
                     $trans->commit();
                     Yii::app()->cache->delete($page->getCacheKey());
                     $this->deleteLinksourceCache($page);
                     $this->redirect(array('view', 'uid' => $uid));
                 }
             }
         }
     }
     $this->render('edit', array('page' => $page, 'comment' => $comment));
 }
开发者ID:sherifflight,项目名称:yupe,代码行数:43,代码来源:DefaultController.php

示例3: 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
     //Here we will edit a wiki page
     $preview = false;
     $data = array_var($_POST, 'wiki', false);
     if (false !== $data) {
         $preview = array_key_exists('preview', $data);
     }
     if (!$preview && $data) {
         //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->setPublish(logged_user()->isMemberOfOwnerCompany() ? $data['publish'] : 0);
         $page->setParentId($data['parent_id']);
         $page->setProjectSidebar(logged_user()->isMemberOfOwnerCompany() ? $data['project_sidebar'] : 0);
         //Make a new revision of this page
         $revision = $page->makeRevision();
         // Check to see if we want to lock this page
         if (isset($data['locked'])) {
             if ($data['locked'] == 1 && $page->canLock(logged_user())) {
                 // If we want to lock this page and the user has permissions to lock it, and the page is not already locked
                 $page->setLocked(true);
                 $page->setLockedById(logged_user()->getId());
                 $page->setLockedOn(DateTimeValueLib::now());
             }
             // if
         }
         // if
         //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
     $revision = new Revision();
     if (!$data) {
         // there was no input POSTed
         $data['content'] = $revision->getContent();
     }
     $data['preview_content'] = do_textile($data['content']);
     //Assign revision object
     tpl_assign('data', $data);
     tpl_assign('page', $page);
     tpl_assign('revision', $revision);
     tpl_assign('tags', '');
     $this->setTemplate('edit');
     $this->setSidebar(get_template_path('textile_help_sidebar'));
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:87,代码来源:WikiController.class.php

示例4: doMove

 function doMove()
 {
     if (!Current_User::authorized('wiki', 'edit_page') && !(PHPWS_Settings::get('wiki', 'allow_page_edit') && Current_User::isLogged()) || !$this->allow_edit) {
         Current_User::disallow(dgettext('wiki', 'User attempted to execute a wiki page move.'));
         return;
     }
     if (strlen($_POST['newpage']) == 0) {
         WikiManager::sendMessage(dgettext('wiki', 'Please supply a new page title'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE)));
     }
     $db = new PHPWS_DB('wiki_pages');
     $db->addWhere('title', $_POST['newpage']);
     $result = $db->select();
     if ($result != NULL) {
         WikiManager::sendMessage(dgettext('wiki', 'Page with that name already exists!'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE)));
     }
     $this->setTitle($_POST['newpage']);
     $db->reset();
     $db->saveObject($this);
     $db2 = new PHPWS_DB('wiki_pages_version');
     $db2->addWhere('title', $_POST['page']);
     $db2->addValue('title', $this->getTitle(FALSE));
     $db2->update();
     $db3 = new PHPWS_DB('phpws_key');
     $db3->addWhere('item_id', $this->getId());
     $db3->addWhere('module', 'wiki');
     $db3->addValue('title', $this->getTitle());
     $db3->addValue('url', (MOD_REWRITE_ENABLED ? 'wiki/' : 'index.php?module=wiki&page=') . $this->getTitle(FALSE));
     $db3->update();
     // Create redirect page
     $redirect = new WikiPage($_POST['page']);
     $redirect->setPagetext(sprintf(dgettext('wiki', 'This page has moved to %s.  Please modify links to point to the new location.'), $this->getTitle(FALSE)));
     $redirect->setOwnerId(Current_User::getId());
     $redirect->setEditorId(Current_User::getId());
     $redirect->setCreated(mktime());
     $redirect->setUpdated(mktime());
     $redirect->setComment(sprintf(dgettext('wiki', 'Moved page to %s.'), $this->getTitle(FALSE)));
     $redirect->save();
     PHPWS_Core::initModClass('version', 'Version.php');
     $version = new Version('wiki_pages');
     $version->setSource($redirect);
     $version->setApproved(1);
     $version->save();
     WikiManager::sendMessage(dgettext('wiki', 'Wiki Page Moved!'), array('page' => $this->getTitle(FALSE)), FALSE);
 }
开发者ID:Jopperi,项目名称:wiki,代码行数:44,代码来源:WikiPage.php

示例5: actionEdit

 public function actionEdit()
 {
     $id = (int) Yii::app()->request->getQuery('id');
     $homePage = WikiPage::model()->contentContainer($this->contentContainer)->findByAttributes(array('is_home' => 1));
     $page = WikiPage::model()->contentContainer($this->contentContainer)->findByAttributes(array('id' => $id));
     if ($page === null) {
         $page = new WikiPage();
         $page->content->setContainer($this->contentContainer);
         $page->content->visibility = Content::VISIBILITY_PRIVATE;
         $page->title = Yii::app()->request->getParam('title');
     }
     if ($page->admin_only && !$page->canAdminister()) {
         throw new CHttpException(403, 'Page not editable!');
     }
     $revision = $page->createRevision();
     if (isset($_POST['WikiPage']) && isset($_POST['WikiPageRevision'])) {
         $page->content->container = $this->contentContainer;
         $page->attributes = $_POST['WikiPage'];
         $revision->attributes = $_POST['WikiPageRevision'];
         if ($page->validate()) {
             $page->save();
             File::attachPrecreated($page, Yii::app()->request->getParam('fileUploaderHiddenGuidField'));
             $revision->wiki_page_id = $page->id;
             if ($revision->validate()) {
                 $revision->save();
                 $this->redirect($this->createContainerUrl('view', array('title' => $page->title)));
             }
         }
     }
     $this->render('edit', array('page' => $page, 'revision' => $revision, 'homePage' => $homePage));
 }
开发者ID:Wikom,项目名称:humhub-modules-wiki,代码行数:31,代码来源:PageController.php

示例6: convertPage

function convertPage($page)
{
    PHPWS_Core::initModClass('wiki', 'WikiManager.php');
    PHPWS_Core::initModClass('wiki', 'WikiPage.php');
    PHPWS_Core::initModClass('version', 'Version.php');
    PHPWS_Core::initModClass('search', 'Search.php');
    $newpage = new WikiPage($page['label']);
    $newpage->setPagetext($page['pagetext']);
    $newpage->setOwnerId(Current_User::getId());
    $newpage->setEditorId(Current_User::getId());
    $newpage->setCreated($page['created']);
    $newpage->setUpdated(mktime());
    $newpage->setComment(dgettext('wiki', 'Converted from previous wiki install'));
    $newpage->allow_edit = $page['allow_edit'];
    $result = $newpage->save();
    if (PEAR::isError($result)) {
        PHPWS_Error::log($result);
        return FALSE;
    }
    $version = new Version('wiki_pages');
    $version->setSource($newpage);
    $version->setApproved(1);
    $version->save();
    return TRUE;
}
开发者ID:Jopperi,项目名称:wiki,代码行数:25,代码来源:convert.php

示例7: 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');
 }
开发者ID:469306621,项目名称:Languages,代码行数:58,代码来源:WikiController.class.php

示例8: __setup_install_wiki__

 /**
  * Wiki の初期データをインストール
  */
 public static function __setup_install_wiki__()
 {
     $frontpage = new WikiPage('name=FrontPage,body=Welcome to rhaco wiki');
     $frontpage->save();
     C($frontpage)->commit();
 }
开发者ID:riaf,项目名称:rhaco2-repository,代码行数:9,代码来源:Wiki.php

示例9: copy

 /**
  * Copy project
  *
  * @param void
  * @return null
  */
 function copy()
 {
     trace(__FILE__, "copy():begin");
     if (!Project::canAdd(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $this->setTemplate('copy_project');
     $this->setLayout('administration');
     $project_data = array_var($_POST, 'project');
     tpl_assign('project_data', $project_data);
     // Submitted...
     if (is_array($project_data)) {
         $source = Projects::findById($project_data['source']);
         if (!$source instanceof Project) {
             flash_error(lang('project dnx'));
             $this->redirectTo('administration', 'projects');
         }
         // if
         try {
             $shift_dates = isset($project_data['shift_dates']) ? $project_data['shift_dates'] == 'checked' : false;
             $copy_details = isset($project_data['copy_details']) ? $project_data['copy_details'] == 'checked' : false;
             $copy_tasks = isset($project_data['copy_tasks']) ? $project_data['copy_tasks'] == 'checked' : false;
             $copy_milestones = isset($project_data['copy_milestones']) ? $project_data['copy_milestones'] == 'checked' : false;
             $copy_messages = isset($project_data['copy_messages']) ? $project_data['copy_messages'] == 'checked' : false;
             $copy_links = isset($project_data['copy_links']) ? $project_data['copy_links'] == 'checked' : false;
             $copy_files = isset($project_data['copy_files']) ? $project_data['copy_files'] == 'checked' : false;
             $copy_users = isset($project_data['copy_users']) ? $project_data['copy_users'] == 'checked' : false;
             $copy_pages = isset($project_data['copy_pages']) ? $project_data['copy_pages'] == 'checked' : false;
             DB::beginWork();
             $project = new Project();
             $new_name = lang('projects copy new name', $source->getName());
             $new_name .= date(' z H:i:s');
             $project->setName($new_name);
             if ($copy_details) {
                 $project->setDescription($source->getDescription());
                 $project->setPriority($source->getPriority());
                 $project->setShowDescriptionInOverview($source->getShowDescriptionInOverview());
             }
             $project->save();
             $project_id = $project->getId();
             $add_seconds = 0;
             if (isset($project_data['add_days'])) {
                 $add_days = 0 + trim($project_data['add_days']);
                 $add_seconds = $add_days * 24 * 60 * 60;
             }
             $source_created_on = $source->getCreatedOn();
             //var_dump($source_created_on);
             $milestone_map = array(0 => 0);
             // project milestones
             if ($copy_milestones) {
                 $source_milestones = $source->getAllMilestones();
                 if (is_array($source_milestones)) {
                     foreach ($source_milestones as $source_milestone) {
                         $milestone = new ProjectMilestone();
                         //$milestone->copy($source_milestone);
                         $milestone->setName($source_milestone->getName());
                         $milestone->setDescription($source_milestone->getDescription());
                         if ($shift_dates) {
                             trace(__FILE__, "copy():shift dates");
                             $milestone->setDueDate(DateTimeValueLib::now());
                             $seconds = $source_milestone->getDueDate()->difference($source_created_on);
                             $milestone->getDueDate()->advance($seconds);
                         } else {
                             $milestone->setDueDate($source_milestone->getDueDate());
                         }
                         $milestone->getDueDate()->advance($add_seconds);
                         $milestone->setIsPrivate($source_milestone->getIsPrivate());
                         $milestone->setAssignedToUserId($source_milestone->getAssignedToUserId());
                         $milestone->setAssignedToCompanyId($source_milestone->getAssignedToCompanyId());
                         $milestone->setProjectId($project_id);
                         $milestone->save();
                         $milestone_map[$source_milestone->getId()] = $milestone->getId();
                     }
                     // foreach
                 }
                 // if
             }
             // if
             // project tasks
             if ($copy_tasks) {
                 $source_task_lists = $source->getAllTaskLists();
                 if (is_array($source_task_lists)) {
                     foreach ($source_task_lists as $source_task_list) {
                         $task_list = new ProjectTaskList();
                         //$task_list->copy($source_milestone);
                         $task_list->setName($source_task_list->getName());
                         $task_list->setPriority($source_task_list->getPriority());
                         $task_list->setDescription($source_task_list->getDescription());
                         if ($copy_milestones) {
                             $task_list->setMilestoneId($milestone_map[$source_task_list->getMilestoneId()]);
                         }
                         $task_list->setDueDate($source_task_list->getDueDate());
//.........这里部分代码省略.........
开发者ID:469306621,项目名称:Languages,代码行数:101,代码来源:ProjectController.class.php


注:本文中的WikiPage::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。