本文整理汇总了PHP中Tags::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::find方法的具体用法?PHP Tags::find怎么用?PHP Tags::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tags
的用法示例。
在下文中一共展示了Tags::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchCidiansCloud
public function fetchCidiansCloud($cidianCloudNum)
{
$totalTags = Tags::count(array('is_cidian' => 1));
$randStart = mt_rand(0, $totalTags - $cidianCloudNum);
$tags = Tags::find(array('is_cidian' => 1, 'limit' => array('number' => $cidianCloudNum, 'offset' => $randStart)))->toArray();
$cidianBgs = array(1, 3);
foreach ($tags as $key => $tag) {
$randBg = mt_rand($cidianBgs[0], $cidianBgs[1]);
$tags[$key]['randBg'] = $randBg;
}
return $tags;
}
示例2: incTagsData
public function incTagsData($startDate, $endDate)
{
$INC = new Incomes();
$Tags = new Tags();
$inctags = [];
$allTags = $Tags->find('all');
foreach ($allTags as $tag) {
$amount = (int) $this->db->query("SELECT Sum(inc.cost ) as total FROM inc_tags as tag,incomes as inc where tag_id = ? and inc.inc_id = tag.inc_id and inc.date >= ? and inc.date <= ? ", [$tag->id, $startDate, $endDate])->first()->total;
if ($amount > 0) {
$inctags[$tag->name] = $amount;
}
}
return $inctags;
}
示例3: expTagsData
public function expTagsData($user_id, $startDate, $endDate)
{
$EXP = new Expenses();
$Tags = new Tags();
$exptags = [];
$allTags = $Tags->find('all');
foreach ($allTags as $tag) {
$amount = (int) $this->db->query("SELECT Sum(exp.cost ) as total FROM exp_tags as tag,expenses as exp where tag_id = ? and exp.exp_id = tag.exp_id and exp.date >= ? and exp.date <= ? and exp.user_id = ?", [$tag->id, $startDate, $endDate, $user_id])->first()->total;
if ($amount > 0) {
$exptags[$tag->name] = $amount;
}
}
return $exptags;
}
示例4: getSuggestions
/**
* getSuggestions
*
* This method returns an array of strings matching the user's query for
* display in the autocomplete box.
*
* @param string $query The user query
*
* @return array The suggestions for the provided query
* @access public
*/
public function getSuggestions($query)
{
$tagList = array();
$tag = new Tags();
$query = $tag->escape($query);
$tag->whereadd("lower(\"tag\") LIKE lower('{$query}%')");
$tag->whereadd('"id" IN (SELECT DISTINCT "tag_id" FROM "resource_tags")');
$tag->find();
if ($tag->N) {
while ($tag->fetch()) {
$tagList[] = $tag->tag;
}
}
return $tagList;
}
示例5: indexAction
public function indexAction()
{
$response = new ApiResponse();
if ($this->request->isGet()) {
$limit = (int) $this->request->get('limit');
$page = (int) $this->request->get('page');
$questions = Tags::find();
$paginator = new PaginatorModel(array("data" => $questions, "limit" => $limit, "page" => $page));
$page = $paginator->getPaginate();
$response->setResponse($page->items, count($questions));
return $response;
} else {
$response->setResponseError('Wrong HTTP Method');
}
return $response;
}
示例6: searchAction
/**
* Searches for tags
*/
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Tags", $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "id";
$tags = Tags::find($parameters);
if (count($tags) == 0) {
$this->flash->notice("The search did not find any tags");
return $this->dispatcher->forward(array("controller" => "tags", "action" => "index"));
}
$paginator = new Paginator(array("data" => $tags, "limit" => 10, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$rules = array('category' => 'required|Integer', 'condition' => 'required|Integer', 'name' => 'required', 'description' => 'required', 'donor' => 'required|Integer', 'orignal_price' => 'required|Numeric', 'price' => 'required|Numeric', 'image' => 'required', 'attributes' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return $this->response(array('statusCode' => 400, 'statusDescription' => 'Bad Request', 'errors' => $validator->messages()->toJson()));
} else {
$iGetInstitute = Donor::where('user_id', Input::get('donor'))->first();
$product = Product::find($id)->update(array('products_price' => Input::get('price'), 'products_orginal_price' => Input::get('orignal_price'), 'brand' => Input::get('brand', NULL), 'products_status' => Input::get('products_status', 1), 'products_donar' => Input::get('donor'), 'condition' => Input::get('condition'), 'products_image' => Input::get('image'), 'gender' => Input::get('gender'), 'age_range' => Input::get('age_range'), 'collections_id' => Input::get('collections_id'), 'seasons_id' => Input::get('seasons_id'), 'types_id' => Input::get('types_id'), 'freshly_faved' => Input::get('freshly_faved'), 'institution_id' => $iGetInstitute->institution_id));
// $product->save();
$category = Categories::find(Input::get('category'));
$product = Product::find($id);
//$product->productCategory()->save($category);
Product::find($id)->productCategory()->detach();
//updateExistingPivot($category->categories_id, array("categories_id"=>$category->categories_id),false);
$product->productCategory()->save($category);
if (Input::has('tags')) {
Product::find($id)->productTags()->detach();
$product = Product::find($id);
$inptags = Input::get("tags");
$tags = explode(",", $inptags);
foreach ($tags as $key => $value) {
$ctag = Tags::find($value);
if ($ctag) {
$product->productTags()->save($ctag);
}
}
}
$attributes = json_decode(Input::get("attributes"), TRUE);
//$attribs = array();
ProductsAttributes::where("products_id", $id)->delete();
foreach ($attributes as $key => $value) {
$opt_values = explode(",", $value);
foreach ($opt_values as $optval) {
//echo $key." ".$optval."<br/>";
$attribute = new ProductsAttributes(array('options_id' => $key, 'options_values_id' => $optval));
$product->productsAttributes()->save($attribute);
}
}
$description = ProductsDescription::find($id)->update(array("products_name" => Input::get("name"), "products_description" => Input::get("description")));
//$product->productsDescription()->save($description);
return $this->response(array('statusCode' => 100, 'statusDescription' => 'Success'));
}
}
示例8: addResource
/**
* Add a resource to the user's account.
*
* @param object $resource The resource to add.
* @param object $list The list to store the resource in.
* @param array $tagArray An array of tags to associate with the
* resource.
* @param string $notes User notes about the resource.
* @param bool $replaceExisting Whether to replace all existing tags (true)
* or append to the existing list (false).
*
* @return bool
* @access public
*/
public function addResource($resource, $list, $tagArray, $notes, $replaceExisting = true)
{
$join = new User_resource();
$join->user_id = $this->id;
$join->resource_id = $resource->id;
$join->list_id = $list->id;
if ($join->find(true)) {
$join->notes = $notes;
$join->update();
// update() will return false if we save without making any changes,
// but we always want to report success after this point.
$result = true;
} else {
if ($notes) {
$join->notes = $notes;
}
$result = $join->insert();
}
if ($result) {
$join = new Resource_tags();
$join->resource_id = $resource->id;
$join->user_id = $this->id;
$join->list_id = $list->id;
if ($replaceExisting) {
// Delete old tags -- note that we need to clone $join for this
// operation or else it will be broken when we use it for searching
// below.
$killer = clone $join;
$killer->delete();
}
// Add new tags, if any:
if (is_array($tagArray) && count($tagArray)) {
foreach ($tagArray as $value) {
$value = str_replace('"', '', $value);
$tag = new Tags();
$tag->tag = $value;
if (!$tag->find(true)) {
$tag->insert();
}
$join->tag_id = $tag->id;
// Don't save duplicate tags!
if (!$join->find(false)) {
$join->insert();
}
}
}
// Update list modification date
$list->updateModifiedDate();
return true;
} else {
return false;
}
}
示例9: var_dump
//If the imageTag could not be saved, dump the error message
if (!$imagesTags->save()) {
var_dump($imagesTags->getMessages());
$app->response->setStatusCode('500');
$app->response->send();
}
$tags[] = $tag;
}
$image->imagesTags->tags = $tags;
//There was an error saving the tags. Dump the error message
if (!$image->save()) {
var_dump($image->getMessages());
$app->response->setStatusCode('500');
$app->response->send();
}
//Return status code 200 if all went well
$app->response->setStatusCode('200');
$app->response->setJsonContent([]);
$app->response->send();
});
/**
* Search for tags
*/
$app->get('/tags', function () {
$request = new Phalcon\Http\Request();
$term = $request->getQuery('term', null, false);
$resultSet = Tags::find('name LIKE \'%' . $term . '%\' AND is_used = 1');
echo json_encode($resultSet->toArray());
});
//Handle the request
$app->handle();
示例10: removeTag
function removeTag($tagId, $user, $removeFromAllResources = false)
{
require_once ROOT_DIR . '/services/MyResearch/lib/Tags.php';
require_once ROOT_DIR . '/services/MyResearch/lib/Resource_tags.php';
$rTag = new Resource_tags();
if (!$removeFromAllResources) {
$rTag->resource_id = $this->id;
}
$rTag->tag_id = $tagId;
$rTag->user_id = $user->id;
$rTag->find();
if ($rTag->N > 0) {
while ($rTag->fetch()) {
$rTag->delete();
}
} else {
//the tag was not found.
return false;
}
//Check to see if the tag is still in use by any user for any resource.
$rTag = new Resource_tags();
$rTag->tag_id = $tagId;
$rTag->find();
if ($rTag->N == 0) {
//Tag is still in use, delete it.
$tags = new Tags();
$tags->id = $tagId;
if ($tags->find(true)) {
$tags->delete();
}
}
return true;
}
示例11: processTagSearch
/**
* Process a search for a particular tag.
*
* @access private
* @param string $lookfor The tag to search for
* @return array A revised searchTerms array to get matching Solr records
* (empty if no tag matches found).
*/
private function processTagSearch($lookfor)
{
// Include the app database objects
require_once ROOT_DIR . '/services/MyResearch/lib/Tags.php';
require_once ROOT_DIR . '/services/MyResearch/lib/Resource.php';
// Find our tag in the database
$tag = new Tags();
$tag->tag = $lookfor;
$newSearch = array();
if ($tag->find(true)) {
// Grab the list of records tagged with this tag
$resourceList = $tag->getResources();
if (count($resourceList)) {
$newSearch[0] = array('join' => 'OR', 'group' => array());
foreach ($resourceList as $resource) {
$id = $resource->record_id;
if ($resource->source == 'eContent') {
$id = 'econtentRecord' . $id;
}
$newSearch[0]['group'][] = array('field' => 'id', 'lookfor' => $id, 'bool' => 'OR');
}
}
}
return $newSearch;
}
示例12: _processTagSearch
/**
* Process a search for a particular tag.
*
* @param string $lookfor The tag to search for
*
* @return array A revised searchTerms array to get matching Solr
* records (empty if no tag matches found).
* @access private
*/
private function _processTagSearch($lookfor)
{
// Include the app database objects
include_once 'services/MyResearch/lib/Tags.php';
include_once 'services/MyResearch/lib/Resource.php';
// Find our tag in the database
$tag = new Tags();
$tag->tag = $lookfor;
$tagList = array();
if ($tag->find(true)) {
// Grab the list of records tagged with this tag
$resourceList = array();
$resourceList = $tag->getResources();
if (count($resourceList)) {
foreach ($resourceList as $resource) {
$tagList[] = $resource->record_id;
}
}
}
return $tagList;
}
示例13: addResource
/**
* @param Resource $resource
* @param User_list $list
* @param string[] $tagArray
* @param string $notes
* @param bool $updateSolr
* @return bool
*/
function addResource($resource, $list, $tagArray, $notes, $updateSolr = true)
{
require_once 'User_resource.php';
require_once 'Tags.php';
$join = new User_resource();
$join->user_id = $this->id;
$join->resource_id = $resource->id;
$join->list_id = $list->id;
if ($join->find(true)) {
if ($notes) {
$join->notes = $notes;
$join->update();
}
$result = true;
} else {
if ($notes) {
$join->notes = $notes;
}
$result = $join->insert();
}
if ($result) {
if (is_array($tagArray) && count($tagArray)) {
require_once 'Resource_tags.php';
$join = new Resource_tags();
$join->resource_id = $resource->id;
$join->user_id = $this->id;
$join->list_id = $list->id;
$join->delete();
foreach ($tagArray as $value) {
$value = trim(strtolower(str_replace('"', '', $value)));
$tag = new Tags();
$tag->tag = $value;
if (!$tag->find(true)) {
$tag->insert();
}
$join->tag_id = $tag->id;
$join->insert();
}
}
if ($updateSolr) {
$list->updateDetailed(true);
}
//Make a call to strands to update that the item was added to the list
global $configArray;
if (isset($configArray['Strands']['APID'])) {
if ($resource->source == 'eContent') {
$strandsUrl = "http://bizsolutions.strands.com/api2/event/addtofavorites.sbs?apid={$configArray['Strands']['APID']}&item={$resource->record_id}&user={$this->id}";
} else {
$strandsUrl = "http://bizsolutions.strands.com/api2/event/addtofavorites.sbs?apid={$configArray['Strands']['APID']}&item=econtentRecord{$resource->record_id}&user={$this->id}";
}
file_get_contents($strandsUrl);
}
return true;
} else {
return false;
}
}
示例14: addTag
/**
* Add a tag to the current resource.
*
* @param string $tag The tag to save.
* @param object $user The user posting the tag.
*
* @return bool True on success, false on failure.
* @access public
*/
public function addTag($tag, $user)
{
$tag = trim($tag);
if (!empty($tag)) {
include_once 'services/MyResearch/lib/Tags.php';
include_once 'services/MyResearch/lib/Resource_tags.php';
$tags = new Tags();
$tags->tag = $tag;
if (!$tags->find(true)) {
$tags->insert();
}
$rTag = new Resource_tags();
$rTag->resource_id = $this->id;
$rTag->tag_id = $tags->id;
if (!$rTag->find()) {
$rTag->user_id = $user->id;
$rTag->insert();
}
}
return true;
}
示例15: fetchWidgetData
public function fetchWidgetData($view, $block = '')
{
$widgetData = array();
$blockCfgKey = $block ? $view . '_' . $block : $view;
$blockCfg = $this->_siteConfig['blockCfg'][$blockCfgKey];
$blockNum = $this->_siteConfig['widgetCfg']['blockNum'];
switch ($view) {
case 'slider':
//理财故事
//理财故事
case 'btslider':
$widgetData[$block] = array('blockName' => $block, 'items' => $this->_siteConfig['slider'][$block]);
break;
case 'dailyword':
$dailyword['title'] = '天天词汇';
$dailyword['word'] = Tags::findFirst(array("conditions" => "is_cidian = ?1", "bind" => array(1 => 1)))->toArray();
$widgetData = $dailyword;
break;
case 'content':
switch ($block) {
case 'node':
$content = TreeData::findFirst($this->_params['nid'])->toArray();
$content['content'] = htmlspecialchars_decode($content['content']);
$widgetData[$block]['content'] = $content;
break;
case 'tag':
$content = Tags::findFirst($this->_params['tid'])->toArray();
$content['content'] = htmlspecialchars_decode($content['description']);
$content['title'] = $content['name'];
$widgetData[$block]['content'] = $content;
break;
case 'static':
$static_content = TreeStruct::findFirst(array("conditions" => "pid = ?1", "bind" => array(1 => $this->_params['nid']), 'order' => 'lft asc'));
$content = array();
if ($static_content) {
$content['title'] = $static_content->TreeData->title;
$content['content'] = htmlspecialchars_decode($static_content->TreeData->content);
}
$widgetData[$block]['blockName'] = $block;
$widgetData[$block]['content'] = $content;
break;
default:
break;
}
break;
case 'cidian':
$cidianCloudNum = $this->_siteConfig['widgetCfg']['cidianCloudNum'];
$tags = Tags::fetchCidiansCloud($cidianCloudNum);
$widgetData = $tags;
break;
case 'hangqing':
case 'lilv':
case 'tool':
break;
case 'taglist':
$taglist = array();
$itemPer = $this->_siteConfig['widgetCfg']['listItemPer'];
$start = ($this->_params['p'] - 1) * $itemPer;
if ($this->_params['tagPrefix']) {
$conditions = 'pinyinPrefix="' . $this->_params['tagPrefix'] . '" and is_cidian=1';
} else {
$conditions = 'is_cidian=1';
}
$taglist['items'] = Tags::find(array('conditions' => $conditions, 'order' => 'id desc', 'limit' => array('number' => $itemPer, 'offset' => $start)))->toArray();
$totalTags = Tags::count($conditions);
$params = array('total_rows' => $totalTags, 'now_page' => $this->_params['p'], 'list_rows' => $itemPer);
$pagerLib = new Pager($params);
$pager = $pagerLib->show(3);
$taglist['pager'] = $pager;
// echo '<pre>';print_r($taglist);echo '</pre>';
$widgetData = $taglist;
break;
case 'taglist_header':
$optRanges = array(97, 122);
$options = array();
$options[] = '0-9';
for ($i = $optRanges[0]; $i <= $optRanges[1]; $i++) {
$options[] = chr($i);
}
$widgetData = $options;
break;
case 'list':
switch ($block) {
case 'node':
$nodeLists = array();
$itemPer = $this->_siteConfig['widgetCfg']['listItemPer'];
$start = ($this->_params['p'] - 1) * $itemPer;
$temNodes = TreeStruct::find(array('conditions' => 'lft>?1 and rgt<?2 and type=:type:', 'bind' => array(1 => $this->_params['node']->lft, 2 => $this->_params['node']->rgt, 'type' => 'article'), 'limit' => array('number' => $itemPer, 'offset' => $start), 'order' => 'id desc'));
$nodes = array();
foreach ($temNodes as $key => $temNode) {
$treeData = $temNode->TreeData->toArray();
$nodes[$key] = $temNode->toArray();
$nodes[$key]['TreeData'] = $treeData;
}
$nodes = TreeStruct::addNodesAttr($nodes, array('menu' => true, 'menuLevel' => 1));
$totalNodes = TreeStruct::count(array('conditions' => 'lft>?1 and rgt<?2 and type=:type:', 'bind' => array(1 => $this->_params['node']->lft, 2 => $this->_params['node']->rgt, 'type' => 'article')));
$params = array('total_rows' => $totalNodes, 'now_page' => $this->_params['p'], 'list_rows' => $itemPer);
$pagerLib = new Pager($params);
$pager = $pagerLib->show(3);
$nodeLists['title'] = $this->_params['node']->TreeData->title;
//.........这里部分代码省略.........