Exemplo n.º 1
0
 /**
  * getTeaserImageForNodeId
  * If not available, try parent pages
  */
 public function getTeaserImageForNodeId($node_id, $role = 'teaser')
 {
     $node_detail = $this->detail($node_id);
     //don't need to call full nodeDetail
     switch ($node_detail['node_controller']) {
         case 'recipe':
             require_once 'models/ecommerce/ecommerce_recipe_image.php';
             $Image = new ecommerce_recipe_image();
             // change node ID
             $image_node_id = $node_detail['content'];
             break;
         case 'product':
             require_once 'models/ecommerce/ecommerce_product_image.php';
             $Image = new ecommerce_product_image();
             // change node ID
             $image_node_id = $node_detail['content'];
             break;
         case 'store':
             require_once 'models/ecommerce/ecommerce_store_image.php';
             $Image = new ecommerce_store_image();
             // change node ID
             $image_node_id = $node_detail['content'];
             break;
         case 'default':
         default:
             require_once 'models/common/common_image.php';
             $Image = new common_image();
             // node_id in common_node is direct reference to common_node.id
             $image_node_id = $node_id;
             break;
     }
     $image_detail = $Image->getTeaserImageForNodeId($image_node_id, $role);
     /* try parent recursively */
     if (!$image_detail && is_numeric($node_detail['parent'])) {
         $image_detail = $this->getTeaserImageForNodeId($node_detail['parent'], $role);
     }
     return $image_detail;
 }
Exemplo n.º 2
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * initialize
      */
     require_once 'models/common/common_node.php';
     require_once 'models/common/common_image.php';
     $Node = new common_node();
     $Image = new common_image();
     /**
      * find node id
      */
     if (is_numeric($this->GET['id'])) {
         $id = $this->GET['id'];
     } else {
         $id = $Node->conf['id_map-blog'];
     }
     /**
      * set header 
      */
     header('Content-Type: text/xml; charset=UTF-8');
     // flash in IE with SSL dont like Cache-Control: no-cache and Pragma: no-coche
     header("Cache-Control: ");
     header("Pragma: ");
     /**
      * Initialize pagination variables
      */
     if (is_numeric($this->GET['limit_from'])) {
         $from = $this->GET['limit_from'];
     } else {
         $from = 0;
     }
     if (is_numeric($this->GET['limit_per_page'])) {
         $per_page = $this->GET['limit_per_page'];
     } else {
         $per_page = 25;
     }
     $limit = "{$from},{$per_page}";
     /**
      * latest date
      */
     $rss_date = date('r', time());
     $this->tpl->assign("RSS_DATE", $rss_date);
     /**
      * check
      */
     if (!is_numeric($id)) {
         msg('export rss: id is not numeric', 'error');
         return false;
     }
     /**
      * process
      */
     $node_data = $Node->getDetail($id);
     $channel_taxonomy_labels = array();
     if ($node_data['publish'] == 1) {
         $this->tpl->assign('NODE', $node_data);
         $taxonomy_filter = '';
         if (is_numeric($this->GET['taxonomy_tree_id']) && $this->GET['taxonomy_tree_id'] > 0) {
             $taxonomy_filter = " AND id IN (SELECT node_id FROM common_node_taxonomy WHERE taxonomy_tree_id = {$this->GET['taxonomy_tree_id']})";
         }
         $children = $Node->listing("parent = {$id} AND publish = 1 AND node_group='page' {$taxonomy_filter}", "created DESC", $limit);
         foreach ($children as $c) {
             /**
              * create public link
              */
             $link = $Node->getSeoURL($c['id']);
             $c['url'] = "http://{$_SERVER['HTTP_HOST']}{$link}";
             /**
              * format date
              */
             $c['rss_date'] = date('r', strtotime($c['created']));
             /**
              * get categories
              */
             $taxonomy_list = $Node->getRelatedTaxonomy($c['id']);
             foreach ($taxonomy_list as $taxonomy) {
                 $this->tpl->assign('CATEGORY', $taxonomy);
                 $this->tpl->parse('content.item.category');
                 $channel_taxonomy_labels[$taxonomy['label']['title']] = true;
             }
             /**
              * add image (not part of RSS spec)
              */
             $c['image'] = $this->processImage($Image->getTeaserImageForNodeId($c['id']));
             /**
              * assign
              */
             $this->tpl->assign('CHILD', $c);
             if ($c['image']) {
                 $this->tpl->parse("content.item.image");
             }
             $this->tpl->parse("content.item");
         }
     }
     // parse channel category list
     $i = 0;
     foreach ($channel_taxonomy_labels as $label => $item) {
         if ($i + 1 < count($channel_taxonomy_labels)) {
             $label = $label . "/";
         }
         $this->tpl->assign('CATEGORY', $label);
         $this->tpl->parse('content.category');
         $i++;
     }
     return true;
 }