public function search($params) { $query = AliasUrl::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id])->andFilterWhere(['like', 'private', $this->private])->andFilterWhere(['like', 'public', $this->public]); return $dataProvider; }
/** * Finds the AliasUrl model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param string $id * * @return AliasUrl the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = AliasUrl::findOne($id)) !== NULL) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @param $id * @param $public * @param bool $is_frontend * @return bool */ public static function isDuplicate($id, $public, $is_frontend = TRUE) { $model = AliasUrl::find()->where(" id != " . $id . " ")->andWhere(['public' => $public])->andWhere(['is_frontend' => $is_frontend])->asArray()->one(); return sizeof($model) ? TRUE : FALSE; }
/** * Parses the user request. * * @param Request $request the request component * * @return array|boolean the route and the associated parameters. The latter is always empty * if [[enablePrettyUrl]] is false. False is returned if the current request cannot be successfully parsed. */ public function parseRequest($request) { if ($this->enablePrettyUrl) { $pathInfo = $request->getPathInfo(); /* @var $rule UrlRule */ foreach ($this->rules as $rule) { if (($result = $rule->parseRequest($this, $request)) !== FALSE) { return $result; } } if ($this->enableStrictParsing) { return FALSE; } Yii::trace('No matching URL rules. Using default URL parsing logic.', __METHOD__); $suffix = (string) $this->suffix; if ($suffix !== '' && $pathInfo !== '') { $n = strlen($this->suffix); if (substr_compare($pathInfo, $this->suffix, -$n, $n) === 0) { $pathInfo = substr($pathInfo, 0, -$n); if ($pathInfo === '') { // suffix alone is not allowed return FALSE; } } else { // suffix doesn't match return FALSE; } } return [$pathInfo, []]; } else { Yii::trace('Pretty URL not enabled. Using default URL parsing logic.', __METHOD__); $route = $request->getQueryParam($this->routeParam, ''); if (is_array($route)) { $route = ''; } /* ~ C006 UPDATE */ // $array_qs = []; $uri = $_SERVER['REQUEST_URI']; $qs = ''; if (stripos($uri, '?') != FALSE) { list($uri, $qs) = explode('?', $_SERVER['REQUEST_URI']); $qs = urldecode($qs); } $uri = preg_replace('/[^0-9|a-z|\\-|_|\\/|\\.]/', '', strtolower(rtrim($uri, '/'))); if (TRUE && $uri && strpos($uri, 'index.php') == FALSE) { $model = AliasUrl::find()->where(['public' => $uri])->andWhere(['is_frontend' => $this->is_frontend])->orderBy("`is_frontend` DESC, CHAR_LENGTH(`public`) ASC")->asArray()->one(); if (sizeof($model)) { $private = $model['private']; if (stripos($private, '?') != FALSE) { list($private, $qs2) = explode('?', $private); $qs .= $qs2; } $array_qs = self::queryStringToArray($qs); // print_r($_SERVER); // echo PHP_EOL; // print_r($model); // echo PHP_EOL; // print_r($array_qs); // echo PHP_EOL; // echo $private; // exit; return ["" . $private, $array_qs]; } } else { $array_qs = self::queryStringToArray($qs); if (isset($array_qs['r'])) { $route = $array_qs['r']; unset($array_qs['r']); } } return ["" . $route, $array_qs]; } }