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; }
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; }
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; }
/** * 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; }
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; }
/** * 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(); }
/** * 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')); } }
/** * 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; } }
//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();
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; }
/** * 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; }
/** * 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; }
/** * @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; } }
/** * 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; }
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; $nodeLists['pager'] = $pager; $nodeLists['items'] = $nodes; $widgetData[$block] = $nodeLists; break; case 'tagnode': $tagNodesNum = $this->_siteConfig['widgetCfg']['tagNodesNum']; $nodeLists = array(); if ($tid = $this->_params['tid']) { $tagNodes = NodeTags::find(array('conditions' => 'tid=' . $tid, 'limit' => $tagNodesNum)); $nodes = array(); foreach ($tagNodes as $key => $tagNode) { $treeStruct = $tagNode->TreeStruct; $treeData = $treeStruct->TreeData->toArray(); $nodes[$key] = $treeStruct->toArray(); $nodes[$key]['TreeData'] = $treeData; } $nodes = TreeStruct::addNodesAttr($nodes, array('menu' => true, 'menuLevel' => 2)); $nodeLists['items'] = $nodes; $nodeLists['title'] = '"' . $this->_params['tag']->name . '" 相关文章'; } $widgetData[$block] = $nodeLists; break; case 'search': $nodeLists = array(); $keyword = $this->_params['search_keyword']; if ($keyword) { $itemPer = $this->_siteConfig['widgetCfg']['listItemPer']; $start = ($this->_params['p'] - 1) * $itemPer; $temNodeDatas = TreeData::find(array('conditions' => 'content like :keyword:', 'bind' => array('keyword' => '%' . $keyword . '%'), 'limit' => array('number' => $itemPer, 'offset' => $start), 'order' => 'id desc')); $nodes = array(); foreach ($temNodeDatas as $key => $temNodeData) { $treeStruct = $temNodeData->TreeStruct; $treeData = $temNodeData->toArray(); $nodes[$key] = $treeStruct->toArray(); $nodes[$key]['TreeData'] = $treeData; } $nodes = TreeStruct::addNodesAttr($nodes, array('menu' => true, 'menuLevel' => 2)); $totalNodes = TreeData::count(array('conditions' => 'content like :keyword:', 'bind' => array('keyword' => '%' . $keyword . '%'))); $params = array('total_rows' => $totalNodes, 'now_page' => $this->_params['p'], 'list_rows' => $itemPer); $pagerLib = new Pager($params); $pager = $pagerLib->show(3); // $nodeLists['is_search'] = 1; $searchResultStr = $totalNodes ? $totalNodes . ' 条记录' : '没有记录'; $nodeLists['title'] = '"' . $keyword . '" 的搜索结果: ' . $searchResultStr; $nodeLists['pager'] = $pager; $nodeLists['items'] = $nodes; } $widgetData[$block] = $nodeLists; break; default: break; } break; case 'listGroup': case 'navTab': case 'panel': case 'panel2': $widgetData[$block]['blockName'] = $block; $widgetData[$block]['items'] = array(); if (isset($this->_siteConfig['blockCfg'][$view . '_' . $block])) { $blockParams = $this->_siteConfig['blockCfg'][$view . '_' . $block]; foreach ($blockParams as $blockParam) { $nodeLists = array('title' => $blockParam['title'], 'data' => array()); $blockNode = TreeStruct::findFirst($blockParam['nid']); $temNodes = TreeStruct::find(array('conditions' => "lft>?1 and rgt<?2 and type=:type:", 'bind' => array(1 => $blockNode->lft, 2 => $blockNode->rgt, 'type' => 'article'), 'limit' => $blockNum, 'order' => 'id desc')); $nodes = array(); foreach ($temNodes as $key => $temNode) { $treeData = array(); if ($temNode->TreeData) { $treeData = $temNode->TreeData->toArray(); } $nodes[$key] = $temNode->toArray(); $nodes[$key]['TreeData'] = $treeData; } $nodes = TreeStruct::addNodesAttr($nodes); $nodeLists['data'] = $nodes; $widgetData[$block]['items'][] = $nodeLists; } } else { $nodeLists = array('title' => '', 'data' => array()); switch ($block) { case 'hot': $nodeLists['title'] = '热门文章'; $hotNids = $this->_siteConfig['hotNids']; $hotNidsStr = implode(',', $hotNids); $temNodes = TreeStruct::find(array('conditions' => "id in (" . $hotNidsStr . ") and type=:type:", 'bind' => array('type' => 'article'), 'order' => 'id asc')); $nodes = array(); foreach ($temNodes as $key => $temNode) { $treeData = $temNode->TreeData->toArray(); $nodes[$key] = $temNode->toArray(); $nodes[$key]['TreeData'] = $treeData; } $nodes = TreeStruct::addNodesAttr($nodes); $nodeLists['data'] = $nodes; break; case 'relation': $nodeLists['title'] = '相关文章'; if ($this->_params['node']->type == 'article') { $temNodes = TreeStruct::find(array('conditions' => "pid=?1 and type=:type:", 'bind' => array(1 => $this->_params['node']->pid, 'type' => 'article'), 'limit' => $blockNum, '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); $nodeLists['data'] = $nodes; } break; default: break; } $widgetData[$block]['items'][] = $nodeLists; } break; case 'breadcrumb': $widgetData = $this->_initBreadcrumb(); break; case 'nodetag': $temNodeTags = NodeTags::find(array('conditions' => 'nid=?1', 'bind' => array(1 => $this->_params['node']->id))); $nodeTags = array(); foreach ($temNodeTags as $key => $temNodeTag) { $tag = $temNodeTag->Tags->toArray(); $nodeTags[$key] = $temNodeTag->toArray(); $nodeTags[$key]['Tags'] = $tag; } $widgetData = $nodeTags; break; case 'siblings': $siblings = array('prev' => array('title' => '上一篇', 'item' => array()), 'next' => array('title' => '下一篇', 'item' => array())); switch ($block) { case 'node': if ($this->_params['node']->type == 'article') { $prevNode = TreeStruct::findFirst(array('conditions' => "lft<?1 and pid=?2 and type=:type:", 'bind' => array(1 => $this->_params['node']->lft, 2 => $this->_params['node']->pid, 'type' => 'article'), 'order' => 'lft desc')); $nextNode = TreeStruct::findFirst(array('conditions' => "lft>?1 and pid=?2 and type=:type:", 'bind' => array(1 => $this->_params['node']->lft, 2 => $this->_params['node']->pid, 'type' => 'article'), 'order' => 'lft asc')); $temNodes = array('prev' => $prevNode, 'next' => $nextNode); $nodes = array(); foreach ($temNodes as $key => $temNode) { if ($temNode) { $treeData = $temNode->TreeData->toArray(); $nodes[$key] = $temNode->toArray(); $nodes[$key]['TreeData'] = $treeData; $nodes[$key]['title'] = $treeData['title']; } } $nodes = TreeStruct::addNodesAttr($nodes); $siblings['prev']['item'] = $nodes['prev']; $siblings['next']['item'] = $nodes['next']; } break; case 'tag': $siblings['prev']['title'] = '上一个'; $siblings['next']['title'] = '下一个'; if ($tag = $this->_params['tag']) { $pinyinPrefix = $tag->pinyinPrefix; if (!$pinyinPrefix) { break; } $prevTag = Tags::findFirst(array('conditions' => "pinyinPrefix=:pinyin:", 'bind' => array('pinyin' => $pinyinPrefix), 'order' => 'id desc'))->toArray(); $nextTag = Tags::findFirst(array('conditions' => "pinyinPrefix=:pinyin:", 'bind' => array('pinyin' => $pinyinPrefix), 'order' => 'id asc'))->toArray(); $tags = array('prev' => $prevTag, 'next' => $nextTag); $tags = Tags::addTagsAttr($tags); foreach ($tags as $key => $tag) { $tags[$key]['title'] = $tag['name']; } $siblings['prev']['item'] = $tags['prev']; $siblings['next']['item'] = $tags['next']; } break; default: break; } $widgetData[$block]['items'] = $siblings; break; case 'xtSidebars': $pNids = array($this->_params['node']->id); foreach ($this->_params['nodeParents'] as $nodeParent) { $pNids[] = $nodeParent->id; } $xtSidebars = TreeStruct::getXtSidebars($pNids); $widgetData = $xtSidebars; break; case 'list_header': $list_header = array(); $temNodes = count($this->_params['nodeChilds']) ? $this->_params['nodeChilds'] : $this->_params['nodeSiblings']; if ($temNodes) { foreach ($temNodes as $key => $temNode) { $treeData = $temNode->TreeData->toArray(); $list_header[$key] = $temNode->toArray(); $list_header[$key]['TreeData'] = $treeData; $list_header[$key]['current'] = false; if ($this->_params['node']->id == $temNode->id) { $list_header[$key]['current'] = true; } } $list_header = TreeStruct::addNodesAttr($list_header); } $widgetData = $list_header; break; case 'search_header': $search_result = array(); $search_result['search_keyword'] = $this->_params['search_keyword']; if ($search_result['search_keyword']) { $search_result['search_result_title'] = '<b>"' . $this->_params['search_keyword'] . '</b>" 的搜索结果.'; } else { $search_result['search_result_title'] = '请输入关键字搜索!'; } $widgetData = $search_result; break; case 'sitemap': $sitemap = array(); $sitemap['menus'] = $this->_menus; $allTags = array(); $temTags = Tags::find(array('conditions' => "", 'order' => 'pinyinPrefix'))->toArray(); $temTags = Tags::addTagsAttr($temTags); foreach ($temTags as $key => $temTag) { $pinyinKey = $temTag['pinyinPrefix'] ? trim($temTag['pinyinPrefix']) : '0-9'; $allTags[$pinyinKey][] = $temTag; } unset($temTags); $sitemap['tags'] = $allTags; // echo '<pre>';print_r($sitemap);echo '</pre>';die(); $widgetData = $sitemap; break; case 'notfound': $widgetData = ''; break; case 'test': $result = 'test'; $widgetData = $result; break; default: break; } return $widgetData; }