コード例 #1
0
ファイル: Default.php プロジェクト: arcavias/arcavias-core
    /**
     * Returns the HTML for the navigation tree.
     *
     * @param MShop_Catalog_Item_Interface $item Catalog item with child nodes
     * @param array Associative list of catalog IDs as keys and catalog nodes as values
     * @param array Associative list of parameters used for filtering
     * @return string Rendered HTML of the navigation tree
     */
    public function transform(MShop_Catalog_Item_Interface $item, array $path, array $params = array())
    {
        if ($item->getStatus() <= 0) {
            return '';
        }
        $id = $item->getId();
        $enc = $this->_encoder;
        $config = $item->getConfig();
        $class = $item->hasChildren() ? ' withchild' : ' nochild';
        $class .= isset($path[$item->getId()]) ? ' active' : '';
        $class .= isset($config['css-class']) ? ' ' . $config['css-class'] : '';
        $params['a-name'] = str_replace(' ', '-', $item->getName());
        $params['f-catalog-id'] = $id;
        $url = $enc->attr($this->url($this->_target, $this->_controller, $this->_action, $params, array(), $this->_config));
        $output = '<li class="cat-item catid-' . $enc->attr($id . $class) . '" data-id="' . $id . '" ><!--
			--><a class="cat-item" href="' . $url . '"><span class="cat-name">' . $enc->html($item->getName(), $enc::TRUST) . '</span></a>';
        $children = $item->getChildren();
        if (!empty($children)) {
            $output .= '<ul class="level-' . $enc->attr($item->getNode()->level + 1) . '">';
            foreach ($children as $child) {
                $output .= $this->transform($child, $path, $params);
            }
            $output .= '</ul>';
        }
        $output .= '</li>';
        return $output;
    }
コード例 #2
0
ファイル: Catalog.php プロジェクト: nos3/aimeos-typo3
 /**
  * Returns the list of category label / ID pairs for the given node and all children
  *
  * @param MShop_Catalog_Item_Interface $item Catalog item to start from
  * @param unknown_type $level Current level on indention
  * @return array Associative array of category label / ID pairs
  */
 protected function getCategoryList(\MShop_Catalog_Item_Interface $item, $level)
 {
     $result = array();
     $result[] = array(str_repeat('.', $level * 4) . $item->getName(), $item->getId());
     foreach ($item->getChildren() as $child) {
         $result = array_merge($result, $this->getCategoryList($child, $level + 1));
     }
     return $result;
 }
コード例 #3
0
ファイル: Default.php プロジェクト: Bananamoon/aimeos-core
 /**
  * Creates a list of nodes with children.
  *
  * @param MShop_Catalog_Item_Interface $node Catalog node
  */
 protected function _createNodeArray(MShop_Catalog_Item_Interface $node)
 {
     $result = $node->toArray();
     foreach ($node->getChildren() as $child) {
         $result['children'][] = $this->_createNodeArray($child);
     }
     return (object) $result;
 }
コード例 #4
0
ファイル: Default.php プロジェクト: Bananamoon/aimeos-core
 /**
  * Get all child nodes.
  *
  * @param MShop_Catalog_Item_Interface $node
  * @return MShop_Catalog_Item_Interface[] $nodes List of nodes
  */
 protected function _getNodeList(MShop_Catalog_Item_Interface $node)
 {
     $nodes = array($node);
     foreach ($node->getChildren() as $child) {
         $nodes = array_merge($nodes, $this->_getNodeList($child));
     }
     return $nodes;
 }
コード例 #5
0
ファイル: Default.php プロジェクト: Bananamoon/aimeos-core
 /**
  * Updates the usage information of a node.
  *
  * @param integer $id Id of the record
  * @param MShop_Catalog_Item_Interface $item Catalog item
  * @param boolean $case True if the record shoud be added or false for an update
  *
  */
 private function _updateUsage($id, MShop_Catalog_Item_Interface $item, $case = false)
 {
     $date = date('Y-m-d H:i:s');
     $context = $this->_getContext();
     $dbm = $context->getDatabaseManager();
     $dbname = $this->_getResourceName();
     $conn = $dbm->acquire($dbname);
     try {
         $siteid = $context->getLocale()->getSiteId();
         if ($case !== true) {
             $path = 'mshop/catalog/manager/default/item/usage/update';
         } else {
             $path = 'mshop/catalog/manager/default/item/usage/add';
         }
         $stmt = $conn->create($context->getConfig()->get($path, $path));
         $stmt->bind(1, json_encode($item->getConfig()));
         $stmt->bind(2, $date);
         // mtime
         $stmt->bind(3, $context->getEditor());
         if ($case !== true) {
             $stmt->bind(4, $siteid, MW_DB_Statement_Abstract::PARAM_INT);
             $stmt->bind(5, $id, MW_DB_Statement_Abstract::PARAM_INT);
         } else {
             $stmt->bind(4, $date);
             // ctime
             $stmt->bind(5, $siteid, MW_DB_Statement_Abstract::PARAM_INT);
             $stmt->bind(6, $id, MW_DB_Statement_Abstract::PARAM_INT);
         }
         $stmt->execute()->finish();
         $dbm->release($conn, $dbname);
     } catch (Exception $e) {
         $dbm->release($conn, $dbname);
         throw $e;
     }
 }
コード例 #6
0
ファイル: Default.php プロジェクト: Bananamoon/aimeos-core
 /**
  * Returns the HTML for the navigation tree.
  *
  * @param MShop_Catalog_Item_Interface $item Catalog item with child nodes
  * @param array Associative list of catalog IDs as keys and catalog nodes as values
  * @param array Associative list of parameters used for filtering
  * @return string Rendered HTML of the navigation tree
  */
 public function transform(MShop_Catalog_Item_Interface $item, array $path, array $params = array())
 {
     if ($item->getStatus() <= 0) {
         return '';
     }
     $id = $item->getId();
     $enc = $this->_encoder;
     $config = $item->getConfig();
     $class = $item->hasChildren() ? ' withchild' : ' nochild';
     $class .= isset($path[$item->getId()]) ? ' active' : '';
     $class .= isset($config['css-class']) ? ' ' . $config['css-class'] : '';
     $params['f_name'] = $item->getName('url');
     $params['f_catid'] = $id;
     $url = $enc->attr($this->_getView()->url($this->_target, $this->_controller, $this->_action, $params, array(), $this->_config));
     $output = '<li class="cat-item catid-' . $enc->attr($id . $class) . '" data-id="' . $id . '" >';
     $output .= '<a class="cat-item" href="' . $url . '"><div class="media-list">';
     foreach ($item->getListItems('media', 'icon') as $listItem) {
         if (($mediaItem = $listItem->getRefItem()) !== null) {
             $output .= $this->media($mediaItem, $this->_contentUrl, array('class' => 'media-item'));
         }
     }
     $output .= '</div><span class="cat-name">' . $enc->html($item->getName(), $enc::TRUST) . '</span></a>';
     $children = $item->getChildren();
     if (!empty($children)) {
         $output .= '<ul class="level-' . $enc->attr($item->getNode()->level + 1) . '">';
         foreach ($children as $child) {
             $output .= $this->transform($child, $path, $params);
         }
         $output .= '</ul>';
     }
     $output .= '</li>';
     return $output;
 }
コード例 #7
0
ファイル: Default.php プロジェクト: arcavias/arcavias-core
 /**
  * Returns the category IDs of the given catalog tree.
  *
  * Only the IDs of the children of the current category are returned.
  *
  * @param MShop_Catalog_Item_Interface $tree Catalog node as entry point of the tree
  * @param array $path Associative list of category IDs as keys and the catalog
  * 	nodes from the currently selected category up to the root node
  * @param string $currentId Currently selected category
  * @return array List of category IDs
  */
 protected function _getCatalogIds(MShop_Catalog_Item_Interface $tree, array $path, $currentId)
 {
     if ($tree->getId() == $currentId) {
         $ids = array();
         foreach ($tree->getChildren() as $item) {
             $ids[] = $item->getId();
         }
         return $ids;
     }
     foreach ($tree->getChildren() as $child) {
         if (isset($path[$child->getId()])) {
             return $this->_getCatalogIds($child, $path, $currentId);
         }
     }
     return array();
 }
コード例 #8
0
 protected function _delete(MShop_Catalog_Item_Interface $catItem)
 {
     $manager = MShop_Catalog_Manager_Factory::createManager($this->_context);
     $listManager = $manager->getSubManager('list');
     foreach ($catItem->getListItems('product') as $listItem) {
         $listManager->deleteItem($listItem->getId());
     }
     $manager->deleteItem($catItem->getId());
 }