Пока работает выборка данных. Сохранение не пробовал.
This commit is contained in:
parent
742bd12d1b
commit
39de8ae0a1
|
|
@ -8,8 +8,9 @@ class Model
|
||||||
private $_id_;
|
private $_id_;
|
||||||
private $_vals_ = array();
|
private $_vals_ = array();
|
||||||
|
|
||||||
function __construct()
|
function __construct($table)
|
||||||
{
|
{
|
||||||
|
$this->_tableName_ = $table;
|
||||||
$this->_primaryKey_ = $this->getPk();
|
$this->_primaryKey_ = $this->getPk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,6 +46,12 @@ class Model
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function getByPrimaryKey($id)
|
||||||
|
{
|
||||||
|
$instance = new self();
|
||||||
|
return $instance->getByPK($id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Возвращает массив с ассоциативными массивами, соответствующими записями в БД.
|
* Возвращает массив с ассоциативными массивами, соответствующими записями в БД.
|
||||||
* @param string $where просто строка с условиями: (`id` > 1) AND (`name` == 'TEST')
|
* @param string $where просто строка с условиями: (`id` > 1) AND (`name` == 'TEST')
|
||||||
|
|
@ -62,8 +69,8 @@ class Model
|
||||||
|
|
||||||
$this->_id_ = NULL; // Это больше не конкретная запись
|
$this->_id_ = NULL; // Это больше не конкретная запись
|
||||||
$ready = array();
|
$ready = array();
|
||||||
|
//print_r($res);die;
|
||||||
while ($row = $res->fetch(PDO::FETCH_ASSOC))
|
while ($res && $row = $res->fetch(PDO::FETCH_ASSOC))
|
||||||
{
|
{
|
||||||
$ready[$row[$this->_primaryKey_]] = $row;
|
$ready[$row[$this->_primaryKey_]] = $row;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class IndexController extends Controller
|
||||||
if (!App::$user )
|
if (!App::$user )
|
||||||
self::addScript('//ulogin.ru/js/ulogin.js');
|
self::addScript('//ulogin.ru/js/ulogin.js');
|
||||||
|
|
||||||
$category = new Category();
|
$category = Category::model()->getAll();
|
||||||
|
|
||||||
$routes = array();
|
$routes = array();
|
||||||
if (App::$user)
|
if (App::$user)
|
||||||
|
|
@ -69,7 +69,7 @@ class IndexController extends Controller
|
||||||
$og['url'] = 'http://wikipoints.ru/?point='.$id;
|
$og['url'] = 'http://wikipoints.ru/?point='.$id;
|
||||||
$og['image'] = $point->img;
|
$og['image'] = $point->img;
|
||||||
}
|
}
|
||||||
else if($_GET['point'] && strtolower($_GET['point']) == 'random')
|
else if(isset($_GET['point']) && $_GET['point'] && strtolower($_GET['point']) == 'random')
|
||||||
{
|
{
|
||||||
$og['title'] = 'Случайная точка на wikipoints.ru';
|
$og['title'] = 'Случайная точка на wikipoints.ru';
|
||||||
$og['description'] = 'Загляните сюда: http://vk.com/wikipoints Случайная точка на карте - лучший способ узнать что-то новое!';
|
$og['description'] = 'Загляните сюда: http://vk.com/wikipoints Случайная точка на карте - лучший способ узнать что-то новое!';
|
||||||
|
|
@ -80,7 +80,7 @@ class IndexController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
self::render('indexTemplate.php', array(
|
self::render('indexTemplate.php', array(
|
||||||
'categories' => $category->getAll('', 'ord'),
|
'categories' => $category,
|
||||||
'user' => App::$user,
|
'user' => App::$user,
|
||||||
'routes' => $routes,
|
'routes' => $routes,
|
||||||
'og' => $og,
|
'og' => $og,
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,8 @@ class JsonController extends Controller
|
||||||
*/
|
*/
|
||||||
static function actionPoints()
|
static function actionPoints()
|
||||||
{
|
{
|
||||||
$points = new Point();
|
$points = Point::model()->getAll();
|
||||||
$points = $points->getAll();
|
$categories = Category::model()->getAll();
|
||||||
|
|
||||||
$categories = new Category();
|
|
||||||
$categories = $categories->getAll();
|
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
|
|
@ -38,13 +35,34 @@ class JsonController extends Controller
|
||||||
$id = (int) App::getParam('id');
|
$id = (int) App::getParam('id');
|
||||||
if ($id)
|
if ($id)
|
||||||
{
|
{
|
||||||
$point = new Point();
|
//$point = Point::getByPrimaryKey($id);
|
||||||
$point = $point->getByPK($id);
|
//$point = $point->getByPK($id);
|
||||||
|
|
||||||
|
// $point = new Point();
|
||||||
|
// $point->name = 'TEST';
|
||||||
|
// $point->lat = 12;
|
||||||
|
// $point->lng = 44;
|
||||||
|
// $point->img = 'sdfsdfsdf';
|
||||||
|
// $point->description = 'sdfsdfsdfsdfsdfsdfsdfsfd';
|
||||||
|
// $point->categoryId = 1;
|
||||||
|
// $point->source = '';
|
||||||
|
// $point->author = 2;
|
||||||
|
// $point->date = time();
|
||||||
|
//
|
||||||
|
// print_r($point->save());
|
||||||
|
//
|
||||||
|
// print '<br/><br/><br/><br/>';
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// print_r($point);
|
||||||
|
// die;
|
||||||
|
|
||||||
|
$point = Point::model()->getByPK($id);
|
||||||
|
|
||||||
$point->descriptionHtml = nl2br($point->description);
|
$point->descriptionHtml = nl2br($point->description);
|
||||||
$point->name = htmlspecialchars($point->name);
|
$point->name = htmlspecialchars($point->name);
|
||||||
|
|
||||||
$categories = new Category();
|
$categories = Category::model()->getAll();
|
||||||
$categories = $categories->getAll();
|
|
||||||
|
|
||||||
$point->categoryIcon = $categories[$point->categoryId]['icon'];
|
$point->categoryIcon = $categories[$point->categoryId]['icon'];
|
||||||
$point->categoryName = $categories[$point->categoryId]['name'];
|
$point->categoryName = $categories[$point->categoryId]['name'];
|
||||||
|
|
@ -61,8 +79,7 @@ class JsonController extends Controller
|
||||||
*/
|
*/
|
||||||
static function actionCategories()
|
static function actionCategories()
|
||||||
{
|
{
|
||||||
$categories = new Category();
|
$categories = Category::model()->getAll();
|
||||||
$categories = $categories->getAll();
|
|
||||||
|
|
||||||
self::renderPartial('json.php', array(
|
self::renderPartial('json.php', array(
|
||||||
'data' => $categories,
|
'data' => $categories,
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,12 @@ class Category extends Model
|
||||||
{
|
{
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
|
return self::model();
|
||||||
$this->_tableName_ = 'categories';
|
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function model()
|
||||||
|
{
|
||||||
|
return new Model('categories');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,12 @@ class Point extends Model
|
||||||
{
|
{
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
|
return self::model();
|
||||||
$this->_tableName_ = 'points';
|
|
||||||
parent::__construct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function model()
|
||||||
|
{
|
||||||
|
return new Model('points');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue