editSondaggi crea e permette di editare sondaggi....ma dublica le
opzioni di voto in edit....da fixare!!!!
This commit is contained in:
@@ -123,7 +123,7 @@ try{
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<textarea name="testo" id="editore_testo" rows="10" cols="80"><?php echo $notizia->testo;?></textarea>
|
||||
<textarea name="testo" id="editore_testo" rows="10" cols="80"><?php echo $notizia->testo;?></textarea>
|
||||
<div style="display:inline-block;">Data: <input type="text" id="datepicker" name="data" value="<?php echo ($edit)? date("d-m-Y",$notizia->about->data->sec):date("d-m-Y");?>"></div>
|
||||
<div style="display:inline-block;">Time: <input type="text" id="timepicker" name="time" value="<?php echo ($edit)? date("H:i",$notizia->about->data->sec):date("H:i");?>"></div>
|
||||
<div style="display:inline-block;">Author: <input value="<?php echo $notizia->about->author;?>" name="author"/></div>
|
||||
@@ -131,7 +131,7 @@ try{
|
||||
<input type="hidden" name="action" value=""/>
|
||||
</form>
|
||||
|
||||
<a href="#" id="submit" >Submit</a>
|
||||
<div style="display:inline-block;margin:25px 5px;"><a href="#" id="submit" >Submit</a></div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
CKEDITOR.replace( 'editore_testo');
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
<?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");
|
||||
}
|
||||
|
||||
try{
|
||||
$error = "";
|
||||
$notiziaId = PostHandler::get("id");
|
||||
$numInput = 1;
|
||||
// $optArr = "no chiave action in post";
|
||||
|
||||
$notizia = new NotiziaModel();
|
||||
// $ansa = false;
|
||||
// var_dump($notizia);
|
||||
if(!is_null($notiziaId) && strcmp($notiziaId, "")!=0){
|
||||
// $optArr = "è presente la chiave action in post";
|
||||
$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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("action", $_POST)){
|
||||
if(strcmp(PostHandler::get("action"),"save")==0){
|
||||
$notizia->sondaggio->titolo = PostHandler::get("sondaggioTitolo");
|
||||
$opzioni = PostHandler::get("opzioniSondaggio");
|
||||
$optArr = explode("~",$opzioni);
|
||||
if(sizeof($optArr)>0){
|
||||
foreach ($optArr as $opzione){
|
||||
$notizia->sondaggio->voci[] = array("nome"=>$opzione,"voti"=>0);
|
||||
}
|
||||
}
|
||||
$notizia->sondaggio->votanti = array();
|
||||
GlobalVariables::get("dao")->save($notizia);
|
||||
|
||||
GUIHandler::redirectPost("admin/homeNotizie.php",array("id"=>$notiziaId));
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
GUIHandler::redirect("admin/listNotizie.php");
|
||||
}
|
||||
|
||||
MenuGenerator::generateMenu();
|
||||
HTMLHelper::generateAdminHead();
|
||||
|
||||
}catch(GUIException $ex){
|
||||
$error = $ex->getMessage();
|
||||
}catch (Exception $exec){
|
||||
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_ERROR, $exec->getMessage());
|
||||
$error = "Si è verificato un errore inaspettato durante l'esecuzione della pagina. Se l'errore persiste contattare il supporto tecnico.";
|
||||
}
|
||||
|
||||
?>
|
||||
<div>
|
||||
<div class="sondaggioContainer">
|
||||
<form id="formSondaggi" method="POST" action="">
|
||||
<input type="hidden" name="id" value="<?php echo $notiziaId;?>" />
|
||||
<textarea id="editore_testo" name="sondaggioTitolo" rows="2" cols="30" style="resize:none;"><?php echo $notizia->sondaggio->titolo;?></textarea>
|
||||
<div class="sondaggioOptions">
|
||||
<?php if($notizia->hasProperty("sondaggio") && !is_null($notizia->sondaggio)){
|
||||
foreach($notizia->sondaggio->voci as $opzione){?>
|
||||
<div class="singleOption"><span style="margin:10px;"><?php echo $opzione->nome;?></span><a href="#" class="rmOption" onclick="javascript:$(this).parent().remove();inputValue.splice(inputValue.indexOf('<?php echo $opzione->nome;?>'),1);" style="text-decoration: none">delete</a></div>
|
||||
<?php }?>
|
||||
<?php }?>
|
||||
</div>
|
||||
<div style="margin:10px;">Opzione:<input name="options" value=""/><a href="" id="addOption" style="text-decoration: none; margin:5px;">Aggiungi</a></div>
|
||||
<input type="hidden" name="opzioniSondaggio" value="" />
|
||||
<input type="hidden" name="action" value="" />
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<a href="#" id="submit">Salva</a>
|
||||
<a href="#" id="back">Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var inputValue = [];
|
||||
$(document).ready(function (){
|
||||
$(".sondaggioOptions .singleOption").each(function(){
|
||||
inputValue.push($(this).find("span").html());
|
||||
});
|
||||
CKEDITOR.replace('editore_testo');
|
||||
|
||||
$("#addOption").click(function (){
|
||||
var index = 0;
|
||||
var cur = $("form#formSondaggi input[name=options]").val();
|
||||
|
||||
if($.inArray(cur,inputValue)!=-1){
|
||||
alert("Esiste già un opzione con questo nome: "+cur);
|
||||
}
|
||||
else{
|
||||
var rep = cur;
|
||||
cur = rep.replace(/\~/g," ");
|
||||
inputValue.push(cur);
|
||||
// alert(inputValue.splice(inputValue.indexOf(cur),1));
|
||||
$(".sondaggioOptions").append('<div class="singleOption"><span style="margin:10px;">'+cur+'</span><a href="#" class="rmOption" onclick="javascript:$(this).parent().remove();inputValue.splice(inputValue.indexOf(\''+cur+'\'),1);" style="text-decoration: none">delete</a></div>');
|
||||
}
|
||||
// index = inputValue.indexOf($("form#formSondaggi input[name=options]").val())
|
||||
|
||||
$("form#formSondaggi input[name=options]").val("");
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#submit").click(function (){
|
||||
var submitOptions = "";
|
||||
submitOptions = inputValue.join("~");
|
||||
$("form#formSondaggi input[type=hidden][name=opzioniSondaggio]").val(submitOptions);
|
||||
$("form#formSondaggi input[type=hidden][name=action]").val("save");
|
||||
$("form#formSondaggi").submit();
|
||||
});
|
||||
|
||||
$("#back").click(function(event){
|
||||
$("form#formSondaggi").attr("action","homeNotizie.php");
|
||||
$("form#formSondaggi input[type=hidden][name=id]").val("<?php echo $notiziaId;?>");
|
||||
$("form#formSondaggi").submit();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -75,7 +75,11 @@ try{
|
||||
<li><a href="#" id="notiziaMenu_multimedia">Gestisci Multimedia</a></li>
|
||||
<li><a href="#" id="notiziaMenu_ansa"><?php echo ($ansa)?"Rimuovi dall'Ansa":"Aggiungi all'Ansa";?></a></li>
|
||||
<li><a href="#" id="notiziaMenu_commenti">Visualizza Commenti</a></li>
|
||||
<li><a href="#" id="notiziaMenu_sondaggi">Visualizza Sondaggio</a></li>
|
||||
<?php if($notizia->hasProperty("sondaggio") && !is_null($notizia->hasProperty("sondaggio"))){?>
|
||||
<li><a href="#" id="notiziaMenu_addSondaggi">Visualizza Sondaggio</a></li>
|
||||
<?php }else{?>
|
||||
<li><a href="#" id="notiziaMenu_addSondaggi">Crea Sondaggio</a></li>
|
||||
<?php } ?>
|
||||
<li><a href="listNotizie.php" id="notiziaMenu_back">Back</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -108,5 +112,10 @@ try{
|
||||
$("#notiziaMenu_commenti").click(function (){
|
||||
openPagePost("notiziaCommentiList.php", [{name:"id",value:"<?php echo $notiziaId;?>"}]);
|
||||
});
|
||||
|
||||
$("#notiziaMenu_addSondaggi").click(function (){
|
||||
openPagePost("editSondaggi.php", [{name:"id",value:"<?php echo $notiziaId;?>"}]);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user