Exemple #1
0
function flickrthumbnails_crawl()
{
    global $THINKTANK_CFG;
    global $db;
    global $conn;
    if (isset($THINKTANK_CFG['flickr_api_key']) && $THINKTANK_CFG['flickr_api_key'] != '') {
        $logger = new Logger($THINKTANK_CFG['log_location']);
        $fa = new FlickrAPIAccessor($THINKTANK_CFG['flickr_api_key'], $logger);
        $ldao = new LinkDAO($db, $logger);
        $flickrlinkstoexpand = $ldao->getLinksToExpandByURL('http://flic.kr/');
        if (count($flickrlinkstoexpand > 0)) {
            $logger->logStatus(count($flickrlinkstoexpand) . " Flickr links to expand", "Flickr Plugin");
        } else {
            $logger->logStatus("No Flickr links to expand", "Flickr Plugin");
        }
        foreach ($flickrlinkstoexpand as $fl) {
            $eurl = $fa->getFlickrPhotoSource($fl);
            if ($eurl["expanded_url"] != '') {
                $ldao->saveExpandedUrl($fl, $eurl["expanded_url"], '', 1);
            } elseif ($eurl["error"] != '') {
                $ldao->saveExpansionError($fl, $eurl["error"]);
            }
        }
        $logger->close();
        # Close logging
    }
}
 function testExpandURLsCrawl()
 {
     global $crawler;
     $crawler->emit("crawl");
     $ldao = new LinkDAO($this->db, $this->logger);
     $link = $ldao->getLinkById(1);
     $this->assertEqual($link->expanded_url, 'http://www.thewashingtonnote.com/archives/2010/04/communications/');
     $this->assertEqual($link->error, '');
 }
Exemple #3
0
 /**
  * Cada plugin deve saber se ao deletar precisa apagar arquivos, desvincular, excluir ou não do banco
  * @param $item_id int da entrada do item a ser deletado no banco.
  * @return ReturnResultVO
  */
 public function delete($item_id)
 {
     //aqui precisa realmente deletar a imagem, ou desvincula-la, o que é melhor
     include_once "library/facil3/core/dao/LinkDAO.class.php";
     $LinkDAO = LinkDAO::getInstance();
     if (FALSE) {
         $LinkDAO = new LinkDAO();
     }
     //desvincula a foto ao table e table_id enviado
     $ReturnResultVinculoVO = $LinkDAO->deleteAllByTableAndTableId("image", $item_id);
     return $ReturnResultVinculoVO;
 }
Exemple #4
0
 function testFlickrCrawl()
 {
     global $crawler;
     $crawler->emit("crawl");
     $ldao = new LinkDAO($this->db, $this->logger);
     $link = $ldao->getLinkById(43);
     $this->assertEqual($link->expanded_url, 'http://farm5.static.flickr.com/4027/4490817394_70452f4cfd_m.jpg');
     $this->assertEqual($link->error, '');
     $link = $ldao->getLinkById(42);
     $this->assertEqual($link->expanded_url, '');
     $this->assertEqual($link->error, 'Photo not found');
     $link = $ldao->getLinkById(41);
     $this->assertEqual($link->expanded_url, '');
     $this->assertEqual($link->error, 'Photo not found');
 }
Exemple #5
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new LinkDAO();
     }
     return self::$instance;
 }
 /**
  * Expand a given short URL
  *
  * @param str $tinyurl Shortened URL
  * @param LinkDAO $ldao
  * @return str Expanded URL
  */
 private function untinyurl($tinyurl, $ldao)
 {
     $logger = Logger::getInstance();
     $url = parse_url($tinyurl);
     $host = $url['host'];
     $port = isset($url['port']) ? $url['port'] : 80;
     $query = isset($url['query']) ? '?' . $url['query'] : '';
     $fragment = isset($url['fragment']) ? '#' . $url['fragment'] : '';
     if (empty($url['path'])) {
         $logger->logstatus("{$tinyurl} has no path", "Expand URLs Plugin");
         $ldao->saveExpansionError($tinyurl, "Error expanding URL");
         return '';
     } else {
         $path = $url['path'];
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_URL, "http://{$host}:{$port}" . $path . $query . $fragment);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
     // seconds
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_NOBODY, true);
     curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     $response = curl_exec($ch);
     if ($response === false) {
         $logger->logstatus("cURL error: " . curl_error($ch), "Expand URLs Plugin");
         $ldao->saveExpansionError($tinyurl, "Error expanding URL");
         $tinyurl = '';
     }
     curl_close($ch);
     $lines = explode("\r\n", $response);
     foreach ($lines as $line) {
         if (stripos($line, 'Location:') === 0) {
             list(, $location) = explode(':', $line, 2);
             return ltrim($location);
         }
     }
     if (strpos($response, 'HTTP/1.1 404 Not Found') === 0) {
         $logger->logstatus("Short URL returned '404 Not Found'", "Expand URLs Plugin");
         $ldao->saveExpansionError($tinyurl, "Error expanding URL");
         return '';
     }
     return $tinyurl;
 }
Exemple #7
0
function expandurls_crawl()
{
    global $THINKTANK_CFG;
    global $db;
    global $conn;
    $logger = new Logger($THINKTANK_CFG['log_location']);
    $ldao = new LinkDAO($db, $logger);
    $linkstoexpand = $ldao->getLinksToExpand();
    $logger->logStatus(count($linkstoexpand) . " links to expand", "Expand URLs Plugin");
    foreach ($linkstoexpand as $l) {
        $eurl = untinyurl($l, $logger, $ldao);
        if ($eurl != '') {
            $ldao->saveExpandedUrl($l, $eurl);
        }
    }
    $logger->logStatus("URL expansion complete for this run", "Expand URLs Plugin");
    $logger->close();
    # Close logging
}
 /**
  * Expand shortened Flickr links to image thumbnails if Flickr API key is set.
  * @param $api_key Flickr API key
  * @param $flickr_link Flickr URL
  */
 public function expandFlickrThumbnail($api_key, $flickr_link, $original_link)
 {
     $flickr_api = new FlickrAPIAccessor($api_key);
     $photo_details = $flickr_api->getFlickrPhotoSource($flickr_link);
     if ($photo_details["image_src"] != '') {
         //@TODO Make another Flickr API call to get the photo title & description and save to tu_links
         $this->link_dao->saveExpandedUrl($original_link, $flickr_link, '', $photo_details["image_src"]);
     } elseif ($photo_details["error"] != '') {
         $this->link_dao->saveExpansionError($original_link, $photo_details["error"]);
     }
 }
Exemple #9
0
 function delete()
 {
     $image_id = DataHandler::getValueByArrayIndex($_POST, "id");
     $ReturnResultVO = new ReturnResultVO();
     if ($image_id > 0) {
         //vai deletar
         $ImageVO = new ImageVO();
         $ImageVO->setId($image_id, TRUE);
         $ImageVO->delete();
         $LinkDAO = LinkDAO::getInstance();
         if (FALSE) {
             $LinkDAO = new LinkDAO();
         }
         $ReturnDataVO = $LinkDAO->deleteAllFromLinkedTableAndLinkedTableId("image", $image_id);
         $ReturnResultVO->success = $ReturnDataVO->success;
         if ($ReturnResultVO->success) {
             $ReturnResultVO->addMessage(Translation::text("Image deleted successfully."));
         } else {
             $ReturnResultVO->addMessage(Translation::text("Error when deleting image."));
         }
     }
     echo $ReturnResultVO->toJson();
     exit;
 }
Exemple #10
0
 /**
  * para listagem de produtos
  */
 public function init()
 {
     //lista todos produtos vinculados a categoria 2
     $returnResult = new HttpResult();
     //iniciando o resultado para o html
     $retornoDaPaginaHTML = new HttpRoot();
     $arrayContentsVO = array();
     //se foi passado o id da categoria entao vai buscar todos os contentents vinculados a mesma
     //echo Debug::li($this->category_id);exit();
     $LinkDAO = LinkDAO::getInstance();
     $category_id = 2;
     //categoria a que todos os produtos estão vinculados
     $returnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, "category", $category_id, "content", NULL, 1, NULL, NULL, $order_by = "order", $order_type = NULL);
     //verifica se o resultado é uma categoryVO
     if ($returnDataVO->success && count($returnDataVO->result) > 0) {
         foreach ($returnDataVO->result as $LinkVO) {
             //Debug::print_r($LinkVO);
             $tempReturnDataVO = $LinkVO->getLinkedVO();
             //Debug::print_r($tempReturnDataVO);exit();
             if ($tempReturnDataVO->success) {
                 $stdClass = $tempReturnDataVO->result;
                 $dads = $stdClass->getCategoriesDad();
                 if ($stdClass->active == 1 && count($dads) > 1) {
                     //pega o nome da sub categoria e categoria que ele pertence
                     //Debug::print_r($dads);
                     $arrayContentsVO[] = $stdClass;
                 }
             }
         }
         //exit();
     }
     DataHandler::objectSort($arrayContentsVO, "title");
     $retornoDaPaginaHTML->arrayContentsVO = $arrayContentsVO;
     //salvando o objeto de resultado de html no retorno
     $returnResult->setHttpContentResult($retornoDaPaginaHTML);
     //Debug::print_r($returnResult);
     //exit();
     return $returnResult;
 }
Exemple #11
0
 private function getContents($category_id)
 {
     $LinkDAO = LinkDAO::getInstance();
     $returnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, "category", $category_id, "content", NULL, 1, NULL, NULL);
     //verifica se o resultado é uma categoryVO
     $arrayContentsVO = array();
     if ($returnDataVO->success && count($returnDataVO->result) > 0) {
         foreach ($returnDataVO->result as $LinkVO) {
             //Debug::print_r($LinkVO);
             $tempReturnDataVO = $LinkVO->getLinkedVO();
             //Debug::print_r($tempReturnDataVO);exit();
             if ($tempReturnDataVO->success) {
                 if ($tempReturnDataVO->result->active >= 0) {
                     $arrayContentsVO[] = $tempReturnDataVO->result;
                 }
                 //end if active
             }
         }
         //exit();
     }
     return $arrayContentsVO;
 }
Exemple #12
0
 public function select()
 {
     //iniciando o retorno padrao em http result
     $returnResult = new HttpResult();
     $resultPage = new DefaultPage();
     $resultPage->__array_category = $this->getCategoryCascade($this->category_id);
     //adicionando ContentVO na lista de category
     $LinkDAO = LinkDAO::getInstance();
     //Debug::print_r($resultPage->__array_category);exit();
     foreach ($resultPage->__array_category as $level1) {
         foreach ($level1->__array_category as $level2) {
             //Debug::print_r($level2);
             $level2->__array_category = array();
             //agora lista os contents e poe aqui como se fosse categoria
             $returnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, "category", $level2->id, "content", NULL, 1);
             //verifica se o resultado é uma categoryVO
             if ($returnDataVO->success && count($returnDataVO->result) > 0) {
                 foreach ($returnDataVO->result as $LinkVO) {
                     $tempReturnDataVO = $LinkVO->getLinkedVO();
                     //Debug::print_r($tempReturnDataVO);exit();
                     if ($tempReturnDataVO->success) {
                         //Debug::print_r($tempReturnDataVO->result);
                         $std = new stdClass();
                         $std->id = $tempReturnDataVO->result->id;
                         $std->name = $tempReturnDataVO->result->title;
                         $std->category_id = $level2->id;
                         $level2->__array_category[] = $std;
                     }
                 }
                 //exit();
             }
         }
     }
     $returnResult->setHttpContentResult($resultPage);
     return $returnResult;
 }
Exemple #13
0
 public function commit($redirect_page = TRUE, $gallery_type = "image")
 {
     //iniciando o retorno padrao
     $_POST["active"] = 1;
     if (!isset($_POST["category"]) || $_POST["category"] == NULL) {
         $_POST["category"] = array($this->category_id);
     } else {
         if (!is_array($_POST["category"])) {
             $_POST["category"] = array($_POST["category"], $this->category_id);
         } else {
             //é uma array, mas melhor garantir que tem o produto id
             $_POST["category"][] = $this->category_id;
         }
     }
     if (isset($_POST["hat"])) {
         $hat = $_POST["hat"];
         //tira o vinculo com a tabela ano (que nao existe)
         if ($content_id) {
             //adiciona o vinculo com a tabela ano de indice hat
             $LinkDAO = LinkDAO::getInstance();
         }
         //deleta vinculos com categoria
         $LinkDAO->deleteAllFromLinkedTableByTableAndTableId('content', $content_id, 'ano');
         $LinkDAO->insert('ano', $hat, 'content', $content_id, 1, 0);
     }
     if (isset($_POST["title"])) {
         $_POST["slug"] = DataHandler::strToURL($_POST["title"]);
     }
     if (!isset($_POST["id"]) && DataHandler::getValueByArrayIndex($this->arrayVariable, "id")) {
         $_POST["id"] = DataHandler::getValueByArrayIndex($this->arrayVariable, "id");
     }
     if (!isset($_POST["order"])) {
         $_POST["order"] = NULL;
     }
     $return = parent::commit(FALSE, $gallery_type);
     $this->updatePdf($return->id);
     if ($redirect_page) {
         //Navigation::redirect($this->my_redirect);
         Navigation::redirect("backend/client/change/id." . $return->id);
         exit;
     }
     return $return;
 }
 /**
  * Return the expanded version of a given short URL or save an error for the $original_link in links table and
  * return an empty string.
  *
  * @param str $tinyurl Shortened URL
  * @param LinkDAO $link_dao
  * @param str $original_link
  * @param int $current_number Current link number
  * @param int $total_number Total links in group
  * @return str Expanded URL
  */
 private function untinyurl($tinyurl, $link_dao, $original_link, $current_number, $total_number)
 {
     $error_log_prefix = $current_number . " of " . $total_number . " links: ";
     $logger = Logger::getInstance();
     $url = parse_url($tinyurl);
     if (isset($url['host'])) {
         $host = $url['host'];
     } else {
         $error_msg = $tinyurl . ": No host found.";
         $logger->logError($error_log_prefix . $error_msg, __METHOD__ . ',' . __LINE__);
         $link_dao->saveExpansionError($original_link, $error_msg);
         return '';
     }
     $port = isset($url['port']) ? ':' . $url['port'] : '';
     $query = isset($url['query']) ? '?' . $url['query'] : '';
     $fragment = isset($url['fragment']) ? '#' . $url['fragment'] : '';
     if (empty($url['path'])) {
         $path = '';
     } else {
         $path = $url['path'];
     }
     $scheme = isset($url['scheme']) ? $url['scheme'] : 'http';
     $reconstructed_url = $scheme . "://{$host}{$port}" . $path . $query . $fragment;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_URL, $reconstructed_url);
     curl_setopt($ch, CURLOPT_TIMEOUT, 5);
     // seconds
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_NOBODY, true);
     curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     $response = curl_exec($ch);
     if ($response === false) {
         $error_msg = $reconstructed_url . " cURL error: " . curl_error($ch);
         $logger->logError($error_log_prefix . $error_msg, __METHOD__ . ',' . __LINE__);
         $link_dao->saveExpansionError($original_link, $error_msg);
         $tinyurl = '';
     }
     curl_close($ch);
     $lines = explode("\r\n", $response);
     foreach ($lines as $line) {
         if (stripos($line, 'Location:') === 0) {
             list(, $location) = explode(':', $line, 2);
             return ltrim($location);
         }
     }
     if (strpos($response, 'HTTP/1.1 404 Not Found') === 0) {
         $error_msg = $reconstructed_url . " returned '404 Not Found'";
         $logger->logError($error_log_prefix . $error_msg, __METHOD__ . ',' . __LINE__);
         $link_dao->saveExpansionError($original_link, $error_msg);
         return '';
     }
     return $tinyurl;
 }
Exemple #15
0
 /**
  * 
  * Usar: backend/product/delete_file/id.N/type.TYPE/
  */
 public function deleteFile()
 {
     $ReturnResultVO = new ReturnResultVO();
     $id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($this->arrayVariable, "id"));
     $product_id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($this->arrayVariable, "product_id"));
     if ($id > 0) {
         $LinkDAO = new LinkDAO();
         $ReturnDataVO = $LinkDAO->deleteAllFromLinkedTableAndLinkedTableId("file", $id);
         $ReturnResultVO->success = $ReturnDataVO->success;
         //n√£o est√° tratando o tipo de erro
     } else {
         $ReturnResultVO->addMessage(Translation::text("id?"));
     }
     Navigation::redirect("backend/product/file/id.{$product_id}/");
     //echo $ReturnResultVO->toJson();
     exit;
 }
Exemple #16
0
 /**
  * @return void da echo de string
  */
 public function link()
 {
     $LinkDAO = LinkDAO::getInstance();
     if (FALSE) {
         $LinkDAO = new LinkDAO();
     }
     $ReturnResultVO = new ReturnResultVO();
     $ReturnResultVO->success = TRUE;
     //enviar por post:
     //category_id
     //array_content_id
     if (DataHandler::getValueByArrayIndex($_POST, "category_id") && DataHandler::getValueByArrayIndex($_POST, "array_content_id")) {
         $category_id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($_POST, "category_id"));
         //talvez não seja array
         $array_content_id = DataHandler::getValueByArrayIndex($_POST, "array_content_id");
         $table = DataHandler::getValueByArrayIndex($_POST, "table");
         $linked_table = DataHandler::getValueByArrayIndex($_POST, "linked_table");
         if (!is_array($array_content_id)) {
             $array_content_id = explode(",", $array_content_id);
         }
         if (is_array($array_content_id)) {
             $contador = 0;
             foreach ($array_content_id as $content_id) {
                 //inicia a linkVO se existir
                 $ReturnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, $table, $category_id, $linked_table, $content_id, 1);
                 if (FALSE) {
                     $ReturnDataVO = new ReturnDataVO();
                 }
                 if ($ReturnDataVO->success) {
                     $arrayResults = $ReturnDataVO->result;
                     if ($ReturnDataVO->count_total > 0) {
                         //pega só o primeiro, mas se tiver mais do que 1 poderia dar um warning
                         if ($ReturnDataVO->count_total > 1) {
                             //warning, deveria ter só 1
                         }
                         $LinkVO = $arrayResults[0];
                         //para ajuda do aptana
                         if (FALSE) {
                             $LinkVO = new LinkVO();
                         }
                         $LinkVO->setOrder($contador);
                         $ReturnDataVO = $LinkDAO->update($LinkVO->getId(), $LinkVO->getActive(), $LinkVO->getTable(), $LinkVO->getTableId(), $LinkVO->getLinkedTable(), $LinkVO->getLinkedTableId(), $LinkVO->getOrder());
                         if (!$ReturnDataVO->success) {
                             $ReturnResultVO->success = FALSE;
                             $ReturnResultVO->addMessage("erro ao atualizar o item de id:" . $LinkVO->getLinkedTableId());
                         }
                         $contador++;
                     }
                 }
             }
             //end foreach
         } else {
             $ReturnResultVO->success = FALSE;
             $ReturnResultVO->addMessage("Enviar content_id por POST em array");
         }
         //end if array
     } else {
         $ReturnResultVO->success = FALSE;
         $ReturnResultVO->addMessage("Enviar por POST category_id e array_content_id.");
     }
     //end if foi enviado posts
     if ($ReturnResultVO->success) {
         $ReturnResultVO->addMessage("Ordem definida com sucesso.");
     }
     echo $ReturnResultVO->toJson();
     exit;
 }
Exemple #17
0
 function testGetLinksToExpandByURL()
 {
     $ldao = new LinkDAO($this->db, $this->logger);
     $flickrlinkstoexpand = $ldao->getLinksToExpandByUrl('http://flic.kr/');
     $this->assertEqual(count($flickrlinkstoexpand), 5);
 }
Exemple #18
0
 public function insertHighlights()
 {
     //inicia um retorno de ReturnResultVO
     $ReturnResultVO = new ReturnResultVO();
     //pega os dados baseado na HighlightsInfoPostVO
     $VO = new HighLightsVO();
     //popula no objeto
     $VO->setId($this->HighlightsInfoPostVO->id);
     $VO->setActive($this->HighlightsInfoPostVO->active);
     $VO->setName($this->HighlightsInfoPostVO->name);
     $VO->setLink($this->HighlightsInfoPostVO->link, $locale);
     $VO->setContent($this->HighlightsInfoPostVO->content, $locale);
     $VO->setImageUrl($this->HighlightsInfoPostVO->image_url, $locale);
     $VO->setDate($this->HighlightsInfoPostVO->date);
     $VO->setDateIn($this->HighlightsInfoPostVO->date_in);
     $VO->setDateOut($this->HighlightsInfoPostVO->date_out);
     $VO->setOrder($this->HighlightsInfoPostVO->order);
     //("Ja") gera id para criar pasta onde vai ser guardado o arquivo
     $ReturnResultHighLightsVO = $VO->commit();
     if ($ReturnResultHighLightsVO->success) {
         $ReturnResultHighLightsVO->result = $VO->getId();
     } else {
         //erro, os motivos estão na ReturnResultVO abaixo
         return $ReturnResultHighLightsVO;
     }
     if ($ReturnResultHighLightsVO->success) {
         //incluir o vinculo com a linked_table e linked_table_id
         //receber 	table
         //			table_id
         if ($this->HighlightsInfoPostVO->request_table != NULL && $this->HighlightsInfoPostVO->request_table_id > 0) {
             $table = $this->HighlightsInfoPostVO->request_table;
             $table_id = $this->HighlightsInfoPostVO->request_table_id;
             include_once "library/facil3/core/dao/LinkDAO.class.php";
             $LinkDAO = new LinkDAO();
             //vincula a foto ao table e table_id enviado
             $ReturnResultVinculoVO = $LinkDAO->insert($table, $table_id, $this->moduleName, $VO->getId(), 1);
             if (!$ReturnResultVinculoVO->success) {
                 //deu erro ao vincular
                 $ReturnResultVO->success = false;
                 $ReturnResultVO->appendMessage($ReturnResultVinculoVO->array_messages);
                 return $ReturnResultVO;
             }
         } else {
             return $ReturnResultVO->addMessage(Translation::text("LibraryLanguage::WARNING_HIGHLIGHTS_NO_LINKED_TABLE"));
         }
     } else {
         return $ReturnResultHighLightsVO;
     }
 }
Exemple #19
0
 public function afiliateBanner()
 {
     //iniciando o retorno padrao em http result
     $returnResult = new HttpResult();
     //iniciando o resultado para o html
     $retornoDaPaginaHTML = new PurchaseInfo();
     //define a dao a ser usada em toda a controler
     $ContentSiteDAO = ContentSiteDAO::getInstance();
     $vo = $ContentSiteDAO->getVO();
     //define a vo a ser usada em toda a controler
     $ContentSiteVO = $ContentSiteDAO->getVO();
     //pega id passado na url
     $LinkDAO = LinkDAO::getInstance();
     $returnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, "category", 20, "content", NULL, 1);
     //			echo $this->category_id;
     //			print_r($returnDataVO);exit();
     //verifica se o resultado é uma categoryVO
     $arrayContentsVO = array();
     if ($returnDataVO->success && count($returnDataVO->result) > 0) {
         foreach ($returnDataVO->result as $LinkVO) {
             //					print_r($LinkVO);;
             $tempReturnDataVO = $LinkVO->getLinkedVO();
             //					print_r($tempReturnDataVO);exit();
             if ($tempReturnDataVO->success) {
                 $arrayContentsVO[] = $tempReturnDataVO->result;
             }
         }
     }
     $novo_content = array();
     foreach ($arrayContentsVO as $ContentsVO) {
         if ($ContentsVO->active > 1) {
             $images = $ContentsVO->getImages();
             $ContentsVO->images = $images;
             $novo_content[] = $ContentsVO;
         }
     }
     $arrayContentsVO = $novo_content;
     $returnResult->setSuccess(TRUE);
     $retornoDaPaginaHTML->array_banner = $arrayContentsVO;
     $returnResult->setHttpContentResult($retornoDaPaginaHTML);
     return $returnResult;
 }
 private function processTweetURLs($tweet)
 {
     $ld = new LinkDAO($this->db, $this->logger);
     $urls = Post::extractURLs($tweet['post_text']);
     foreach ($urls as $u) {
         //if it's an image (Twitpic/Twitgoo/Yfrog/Flickr for now), insert direct path to thumb as expanded url, otherwise, just expand
         //set defaults
         $is_image = 0;
         $title = '';
         $eurl = '';
         //TODO Abstract out this image thumbnail link expansion into an Image Thumbnail plugin, modeled after the Flickr Thumbnails plugin
         if (substr($u, 0, strlen('http://twitpic.com/')) == 'http://twitpic.com/') {
             $eurl = 'http://twitpic.com/show/thumb/' . substr($u, strlen('http://twitpic.com/'));
             $is_image = 1;
         } elseif (substr($u, 0, strlen('http://yfrog.com/')) == 'http://yfrog.com/') {
             $eurl = $u . '.th.jpg';
             $is_image = 1;
         } elseif (substr($u, 0, strlen('http://twitgoo.com/')) == 'http://twitgoo.com/') {
             $eurl = 'http://twitgoo.com/show/thumb/' . substr($u, strlen('http://twitgoo.com/'));
             $is_image = 1;
         } elseif (substr($u, 0, strlen('http://flic.kr/')) == 'http://flic.kr/') {
             $is_image = 1;
         }
         if ($ld->insert($u, $eurl, $title, $tweet['post_id'], $is_image)) {
             $this->logger->logStatus("Inserted " . $u . " (" . $eurl . ", " . $is_image . "),  into links table", get_class($this));
         } else {
             $this->logger->logStatus("Did NOT insert " . $u . " (" . $eurl . ") into links table", get_class($this));
         }
     }
 }
Exemple #21
0
 /**
  * recebe a imagem por post
  * @return ReturnResultVO
  */
 public function insert()
 {
     //inicia um retorno de ReturnResultVO
     $ReturnResultVO = new ReturnResultVO();
     //pega os dados baseado na infoPost
     $VO = new ImageVO();
     //var_dump($this->infoPost);
     //exit();
     if ($this->infoPost->image_info_id > 0) {
         //passou o id, vai atualizar essa VO
         //					echo Debug::li("image_info_id >>>>>>>>>> ".$this->infoPost->image_info_id);
         $VO->setId($this->infoPost->image_info_id, TRUE);
     }
     $VO->setActive($this->infoPost->image_info_active);
     $VO->setName($this->infoPost->image_info_name);
     $VO->setDescription($this->infoPost->image_info_description);
     $VO->setType($this->infoPost->image_info_type);
     $VO->setAuthor($this->infoPost->image_info_author);
     $VO->setLocale($this->infoPost->image_info_locale);
     $VO->setOrder($this->infoPost->image_info_order);
     //				var_dump($_FILES);
     //				var_dump($this->infoPost->file_data);
     //comitando as infos enviadas, dados apenas
     if ($VO->getId() > 0 || $this->infoPost->file_data['tmp_name']) {
         //só comita a imagem se tiver ou id ou enviado o file_data, se não nem tem o que fazer
         $ReturnResultImageVO = $VO->commit();
     } else {
         //nem enviou o id e nem o file_data, retorna
         $ReturnResultVO->addMessage(Translation::text("Have nothing to commit."));
         return $ReturnResultVO;
     }
     if ($ReturnResultImageVO->success) {
         $ReturnResultImageVO->result = $VO->getId();
     } else {
         //erro, os motivos estão na ReturnResultVO abaixo
         return $ReturnResultImageVO;
     }
     //pega o id da imagem
     $IMAGE_ID = $VO->getId();
     $ReturnResultImageVO = new ReturnResultVO();
     //echo Debug::li("this->infoPost->file_data: ".$this->infoPost->file_data);
     if (isset($this->infoPost->file_data) && $this->infoPost->file_data['tmp_name']) {
         set_time_limit(0);
         //var_dump($_FILES);
         $sentFileData = $this->infoPost->file_data;
         //$_FILES['Filedata'];
         $name = $sentFileData['name'];
         // extens�o enviada
         $sentExtension = DataHandler::returnExtensionOfFile($name);
         // remove caracteres escrotos
         $name = DataHandler::returnFilenameWithoutExtension($name);
         $name = DataHandler::removeAccent($name);
         $name = DataHandler::removeSpecialCharacters($name);
         $name = trim(substr($name, 0, 80));
         switch ($sentFileData["type"]) {
             case "image/pjpeg":
             case "image/jpeg":
             case "image/jpg":
                 $extension = "jpg";
                 break;
             case "image/gif":
                 $extension = "gif";
                 break;
             case "image/png":
             case "image/x-png":
                 $extension = "png";
                 break;
             case "image/bmp":
                 $extension = "bmp";
                 break;
             default:
                 $extension = strtolower($sentExtension);
                 break;
         }
         //verifica se a pasta existe, se não existir, inventa
         DataHandler::createFolderIfNotExist($this->defaultFolderForNewImages);
         // pasta de upload de imagens est� no config.php
         $tempFolder = DataHandler::removeDobleBars($this->defaultFolderForNewImages . "/" . $IMAGE_ID);
         DataHandler::createFolderIfNotExist($tempFolder);
         //echo Debug::li("name: $name");
         $tempUrl = $tempFolder . "/original_" . strtolower($name . "." . $extension);
         //echo Debug::li("tempUrl: $tempUrl");
         //exit();
         $i = 2;
         while (file_exists($tempUrl)) {
             $tempUrl = $tempFolder . "/original_" . strtolower($name . "-" . $i . "." . $extension);
             $i++;
         }
         $VO->setUrl($tempUrl);
         $ReturnResultImageVO = $VO->commit();
         //Debug::li("aaa");
         //Debug::print_r($ReturnResultImageVO);
         if ($ReturnResultImageVO->success) {
             //incluir o vinculo com a linked_table e linked_table_id
             //receber 	table
             //			table_id
             if ($this->infoPost->table) {
                 $table = $this->infoPost->table;
                 $table_id = $this->infoPost->table_id;
                 include_once "library/facil3/core/dao/LinkDAO.class.php";
                 $LinkDAO = new LinkDAO();
                 //vincula a foto ao table e table_id enviado
                 $ReturnResultVinculoVO = $LinkDAO->insert($table, $table_id, $this->moduleName, $VO->getId(), 1);
                 if (!$ReturnResultVinculoVO->success) {
                     //deu erro ao vincular
                     $ReturnResultVO->success = false;
                     $ReturnResultVO->appendMessage($ReturnResultVinculoVO->array_messages);
                     return $ReturnResultVO;
                 }
             } else {
                 $ReturnResultVO->addMessage("WARNING IMAGE NO LINKED TABLE");
             }
             //movendo a foto original para sua respectiva pasta.
             $originalImage = $VO->getUrl();
             if (!move_uploaded_file($sentFileData['tmp_name'], $originalImage)) {
                 $ReturnResultVO->success = false;
                 $ReturnResultVO->addMessage(LibraryLanguage::ERROR_IMAGE_MOVE_FILE_FAIL);
                 return $ReturnResultVO;
             } else {
                 $ReturnResultVO->success = TRUE;
                 $ReturnResultVO->result = $VO->getId();
                 $ReturnResultVO->addMessage("Foto enviada com sucesso.");
             }
         } else {
             return $ReturnResultImageVO;
         }
         return $ReturnResultVO;
     } else {
         if ($VO->getId() > 0) {
             //se tem id, ele manda atualizar a parada
             $ReturnResultImageVO = $VO->commit();
             return $ReturnResultImageVO;
         }
         $ReturnResultImageVO = new ReturnResultVO();
         $ReturnResultImageVO->addMessage(Translation::text("Send file data."));
         // nao veio filedata
         return $ReturnResultImageVO;
     }
 }
Exemple #22
0
 public function insert()
 {
     //inicia um retorno de ReturnResultVO
     $ReturnResultVO = new ReturnResultVO();
     //pega os dados baseado na ContentInfoPostVO
     $VO = new ContentVO();
     //popula no objeto
     if ($this->ContentInfoPostVO->id) {
         $VO->setId($this->ContentInfoPostVO->id, TRUE);
     }
     $VO->setActive($this->ContentInfoPostVO->active);
     $VO->setName($this->ContentInfoPostVO->name);
     $VO->setTitle($this->ContentInfoPostVO->title, $this->ContentInfoPostVO->request_locale);
     $VO->setHat($this->ContentInfoPostVO->hat, $this->ContentInfoPostVO->request_locale);
     $VO->setDescription($this->ContentInfoPostVO->description, $this->ContentInfoPostVO->request_locale);
     $VO->setContent($this->ContentInfoPostVO->content, $this->ContentInfoPostVO->request_locale);
     $VO->setAuthor($this->ContentInfoPostVO->author);
     $VO->setTemplateUrl($this->ContentInfoPostVO->template_url, $this->ContentInfoPostVO->request_locale);
     $VO->setSlug($this->ContentInfoPostVO->slug, $this->ContentInfoPostVO->request_locale);
     $VO->setKeyWords($this->ContentInfoPostVO->key_words, $this->ContentInfoPostVO->request_locale);
     $VO->setDate($this->ContentInfoPostVO->date);
     $VO->setDateIn($this->ContentInfoPostVO->date_in);
     $VO->setDateOut($this->ContentInfoPostVO->date_out);
     $VO->setOrder($this->ContentInfoPostVO->order);
     include "";
     //("Ja") gera id para criar pasta onde vai ser guardado o arquivo
     $ReturnResultContentVO = $VO->commit();
     if ($ReturnResultContentVO->success) {
         $ReturnResultContentVO->result = $VO->getId();
         // TODO: AQ ADD IMGAGE  e/ou FILE - $arr_uploaded_files
         // $this->ContentInfoPostVO->arr_uploaded_files['image'][0]->table 		= 'content';
         // $this->ContentInfoPostVO->arr_uploaded_files['image'][0]->table_id 	= $ReturnResultContentVO->result ;
         // $facilFile = new FacilImage( $this->ContentInfoPostVO->arr_uploaded_files['image'][0])
         // $facilFile = new FacilFile( $this->ContentInfoPostVO->arr_uploaded_files['file'][0])
     }
     if ($ReturnResultContentVO->success) {
         //incluir o vinculo com a linked_table e linked_table_id
         //receber 	table
         //			table_id
         if ($this->ContentInfoPostVO->request_table != NULL && $this->ContentInfoPostVO->request_table_id > 0) {
             $table = $this->ContentInfoPostVO->request_table;
             $table_id = $this->ContentInfoPostVO->request_table_id;
             include_once "library/facil3/core/dao/LinkDAO.class.php";
             $LinkDAO = new LinkDAO();
             //vincula a foto ao table e table_id enviado
             $ReturnResultVinculoVO = $LinkDAO->insert($table, $table_id, $this->moduleName, $VO->getId(), 1);
             if (!$ReturnResultVinculoVO->success) {
                 //deu erro ao vincular
                 $ReturnResultContentVO->appendMessage($ReturnResultVinculoVO->array_messages);
             }
         }
     }
     return $ReturnResultContentVO;
 }
Exemple #23
0
 private function createFormData($ReturnResultVO = NULL)
 {
     //adiciona o content na url de envio do formulario
     if ($this->content_id > 0) {
         $this->my_action .= "/id.{$this->content_id}/";
     }
     //echo $this->my_action;
     $formData = new ContentFormView($this->ContentSiteVO, Config::getRootPath($this->my_action));
     $ImageFormView = new ImageFormView();
     $ImageFormView->setFormLabel("Selecionar Foto");
     $ImageFormView->setShowImageUrl(TRUE);
     //		$ImageFormView->setName(array("label"=>"link", "visible"=>TRUE));
     if ($this->sub == "unidades") {
         $ImageFormView->setQuantity(0);
     } else {
         $ImageFormView->setQuantity(1);
     }
     //		$ImageFormView->setDescription(array('label'=>Translation::text('Link'), 'visible'=>false, 'type'=>'simpleText'));
     $FileFormView = new FileFormView();
     $FileFormView->setFormLabel("Selecionar Arquivo");
     $FileFormView->setQuantity($this->total_files);
     if ($this->sub == "blog") {
         //id do blog 36
         $CategoryVO = new CategoryVO();
         $CategoryVO->setId(36, TRUE);
         $array_categorias = $CategoryVO->selectCascade(CategoryDAO::RETURN_STD_OBJECT, 1);
         $selected_category = array();
         $LinkDAO = LinkDAO::getInstance();
         if (FALSE) {
             $LinkDAO = new LinkDAO();
         }
         if ($this->ContentSiteVO->id > 0) {
             $ReturnLinkCategory = $LinkDAO->select(LinkDAO::RETURN_STD_OBJECT, NULL, NULL, "content", $this->ContentSiteVO->id, 1);
             if ($ReturnLinkCategory->success && $ReturnLinkCategory->count_total > 0) {
                 foreach ($ReturnLinkCategory->result as $link_std) {
                     $selected_category[] = $link_std->table_id;
                 }
             }
         }
         //Debug::print_r($ReturnLinkCategory);exit();
         //new ContentSiteVO();
         $formData->setCategory(array("visible" => TRUE, "name" => "category[]", "label" => "Categorias", "selected" => $selected_category, "options" => $array_categorias));
     } else {
         $formData->setCategory(array("visible" => FALSE, "name" => "category[]", "selected" => array($this->category_id)));
     }
     if ($this->sub == "unidades") {
         $formData->setContent(array("label" => "Endereço:", "value" => "unidade"));
     } else {
         //trocando o rótulo para Content
         $formData->setContent(array("label" => "Descrição:"));
     }
     //trocando o rótulo para Title
     $formData->setTitle(array("label" => "Titulo:"));
     //		$formData->setHat(array("label"=>"Link:"));
     $formData->setDate(array("label" => "Data(formato: dd/mm/aaaa hh:mm:ss para 'agora' deixe vazio):"));
     $formData->setImage($ImageFormView);
     $formData->setFile($FileFormView);
     $array_to_visible_false = array('Name', 'Hat', 'Description', 'Author', 'TemplateUrl', 'Slug', 'KeyWords', 'DateIn', 'DateOut', 'Order');
     if ($this->sub == "unidades") {
         $array_to_visible_false = array('Name', 'Description', 'Content', 'TemplateUrl', 'Slug', 'KeyWords', 'Date', 'DateIn', 'DateOut', 'Order');
         $formData->setHat(array("label" => "Endereço"));
         $formData->setAuthor(array("label" => "Link Mapa"));
     }
     $formData->setMassiveAttr('visible', FALSE, $array_to_visible_false);
     $formData->setActive(array("value" => "1", "visible" => FALSE));
     //$this->my_redirect = "admin/page/select/";
     parent::edit($formData, TRUE, NULL, $this->my_redirect, NULL, $ReturnResultVO);
 }
 private function processTweetURLs($tweet, $lurl, $fa)
 {
     $ld = new LinkDAO($this->db, $this->logger);
     $urls = Tweet::extractURLs($tweet['tweet_text']);
     foreach ($urls as $u) {
         //if it's an image (Twitpic/Twitgoo/Yfrog/Flickr for now), insert direct path to thumb as expanded url, otherwise, just expand
         //set defaults
         $is_image = 0;
         $title = '';
         $eurl = '';
         if (substr($u, 0, strlen('http://twitpic.com/')) == 'http://twitpic.com/') {
             $eurl = 'http://twitpic.com/show/thumb/' . substr($u, strlen('http://twitpic.com/'));
             $is_image = 1;
         } elseif (substr($u, 0, strlen('http://yfrog.com/')) == 'http://yfrog.com/') {
             $eurl = $u . '.th.jpg';
             $is_image = 1;
         } elseif (substr($u, 0, strlen('http://twitgoo.com/')) == 'http://twitgoo.com/') {
             $eurl = 'http://twitgoo.com/show/thumb/' . substr($u, strlen('http://twitgoo.com/'));
             $is_image = 1;
         } elseif ($fa->api_key != null && substr($u, 0, strlen('http://flic.kr/p/')) == 'http://flic.kr/p/') {
             $eurl = $fa->getFlickrPhotoSource($u);
             if ($eurl != '') {
                 $is_image = 1;
             }
         } else {
             $eurl_arr = $lurl->expandUrl($u);
             if (isset($eurl_arr['response-code']) && $eurl_arr['response-code'] == 200) {
                 $eurl = $eurl_arr['long-url'];
                 if (isset($eurl_arr['title'])) {
                     $title = $eurl_arr['title'];
                 }
             }
         }
         if ($ld->insert($u, $eurl, $title, $tweet['status_id'], $is_image)) {
             $this->logger->logStatus("Inserted " . $u . " (" . $eurl . ") into links table", get_class($this));
         } else {
             $this->logger->logStatus("Did NOT insert " . $u . " (" . $eurl . ") into links table", get_class($this));
         }
     }
 }
Exemple #25
0
    die;
}
if (!isset($_REQUEST['d'])) {
    $_REQUEST['d'] = "all-tweets";
}
$s = new SmartyThinkTank();
if (!$s->is_cached('inline.view.tpl', $i->network_username . "-" . $_SESSION['user'] . "-" . $_REQUEST['d'])) {
    $cfg = new Config($i->network_username, $i->network_user_id);
    $s->assign('cfg', $cfg);
    $s->assign('i', $i);
    $u = new Utils();
    // instantiate data access objects
    $ud = new UserDAO($db);
    $pd = new PostDAO($db);
    $fd = new FollowDAO($db);
    $ld = new LinkDAO($db);
    $s->assign('display', $_REQUEST['d']);
    // pass data to smarty
    switch ($_REQUEST['d']) {
        case "tweets-all":
            $s->assign('header', 'All Posts');
            $s->assign('all_tweets', $pd->getAllPosts($i->network_user_id, 15));
            break;
        case "tweets-mostreplies":
            $s->assign('header', 'Most Replied-To Posts');
            $s->assign('most_replied_to_tweets', $pd->getMostRepliedToPosts($i->network_user_id, 15));
            break;
        case "tweets-mostretweeted":
            $s->assign('header', 'Most Forwarded');
            $s->assign('most_retweeted', $pd->getMostRetweetedPosts($i->network_user_id, 15));
            break;
Exemple #26
0
 public function init()
 {
     //busca todas as paginas cadastradas na tabela content
     $returnResult = new HttpResult();
     //iniciando o resultado para o html
     $retornoDaPaginaHTML = new HttpContentModule();
     $retornoDaPaginaHTML->arrayVariable = $this->arrayVariable;
     /*
     	$address1 = new stdClass();
     			$address1->area = 'Rio de Janeiro (RJ)';
     			$address1->description = 'Av. Das Nações Unidas, 4777 Lj 27 - Piso G1 / Tel: (11) 5042-7840';
     			$address1->google_maps_url = 'http://maps.google.com.br/maps?f=q&source=s_q&hl=pt-BR&geocode=&q=Avenida+dos+Eucaliptos,+762,+Moema,+S%C3%A3o+Paulo&sll=-23.484148,-46.838983&sspn=0.01234,0.022724&ie=UTF8&hq=&hnear=Av.+dos+Eucaliptos,+762+-+Moema,+S%C3%A3o+Paulo,+04517-050&ll=-23.609531,-46.669793&spn=0.012092,0.022724&z=16';
     			
     			$place1 = new stdClass();
     			$place1->area = 'SUDESTE';
     			$place1->addresses = array($address1,$address1,$address1,$address1);
     			
     			$region1 = new stdClass();
     			$region1->name = 'embreve';
     			$region1->title = 'Em breve nocas unidades:';
     			$region1->places = array($place1,$place1,$place1,$place1);
     
     	$region2 = new stdClass();
     	$region2->name = 'sp';
     	$region2->title = 'São Paulo';
     	$region2->places = array($place1,$place1,$place1,$place1);
     	
     	$region3 = new stdClass();
     	$region3->name = 'ba';
     	$region3->title = 'Bahia';
     	$region3->places = array($place1,$place1,$place1,$place1);
     	
     	$region4 = new stdClass();
     	$region4->name = 'mt';
     	$region4->title = 'Mato Grosso';
     	$region4->places = array($place1,$place1,$place1,$place1);
     	
     	$region4 = new stdClass();
     	$region4->name = 'ms';
     	$region4->title = 'Mato Grosso do Sul';
     	$region4->places = array($place1,$place1,$place1,$place1);
     	
     	$HttpContentResult->regions = array($region1,$region2,$region3,$region4);
     */
     //listar categorias de 19
     $array_category = $this->getCategoryCascade(19);
     //Debug::print_r($array_category);
     $arrayRegions = array();
     foreach ($array_category as $stdCategory) {
         $region = $this->getRegion($stdCategory->id, $stdCategory->name, $stdCategory->name);
         foreach ($stdCategory->__array_category as $stdCategory2) {
             //Debug::print_r($stdCategory2);
             $place = $this->getPlace($stdCategory2->name);
             $LinkDAO = LinkDAO::getInstance();
             $returnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, "category", $stdCategory2->id, "content", NULL, 1);
             //verifica se o resultado é uma categoryVO
             if ($returnDataVO->success && count($returnDataVO->result) > 0) {
                 foreach ($returnDataVO->result as $LinkVO) {
                     $tempReturnDataVO = $LinkVO->getLinkedVO();
                     //Debug::print_r($tempReturnDataVO);exit();
                     if ($tempReturnDataVO->success) {
                         //Debug::print_r($tempReturnDataVO->result);
                         $address = new stdClass();
                         $address->area = $tempReturnDataVO->result->title;
                         $address->description = $tempReturnDataVO->result->hat;
                         $address->google_maps_url = $tempReturnDataVO->result->author;
                         $place->addresses[] = $address;
                     }
                 }
                 //exit();
             }
             $region->places[] = $place;
         }
         $arrayRegions[] = $region;
     }
     //Debug::print_r($arrayRegions);
     //em breve
     $retornoDaPaginaHTML->regions = $arrayRegions;
     //array($region1,$region2,$region3,$region4);
     $returnResult->setHttpContentResult($retornoDaPaginaHTML);
     return $returnResult;
 }
Exemple #27
0
 public function getCategoriesDad()
 {
     if (!$this->_array_categories_dad) {
         $LinkDAO = LinkDAO::getInstance();
         if (FALSE) {
             $LinkDAO = new LinkDAO();
         }
         $ReturnResultDAO = $LinkDAO->select(LinkDAO::RETURN_STD_OBJECT, "category", NULL, "content", $this->id, 1);
         if ($ReturnResultDAO->success && $ReturnResultDAO->count_total > 0) {
             $this->_array_categories_dad = array();
             foreach ($ReturnResultDAO->result as $linkVO) {
                 $this->_array_categories_dad[] = $linkVO->table_id;
             }
         }
     }
     return $this->_array_categories_dad;
 }
Exemple #28
0
 /**
  * para detalhe de um produto
  */
 public function init()
 {
     //Debug::print_r($this->arrayVariable);
     //filtro vindo por parametro é o addres que ele tem que enviar de volta como busca
     //rel ids de produtos relacionados
     //exit();
     //echo 12;
     $id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($this->arrayVariable, "id"));
     if ($id > 0) {
         $ContentSiteVO = new ContentSiteVO();
         $ReturnResult_vo = $ContentSiteVO->setId($id, TRUE);
         if ($ReturnResult_vo->success) {
             $stdProduct = $ContentSiteVO->toStdClass();
             $stdProduct->array_gallery = $ContentSiteVO->getImages(NULL, "gallery", true);
             $stdProduct->array_dimensions = $ContentSiteVO->getImages(NULL, "dimensions", true);
             $stdProduct->array_video = $ContentSiteVO->getImages(NULL, "video", true);
             $stdProduct->array_360 = $ContentSiteVO->getImages(NULL, "360", true);
             $stdProduct->array_tagged = $ContentSiteVO->getImages(NULL, "tagged", true);
             $LinkDAO = LinkDAO::getInstance();
             //passo 1, descobrir a qual família esse protudo pertence
             //passo 2, pegar todos os produtos pertencente a mesma família
             //passo 3, tirar o próprio produto da listagem de produtos da mesma família
             $array_links = array();
             $resultLinks = $LinkDAO->select(DbInterface::RETURN_STD_OBJECT, "content", $table_id = null, $linked_table = 'content', $linked_table_id = $id, $active = 1, $quant_started = NULL, $quant_limit = NULL, $order_by = "order", $order_type = " ASC ");
             if ($resultLinks->success && $resultLinks->count_total > 0) {
                 foreach ($resultLinks->result as $familia) {
                     $link = $familia;
                     //$resultLinks->result[0];
                     $ContentFamiliaVO = new ContentSiteVO();
                     $ContentFamiliaVO->setId($link->table_id, TRUE);
                     Debug::print_r($ContentFamiliaVO);
                     exit;
                     if ($ContentFamiliaVO->active > 0) {
                         $arrayResult_links = $ContentFamiliaVO->getLinks("content");
                         foreach ($arrayResult_links as $link) {
                             if ($link->linked_table_id != $id) {
                                 $ResultTempLink = $link->getLinkedVO();
                                 if ($ResultTempLink->success) {
                                     $produtoVO = $ResultTempLink->result;
                                     if ($produtoVO->active > 0) {
                                         $stdProduto = $produtoVO->toStdClass();
                                         $stdProduto->array_tagged = $produtoVO->getImages(NULL, "tagged", NULL);
                                         $array_links[] = $stdProduto;
                                     }
                                     //Debug::print_r($stdProduto);exit();
                                 }
                             }
                             //end if
                         }
                         //end foerach
                     }
                 }
             }
             //verifica a qual familia esse produto pertence
             $stdProduct->array_produtos_vinculados = $array_links;
             //Debug::print_r($array_links);
             //exit();
             //pegando array de vinculados enviados como id
             $str_ids_send = DataHandler::getValueByArrayIndex($this->arrayVariable, "rel");
             $array_ids_send = explode("|", $str_ids_send);
             $array_filtro = array();
             foreach ($array_ids_send as $id) {
                 $ContentSiteVO = new ContentSiteVO();
                 $tempResult = $ContentSiteVO->setId($id, TRUE);
                 if ($tempResult->success) {
                     $stdProduto = $ContentSiteVO->toStdClass();
                     $stdProduto->array_tagged = $ContentSiteVO->getImages(NULL, "tagged", NULL);
                     $array_filtro[] = $stdProduto;
                 }
             }
             $stdProduct->array_filtro = $array_filtro;
             //Debug::print_r($array_links);
             $returnResult = new HttpResult();
             //exit();
             //iniciando o resultado para o html
             $retornoDaPaginaHTML = new HttpRoot();
             $retornoDaPaginaHTML->vo = $stdProduct;
             $retornoDaPaginaHTML->addressToReturn = str_replace("|", "/", DataHandler::getValueByArrayIndex($this->arrayVariable, "filtro"));
             $strToResend = implode("/", $this->arrayRestFolder);
             $strToResend = explode("/:/", $strToResend);
             if (is_array($strToResend) && count($strToResend) > 1) {
                 $strToResend = $strToResend[1];
             } else {
                 $strToResend = "";
             }
             $retornoDaPaginaHTML->addressToResend = $strToResend;
             $returnResult->setHttpContentResult($retornoDaPaginaHTML);
             return $returnResult;
         } else {
             Navigation::redirect("");
         }
     } else {
         //não mandou o id, vai pra listagem
         Navigation::redirect("produtos");
     }
 }
Exemple #29
0
 public function insert()
 {
     //inicia um retorno de ReturnResultVO
     $ReturnResultVO = new ReturnResultVO();
     //pega os dados baseado na infoPost
     $VO = new FileVO();
     if ($this->infoPost->file_info_id) {
         $VO->setId($this->infoPost->file_info_id, TRUE);
     }
     $VO->setActive($this->infoPost->file_info_active);
     $VO->setName($this->infoPost->file_info_name);
     $VO->setDescription($this->infoPost->file_info_description);
     $VO->setType($this->infoPost->file_info_type);
     $VO->setAuthor($this->infoPost->file_info_author);
     $VO->setLocale($this->infoPost->file_info_locale);
     $VO->setOrder($this->infoPost->file_info_order);
     //("JÁ") gera id para criar pasta onde vai ser guardado o arquivo
     $ReturnResultFileVO = $VO->commit();
     if ($ReturnResultFileVO->success) {
         $ReturnResultFileVO->result = $VO->getId();
     } else {
         //erro, os motivos estão na ReturnResultVO abaixo
         return $ReturnResultFileVO;
     }
     //pega o id da file
     $FILE_ID = $VO->getId();
     $ReturnResultFileVO = new ReturnResultVO();
     if (isset($this->infoPost->file_data) && !$this->infoPost->file_info_id > 0) {
         set_time_limit(0);
         $sentFileData = $this->infoPost->file_data;
         //$_FILES['Filedata'];
         $name = $sentFileData['name'];
         // extens�o enviada
         $sentExtension = DataHandler::returnExtensionOfFile($name);
         // remove caracteres escrotos
         $name = DataHandler::returnFilenameWithoutExtension($name);
         $name = DataHandler::removeAccent($name);
         $name = DataHandler::removeSpecialCharacters($name);
         $name = trim(substr($name, 0, 80));
         switch ($sentFileData["type"]) {
             case "text/plain":
                 $extension = "txt";
                 break;
             default:
                 $extension = strtolower($sentExtension);
                 break;
         }
         //verifica se a pasta existe, se não existir, inventa
         DataHandler::createFolderIfNotExist($this->defaultFolderForNewFiles);
         // pasta de upload de files está no config.php
         $tempFolder = DataHandler::removeDobleBars($this->defaultFolderForNewFiles . "/" . $FILE_ID);
         DataHandler::createFolderIfNotExist($tempFolder);
         $tempUrl = $tempFolder . "/" . strtolower($name . "." . $extension);
         $i = 2;
         while (file_exists($tempUrl)) {
             $tempUrl = $tempFolder . "/" . strtolower($name . "-" . $i . "." . $extension);
             $i++;
         }
         $VO->setUrl($tempUrl);
         $ReturnResultFileVO = $VO->commit();
         //Debug::li("aaa");
         if ($ReturnResultFileVO->success) {
             //incluir o vinculo com a linked_table e linked_table_id
             //receber 	table
             //			table_id
             if ($this->infoPost->table) {
                 $table = $this->infoPost->table;
                 $table_id = $this->infoPost->table_id;
                 include_once "library/facil3/core/dao/LinkDAO.class.php";
                 $LinkDAO = new LinkDAO();
                 //vincula a foto ao table e table_id enviado
                 $ReturnResultVinculoVO = $LinkDAO->insert($table, $table_id, $this->moduleName, $VO->getId(), 1);
                 if (!$ReturnResultVinculoVO->success) {
                     //deu erro ao vincular
                     $ReturnResultVO->success = false;
                     $ReturnResultVO->appendMessage($ReturnResultVinculoVO->array_messages);
                     return $ReturnResultVO;
                 }
             } else {
                 $ReturnResultVO->addMessage(Translation::text("LibraryLanguage::WARNING_FILE_NO_LINKED_TABLE"));
             }
             //movendo o arquivo para sua respectiva pasta.
             $localFile = $VO->getUrl();
             if (!move_uploaded_file($sentFileData['tmp_name'], $localFile)) {
                 $ReturnResultVO->success = false;
                 $ReturnResultVO->addMessage(Translation::text("Arquivo não encontrado"));
                 return $ReturnResultVO;
             } else {
                 $ReturnResultVO->success = TRUE;
                 $ReturnResultVO->result = $VO->getId();
                 $ReturnResultVO->addMessage(Translation::text("Arquivo gravado"));
             }
         } else {
             return $ReturnResultFileVO;
         }
         return $ReturnResultVO;
     } else {
         $ReturnResultFileVO = new ReturnResultVO();
         $ReturnResultFileVO->addMessage("Envie o Filedata");
         // nao veio filedata
         return $ReturnResultFileVO;
     }
 }
Exemple #30
0
    die;
}
if (!isset($_REQUEST['d'])) {
    $_REQUEST['d'] = "all-tweets";
}
$s = new SmartyThinkTank();
if (!$s->is_cached('inline.view.tpl', $i->twitter_username . "-" . $_SESSION['user'] . "-" . $_REQUEST['d'])) {
    $cfg = new Config($i->twitter_username, $i->twitter_user_id);
    $s->assign('cfg', $cfg);
    $s->assign('i', $i);
    $u = new Utils();
    // instantiate data access objects
    $ud = new UserDAO($db);
    $td = new TweetDAO($db);
    $fd = new FollowDAO($db);
    $ld = new LinkDAO($db);
    $s->assign('display', $_REQUEST['d']);
    // pass data to smarty
    switch ($_REQUEST['d']) {
        case "tweets-all":
            $s->assign('header', 'All Tweets');
            $s->assign('all_tweets', $td->getAllTweets($cfg->twitter_user_id, 15));
            break;
        case "tweets-mostreplies":
            $s->assign('header', 'Most Replied-To Tweets');
            $s->assign('most_replied_to_tweets', $td->getMostRepliedToTweets($cfg->twitter_user_id, 15));
            break;
        case "tweets-mostretweeted":
            $s->assign('header', 'Most Retweeted');
            $s->assign('most_retweeted', $td->getMostRetweetedTweets($cfg->twitter_user_id, 15));
            break;