Modifiche alla funzione di import dei vecchi dati
This commit is contained in:
@@ -47,7 +47,12 @@ $dati = $statement->fetchALL(PDO::FETCH_CLASS,"stdClass");
|
||||
|
||||
$notizia->titolo = $ele->mainTitle;
|
||||
$notizia->sottotitolo = $ele->secTitle;
|
||||
$notizia->testo = $ele->corpo;
|
||||
|
||||
$corpo = $ele->corpo;
|
||||
$corpo = preg_replace("~link[(]([^,]+),([^)]+)[)];~", '<a href="$2" target="_blank">$1</a>', $corpo);
|
||||
$corpo = preg_replace("~mail[(]([^,]+),([^)]+)[)];~", '<a href="mailto:$2" target="_blank">$1</a>', $corpo);
|
||||
|
||||
$notizia->testo = $corpo;
|
||||
|
||||
switch ($ele->menu){
|
||||
case 1://POLITICA
|
||||
@@ -96,6 +101,20 @@ $dati = $statement->fetchALL(PDO::FETCH_CLASS,"stdClass");
|
||||
$curFile = $curDir."/big/".$i++.".jpg";
|
||||
}
|
||||
}
|
||||
|
||||
// $statement = $pdo->query("select * from commenti where notizia = ".$ele->id);
|
||||
// $commenti = $statement->fetchALL(PDO::FETCH_CLASS,"stdClass");
|
||||
// if (sizeof($commenti)>0){
|
||||
// foreach ($commenti as $commento){
|
||||
// $comm = new stdClass();
|
||||
// $comm->notizia = $notizia->id;
|
||||
// $comm->status = CommentoModel::STATUS_ACCEPTED;
|
||||
// $comm->date = new MongoDate(strtotime($commento->data));
|
||||
// $comm->titolo = $commento->titolo;
|
||||
// $comm->testo = $commento->testo;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ class MediaModel extends Model implements MediaInterface{
|
||||
|
||||
|
||||
private $mediaRenderer;
|
||||
public function getRenderer(){
|
||||
return $this->mediaRenderer;
|
||||
}
|
||||
|
||||
|
||||
public function __construct($saveableObject = null){
|
||||
|
||||
@@ -76,6 +76,10 @@ class GUIHandler {
|
||||
echo '});'."\n";
|
||||
echo '</script>'."\n";
|
||||
}
|
||||
|
||||
if (array_key_exists("additionalHeaders", $data) && is_array($data["additionalHeaders"]) && sizeof($data["additionalHeaders"])>0){
|
||||
echo implode("\n", $data["additionalHeaders"]);
|
||||
}
|
||||
echo '</head>';
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class MediaImage extends MediaRenderer{
|
||||
if(array_key_exists("size", $opt) && array_key_exists($opt["size"], self::$SIZES)){
|
||||
$size = $opt["size"];
|
||||
}
|
||||
return '<img src="'.GUIHandler::getBaseUrl().'getImage.php?id='.$this->id.'&size='.$size.'"/>';
|
||||
return '<img src="'.$this->getImageLink($size).'"/>';
|
||||
}
|
||||
|
||||
public function render(array $opt = array ()){
|
||||
@@ -24,5 +24,13 @@ class MediaImage extends MediaRenderer{
|
||||
$basepath = GlobalVariables::get("config")->paths->media;
|
||||
return $basepath."/".$this->id.".".$this->extension;
|
||||
}
|
||||
|
||||
public function getImageLink($size){
|
||||
if(!array_key_exists($size, self::$SIZES)){
|
||||
$size = MediaRendererInterface::SIZE_ORIGINAL;
|
||||
}
|
||||
return GUIHandler::getBaseUrl().'getImage.php?id='.$this->id.'&size='.$size;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -10,12 +10,20 @@ class MediaYoutube extends MediaRenderer{
|
||||
public function asText(array $opt = array()){
|
||||
// return $this->link;
|
||||
return '<iframe width="420" height="315"
|
||||
src="'.$this->link.'?autoplay=0" frameborder="0"></iframe>';
|
||||
src="'.$this->getVideoLink().'" frameborder="0"></iframe>';
|
||||
// return '<iframe width="560" height="315" src="https://www.youtube.com/embed/4qkv-iy_MaQ" frameborder="0" allowfullscreen></iframe>';
|
||||
}
|
||||
|
||||
public function render(array $opt = array()){
|
||||
echo $this->asText($opt);
|
||||
}
|
||||
|
||||
public function getThumbnailLink(){
|
||||
return 'http://i.ytimg.com/vi/'.$this->link.'/2.jpg';
|
||||
}
|
||||
|
||||
public function getVideoLink(){
|
||||
return 'https://www.youtube.com/embed/'.$this->link.'?autoplay=0';
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -33,7 +33,21 @@ try{
|
||||
$saveable = new stdClass();
|
||||
$saveable->mediaType = $mediaType;
|
||||
if(strcmp($mediaType,MediaModel::TYPE_YOUTUBE)==0){
|
||||
$saveable->link = PostHandler::get("data");
|
||||
$matches = array();
|
||||
var_dump(PostHandler::get("data"));
|
||||
if ( preg_match("~^https[:]//youtu\.be/(.+)$~", trim(PostHandler::get("data")), $matches) ){
|
||||
$saveable->link = $matches[1];
|
||||
}
|
||||
else if (preg_match("~https[:]//www\.youtube\.com/embed/([^\"]+)[\"]~", trim(PostHandler::get("data")), $matches)){
|
||||
$saveable->link = $matches[1];
|
||||
}
|
||||
else if (preg_match("~https[:]//www\.youtube\.com/watch[?]v[=](.+)$~", trim(PostHandler::get("data")), $matches)){
|
||||
$saveable->link = $matches[1];
|
||||
}
|
||||
else {
|
||||
throw new GUIException("Formato del link youtube non valido");
|
||||
}
|
||||
// $saveable->link = PostHandler::get("data");
|
||||
$media = DaoMediaHandler::createNewTextBasedMedia($saveable);
|
||||
}
|
||||
else if(strcmp($mediaType,MediaModel::TYPE_HTML5)==0){
|
||||
|
||||
+18
-1
@@ -17,7 +17,7 @@ try {
|
||||
AnalyticsHelper::logNotiziaImpression($articolo->id);
|
||||
AnalyticsHelper::logPageImpression();
|
||||
|
||||
GUIHandler::generateHtmlHeaders();
|
||||
|
||||
|
||||
$media = DaoMediaHandler::getMainMediaFromModel($articolo);
|
||||
$medias = DaoMediaHandler::getMedias($articolo);
|
||||
@@ -29,12 +29,27 @@ try {
|
||||
|
||||
$data = date("d",$articolo->about->data->sec)." ".$mesi[date("n",$articolo->about->data->sec)]." ".date("Y",$articolo->about->data->sec);
|
||||
|
||||
$additionalHeaders = array();
|
||||
$additionalHeaders[] = '<meta property="og:url" content="'.$_SERVER['REQUEST_URI'].'"/>';
|
||||
$additionalHeaders[] = '<meta property="og:site_name" content="I Fatti di Napoli"/>';
|
||||
$additionalHeaders[] = '<meta property="og:title" content="'.preg_replace('/"/', '\"', strip_tags($articolo->titolo)).'"/>';
|
||||
$additionalHeaders[] = '<meta property="og:description" content="'.preg_replace('/"/', '\"', strip_tags($articolo->sottotitolo)).'"/>';
|
||||
|
||||
$mediaMetaInfo = '';
|
||||
if ($media->mediaType == MediaModel::TYPE_LOCALVIDEO || $media->mediaType == MediaModel::TYPE_YOUTUBE){
|
||||
$mediaMetaInfo = 'itemprop="video"';
|
||||
if ($media->mediaType == MediaModel::TYPE_YOUTUBE){
|
||||
$additionalHeaders[] = '<meta property="og:image" content="'.$media->getRenderer()->getThumbnailLink().'"/>';
|
||||
|
||||
$additionalHeaders[] = '<meta property="og:video" content="'.$media->getRenderer()->getVideoLink().'"/>';
|
||||
$additionalHeaders[] = '<meta property="og:video:type" content="application/x-shockwave-flash"/>';
|
||||
$additionalHeaders[] = '<meta property="og:video:width" content="240"/>';
|
||||
$additionalHeaders[] = '<meta property="og:video:height" content="205"/>';
|
||||
}
|
||||
}
|
||||
else if ($media->mediaType == MediaModel::TYPE_IMAGE){
|
||||
$mediaMetaInfo = 'itemprop="image"';
|
||||
$additionalHeaders[] = '<meta property="og:image" content="'.$media->getRenderer()->getImageLink(MediaRenderer::SIZE_SMALL).'"/>';
|
||||
}
|
||||
}catch(GUIException $ex){
|
||||
$error = $ex->getMessage();
|
||||
@@ -44,9 +59,11 @@ try {
|
||||
|
||||
GUIHandler::redirect("index.php");
|
||||
}
|
||||
GUIHandler::generateHtmlHeaders(array("additionalHeaders"=>$additionalHeaders));
|
||||
?>
|
||||
<div style="width:1000px;margin-left:auto;margin-right:auto;" itemscope itemtype="http://schema.org/Article">
|
||||
<?php
|
||||
|
||||
GUIHandler::generateHeadPublic();
|
||||
GUIHandler::generateMenu();
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user