예제 #1
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * initialise
      */
     require_once 'models/common/common_node.php';
     $Node = new common_node();
     switch ($this->GET['relation']) {
         case 'product':
             require_once 'models/ecommerce/ecommerce_product_taxonomy.php';
             $Taxonomy = new ecommerce_product_taxonomy();
             break;
         case 'variety':
             require_once 'models/ecommerce/ecommerce_product_variety_taxonomy.php';
             $Taxonomy = new ecommerce_product_variety_taxonomy();
             break;
         case 'recipe':
             require_once 'models/ecommerce/ecommerce_recipe_taxonomy.php';
             $Taxonomy = new ecommerce_recipe_taxonomy();
             break;
         case 'store':
             require_once 'models/ecommerce/ecommerce_store_taxonomy.php';
             $Taxonomy = new ecommerce_store_taxonomy();
             break;
         case 'customer':
             require_once 'models/client/client_customer_taxonomy.php';
             $Taxonomy = new client_customer_taxonomy();
             break;
         case 'node':
         default:
             require_once 'models/common/common_node_taxonomy.php';
             $Taxonomy = new common_node_taxonomy();
             break;
     }
     /**
      * input variables
      */
     $node_id = $this->GET['id'];
     /**
      * saving
      */
     if (is_array($_POST['relation_taxonomy']) && is_numeric($node_id)) {
         $current = array();
         $submitted = array();
         // prepare list of ids currently in the database
         $current_raw = $Taxonomy->listing("node_id = " . $node_id);
         if (is_array($current_raw)) {
             foreach ($current_raw as $c) {
                 $current[$c['taxonomy_tree_id']] = $c['id'];
             }
         }
         // prepare list if ids submitted by client
         foreach ($_POST['relation_taxonomy'] as $taxonomy_tree_id) {
             if (is_numeric($taxonomy_tree_id)) {
                 $submitted[] = $taxonomy_tree_id;
             }
         }
         // delete items which were not submitted
         foreach ($current as $taxonomy_tree_id => $id) {
             if (!in_array($taxonomy_tree_id, $submitted)) {
                 $Taxonomy->delete($id);
                 msg("Relation to the category {$taxonomy_tree_id} has been removed.", 'ok', 1);
             }
         }
         // insert items which were submitted and not in the database yet
         foreach ($submitted as $taxonomy_tree_id) {
             if (!isset($current[$taxonomy_tree_id])) {
                 if ($Taxonomy->insert(array('node_id' => $node_id, 'taxonomy_tree_id' => $taxonomy_tree_id))) {
                     msg("Relation to the category {$taxonomy_tree_id} has been added.", 'ok', 1);
                 }
             }
         }
     }
     /**
      * listing
      */
     if (is_numeric($node_id)) {
         $current = $Taxonomy->listing("node_id = " . $node_id);
         if (is_array($current)) {
             foreach ($current as $c) {
                 $taxonomy_data = $Taxonomy->getLabel($c['taxonomy_tree_id']);
                 //print_r($taxonomy_data);
                 //check, if there is product_list_container ??
                 $this->tpl->assign("CURRENT", $taxonomy_data);
                 $_Onxshop_Request = new Onxshop_Request("component/breadcrumb_taxonomy~id={$taxonomy_data['id']}~");
                 $this->tpl->assign('BREADCRUMB', $_Onxshop_Request->getContent());
                 $this->tpl->parse("content.ptn");
             }
         }
     }
     return true;
 }
예제 #2
0
 /**
  * Return array of taxonomy_ids associated to given node
  * 
  * @param  int    $node_id Node id
  * @return Array
  */
 protected function getPageTaxonomyIds($node_id)
 {
     $Node_Taxonomy = new common_node_taxonomy();
     $page_categories_raw = $Node_Taxonomy->listing("node_id = {$node_id}");
     $page_categories = array();
     foreach ($page_categories_raw as $category) {
         $page_categories[] = $category['taxonomy_tree_id'];
     }
     return $page_categories;
 }
예제 #3
0
 /**
  * getRelatedTaxonomy
  */
 public function getRelatedTaxonomy($node_id)
 {
     if (!is_numeric($node_id)) {
         return false;
     }
     require_once 'models/common/common_node_taxonomy.php';
     $Taxonomy = new common_node_taxonomy();
     $related_taxonomy_ids = $Taxonomy->getRelationsToNode($node_id);
     $related_taxonomy = array();
     if (is_array($related_taxonomy_ids)) {
         foreach ($related_taxonomy_ids as $item_id) {
             $related_taxonomy[] = $Taxonomy->getLabel($item_id);
         }
     }
     return $related_taxonomy;
 }
예제 #4
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * initialize node
      */
     require_once 'models/common/common_node.php';
     $Node = new common_node();
     $node_data = $Node->nodeDetail($this->GET['id']);
     /**
      * detect controller for recipe list
      */
     switch ($node_data['component']['template']) {
         case 'shelf':
             $controller = 'recipe_list_shelf';
             break;
         case 'stack':
             $controller = 'recipe_list_stack';
             break;
         case '4col':
             $controller = 'recipe_list_4columns';
             break;
         case '3col':
         default:
             $controller = 'recipe_list_3columns';
             break;
         case '2col':
             $controller = 'recipe_list_2columns';
             break;
     }
     /**
      * get related categories
      */
     require_once 'models/common/common_node_taxonomy.php';
     $Node_Taxonomy = new common_node_taxonomy();
     $taxonomy_ids = $Node_Taxonomy->getRelationsToNode($node_data['id']);
     $taxonomy_ids = implode(",", $taxonomy_ids);
     /**
      * sorting
      */
     $sort_by = $node_data['component']['sort']['by'];
     $sort_direction = $node_data['component']['sort']['direction'];
     /**
      * limit
      */
     if (is_numeric($this->GET['limit_from']) && is_numeric($this->GET['limit_per_page'])) {
         $limit_from = $this->GET['limit_from'];
         $limit_per_page = $this->GET['limit_per_page'];
     } else {
         if (is_numeric($node_data['component']['limit'])) {
             $limit_from = 0;
             $limit_per_page = $node_data['component']['limit'];
         } else {
             $limit_from = '';
             $limit_per_page = '';
         }
     }
     /**
      * pagination
      */
     if ($node_data['component']['pagination'] == 1) {
         $display_pagination = 1;
     } else {
         $display_pagination = 0;
     }
     /**
      * call controller
      */
     $_Onxshop_Request = new Onxshop_Request("component/ecommerce/{$controller}~taxonomy_tree_id={$taxonomy_ids}:sort[by]={$sort_by}:sort[direction]={$sort_direction}:limit_from={$limit_from}:limit_per_page={$limit_per_page}:display_pagination={$display_pagination}~");
     $this->tpl->assign('RECIPE_LIST', $_Onxshop_Request->getContent());
     $this->tpl->assign('NODE', $node_data);
     if ($node_data['display_title']) {
         $this->tpl->parse('content.title');
     }
     return true;
 }