Exemplo n.º 1
0
 public function add()
 {
     //name
     $nome = DataHandler::getValueByArrayIndex($_POST, "nome");
     //title
     $sobreNome = DataHandler::getValueByArrayIndex($_POST, "sobreNome");
     //author
     $email = DataHandler::getValueByArrayIndex($_POST, "email");
     //hat
     $companhia = DataHandler::getValueByArrayIndex($_POST, "companhia");
     //slug
     $profissao = DataHandler::getValueByArrayIndex($_POST, "provissao");
     //key_words
     $arquiteto = DataHandler::getValueByArrayIndex($_POST, "arquiteto");
     $erros = array();
     //validação
     if (!Validation::validateEmail($email)) {
         $erros[] = "email inválido";
     }
     if (!$nome) {
         $erros[] = "nome inválido";
     }
     if (!$sobreNome) {
         $erros[] = "sobrenome incorreto";
     }
     $ReturnResultVO = new ReturnResultVO($erros);
     if (!count($erros) > 0) {
         //nao tem erros na validação
         $ContentSiteVO = new ContentSiteVO();
         $ContentSiteVO->setName($nome);
         $ContentSiteVO->setTitle($sobreNome);
         $ContentSiteVO->setAuthor($email);
         $ContentSiteVO->setHat($companhia);
         $ContentSiteVO->setSlug($profissao);
         $ContentSiteVO->setKeyWords($arquiteto);
         $ReturnResultVO = $ContentSiteVO->commit();
         if ($ReturnResultVO->success) {
             //agora poe esse content na categoria correta
             $CategoryVO = new CategoryVO();
             echo "id de category necessária para newslatter funcionar";
             exit;
             $CategoryVO->setId(127, TRUE);
             if ($ContentSiteVO->getId() > 0) {
                 $CategoryVO->addLink("newslatter", $ContentSiteVO->getId());
                 $CategoryVO->commit();
             }
         }
     }
     echo $ReturnResultVO->toJson();
     exit;
 }
Exemplo n.º 2
0
 protected function getContent($id, $width = "400", $height = "400")
 {
     //pega a CategoryVO
     $ContentVO = new ContentSiteVO();
     $ContentVO->setId($id, TRUE);
     $images = $ContentVO->getImages();
     $stdResult = new stdClass();
     $stdResult->id = $ContentVO->getId();
     $stdResult->title = $ContentVO->getTitle();
     $stdResult->content = $ContentVO->getContent();
     $stdResult->image_url = array();
     if (count($images) > 0) {
         foreach ($images as $image) {
             $url = Config::getRootPath("/image/get_image/image_id." . $image->id . "/max_width.{$width}/max_height.{$height}/crop.1/");
             //é o link
             $stdResult->image_url[] = $url;
         }
     }
     return $stdResult;
 }