aboutsummaryrefslogtreecommitdiff
path: root/h-source/Application/Models/WikiModel.php
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-02-15 11:45:38 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-02-15 11:45:38 +0000
commitd85570c9946aef61d8d935d9f50169215338d665 (patch)
tree80ff5e94178d9aa09bebfc6b897251078836cdd5 /h-source/Application/Models/WikiModel.php
parent8c287999487883a54271ae5e91bbb79b4fd15826 (diff)
improved wiki
Diffstat (limited to 'h-source/Application/Models/WikiModel.php')
-rw-r--r--h-source/Application/Models/WikiModel.php41
1 files changed, 37 insertions, 4 deletions
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);