Esempio n. 1
0
    public function getDistrictLinks($rubr,$module = 'catalog')
    {
    	$districts = District::model()->findAll(array('condition'=>'city_id=:city_id','params'=>array(':city_id'=>$this->id)));
   		$links = '';
   		if($districts)
   		{
   			foreach ($districts as $district) 
   			{
   				if((mb_strpos($district->district_name, 'район', 0, 'UTF-8') !== false) && (mb_strpos($district->district_name, 'микрорайон', 0, 'UTF-8') === false))
				{
					$url = Yii::app()->createAbsoluteUrl('/'.$module.'/catalog/district', array('city'=>$this->url,  'url'=>$rubr->url, 'district'=>'rayon'));
					$links .= '<a class="parentCategoryElement" href="'.$url.'">'.$rubr->title.' по районам города</a>';
					break;
				}
   			}
   			foreach ($districts as $district) 
   			{
   				if(mb_strpos($district->district_name, 'микрорайон', 0, 'UTF-8') !== false )
				{
					$url = Yii::app()->createAbsoluteUrl('/'.$module.'/catalog/district', array('city'=>$this->url,  'url'=>$rubr->url, 'district'=>'mikrorayon'));
					$links .= '<a class="parentCategoryElement" href="'.$url.'">'.$rubr->title.' по микрорайонам города</a>';
					break;
				}
   			}
   			foreach ($districts as $district) 
   			{
   				if(mb_strpos($district->district_name, 'округ', 0, 'UTF-8') !== false )
				{
					$url = Yii::app()->createAbsoluteUrl('/'.$module.'/catalog/district', array('city'=>$this->url,  'url'=>$rubr->url, 'district'=>'okrug'));
					$links .= '<a class="parentCategoryElement" href="'.$url.'">'.$rubr->title.' по округам</a>';
					break;
				}
   			}

   		}
   		 if($module == 'catalog'){
	   		$metros = Metro::model()->find(array('condition'=>'city_id=:city_id','params'=>array(':city_id'=>$this->id)));
	   		if($metros)
	   		{
	   			$url = Yii::app()->createAbsoluteUrl('/'.$module.'/catalog/district', array('city'=>$this->url,  'url'=>$rubr->url, 'district'=>'metro'));
				$links .= '<a class="parentCategoryElement" href="'.$url.'">'.$rubr->title.' по станциям метро</a>';
	   		}
	   	}
   		return $links;
    }
 public function _loadMetro($url)
 {
    $model = Metro::model()->withUrl($url,$this->city->id)->find();
    if (!$model) throw new CHttpException(404, 'Страница не найдена.');
     return $model;
 }
Esempio n. 3
0
<?php

session_start();
/* servervars.php contains the server variables */
require_once 'servervars.php';
$metro = new Metro($db_location, $db_username, $db_password, $db_name);
$user = new User($db_location, $db_username, $db_password, $db_name);
class User
{
    var $mysqli;
    var $getUserSql = "SELECT favorite_station, stop_name FROM \n\t\t\tusers JOIN stop_names ON stop_num = favorite_station \n\t\t\tWHERE username = ?";
    var $addUserSql = "INSERT INTO users (username, favorite_station)\n\t\t\tVALUES (?, ?)";
    function User($db_location, $db_username, $db_password, $db_name)
    {
        $this->mysqli = new mysqli($db_location, $db_username, $db_password, $db_name);
        if ($this->mysqli->connect_error) {
            die('Connect Error');
        }
    }
    function register($username, $favorite_station)
    {
        $stmt = $this->mysqli->prepare($this->addUserSql);
        $stmt->bind_param('si', $username, $favorite_station);
        $stmt->execute();
        $stmt->close();
        if ($this->mysqli->affected_rows() > 0) {
            return 'Success';
        }
        return 'Failure';
    }
    function login($username)
Esempio n. 4
0
<?php 
$cr=new CDbCriteria;
$cr->condition = 'city_id=:city_id';
$cr->params = array(':city_id'=>$this->city->id);
$cr->order = 'metro_name';
$metros = Metro::model()->findAll($cr);
/*$sql = 'SELECT DISTINCT t.nearest_metro 
		FROM orgs t
		LEFT JOIN "orgs_category" "categorization" ON ("categorization"."org"="t"."id")
		WHERE t.city_id='.$this->city->id .' and "categorization"."category"='.$model->id.' and t.status_org='.Orgs::STATUS_ACTIVE;

$connection=Yii::app()->db;
$command=$connection->createCommand($sql);
$datas=$command->queryALL();
*/
if($metros)
{
	echo '<div class="row">
	<div class="col-lg-8 col-lg-offset-1 col-md-8 col-md-offset-1 col-sm-8 col-sm-offset-1 col-xs-12">
	<h2 class="org_title" style="padding-left:26px;margin-bottom:26px;">'.$model->title .' по станциям метро '.$this->city->rodpad.'</h2>
	<div class="card">
	<div class="card-body card-padding">
	<div class="row">';
	foreach ($metros as $metro) 
	{
		$query = new Orgs(null);

        	$query->active()
                ->with(array(
                    'images',
                    'city',