diff options
author | Antonio Gallo <tonicucoz@gmail.com> | 2011-02-15 11:45:38 +0000 |
---|---|---|
committer | Antonio Gallo <tonicucoz@gmail.com> | 2011-02-15 11:45:38 +0000 |
commit | d85570c9946aef61d8d935d9f50169215338d665 (patch) | |
tree | 80ff5e94178d9aa09bebfc6b897251078836cdd5 | |
parent | 8c287999487883a54271ae5e91bbb79b4fd15826 (diff) |
improved wiki
-rw-r--r-- | h-source/Application/Controllers/BaseController.php | 1 | ||||
-rw-r--r-- | h-source/Application/Controllers/WikiController.php | 55 | ||||
-rw-r--r-- | h-source/Application/Include/languages.php | 7 | ||||
-rw-r--r-- | h-source/Application/Include/myFunctions.php | 7 | ||||
-rwxr-xr-x | h-source/Application/Models/UsersModel.php | 18 | ||||
-rw-r--r-- | h-source/Application/Models/WikiModel.php | 41 | ||||
-rw-r--r-- | h-source/Application/Views/Wiki/history.php | 6 | ||||
-rw-r--r-- | h-source/Application/Views/Wiki/not_found.php | 2 | ||||
-rw-r--r-- | h-source/Application/Views/Wiki/page.php | 6 | ||||
-rw-r--r-- | h-source/Application/Views/header.php | 2 | ||||
-rw-r--r-- | h-source/Application/Views/history.php | 4 | ||||
-rw-r--r-- | h-source/Application/Views/right.php | 2 | ||||
-rw-r--r-- | h-source/Public/Css/explorer6.css | 6 | ||||
-rw-r--r-- | h-source/Public/Css/explorer7.css | 8 | ||||
-rw-r--r-- | h-source/Public/Css/main.css | 14 | ||||
-rw-r--r-- | h-source/tables.sql | 5 |
16 files changed, 147 insertions, 37 deletions
diff --git a/h-source/Application/Controllers/BaseController.php b/h-source/Application/Controllers/BaseController.php index 0f7c532..29d0642 100644 --- a/h-source/Application/Controllers/BaseController.php +++ b/h-source/Application/Controllers/BaseController.php @@ -38,6 +38,7 @@ class BaseController extends Controller "news" => null, "download" => null, "help" => null, + "wiki" => null, ); public function __construct($model, $controller, $queryString) { diff --git a/h-source/Application/Controllers/WikiController.php b/h-source/Application/Controllers/WikiController.php index 2ddc54d..1c4c154 100644 --- a/h-source/Application/Controllers/WikiController.php +++ b/h-source/Application/Controllers/WikiController.php @@ -24,6 +24,9 @@ class WikiController extends BaseController { public function __construct($model, $controller, $queryString) { + + $this->_topMenuClasses['wiki'] = " class='currentitem'"; + parent::__construct($model, $controller, $queryString); $this->model('UsersModel'); @@ -158,33 +161,51 @@ class WikiController extends BaseController $clean['title_clean'] = sanitizeAll($title_clean); $data['isDeleted'] = 'no'; - - $res = $this->m['WikiModel']->select()->where(array('title_clean'=>$clean['title_clean']))->send(); - if ( count($res) > 0 ) + if (isset($title_clean)) { - $data['table'] = $res; - $data['tree_name'] = $res[0]['wiki']['title']; - $data['title'] = $res[0]['wiki']['title'] . ' - ' . Website::$generalName; - $data['isDeleted'] = $res[0]['wiki']['deleted']; - - if ( count($res) < 2 ) + $res = $this->m['WikiModel']->select()->where(array('title_clean'=>$clean['title_clean']))->orderBy('id_wiki desc')->limit(1)->send(); + + if ( count($res) > 0 ) { - $data['talk_number'] = $this->m['WikitalkModel']->select('count(*) as numb,id_wiki')->where(array('id_wiki'=>$res[0]['wiki']['id_wiki'],'deleted'=>'no'))->rowNumber(); - - $viewFile = 'page'; - $data['id_wiki'] = $res[0]['wiki']['id_wiki']; + $data['table'] = $res; + $data['tree_name'] = $res[0]['wiki']['title']; + $data['title'] = $res[0]['wiki']['title'] . ' - ' . Website::$generalName; + $data['isDeleted'] = $res[0]['wiki']['deleted']; + + if ( count($res) < 2 ) + { + $data['talk_number'] = $this->m['WikitalkModel']->select('count(*) as numb,id_wiki')->where(array('id_wiki'=>$res[0]['wiki']['id_wiki'],'deleted'=>'no'))->rowNumber(); + + $viewFile = 'page'; + $data['id_wiki'] = $res[0]['wiki']['id_wiki']; + } + else + { + $viewFile = 'select'; + } } else { - $viewFile = 'select'; + $rev = new WikirevisionsModel(); + $res_rev = $rev->select()->where(array('title_clean'=>$clean['title_clean']))->orderBy('id_rev desc')->limit(1)->send(); + if ( count($res_rev) > 0 ) + { + $clean['idWiki'] = $rev->getIdPage($res_rev[0]['wiki_revisions']['id_rev']); + $newTitle = $this->m['WikiModel']->getTheModelName($clean['idWiki']); + $this->redirect('wiki/page/'.$this->lang.'/'.encodeUrl($newTitle)); + } + else + { + $viewFile = 'not_found'; + } } } else { - $viewFile = 'not_found'; + $this->redirect('wiki/page/'.$this->lang.'/Main-Page'); } - + $this->append($data); $this->load($viewFile); @@ -470,7 +491,7 @@ class WikiController extends BaseController protected function getSpecPageLink() { - return "<a href='".$this->baseUrl.'/'.$this->controller.'/page/'.$this->lang."'>".$this->controller."</a>"; + return "<a href='".$this->baseUrl.'/'.$this->controller.'/page/'.$this->lang."/Main-Page'>".ucfirst($this->controller)."</a>"; } }
\ No newline at end of file diff --git a/h-source/Application/Include/languages.php b/h-source/Application/Include/languages.php index 4bfb7fe..692c214 100644 --- a/h-source/Application/Include/languages.php +++ b/h-source/Application/Include/languages.php @@ -192,7 +192,12 @@ class Lang "Make this revision the current revision of the page" => "Rendi questa revisione la revisione corrente della pagina", "This wiki page has been hidden" => "Questa pagina della wiki è stata nascosta", "Talk" => "Discussione", - "Talk page of the wiki page" => "Pagina di discussione della pagina della wiki" + "Talk page of the wiki page" => "Pagina di discussione della pagina della wiki", + "a page with the same title already exists" => "esiste già una pagina con questo titolo", + "title is too length" => "il titolo è troppo lungo", + "the page text is too length" => "il testo della pagina è troppo lungo", + "History of the wiki page" => "History della pagina della wiki", + "Would you like to insert it?" => "Vuoi inserirla?", ), 'es' => array ( diff --git a/h-source/Application/Include/myFunctions.php b/h-source/Application/Include/myFunctions.php index d494eb6..8299157 100644 --- a/h-source/Application/Include/myFunctions.php +++ b/h-source/Application/Include/myFunctions.php @@ -195,6 +195,8 @@ function decodeWikiText($string) $string = preg_replace('/(\[hr\])/', '<hr />',$string); + $string = preg_replace_callback('/(\[\[)(.*?)(\]\])/', 'linkToInternalPage' ,$string); + $string = preg_replace_callback('/(\[a\])(.*?)(\[\/a\])/', 'linkTo',$string); $string = preg_replace_callback('/(\[a\])(.*?)\|(.*?)(\[\/a\])/', 'linkToWithText',$string); @@ -269,6 +271,11 @@ function linkTo($match) } } +function linkToInternalPage($match) +{ + return "<a title = '".$match[2]."' href='http://".DOMAIN_NAME."/wiki/page/".Lang::$current."/".encodeUrl($match[2])."'>".$match[2]."</a>"; +} + function linkToWithText($match) { if (checkUrl($match[2])) diff --git a/h-source/Application/Models/UsersModel.php b/h-source/Application/Models/UsersModel.php index a7c3845..fe72ce7 100755 --- a/h-source/Application/Models/UsersModel.php +++ b/h-source/Application/Models/UsersModel.php @@ -88,6 +88,24 @@ class UsersModel extends Model_Map } } + public function getLinkToUser($user) + { + if (strstr($user,'__')) + { + return str_replace('__',null,$user); + } + else + { + return "<a href='http://".DOMAIN_NAME."/meet/user/".Lang::$current."/$user'>$user</a>"; + } + } + + public function getLinkToUserFromId($id_user = 0) + { + $clean['id_user'] = (int)$id_user; + return $this->getLinkToUser($this->getUser($clean['id_user'])); + } + //get the user id from the username public function getUserId($username = '') { 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); diff --git a/h-source/Application/Views/Wiki/history.php b/h-source/Application/Views/Wiki/history.php index b979063..5e5c041 100644 --- a/h-source/Application/Views/Wiki/history.php +++ b/h-source/Application/Views/Wiki/history.php @@ -27,7 +27,7 @@ </div> <div class="notebook_view_title"> - History of the wiki page <b><?php echo $tree_name;?></b> + <?php echo gtext('History of the wiki page'); ?> <b><?php echo $tree_name;?></b> </div> <div class="notebook_insert_link"> @@ -40,14 +40,14 @@ <?php if ($this->viewArgs['page'] === 1) { ?> <?php foreach ($rev1 as $rev) { ?> - <li class="page_history_current_item"><b><?php echo gtext("Current revision");?>:</b> <?php echo smartDate($rev['wiki']['update_date']);?> by <?php echo getLinkToUser($u->getUser($rev['wiki']['created_by']));?> (<a href="<?php echo $this->baseUrl."/".$this->controller."/differences/$lang/$id/0".$this->viewStatus;?>">diff</a>)</li> + <li class="page_history_current_item"><b><?php echo gtext("Current revision");?>:</b> <?php echo smartDate($rev['wiki']['update_date']);?> by <?php echo $u->getLinkToUserFromId($rev['wiki']['created_by']);?> (<a href="<?php echo $this->baseUrl."/".$this->controller."/differences/$lang/$id/0".$this->viewStatus;?>">diff</a>)</li> <?php } ?> <?php } ?> <?php foreach ($rev2 as $rev) { ?> <li class="page_history_item"> - <a href="<?php echo $this->baseUrl."/".$this->controller."/revision/$lang/".$rev['wiki_revisions']['id_rev'].$this->viewStatus;?>"><?php echo smartDate($rev['wiki_revisions']['update_date']);?></a> by <?php echo getLinkToUser($u->getUser($rev['wiki_revisions']['created_by']));?> + <a href="<?php echo $this->baseUrl."/".$this->controller."/revision/$lang/".$rev['wiki_revisions']['id_rev'].$this->viewStatus;?>"><?php echo smartDate($rev['wiki_revisions']['update_date']);?></a> by <?php echo $u->getLinkToUserFromId($rev['wiki_revisions']['created_by']);?> <?php if (strcmp($rev['wiki_revisions']['id_rev'],$firstRev) !== 0) {?> (<a href="<?php echo $this->baseUrl."/".$this->controller."/differences/$lang/$id/".$rev['wiki_revisions']['id_rev'].$this->viewStatus;?>">diff</a>) diff --git a/h-source/Application/Views/Wiki/not_found.php b/h-source/Application/Views/Wiki/not_found.php index dc95c21..cd435de 100644 --- a/h-source/Application/Views/Wiki/not_found.php +++ b/h-source/Application/Views/Wiki/not_found.php @@ -28,7 +28,7 @@ <div class="wiki_external_box"> <div> - <?php echo gtext('the wiki page has not been found');?> + <?php echo gtext('the wiki page has not been found');?>. <a href="<?php echo $this->baseUrl."/wiki/insert/$lang";?>"><?php echo gtext('Would you like to insert it?');?></a> </div> </div> diff --git a/h-source/Application/Views/Wiki/page.php b/h-source/Application/Views/Wiki/page.php index 92e3c9b..c690771 100644 --- a/h-source/Application/Views/Wiki/page.php +++ b/h-source/Application/Views/Wiki/page.php @@ -27,7 +27,7 @@ <?php if ( strcmp($this->action,'page') === 0 ) { ?> <div class="position_tree_box"> - <a href="<?php echo $this->baseUrl."/home/index/$lang";?>">Home</a> » <a href="<?php echo $this->baseUrl."/wiki/page/$lang";?>">Wiki</a> » <?php echo $tree_name;?> + <a href="<?php echo $this->baseUrl."/home/index/$lang";?>">Home</a> » <a href="<?php echo $this->baseUrl."/wiki/page/$lang/Main-Page";?>">Wiki</a> » <?php echo $tree_name;?> </div> <div class="notebook_insert_link"> @@ -49,7 +49,7 @@ <?php } ?> </div> - <div class="talk_numb_ext"> + <div class="talk_numb_ext_wiki"> <a href="<?php echo $this->baseUrl."/".$this->controller."/talk/$lang/$id_wiki";?>">talk messages: <?php echo $talk_number;?></a> </div> @@ -84,7 +84,7 @@ <!--if revision--> <?php if (strcmp($this->action,'revision') === 0) { ?> <div class="revision_alert"> - This is an old revision of this page, as edited by <b><?php echo getLinkToUser($u->getUser($created_by));?></b> at <b><?php echo smartDate($update_date); ?></b>. It may differ significantly from the <a href="<?php echo $this->baseUrl."/wiki/page/$lang/".encodeUrl($tree_name);?>">current revision</a>. + This is an old revision of this page, as edited by <b><?php echo $u->getLinkToUserFromId($created_by);?></b> at <b><?php echo smartDate($update_date); ?></b>. It may differ significantly from the <a href="<?php echo $this->baseUrl."/wiki/page/$lang/".encodeUrl($tree_name);?>">current revision</a>. </div> <?php } ?> diff --git a/h-source/Application/Views/header.php b/h-source/Application/Views/header.php index 8686221..625ebae 100644 --- a/h-source/Application/Views/header.php +++ b/h-source/Application/Views/header.php @@ -80,7 +80,7 @@ $currPos = $querySanitized ? $this->controller."/".$this->action : 'home/index'; <div id="top_menu_external"> <div id="top_menu"> <ul> - <li<?php echo $tm['home']; ?>><a href="<?php echo $this->baseUrl."/home/index/$lang";?>">Home</a></li><li<?php echo $tm['hardware']; ?>><a href="<?php echo $this->baseUrl."/hardware/catalogue/$lang";?>">Hardware</a></li><li<?php echo $tm['issues']; ?>><a href="<?php echo $this->baseUrl."/issues/viewall/$lang/1/$token";?>">Issues</a></li><li<?php echo $tm['search']; ?>><a href="<?php echo $this->baseUrl."/search/form/$lang";?>">Search</a></li><li<?php echo $tm['news']; ?>><a href="<?php echo $this->baseUrl."/news/index/$lang";?>">News</a></li><li<?php echo $tm['download']; ?>><a href="<?php echo $this->baseUrl."/download/index/$lang";?>">Download</a></li><li<?php echo $tm['help']; ?>><a href="<?php echo $this->baseUrl."/help/index/$lang";?>">Help</a></li> + <li<?php echo $tm['home']; ?>><a href="<?php echo $this->baseUrl."/home/index/$lang";?>">Home</a></li><li<?php echo $tm['hardware']; ?>><a href="<?php echo $this->baseUrl."/hardware/catalogue/$lang";?>">Hardware</a></li><li<?php echo $tm['issues']; ?>><a href="<?php echo $this->baseUrl."/issues/viewall/$lang/1/$token";?>">Issues</a></li><li<?php echo $tm['search']; ?>><a href="<?php echo $this->baseUrl."/search/form/$lang";?>">Search</a></li><li<?php echo $tm['news']; ?>><a href="<?php echo $this->baseUrl."/news/index/$lang";?>">News</a></li><li<?php echo $tm['download']; ?>><a href="<?php echo $this->baseUrl."/download/index/$lang";?>">Download</a></li><li<?php echo $tm['help']; ?>><a href="<?php echo $this->baseUrl."/help/index/$lang";?>">Help</a></li><li<?php echo $tm['wiki']; ?>><a href="<?php echo $this->baseUrl."/wiki/page/$lang/Main-Page";?>">Wiki</a></li> </ul> </div> </div> diff --git a/h-source/Application/Views/history.php b/h-source/Application/Views/history.php index a809596..55032f0 100644 --- a/h-source/Application/Views/history.php +++ b/h-source/Application/Views/history.php @@ -26,14 +26,14 @@ <?php if ($this->viewArgs['history_page'] === 1) { ?> <?php foreach ($rev1 as $rev) { ?> - <li class="page_history_current_item"><b><?php echo gtext("Current revision");?>:</b> <?php echo smartDate($rev['hardware']['update_date']);?> by <?php echo getLinkToUser($u->getUser($rev['hardware']['updated_by']));?> (<a href="<?php echo $this->baseUrl."/".$this->controller."/differences/$lang/$id/0".$this->viewStatus;?>">diff</a>)</li> + <li class="page_history_current_item"><b><?php echo gtext("Current revision");?>:</b> <?php echo smartDate($rev['hardware']['update_date']);?> by <?php echo $u->getLinkToUserFromId($rev['hardware']['updated_by']);?> (<a href="<?php echo $this->baseUrl."/".$this->controller."/differences/$lang/$id/0".$this->viewStatus;?>">diff</a>)</li> <?php } ?> <?php } ?> <?php foreach ($rev2 as $rev) { ?> <li class="page_history_item"> - <a href="<?php echo $this->baseUrl."/".$this->controller."/revision/$lang/".$rev['revisions']['id_rev'].$this->viewStatus;?>"><?php echo smartDate($rev['revisions']['update_date']);?></a> by <?php echo getLinkToUser($u->getUser($rev['revisions']['updated_by']));?> + <a href="<?php echo $this->baseUrl."/".$this->controller."/revision/$lang/".$rev['revisions']['id_rev'].$this->viewStatus;?>"><?php echo smartDate($rev['revisions']['update_date']);?></a> by <?php echo $u->getLinkToUserFromId($rev['revisions']['updated_by']);?> <?php if (strcmp($rev['revisions']['id_rev'],$firstRev) !== 0) {?> (<a href="<?php echo $this->baseUrl."/".$this->controller."/differences/$lang/$id/".$rev['revisions']['id_rev'].$this->viewStatus;?>">diff</a>) diff --git a/h-source/Application/Views/right.php b/h-source/Application/Views/right.php index a6c7950..3bde69e 100644 --- a/h-source/Application/Views/right.php +++ b/h-source/Application/Views/right.php @@ -90,6 +90,7 @@ <a href="<?php echo $this->baseUrl."/download/index/$lang";?>"><img src="<?php echo $this->baseUrl;?>/Public/Img/download.png"></a> </div> + <?php if ( strcmp($this->controller,'wiki') !== 0 ) { ?> <div class="last_modifications"> <div class="last_modifications_title"> <?php echo gtext('last modifications');?> @@ -105,6 +106,7 @@ </span> </div> </div> + <?php } ?> <div class="statistics_ext_box"> <div class="statistics_int_title"> diff --git a/h-source/Public/Css/explorer6.css b/h-source/Public/Css/explorer6.css index c4bacc8..29b6456 100644 --- a/h-source/Public/Css/explorer6.css +++ b/h-source/Public/Css/explorer6.css @@ -93,10 +93,14 @@ ul#menuBlock li ul { { margin-top:-30px; } -.talk_numb_ext a +.talk_numb_ext a, .talk_numb_ext_wiki a { margin-bottom:0px; } +.talk_numb_ext_wiki +{ + width:130px; +} .language_links_box a.current_lang { background:#6495ED; diff --git a/h-source/Public/Css/explorer7.css b/h-source/Public/Css/explorer7.css index 4060474..f63bf5b 100644 --- a/h-source/Public/Css/explorer7.css +++ b/h-source/Public/Css/explorer7.css @@ -14,4 +14,12 @@ .last_modifications ul { margin-left:0px; +} +.talk_numb_ext a, .talk_numb_ext_wiki a +{ + margin-bottom:0px; +} +.talk_numb_ext_wiki +{ + width:130px; }
\ No newline at end of file diff --git a/h-source/Public/Css/main.css b/h-source/Public/Css/main.css index 3eed9d2..abdeb0a 100644 --- a/h-source/Public/Css/main.css +++ b/h-source/Public/Css/main.css @@ -684,7 +684,7 @@ ins .div_h1 { font:bold 15px/1 sans-serif,arial; - border-bottom:1px solid gray; + border-bottom:1px dashed #000; padding:3px 0px; margin:10px 0px; color:gray; @@ -1399,7 +1399,7 @@ ins text-align:left; margin-left:10px; } -.talk_numb_ext a +.talk_numb_ext a, .talk_numb_ext_wiki a { display:block; width:150px; @@ -1662,13 +1662,14 @@ td.text_item_date .wiki_external_box { - margin:4em 10px; + margin:4em 5px; clear:both; clear:right; } .wiki_page_title { font:bold 16px/1 sans-serif,arial; + color:gray; margin:20px 0px; padding-bottom:4px; border-bottom:1px solid #000; @@ -1676,4 +1677,11 @@ td.text_item_date .wiki_page_content { margin:2em 0px; +} + +.talk_numb_ext_wiki +{ + float:left; + text-align:left; + margin-left:10px; }
\ No newline at end of file diff --git a/h-source/tables.sql b/h-source/tables.sql index 3a50a1a..c59cf23 100644 --- a/h-source/tables.sql +++ b/h-source/tables.sql @@ -274,4 +274,7 @@ create table wiki_talk ( message text CHARACTER SET utf8 not null, id_wiki INT UNSIGNED NOT NULL, deleted char(4) not null default 'no' -)engine=innodb;
\ No newline at end of file +)engine=innodb; + +insert into wiki (title,title_clean,is_main) values ('Main Page','Main-Page','yes'); +update wiki set update_date=creation_date where title='Main Page';
\ No newline at end of file |