/**
  * Analyze the action and determine a request.
  *
  * @return null
  */
 public function analyzeAction()
 {
     //Overload
     switch ($this->petitionAction) {
         /**
          * 
          */
         case 'list':
             $this->createModel();
             $storyModel = new StoryModel();
             $stories = $storyModel->getStories();
             $mythModel = new MythModel();
             $myths = $mythModel->getMyths();
             $sliders = $this->actualModel->getSliders();
             $this->createView($this->petitionAction);
             $this->actualView->render($sliders, $stories, $myths);
             break;
             /**
              * 
              */
         /**
          * 
          */
         case 'add':
             if (empty($_POST)) {
                 $this->createView($this->petitionAction);
                 $this->actualView->render();
             } else {
                 $this->createModel();
                 $slider = new Slider("", $_POST['title'], $_POST['body'], $_POST['link']);
                 $res = $this->actualModel->addSlider($slider);
                 $lastId = getLastId("slider");
                 $arrayFiles = $_FILES["slider_image"];
                 if ($res && $arrayFiles) {
                     for ($i = 0; $i < count($arrayFiles["name"]); $i++) {
                         if ($arrayFiles["error"][$i] === 0) {
                             if ($this->actualModel->validateSliderImage($arrayFiles["name"][$i], $arrayFiles["type"][$i])) {
                                 $this->actualModel->addSliderImage($arrayFiles["tmp_name"][$i], $arrayFiles["type"][$i], $lastId);
                             }
                         }
                     }
                 }
                 $this->createLoadingView();
                 $this->actualView->render();
                 $this->redirect();
             }
             break;
             /**
              * 
              */
         /**
          * 
          */
         case 'edit':
             if (empty($_POST)) {
                 $this->createModel();
                 $slider = $this->actualModel->getSlider($_GET["id_slider"]);
                 $this->createView($this->petitionAction);
                 $this->actualView->render($slider);
             } else {
                 $this->createModel();
                 $slider = new Slider($_GET['id_slider'], $_POST['title'], $_POST['body'], $_POST['link']);
                 $this->actualModel->editSlider($slider);
                 $this->createLoadingView();
                 $this->actualView->render();
                 $this->redirect();
             }
             break;
             /**
              * 
              */
         /**
          * 
          */
         case 'delete':
             $this->createModel();
             $this->actualModel->deleteSliderGallery($_GET["id_slider"]);
             $this->actualModel->deleteSlider($_GET['id_slider']);
             $this->createLoadingView();
             $this->actualView->render();
             $this->redirect();
             break;
             /**
              * 
              */
         /**
          * 
          */
         case 'edit_gallery':
             $this->createModel();
             $gallery = $this->actualModel->getGallery($_GET["id_slider"]);
             $this->createView("Edit_Gallery", true);
             //Corregir
             $this->actualView->render($gallery);
             break;
             /**
              * 
              */
         /**
          * 
          */
         case 'add_gallery':
             $this->createModel();
             $arrayFiles = $_FILES["slider_image"];
             if ($arrayFiles) {
                 for ($i = 0; $i < count($arrayFiles["name"]); $i++) {
                     if ($arrayFiles["error"][$i] === 0) {
                         if ($this->actualModel->validateSliderImage($arrayFiles["name"][$i], $arrayFiles["type"][$i])) {
                             $this->actualModel->addSliderImage($arrayFiles["tmp_name"][$i], $arrayFiles["type"][$i], $_GET["id_slider"]);
                         }
                     }
                 }
             }
             $this->createLoadingView();
             $this->actualView->render();
             $this->redirect();
             break;
             /**
              * 
              */
         /**
          * 
          */
         case 'delete_gallery':
             $this->createModel();
             $this->actualModel->deleteSliderImage($_GET["id_slider_image"]);
             $this->createLoadingView();
             $this->actualView->render();
             $this->redirect();
             break;
     }
 }
Exemple #2
0
	echo $rec[4];
	echo " ";
	echo $rec[5];
	echo " ";
	echo $rec[6];
	echo " ";
	echo $rec[7];
	echo " ";
	echo $rec[8];
	echo "<br/>";
}
//var_dump($array);*/
include 'init.php';
include ROOT_PATH . '/application/models/storyModel.php';
//include(ROOT_PATH . '/application/userModel.php');
$sModel = new StoryModel();
//$sModel->setApvDate(1, "08/12/2015");
//$sModel->createStory("212414600", "200020088", "A gift to my plus 1", "08/13/2015", "Integrity", "Passion", "Humility");
//$success = $sModel->setStatus(1, "Approved");
/*if($success) {
	echo "Status Update Successful";
} else {
	echo "Status Update Failed";
}
echo "<br/>";*/
//$rec = $sModel->getStoryByID(3);
//test for creating vote
//$sModel->voteNo(1, "212414600");
/*$voteList = $sModel->getVotes(1);
echo "Yes Votes: " . $voteList[0];
echo "<br/>";