コード例 #1
0
ファイル: RssController.php プロジェクト: kokkez/shineisp
 /**
  * Create a RSS file with the CMS pages and Products
  */
 public function indexAction()
 {
     $out = "";
     try {
         $ISP = Shineisp_Registry::get('ISP');
         $ns = new Zend_Session_Namespace();
         $localeID = $ns->idlang;
         $locale = $ns->lang;
         $feed = new Zend_Feed_Writer_Feed();
         $feed->setTitle($ISP->company);
         $feed->setLink($ISP->website);
         $feed->setFeedLink('http://' . $_SERVER['HTTP_HOST'] . '/rss', 'atom');
         $feed->addAuthor(array('name' => $ISP->company, 'email' => $ISP->email, 'uri' => $ISP->website));
         $feed->setEncoding('UTF8');
         $feed->setDateModified(time());
         $feed->addHub($ISP->website);
         // Get all the cms pages
         $records = CmsPages::getRssPages($locale);
         foreach ($records as $record) {
             $link = 'http://' . $_SERVER['HTTP_HOST'] . '/cms/' . $record['var'] . '.html';
             self::createEntry($feed, $record['title'], $record['body'], $link);
         }
         // Get all the products
         $records = Products::getAllHighlighted($localeID);
         foreach ($records as $record) {
             $title = $record['ProductsData'][0]['name'];
             $descritption = strip_tags($record['ProductsData'][0]['shortdescription']);
             $inserted_at = !empty($record['inserted_at']) ? strtotime($record['inserted_at']) : null;
             $updated_at = !empty($record['updated_at']) ? strtotime($record['updated_at']) : null;
             $link = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $record['uri'] . '.html';
             self::createEntry($feed, $title, $descritption, $link, $inserted_at, $updated_at);
         }
         /**
          * Render the resulting feed to Atom 1.0 and assign to $out.
          * You can substitute "atom" with "rss" to generate an RSS 2.0 feed.
          */
         $out = $feed->export('atom');
     } catch (Zend_Feed_Exception $e) {
         die($e->getMessage());
     }
     die($out);
 }
コード例 #2
0
ファイル: Newsletters.php プロジェクト: kokkez/shineisp
 /**
  * Prepare the newsletter content
  */
 private static function fill_content()
 {
     $ns = new Zend_Session_Namespace();
     $contents = array();
     // Get all the products
     $contents['products'] = "<ul>";
     $records = Products::getAllHighlighted($ns->idlang);
     foreach ($records as $record) {
         $contents['products'] .= "<b><a href='http://" . $_SERVER['HTTP_HOST'] . "/" . $record['uri'] . ".html'>" . $record['ProductsData'][0]['name'] . "</a></b><p>" . $record['ProductsData'][0]['shortdescription'] . "</p>";
     }
     $contents['products'] .= "</ul>";
     // Get all the cms pages
     $contents['pages'] = "";
     $records = CmsPages::getRssPages($ns->lang);
     foreach ($records as $record) {
         $link = 'http://' . $_SERVER['HTTP_HOST'] . '/cms/' . $record['var'] . '.html';
         $contents['pages'] .= "<p><b><a href='" . $link . "'>" . $record['title'] . "</a></b></p>";
         $contents['pages'] .= Shineisp_Commons_Utilities::truncate($record['body'], 200, "...", false, true);
     }
     $contents['pages'] = str_replace("src=\"/", "src=\"http://" . $_SERVER['HTTP_HOST'] . "/", $contents['pages']);
     return $contents;
 }