本文整理汇总了PHP中Tags类的典型用法代码示例。如果您正苦于以下问题:PHP Tags类的具体用法?PHP Tags怎么用?PHP Tags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tags类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
// Get, check and setup the parameters
if (!($widget_id = $this->getRequest()->getParam("id"))) {
throw new Stuffpress_Exception("No widget id provided to the widget controller");
}
// Verify if the requested widget exist and get its data
$widgets = new Widgets();
if (!($widget = $widgets->getWidget($widget_id))) {
throw new Stuffpress_Exception("Invalid widget id");
}
// Get the widget properties
$properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
$title = $properties->getProperty('title');
$this->view->title = $title ? $title : "Tag cloud";
// Get the archives
$db_tags = new Tags(array(Stuffpress_Db_Table::USER => $widget['user_id']));
if ($tags = $db_tags->getTopTags(20)) {
$max = $tags[0]['count'];
$min = $tags[count($tags) - 1]['count'];
sort($tags);
$this->view->tags = $tags;
$this->view->max = $max;
$this->view->min = $min;
}
}
示例2: updateMeta
public function updateMeta($event, Tags $tag)
{
$meta = $tag->getTagmetaOrNew();
if ($meta->id) {
$meta->save();
}
}
示例3: actionCreate
public function actionCreate()
{
$request = Yii::app()->request->getIsPostRequest();
$ajaxRequest = Yii::app()->request->getIsAjaxRequest();
if ($request) {
$berita = new Berita();
$kategori = new Kategori();
$tags = new Tags();
$image = new Image();
$postBerita = !empty($_POST['Berita']) ? $_POST['Berita'] : "";
$postKategori = !empty($_POST['Kategori']) ? $_POST['Kategori'] : "";
$postTags = !empty($_POST['Tags']) ? $_POST['Tags'] : "";
if ($kategori) {
$kategori->setAttributes($postKategori);
}
if ($tags) {
$tags->setAttributes($postTags);
}
if ($postBerita) {
$berita->setAttributes($postBerita);
$berita->setCreatetime($postBerita['tgl_create']);
$berita->setUpdatetime($postBerita['tgl_update']);
}
}
$jsonData = array();
if ($ajaxRequest) {
echo CJSON::encode($jsonData);
Yii::app()->end();
} else {
$this->render("create", array());
}
}
示例4: tagslist
function tagslist()
{
require_once _base_ . '/lib/lib.table.php';
require_once $GLOBALS['where_framework'] . '/lib/lib.tags.php';
$lang =& DoceboLanguage::createInstance('tags', 'framework');
$id_tag = Get::req('id_tag', DOTY_INT, 0);
$tag_name = Get::req('tag', DOTY_STRING, '');
$filter = Get::req('filter', DOTY_STRING, '');
$nav_bar = new NavBar('ini', Get::sett('visuItem'), 0);
$nav_bar->setLink('index.php?modname=tags&op=tags&id_tag=' . $id_tag);
$ini = $nav_bar->getSelectedElement();
$tags = new Tags('*');
$resources = $tags->getResourceByTags($id_tag, false, false, $ini, Get::sett('visuItem'));
$GLOBALS['page']->add(getTitleArea(array($lang->def('_TAGS')), 'tags') . '<div class="std_block">' . '<div class="tag_list">', 'content');
while (list(, $res) = each($resources['list'])) {
$link = $res['permalink'];
$delim = strpos($link, '?') === false ? '?' : '&';
if (strpos($link, '#') === false) {
$link = $link . $delim . 'sop=setcourse&sop_idc=' . $res['id_course'];
} else {
$link = str_replace('#', $delim . 'sop=setcourse&sop_idc=' . $res['id_course'] . '#', $link);
}
$GLOBALS['page']->add('' . '<h2>' . '<a href="' . $link . '">' . $res['title'] . '</a>' . '</h2>' . '<p>' . $res['sample_text'] . '</p>' . '<div class="tag_cloud">' . '<span>' . $lang->def('_TAGS') . ' : </span>' . '<ul><li>' . implode('</li><li>', $res['related_tags']) . '</li></ul>' . '</div>' . '<br />', 'content');
}
$GLOBALS['page']->add('</div>' . $nav_bar->getNavBar($ini, $resources['count']) . '</div>', 'content');
}
示例5: getProductById
function getProductById($product_id)
{
$sql = "SELECT p.* FROM {$this->table_prefix}products p WHERE p.id=" . $product_id;
$result = $this->dbstuff->GetRow($sql);
if (empty($result) || !$result) {
return false;
}
$result['pubdate'] = @date("Y-m-d", $result['created']);
if (!empty($result['picture'])) {
$result['imgsmall'] = "../" . pb_get_attachmenturl($result['picture']) . ".small.jpg";
$result['imgmiddle'] = "../" . pb_get_attachmenturl($result['picture']) . ".middle.jpg";
$result['image'] = "../" . pb_get_attachmenturl($result['picture']);
$result['image_url'] = rawurlencode($result['picture']);
} else {
$result['image'] = pb_get_attachmenturl('', '', 'middle');
}
if (!empty($result['tag_ids'])) {
uses("tag");
$tag = new Tags();
$tag_res = $tag->getTagsByIds($result['tag_ids']);
if (!empty($tag_res)) {
$tags = null;
foreach ($tag_res as $key => $val) {
$tags .= '<a href="product/list.php?do=search&q=' . urlencode($val) . '" target="_blank">' . $val . '</a> ';
}
$result['tag'] = $tags;
unset($tags, $tag_res, $tag);
}
}
$this->info = $result;
return $result;
}
示例6: addTags
private static function addTags($model)
{
// add tags
if (!empty($_POST['tags'])) {
$taglist = explode(',', $_POST['tags']);
if ($taglist !== false) {
foreach ($taglist as &$tag) {
if ($tag === '') {
continue;
}
if (substr($tag, 0, 1) != '#') {
$tag = '#' . $tag;
}
$tagModel = new Tags();
$tagModel->taggedBy = 'API';
$tagModel->timestamp = time();
$tagModel->type = get_class($model);
$tagModel->itemId = $model->id;
$tagModel->tag = $tag;
$tagModel->itemName = $model->name;
$tagModel->save();
X2Flow::trigger('RecordTagAddTrigger', array('model' => $model, 'tags' => $tag));
}
}
}
}
示例7: assocciatePhotoWith
/**
* Assocciates photo with supplied tags, if tags does not exists
* they will be created.
*
* @param Zend_Db_Row $photo
* @param array $tagNames
*/
public function assocciatePhotoWith($photo, array $tagNames)
{
if ($photo instanceof Yag_Db_Table_Row) {
$photoId = $photo->id;
}
$photoId = $photo;
// Remove all references
$this->deleteByPhotoId($photoId);
$tags = new Tags();
$assoccTags = array();
foreach ($tagNames as $name) {
$name = trim($name);
// TODO: should be fixed by a filter automagic
if ($name == '') {
continue;
// skip bogus names in array.
}
$tag = $tags->findByName($name);
if (null == $tag) {
$tag = $tags->createRow();
$tag->name = (string) $name;
$tag->created_on = date('Y-m-d H:i:s');
// TODO: Should be handle behind
$tag->save();
}
$taggedPhotos = $this->createRow(array('tag_id' => $tag->id, 'photo_id' => $photoId));
$taggedPhotos->save();
$assoccTags[] = $tag;
}
return $assoccTags;
}
示例8: findAndAdd
public static function findAndAdd($title, $classify, $logid)
{
$title = zmf::filterInput($title, 't', 1);
if (!$title) {
return false;
}
$info = Tags::model()->find('title=:title AND classify=:classify', array(':title' => $title, ':classify' => $classify));
if (!$info) {
if (Yii::app()->session['checkHasBadword'] == 'yes') {
$status = Posts::STATUS_STAYCHECK;
} else {
$status = Posts::STATUS_PASSED;
}
unset(Yii::app()->session['checkHasBadword']);
$_data = array('title' => $title, 'name' => tools::pinyin($title), 'classify' => $classify, 'status' => $status, 'cTime' => time(), 'length' => mb_strlen($title, 'GBK'));
$modelB = new Tags();
$modelB->attributes = $_data;
if ($modelB->save()) {
$tagid = $modelB->id;
}
} else {
$tagid = $info['id'];
}
if ($tagid && $logid) {
$_info = TagRelation::model()->find('tagid=:tagid AND logid=:logid AND classify=:classify', array(':tagid' => $tagid, ':logid' => $logid, ':classify' => $classify));
if (!$_info) {
$_tagre = array('tagid' => $tagid, 'logid' => $logid, 'classify' => $classify, 'cTime' => zmf::now());
$modelC = new TagRelation();
$modelC->attributes = $_tagre;
$modelC->save();
}
}
return $tagid;
}
示例9: action_list
/**
* 列表页
*/
public function action_list()
{
$this->_add_css('styles/album/my_library.css');
$this->_add_script('scripts/dtree.js');
$tag = new Tags();
$cate = new Bookcategory();
$position = trim($this->getQuery('position'));
switch ($position) {
case 'is_hot':
$pageTitle = '热门文章';
break;
case 'is_recommend':
$pageTitle = '美文推荐';
break;
default:
$pageTitle = '最新文章';
break;
}
$this->template->position = $pageTitle;
$select = DB::select('a.*', 'cate.cate_name', 'u.username')->from(array('articles', 'a'))->join(array('article_categories', 'cate'))->on('cate.cate_id', '=', 'a.cate_id')->join(array('users', 'u'))->on('u.uid', '=', 'a.uid')->where('a.recycle', '=', 0)->where('a.is_show', '=', 1)->order_by('a.article_id', 'DESC');
if (!empty($position) && $position != 'is_new') {
$select->where('a.' . $position, '=', 1);
}
$this->template->cate_id = $cate_id = trim($this->getQuery('cate_id'));
if ($cate_id > 0) {
$select->where('a.cate_id', '=', $cate_id);
}
$this->template->pagination = $pagination = Pagination::factory(array('total_items' => count($select->execute()->as_array()), 'items_per_page' => 30));
$this->template->results = $select->limit($pagination->items_per_page)->offset($pagination->offset)->execute();
$this->template->tags = $tags = $tag->getHotTags('article');
if ($this->auth) {
$this->template->categories = $categories = $cate->getCates($this->auth['uid']);
}
}
示例10: showTagAction
public function showTagAction(Users $user, Tags $tag, $page = 1)
{
$this->view->mytag = $tag;
$this->view->page = $this->getPaginator($tag->getTaggedFiles($user), 25, $page);
$this->view->form = myForm::buildCommentForm($tag);
//这个应该去掉
$this->view->user = $user;
}
示例11: testMultiSearch
/**
* @covers Instaphp\Instagram\Tags::MultiSearch
* @todo Implement testMultiSearch().
*/
public function testMultiSearch()
{
$res = $this->object->multiSearch('test insta', ['count' => 10]);
$this->assertNotEmpty($res);
$this->assertInstanceOf('\\Instaphp\\Instagram\\Response', $res[0]);
$res = $this->object->multiSearch(['test', 'insta'], ['count' => 10]);
$this->assertNotEmpty($res);
$this->assertInstanceOf('\\Instaphp\\Instagram\\Response', $res[0]);
}
示例12: editAction
public function editAction(Tags $tag)
{
if ($this->request->isPost()) {
$data = $this->request->getPost();
$tag->update($data);
$this->redirectByRoute(['for' => 'tags.show', 'tag' => $tag->id]);
}
$this->view->myTag = $tag;
$this->view->form = $this->buildFormFromModel($tag);
}
示例13: getTagByName
public function getTagByName($name)
{
$tag = Tags::findFirst(['conditions' => 'name = :name:', 'bind' => ['name' => $name]]);
if (null == $tag) {
$tag = new Tags();
$tag->name = $name;
$tag->save();
}
return $tag;
}
示例14: insertRel
private function insertRel($value)
{
try {
$this->log->addInfo("Inicia funcion MainPeople::insertRel() ");
$tags = new Tags();
$rel = array(0, "lkp_persons", $value->id);
$tags->insert($rel);
} catch (\Excetion $e) {
$this->log->addError($e->getMessage(), array(basename(__FILE__) . "::" . __LINE__));
}
}
示例15: tagsToLinks
public function tagsToLinks($item)
{
$tags = $this->tagsModel->extractTags($item);
if ($tags) {
foreach ($tags[0] as $index => $tag) {
$url = $this->linkFactory->link('Search:default', ['s' => 'tag:' . $tag]);
$item = str_replace('[' . $tags[1][$index] . ']', "<a href=\"{$url}\"><span class=\"label label-info\">{$tag}</span></a> ", $item);
}
}
return $item;
}