public function getCategoryNews($url, $cityId) { $result = file_get_contents($url); $ar = explode('forecast-brief forecast-item', $result); // Сегодняшний день $newMatches = array(); $ar2 = explode('"current-weather"', $ar[0]); $ar2 = explode('current-weather__comment', $ar2[1]); $newMatches[1] = "Сейчас"; $ar2 = explode('current-weather__thermometer_type_now">', $ar2[1]); $newMatches[2] = trim(strip_tags('<span class="' . $ar2[0])); $ar2 = explode('current-weather__col_type_after', $ar2[1]); $ar3 = explode(' ', $ar2[0]); $newMatches[3] = $ar3[0]; $ar2 = explode('current-weather__info', $ar2[2]); $ar2 = explode('weather__thermometer_type_after', $ar2[0]); $newMatches[4] = trim(strip_tags('<span class="' . $ar2[1])); $newMatches[5] = $this->getImage($newMatches[2]); $new = new CatalogWheters(); $new->city_id = $cityId; $new->name = $newMatches[1]; $new->title = $newMatches[2]; $new->image = $newMatches[5]; $new->value1 = $newMatches[3]; $new->value2 = $newMatches[4]; $new->save(); $ar = explode('tabs-panes__pane', $ar[1]); $arrayDays = array("вс", "пн", "вт", "ср", "чт", "пт", "сб"); $ar = explode('<li', $ar[0]); for ($i = 1; $i < sizeof($ar); $i++) { $newMatches = array(); $ar2 = explode('forecast-brief__item-dayname', $ar[$i]); $ar2 = explode('forecast-brief__item-day', $ar2[1]); $newMatches[0] = trim(strip_tags('<span class="' . $ar2[0])); if ($newMatches[0] == "сегодня") { $newMatches[0] = $arrayDays[date("w")]; } $ar2 = explode('forecast-brief__item-description', $ar2[1]); $newMatches[1] = trim(strip_tags('<span class="' . $ar2[0])); $ar2 = explode('forecast-brief__item-temp-day', $ar2[1]); $newMatches[2] = trim(strip_tags('<span class="' . $ar2[0])); $ar2 = explode('forecast-brief__item-temp-night', $ar2[1]); $newMatches[3] = trim(strip_tags('<span class="' . $ar2[0])); $newMatches[4] = trim(strip_tags('<span class="' . $ar2[1])); $newMatches[5] = $this->getImage($newMatches[2]); $new = new CatalogWheters(); $new->city_id = $cityId; $new->name = $newMatches[1]; $new->title = $newMatches[2]; $new->image = $newMatches[5]; $new->value1 = $newMatches[3]; $new->value2 = $newMatches[4]; $new->save(); } }
public function actionDescription() { $slug = Yii::app()->request->getParam("slug", ""); if (!empty($slug)) { $item = CatalogMaps::fetchBySlug("map-" . $slug); Yii::app()->page->setTitle($item->name); $list = CatalogWheters::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("city_id=:id")->setParams(array(":id" => $item->city_id->id))->setLimit(-1)); $this->render("description", array("item" => $item, "list" => $list)); } else { $this->redirect(SiteHelper::createUrl("/uzbekistanMaps")); } }
<?php $this->widget('addressLineWidget', array('links' => array('Погода в Узбекистане'))); ?> <h1>Погода в Узбекистане</h1> <div class="textAlignCenter WeatherBlock"> <?php foreach ($list as $item) { $info = CatalogWheters::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("city_id=:id")->setParams(array(":id" => $item->city_id->id))->setLimit(1)->setOrderBy("id")); ?> <div class="WItems"> <h2><?php echo $item->name; ?> </h2> <div class="WIImage"> <?php if ($info[0]->image) { ?> <img src="themes/classic/images/wheter/<?php echo $info[0]->image; ?> " alt="<?php echo $info[0]->title; ?> " /><br/><?php } ?> <?php echo $info[0]->title; ?>