當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Linker::linkItemToTag方法代碼示例

本文整理匯總了PHP中Linker::linkItemToTag方法的典型用法代碼示例。如果您正苦於以下問題:PHP Linker::linkItemToTag方法的具體用法?PHP Linker::linkItemToTag怎麽用?PHP Linker::linkItemToTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Linker的用法示例。


在下文中一共展示了Linker::linkItemToTag方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: tag

 public function tag($type = FALSE, $tags = '', $item_id = NULL, $category_id = NULL)
 {
     if (!$type) {
         return FALSE;
     }
     if (!isset($this->tag_types[$type])) {
         $this->tag_types = array_merge($this->tag_types, $this->ci->tag_type_m->get(array('name' => $type, 'array_key' => 'name')));
     }
     $tag_type = $this->tag_types[$type];
     $return_tag_ids = array();
     if ($tags !== '') {
         // Check if tag type requires any chars to be removed
         if (isset($tag_type['remove_chars'])) {
             // Format remove chars to support replacement
             $removes = explode('\',', substr($tag_type['remove_chars'], 1, -1));
             $tags = str_replace($removes, '', (string) $tags);
         }
         // Explode tag string by predefined delimiter
         $ex = explode($tag_type['delimiter'], $tags);
         foreach ($ex as $k => $tag) {
             // Check store's cache before asking DB
             if (array_key_exists($tag, $this->_tag_cache)) {
                 $otag = $this->_tag_cache[$tag];
             } else {
                 $otag = $this->ci->tag_m->get(array('value' => $tag, 'single' => TRUE));
             }
             if ($otag !== FALSE) {
                 //$price = $this->ci->price_m->get(array('id'=>$otag['price_id']));
                 $this->ci->tag_m->update(array('numItems' => $otag['numItems'] + 1), array('id' => $otag['id']));
                 $tag_id = $otag['id'];
                 // $this->_tag_cache[$otag['value']] = array('id'=>$tag_id,'numItems'=>$otag['numItems']+1);
             } else {
                 // Set up a base price grouping for the tag
                 $price_id = $this->ci->price_m->insert(array('min' => '0.00'));
                 // Add the tag and link it to its new price grouping
                 $tag_id = $this->ci->tag_m->insert(array('value' => $tag, 'tag_type_id' => $tag_type['id'], 'price_id' => $price_id));
                 $this->_tag_cache[$tag] = array('id' => $tag_id, 'numItems' => 1);
             }
             $return_tag_ids[] = $tag_id;
             parent::linkItemToTag($item_id, $tag_id);
         }
         return $return_tag_ids;
         //$this->tag_group($ex);
     }
     return array();
 }
開發者ID:ohjack,項目名稱:csc385,代碼行數:46,代碼來源:Store.php


注:本文中的Linker::linkItemToTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。