104 lines
3.2 KiB
PHP
104 lines
3.2 KiB
PHP
<?php
|
|
|
|
|
|
require_once(dirname(__FILE__)."/../load.php");
|
|
|
|
GUIHandler::generateHtmlHeaders(array(),true);
|
|
|
|
if (!AdminLoginManager::isLogged()){
|
|
GUIHandler::redirect("admin/login.php");
|
|
}
|
|
else if (!AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_EDITORE_SUPERVISOR) &&
|
|
!AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_EDITORE)){
|
|
GUIHandler::redirect("admin/index.php");
|
|
}
|
|
|
|
$edit = false;
|
|
$notiziaId = PostHandler::get("id");
|
|
|
|
$notizia = new NotiziaModel();
|
|
// var_dump($notizia);
|
|
if(!is_null($notiziaId)){
|
|
$edit = true;
|
|
$notizia = GlobalVariables::get("dao")->getFirst("NotiziaModel",array("id"=>$notiziaId));
|
|
// echo "pene";
|
|
if(is_null($notizia)){
|
|
GUIHandler::redirect("admin/myNotizie.php");
|
|
}
|
|
|
|
if (!AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_EDITORE_SUPERVISOR) &&
|
|
AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_EDITORE)){
|
|
if(strcmp($notizia->about->owner, AdminLoginManager::getLogged()->id) != 0){
|
|
GUIHandler::redirect("admin/myNotizie.php");
|
|
}
|
|
}
|
|
}
|
|
|
|
MenuGenerator::generateMenu();
|
|
HTMLHelper::generateAdminHead();
|
|
|
|
if(!is_null(PostHandler::get("action")) && strcmp(PostHandler::get("action"), "")!=0){
|
|
$save = PostHandler::get("action");
|
|
if(strcmp($save, "save")==0){
|
|
|
|
$notizia->titolo = PostHandler::get("titolo");
|
|
$notizia->sottotitolo = PostHandler::get("sottotitolo");
|
|
$notizia->testo = PostHandler::get("testo");
|
|
$mongoDate = new MongoDate(strtotime(PostHandler::get("data")));
|
|
// $mongoDate = new DateTime('2013-09-22T10:41:44.451999');
|
|
// $seconds = $mongoDate->getTimestamp();
|
|
|
|
// $microseconds = $mongoDate->format("u");
|
|
$notizia->about->data = $mongoDate;
|
|
|
|
if(!$edit){
|
|
$notizia->about->author = AdminLoginManager::getLogged()->nome." ".AdminLoginManager::getLogged()->nome;
|
|
$notizia->about->owner = AdminLoginManager::getLogged()->id;
|
|
}
|
|
|
|
|
|
GlobalVariables::get("dao")->save($notizia);
|
|
GUIHandler::redirect("admin/listNotizie.php");
|
|
}
|
|
else{
|
|
echo "non salvo";
|
|
}
|
|
}
|
|
else{
|
|
echo "post nullo";
|
|
}
|
|
|
|
?>
|
|
<div><?php
|
|
var_dump($notizia->about->data);?>
|
|
<form method="POST" id="notiziaForm">
|
|
<input type="hidden" value="<?php echo $notiziaId;?>" name="id"/>
|
|
<div style="padding:10px;">
|
|
<div style="padding:5px; display:inline-block;">Titolo:
|
|
<textarea name="titolo" rows="2" cols="30" style="resize:none;"><?php echo $notizia->titolo;?></textarea>
|
|
</div>
|
|
<div style="padding:5px;display:inline-block;">Sottotitolo:
|
|
<textarea name="sottotitolo" rows="2" cols="30" style="resize:none;"><?php echo $notizia->sottotitolo;?></textarea>
|
|
</div>
|
|
</div>
|
|
<textarea name="testo" id="editore_testo" rows="10" cols="80"><?php echo $notizia->testo;?></textarea>
|
|
<div>Data: <input type="text" id="datepicker" name="data" value="<?php echo date("d-m-Y",$notizia->about->data->sec);?>"></div>
|
|
|
|
<input type="hidden" name="action" value=""/>
|
|
</form>
|
|
|
|
<a href="#" id="submit" >Submit</a>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
CKEDITOR.replace( 'editore_testo');
|
|
$(document).ready(function(event){
|
|
$("#submit").click(function(event){
|
|
$("form#notiziaForm input[type=hidden][name=action]").val("save");
|
|
$("form#notiziaForm").submit();
|
|
});
|
|
|
|
$("#datepicker").datepicker({dateFormat:"dd-mm-yy"});
|
|
});
|
|
</script>
|