/** * * @param type $id * @return type */ public function show($id) { try { return $this->repository->find($id); } catch (\Exception $e) { return ['error' => 'true', 'messege' => "Usuário não encontrado!"]; } }
/** * check exist wallet with user id * @param type $wallet * @param type $userId * @return boolean */ public function checkWalletDefault($wallet, $userId) { $data = $wallet->find()->where(['user_id' => $userId])->toArray(); if (count($data) == 0) { return true; } return false; }
/** * @desc This method display whole list of customers * @param type $controller This is controller objict * @param type isPaginate True/False * @return Return detail list of customer array */ function viewAll($controller, $isPaginate = false) { if ($isPaginate) { $data = $controller->paginate('User'); } else { $data = $controller->find("all"); } return $data; }
/** * _getUsermetas * * Returns the metadata from the selected user. * Use the first parameter for the id. * If it's empty it returns the logged in users metadata. * * @param mixed int|void $id ID of the user * @param array $options Options. * @return \Cake\ORM\Entity */ protected function _getUsermetas($id = null, $options = []) { $_options = ['autoCreate' => true]; $options = array_merge($_options, $options); if (!$id) { $id = $this->Controller->request->Session()->read($this->config('userId')); } $data = $this->Usermetas->find()->where(['user_id' => $id]); if ($data->Count() > 0) { return $data->first(); } $generated = null; if ($options['autoCreate']) { $generated = $this->_createUsermetas($id); } return $generated; }
/** * * @param type $numPage * @param type $query * @return type */ public static function consultaInmuebles($numPage, $query) { $limite = $numPage * 10; $inicio = $limite - 10; $json = array(); $jsonArray = array(); $query->limit($limite); $resultado = $query->find(); for ($i = $inicio; $i < count($resultado); $i++) { $inmueble = $resultado[$i]; $id = $inmueble->getObjectId(); $descripcion = $inmueble->get('descripcion'); $precio = $inmueble->get('precio'); $json['id'] = $id; $urlImg = APIInmueble::urlImagen($query); $json['descripcion'] = $descripcion; $json['precio'] = $precio; $json['url'] = $urlImg; $jsonArray[$i] = $json; } return $jsonArray; }
/** * * @param type $con * @return boolean * * * * * */ protected function parse_topseller($con, $from) { if (!$con) { return false; } $this->position = 1; $a = $con->find('a'); for ($i = 0; $i < count($a); $i++) { $link = $a[$i]->getAttribute('href'); $first = strpos($link, '.de/') + 4; $fl = substr($link, $first); $pzn = $this->strict_numbers(substr($fl, 0, strpos($fl, '/'))); if (in_array($pzn, $this->pzn, TRUE)) { if ($this->save_links) { $this->mysql->insert_links(self::ID, $link, $this->position, $from); } $this->products_url[] = ['link' => $link, 'position' => $this->position, 'kws' => '', 'from' => $from]; // var_dump($link); } ++$this->position; } }
/** * * @param type $id * @return type */ public function find($id) { $result = $this->cbo->find($id); return $result; }
/** * 清理无用HTML * @param type $domContent */ private function clearHTML($domContent) { //清理隐藏的HTML $dom_hiddens = $domContent->find('[style^=display]'); foreach ($dom_hiddens as $dom_hidden) { $dom_hidden->outertext = ''; } //清理内容部分图片以防重复 $dom_imgs = $domContent->find('img[src^=uploadpic]'); foreach ($dom_imgs as $dom_img) { $dom_img->outertext = ''; } //描述标记 $dom_h3s = $domContent->find('h3'); foreach ($dom_h3s as $dom_h3) { if (mb_substr($dom_h3->innertext, 0, 2, 'utf-8') == '描述') { $dom_h3->outertext = ''; continue; } if (mb_substr($dom_h3->innertext, 0, 2, 'utf-8') == '地图') { $dom_h3->next_sibling()->outertext = ''; $dom_h3->outertext = ''; continue; } if (mb_substr($dom_h3->innertext, 0, 2, 'utf-8') == '图片') { $dom_h3->outertext = ''; continue; } } //附加信息 $dom_mt = $domContent->find('p.mt', 0); $dom_mt->outertext = ''; }
/** * Metoda pobiera specyfikacje produktu * @param type $element simple_html_dom fragment strony * @return type json specyfikacja produktu */ public function getProductSpecs($element) { $specs = array(); $i = 0; foreach ($element->find(".specs-group") as $spec) { if (is_object($spec->find(".section-header h3", 0))) { $specs[$i]["name"] = $spec->find(".section-header h3", 0)->text(); } $specs[$i]["specs"] = array(); $j = 0; foreach ($spec->find("table tr") as $row) { if (is_object($row->find("th", 0))) { $specs[$i]["specs"][$j][] = $row->find("th", 0)->text(); } if (is_object($row->find("td", 0))) { $specs[$i]["specs"][$j][] = $row->find("td", 0)->text(); } else { if (count($row->find("td ul li")) > 0) { $attrs = array(); foreach ($row->find("td ul li") as $attr) { if (is_object($attr->find("a", 0))) { $attrs[] = $attr->find("a", 0)->text(); } else { $attrs[] = $attr->text(); } } $specs[$i]["specs"][$j][] = implode(",", $attrs); } } $j++; } $i++; } return json_encode($specs); }
/** * get account by email * @param type $user * @param type $email * @return type */ public function getAccount($user, $email) { return $user->find()->where(['email' => $email])->first(); }
/** * @param $entity * @param $id * @return mixed */ public function find($entity, $id) { $result = $this->dao->find($entity, $id); return $result; }
/** * This function provide the next menu order value for related Content. * * @param type $parent * @param type $content_type * @return int */ protected function _getNextMenuOrder($parent_id, $cms_content_type_id) { return $this->Table->find('all')->where(['parent_id' => $parent_id, 'cms_content_type_id' => $cms_content_type_id])->order(['menu_order' => 'DESC'])->count() + 1; }
/** * Retrieve the list of Content, and loads the template for the view in list. */ public function index() { $this->set('data', $this->Content->find(['type_id' => $this->type_id, 'limit' => $this->limit])); $this->set('_serialize', ['data']); }
/** * Metoda pobiera informacje o użyteczności recenzji * @param type $element simple_html_dom fragment strony * @param type $i int index elementu * @return type array tablica z informacją o użyteczności recenzji */ public function getUsefullnes($element, $i) { $rate = $element->find(".rate-count", $i); $rate_count = $rate->find("strong", 0)->text(); $rate_positive = $rate->find("strong", 1)->text(); $rate_positive = str_replace("%", "", $rate_positive); $comment_rate = array(); $comment_rate[0] = round($rate_count * $rate_positive / 100); $comment_rate[1] = round($rate_count - $comment_rate[0]); return $comment_rate; }