Commit 37cd9836 authored by Francesco Iannuzzelli's avatar Francesco Iannuzzelli

#21 Landing pages

parent d2c81a89
......@@ -45,8 +45,29 @@ echo "<p><a href=\"publish.php\">" . $hh->tr->Translate("publish") . "</a></p>\n
echo "<h3>" . $hh->tr->Translate("preview") . "</h3>\n";
echo "<ul>";
echo "<li><a href=\"../topics/preview.php?id_gtype=0\" target=\"_blank\">Homepage</a></li>\n";
foreach($conf->Get("landing") as $landing) {
echo "<li><a href=\"../topics/preview.php?id_gtype=0&subtype=landing&landing=$landing\" target=\"_blank\">$landing</a></li>\n";
$landings = $conf->Get("landing");
if(count($landings)>0) {
echo "<li><h4>Landing</h4>";
echo "<ul>";
foreach($landings as $landing) {
echo "<li><a href=\"../topics/preview.php?id_gtype=0&subtype=landing&landing=$landing\" target=\"_blank\">$landing</a></li>\n";
}
echo "</ul>";
echo "<li>";
}
include_once(SERVER_ROOT."/../classes/ontology.php");
$o = new Ontology();
$klandings = array();
$o->KeywordsLanding($klandings,false);
if(count($klandings)>0) {
echo "<li><h4>Keywords</h4>";
echo "<ul>";
foreach($klandings as $klanding) {
echo "<li><a href=\"../topics/preview.php?id_gtype=0&subtype=keyword&id_keyword={$klanding['id_keyword']}\" target=\"_blank\">{$klanding['keyword']}</a></li>\n";
}
echo "</ul>";
echo "<li>";
}
echo "</ul>";
......
......@@ -107,6 +107,39 @@ if ($from=="feed")
header("Location: feeds.php");
}
if ($from=="landing")
{
$action = $fh->ActionGet($post);
$id_keyword = $post['id_keyword'];
$keyword = $post['keyword'];
$content = $post['content'];
$youtube = $post['youtube'];
include_once(SERVER_ROOT."/../classes/ontology.php");
$o = new Ontology;
if ($action=="update")
{
if($id_keyword>0)
{
$o->KeywordLandingUpdate($id_keyword,$content,$youtube);
}
else
{
include_once(SERVER_ROOT."/../classes/keyword.php");
$k = new Keyword();
$id_k = $k->KeywordGetId($keyword);
if(!$id_k>0)
$ah->MessageSetTranslated("keyword &quot;$keyword&quot; not found");
else
{
$o->KeywordLandingInsert($id_k,$content,$youtube);
}
}
}
if ($action=="delete")
$o->KeywordLandingDelete($id_keyword);
header("Location: landings.php");
}
if ($from=="relation")
{
$action = $fh->ActionGet($post);
......
......@@ -51,8 +51,9 @@ echo "<h3>" . $trm13->Translate("keywords") . "</h3>";
echo "<ul>";
echo "<li><a href=\"keywords.php\">" . $hh->tr->Translate("list") . "</a></li>";
echo "<li><a href=\"keyword.php?id=0\">" . $hh->tr->Translate("add_new") . "</a></li>";
if($module_admin)
if($module_admin)
echo "<li><a href=\"feeds.php\">Feeds</a></li>";
echo "<li><a href=\"landings.php\">Landing</a></li>";
echo "</ul>";
echo "<h3><a href=\"relations.php\">" . $trm13->Translate("relations") . "</a></h3>";
......
<?php
/********************************************************************
PhPeace - Portal Management System
Copyright notice
(C) 2003-2019 Francesco Iannuzzelli <francesco@phpeace.org>
All rights reserved
This script is part of PhPeace.
PhPeace 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.
PhPeace 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.
The GNU General Public License (GPL) is available at
http://www.gnu.org/copyleft/gpl.html.
A copy can be found in the file COPYING distributed with
these scripts.
This copyright notice MUST APPEAR in all copies of the script!
********************************************************************/
if (!defined('SERVER_ROOT'))
define('SERVER_ROOT',$_SERVER['DOCUMENT_ROOT']);
$tinymce = true;
include_once(SERVER_ROOT."/include/header.php");
include_once(SERVER_ROOT."/../classes/ontology.php");
$o = new Ontology();
$trm13 = new Translator($hh->tr->id_language,13);
$id = $_GET['id'];
$title[] = array('Landing','landings.php');
if ($id>0)
{
$row = $o->KeywordLandingGet($id);
$title[] = array($row['keyword'],'');
}
else
{
$title[] = array('add_new','');
}
if ($module_admin)
$input_right = 1;
echo $hh->ShowTitle($title);
echo $hh->input_form_open();
echo $hh->input_hidden("from","landing");
echo $hh->input_hidden("id_keyword",$id);
echo $hh->input_table_open();
echo $hh->input_text($trm13->Translate("keyword"),"keyword",$row['keyword'],"50",0,$input_right && !$id>0);
echo $hh->input_wysiwyg("content","content",$row['content'],true,20,$input_right,true);
echo $hh->input_text("youtube playlist","youtube",$row['youtube'],50,0,$input_right);
$actions = array();
$actions[] = array('action'=>"update",'label'=>"submit",'right'=>$input_right);
$actions[] = array('action'=>"delete",'label'=>"delete",'right'=>($id>0 && $input_right));
echo $hh->input_actions($actions,$input_right);
echo $hh->input_table_close() . $hh->input_form_close();
if($module_admin && $id>0)
echo "<p><a href=\"keyword.php?id=$id\">Keyword definition</a></p>";
include_once(SERVER_ROOT."/include/footer.php");
?>
<?php
/********************************************************************
PhPeace - Portal Management System
Copyright notice
(C) 2003-2019 Francesco Iannuzzelli <francesco@phpeace.org>
All rights reserved
This script is part of PhPeace.
PhPeace 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.
PhPeace 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.
The GNU General Public License (GPL) is available at
http://www.gnu.org/copyleft/gpl.html.
A copy can be found in the file COPYING distributed with
these scripts.
This copyright notice MUST APPEAR in all copies of the script!
********************************************************************/
if (!defined('SERVER_ROOT'))
define('SERVER_ROOT',$_SERVER['DOCUMENT_ROOT']);
include_once(SERVER_ROOT."/include/header.php");
include_once(SERVER_ROOT."/../classes/ontology.php");
$title[] = array('landing','');
echo $hh->ShowTitle($title);
$o = new Ontology;
$num = $o->KeywordsLanding( $rows );
$table_headers = array('keyword','description');
$table_content = array('{LinkTitle("landing.php?id=$row[id_keyword]",$row[keyword])}','$row[description]');
echo $hh->ShowTable($rows, $table_headers, $table_content, $num);
if($module_admin) {
echo "<p><a href=\"landing.php?id=0\">" . $hh->tr->Translate("add_new") . "</a></p>\n";
}
include_once(SERVER_ROOT."/include/footer.php");
?>
......@@ -1642,6 +1642,9 @@ class IRL
case "landing":
$path .= "{$params['landing']}.html";
break;
case "keyword":
$path .= "{$params['keyword']}.html";
break;
default:
$hometype = $this->ini->GetModule("homepage","hometype",0);
$path .= $hometype>0? "index.php" : "index.html";
......
......@@ -4477,6 +4477,40 @@ class Layout
break;
}
}
if($this->subtype=='keyword') {
include_once(SERVER_ROOT."/../classes/ontology.php");
$o = new Ontology();
$keyword = $o->KeywordLandingGet($params['id_keyword']);
if(isset($keyword['id_keyword'])) {
$k_array = $this->KeywordItem($keyword);
$k_array['description'] = $keyword['description'];
$k_array['content'] = array('xvalue'=>$keyword['content']);
$k_array['youtube'] = $keyword['youtube'];
$k_array['id_type'] = $keyword['id_type'];
$this->Urlify($k_array,"keyword",array('k'=>$keyword['keyword']),true);
include_once(SERVER_ROOT."/../classes/keyword.php");
$k = new Keyword();
$articles = array();
$num_articles = $k->UseArticlesPaged($articles,$keyword['id_keyword'],0,0);
$articles_paged = $this->Page($articles,$num_articles);
$k_array['articles'] = $articles_paged;
$links = $k->UseLinks($keyword['id_keyword'],0,$this->records_per_page);
$k_links = array();
foreach($links as $link) {
$k_links['l_'.$link['id_link']] = $this->LinkItem($link);
}
$k_array['links'] = $k_links;
include_once(SERVER_ROOT."/../classes/events.php");
$ee = new Events();
$events = $ee->Keyword($keyword['id_keyword'], $this->records_per_page);
$k_events = array();
foreach($events as $event) {
$k_events['e_'.$event['id_event']] = $this->EventItem($event);
}
$k_array['events'] = $k_events;
$home['keyword'] = $k_array;
}
}
if($this->subtype=='landing') {
$home['publish']['landing'] = $params['landing'];
}
......
......@@ -232,6 +232,45 @@ class Ontology
Db::finish( $res, $db);
}
public function KeywordLandingDelete($id_keyword)
{
$db =& Db::globaldb();
$db->begin();
$db->lock( "keywords_landing" );
$res[] = $db->query( "DELETE FROM keywords_landing WHERE id_keyword=$id_keyword" );
Db::finish( $res, $db);
}
public function KeywordLandingGet($id_keyword)
{
$row = array();
$db =& Db::globaldb();
$sqlstr = "SELECT kl.id_keyword,kl.content,k.keyword,kl.youtube,k.description,k.id_type
FROM keywords_landing kl
INNER JOIN keywords k ON kl.id_keyword=k.id_keyword
WHERE kl.id_keyword=$id_keyword";
$db->query_single($row, $sqlstr);
return $row;
}
public function KeywordLandingInsert($id_keyword,$content,$youtube)
{
$db =& Db::globaldb();
$db->begin();
$db->lock( "keywords_landing" );
$res[] = $db->query( "INSERT INTO keywords_landing (id_keyword,content,youtube) VALUES ($id_keyword,'$content','$youtube')" );
Db::finish( $res, $db);
}
public function KeywordLandingUpdate($id_keyword,$content,$youtube)
{
$db =& Db::globaldb();
$db->begin();
$db->lock( "keywords_landing" );
$res[] = $db->query( "UPDATE keywords_landing SET content='$content',youtube='$youtube' WHERE id_keyword=$id_keyword" );
Db::finish( $res, $db);
}
public function KeywordNeighbours($id_keyword,$strict=false)
{
$neighbours = array();
......@@ -296,6 +335,16 @@ class Ontology
return $db->QueryExe($rows, $sqlstr, $paged);
}
public function KeywordsLanding( &$rows, $paged=true )
{
$db =& Db::globaldb();
$sqlstr = "SELECT kl.id_keyword,k.keyword,kl.content,k.description,k.id_type,kl.youtube
FROM keywords_landing kl
INNER JOIN keywords k ON kl.id_keyword=k.id_keyword
ORDER BY k.keyword";
return $db->QueryExe($rows, $sqlstr, $paged);
}
public function LoadTree($id_type)
{
$tree = array();
......
......@@ -59,7 +59,7 @@ define('PHPEACE_VERSION',"2.6.20");
* PhPeace Database version number (integer)
* Increased by 1 for each DB schema change
*/
define('PHPEACE_DB_VERSION',267);
define('PHPEACE_DB_VERSION',268);
/* ##################################### */
......
......@@ -126,6 +126,9 @@ class PhPeaceUpdates
{
switch($version_new)
{
case "299":
$this->UpdateDB("268");
break;
case "296":
$this->UpdateDB("267");
break;
......@@ -467,6 +470,9 @@ class PhPeaceUpdates
$dbconf = $conf->Get("dbconf");
switch($db_version)
{
case "268":
$db->TableCreate('keywords_landing', "`id_keyword` mediumint(9) NOT NULL DEFAULT '0',`content` TEXT NOT NULL,`youtube` VARCHAR(150) NOT NULL DEFAULT ''");
break;
case "267":
$db->query("ALTER TABLE features CHANGE COLUMN condition_id condition_id MEDIUMINT(6) UNSIGNED NOT NULL DEFAULT '0'");
break;
......
......@@ -405,6 +405,14 @@ class PublishManager
foreach($this->landing as $landing) {
$this->Output("homepage",array('subtype'=>'landing','landing'=>$landing),TRUE);
}
include_once(SERVER_ROOT."/../classes/ontology.php");
$o = new Ontology();
$klanding = array();
$o->KeywordsLanding($klanding,false);
foreach($klanding as $keyword) {
$this->MessageSet("publish_keyword",array("{$this->layout->pub_web}/{$keyword['keyword']}",$keyword['keyword']));
$this->Output("homepage",array('subtype'=>'keyword','id_keyword'=>$keyword['id_keyword'],'keyword'=>$keyword['keyword']),TRUE);
}
}
$this->MessageSet("publish_home",array($this->layout->pub_web));
}
......
......@@ -994,7 +994,7 @@ CREATE TABLE `features` (
`condition_var` varchar(32) NOT NULL DEFAULT '',
`condition_type` tinyint(2) NOT NULL DEFAULT '0',
`condition_value` varchar(32) NOT NULL DEFAULT '',
`condition_id` smallint(3) NOT NULL DEFAULT '0',
`condition_id` mediumint(6) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id_feature`)
);
/*!40101 SET character_set_client = @saved_cs_client */;
......@@ -1374,6 +1374,14 @@ CREATE TABLE `keywords_feeds` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `keywords_landing` (
`id_keyword` mediumint(9) NOT NULL DEFAULT '0',
`content` text COLLATE utf8_unicode_ci NOT NULL,
`youtube` varchar(150) COLLATE utf8_unicode_ci NOT NULL DEFAULT ''
);
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `keywords_use` (
`id_keyword` smallint(6) NOT NULL DEFAULT '0',
`id` mediumint(6) unsigned NOT NULL DEFAULT '0',
......
......@@ -740,6 +740,7 @@ publish_force = Alternatively you can <a href="%s">force the publish</a>, but th
publish_heavy = It's suggested that you <a href="%s">insert the update in the queue</a> so that all the articles will be rebuilt by the system at a suitable time
publish_heavy_warning = WARNING: many web pages (%s) must be rebuilt by the system in background.
publish_home = Updated <a href="%s" target="_blank">homepage</a>
publish_keyword = Published keyword %s
publish_map = Updated <a href="%s" target="_blank">site map</a>
publish_next_step = Click here to execute the next publishing step
publish_queued = The update will be executed as soon as possible
......
......@@ -740,6 +740,7 @@ publish_force = In alternativa si può <a href="%s">forzare la pubblicazione</a>
publish_heavy = Si consiglia di <a href="%s">inserire l'aggiornamento nella coda di pubblicazione</a> in modo che le pagine siano ricostruite dal sistema al più presto
publish_heavy_warning = ATTENZIONE: un alto numero di pagine (%s) devono essere ricostruite.
publish_home = Aggiornata <a href="%s" target="_blank">homepage</a>
publish_keyword = Pubblicata parola chiave <a href="%s" target="_blank">%s</a>
publish_map = Aggiornata <a href="%s" target="_blank">mappa del sito</a>
publish_next_step = Clicca qui per eseguire il passo successivo della pubblicazione
publish_queued = L'aggiornamento verrà eseguito dal sistema al più presto
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment