本文整理汇总了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();
}