From d85570c9946aef61d8d935d9f50169215338d665 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Tue, 15 Feb 2011 11:45:38 +0000 Subject: improved wiki --- h-source/Application/Models/WikiModel.php | 41 ++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'h-source/Application/Models/WikiModel.php') diff --git a/h-source/Application/Models/WikiModel.php b/h-source/Application/Models/WikiModel.php index 1372a04..0a00bfb 100644 --- a/h-source/Application/Models/WikiModel.php +++ b/h-source/Application/Models/WikiModel.php @@ -50,13 +50,21 @@ class WikiModel extends Model_Map { $this->fieldsWithBreaks = array(gtext('wiki page')); $this->strongConditions['insert'] = array( - "checkLength|99" => 'title', - "+checkLength|5000" => 'page', + "checkLength|99" => 'title|'.gtext('title is too length'), + "+checkLength|9000" => 'page|'.gtext('the page text is too length'), ); $this->strongConditions['update'] = array( - "checkLength|99" => 'title', - "+checkLength|5000" => 'page', + "checkLength|99" => 'title|'.gtext('title is too length'), + "+checkLength|9000" => 'page|'.gtext('the page text is too length'), + ); + + $this->databaseConditions['insert'] = array( + "checkUnique" => 'title|'.gtext('a page with the same title already exists'), + ); + + $this->databaseConditions['update'] = array( + "checkUniqueCompl" => 'title|'.gtext('a page with the same title already exists'), ); parent::__construct(); @@ -95,6 +103,7 @@ class WikiModel extends Model_Map { { $clean['id'] = (int)$id; + $this->values['created_by'] = (int)$this->id_user; $this->values['update_date'] = date('Y-m-d H:i:s'); $this->values['title_clean'] = encodeUrl($this->values['title']); @@ -110,6 +119,13 @@ class WikiModel extends Model_Map { $revisions->values = $oldValues; if ($revisions->insert()) { + + if ($this->isMain($clean['id'])) + { + $this->values['title'] = 'Main Page'; + $this->values['title_clean'] = 'Main-Page'; + } + parent::update($clean['id']); if ($this->queryResult) { @@ -155,6 +171,12 @@ class WikiModel extends Model_Map { $this->values['created_by'] = (int)$this->id_user; $this->values['update_date'] = date('Y-m-d H:i:s'); + if ($this->isMain($clean['id_wiki'])) + { + $this->values['title'] = 'Main Page'; + $this->values['title_clean'] = 'Main-Page'; + } + if ($revisions->insert()) { if (parent::update($clean['id_wiki'])) @@ -221,6 +243,17 @@ class WikiModel extends Model_Map { } } + public function isMain($id) + { + $clean['id'] = (int)$id; + $res = $this->select('is_main')->where(array('id_wiki'=>$clean['id']))->send(); + if ( count($res) > 0 ) + { + return strcmp($res[0]['wiki']['is_main'],'no') === 0 ? false : true; + } + return false; + } + public function getDiffArray($oldArray, $newArray) { return getDiffArray($this->diffFields, $oldArray, $newArray); -- cgit v1.2.3