本文整理汇总了PHP中WikiPage::model方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiPage::model方法的具体用法?PHP WikiPage::model怎么用?PHP WikiPage::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiPage
的用法示例。
在下文中一共展示了WikiPage::model方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateWikiLinks
/**
* Updates wiki-links of a page
*
* @param WikiPage $page
* @param bool $justCreated if page was just created
* @return bool
*/
private function updateWikiLinks(WikiPage $page, $justCreated = false)
{
if ($justCreated) {
$criteria = new CDbCriteria();
$criteria->compare('wiki_uid', $page->getWikiUid());
WikiLink::model()->updateAll(array('page_to_id' => $page->id), $criteria);
}
WikiLink::model()->deleteAllByAttributes(array('page_from_id' => $page->id));
$links = $this->getWikiLinks($page->content);
foreach ($links as $link) {
$wikiLink = new WikiLink();
$wikiLink->page_from_id = $page->id;
$wikiLink->wiki_uid = $link['wiki_uid'];
$wikiLink->title = $link['title'];
$linkedPage = WikiPage::model()->findByWikiUid($link['wiki_uid']);
if ($linkedPage) {
$wikiLink->page_to_id = $linkedPage->id;
}
if (!$wikiLink->save()) {
return false;
}
}
return true;
}
示例2: validateTitle
/**
* Title field validator
*
* @param type $attribute
* @param type $params
*/
public function validateTitle($attribute, $params)
{
if (strpos($this->title, "/") !== false || strpos($this->title, ")") !== false || strpos($this->title, "(") !== false) {
$this->addError('title', Yii::t('WikiModule.base', 'Invalid character in page title!'));
}
$criteria = new CDbCriteria();
if (!$this->isNewRecord) {
$criteria->condition = 't.id != :selfId';
$criteria->params = array(':selfId' => $this->id);
}
$page = WikiPage::model()->contentContainer($this->content->container)->findByAttributes(array('title' => $this->title), $criteria);
if ($page !== null) {
$this->addError('title', Yii::t('WikiModule.base', 'Page title already in use!'));
}
}
示例3: actionRevert
public function actionRevert()
{
$this->forcePostRequest();
$id = (int) Yii::app()->request->getQuery('id');
$toRevision = (int) Yii::app()->request->getQuery('toRevision');
$page = WikiPage::model()->contentContainer($this->contentContainer)->findByPk($id);
if ($page === null) {
throw new CHttpException(404, 'Page not found!');
}
if ($page->admin_only && !$page->canAdminister()) {
throw new CHttpException(403, 'Page not editable!');
}
$revision = WikiPageRevision::model()->findByAttributes(array('revision' => $toRevision, 'wiki_page_id' => $page->id));
if ($revision->is_latest) {
throw new CHttpException(404, 'Already latest revision!');
}
$revertedRevision = $page->createRevision();
$revertedRevision->content = $revision->content;
$revertedRevision->save();
$this->redirect($this->createContainerUrl('view', array('title' => $page->title)));
}
示例4: disableUserModule
public function disableUserModule(User $user)
{
foreach (WikiPage::model()->contentContainer($user)->findAll() as $page) {
$page->delete();
}
}