示例#1
0
 public function get()
 {
     $tpl = new Template("pushedChronicle");
     $chronicleAdpater = new ChronicleAdapter($this->chronicle);
     $tpl->setVariables(array("chronicle" => $chronicleAdpater->getAsChronicleViewModel()));
     return $tpl->output();
 }
示例#2
0
 public function get($chronicleId)
 {
     try {
         $key = self::CHRONICE_PAGE . "_id_" . $chronicleId;
         $result = $this->getData($key);
         if ($result === false) {
             $result = new ChroniclePage();
             $chronicle = ChronicleDao::getInstance()->get($chronicleId);
             if ($chronicle) {
                 // Set chronicle
                 $result->setChronicle($chronicle);
                 // Set chronicleViewModel
                 $chronicleAdapter = new ChronicleAdapter($chronicle);
                 $chronicleViewModel = $chronicleAdapter->getAsChronicleViewModel(3, 5, 5, false);
                 $result->setChronicleViewModel($chronicleViewModel);
                 // Set press reviews
                 $result->setPressReviews($chronicleViewModel->getPressReviews());
                 // Set same author chronicles
                 $result->setSameAuthorChronicles($chronicleViewModel->getSameAuthorChronicles());
                 // Set similar chronicles
                 $result->setSimilarChronicles($chronicleViewModel->getSimilarChronicles());
                 // Set user book reviews
                 $result->setUserBooksReviews($this->getUserBooksReviews($chronicle));
                 // Set viedo press review
                 $result->setVideoPressReview($this->getVideoPressReview($chronicle));
                 $this->setData($key, $result);
             } else {
                 return null;
             }
         }
         return $result;
     } catch (\Exception $e) {
         $this->logException(get_class(), __FUNCTION__, $e);
     }
 }
 /**
  * Post a message on facebook
  * @param Chronicle $chronicle the chronicle to post on facebook
  * @return boolean return TRUE if post was succesfull, FALSE otherwise
  */
 private function postOnFacebook(Chronicle $chronicle, $facebookSvc)
 {
     try {
         Trace::addItem("postOnFacebook");
         $globalContext = new \Sb\Context\Model\Context();
         // Set facebook posts variables using a ChronicleAdapter and a PushedChronicle
         $chronicleAdapter = new ChronicleAdapter($chronicle);
         $pushedChronicle = $chronicleAdapter->getAsChronicleViewModelLight();
         $facebookMessage = $pushedChronicle->getTitle();
         $facebookTitle = sprintf(__("%s vient de poster une chronique sur %s", "s1b"), $globalContext->getConnectedUser()->getFirstName(), Constants::SITENAME);
         $facebookCaption = $pushedChronicle->getShortenText();
         $facebookLink = $pushedChronicle->getDetailLink();
         $facebookPicture = $pushedChronicle->getImage();
         Trace::addItem("posting {$facebookMessage} with title {$facebookTitle} and caption {$facebookCaption}, link {$facebookLink} and picture {$facebookPicture}");
         $post = $facebookSvc->post($facebookMessage, $facebookTitle, $facebookCaption, $facebookLink, $facebookPicture);
         return $post;
     } catch (\Exception $e) {
         Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $e->getTraceAsString()));
         return false;
     }
 }