Сохранение урла точек, добавлемых ссылкой

This commit is contained in:
Krivchikov Dmitry 2015-05-30 16:35:04 +03:00
parent 615390860c
commit 2a5f34f679
3 changed files with 23 additions and 6 deletions

View File

@ -153,6 +153,7 @@ class JsonController extends Controller
if (file_put_contents($uploaddir . $photo, file_get_contents($img)))
{
PhotoLinks::addLink($photo, $img);
$images[] = $photo;
}
} else

View File

@ -0,0 +1,22 @@
<?php
class PhotoLinks extends Model
{
function __construct($fromArray = array())
{
$this->_tableName_ = 'photoLinks';
parent::__construct($fromArray);
}
static function model()
{
return new self();
}
static function addLink($photo, $url)
{
$parsedUrl = parse_url($url);
App::DB()->query('INSERT INTO photoLinks VALUES ("'.$photo.'","'.$url.'","'.$parsedUrl['host'].'") ON DUPLICATE KEY UPDATE url=url;');
}
}

View File

@ -77,12 +77,6 @@
<?php if (App::$user && App::$user->isAdmin == 1): ?>
[ <span class="glyphicon glyphicon-new-window"></span> <a href="<?= $point->source ?>" target="_blank">источник: <?= $point->source ?></a> ]
<?php endif; ?>
<!-- [ <span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star-empty"></span> ] -->
</p>
</div>
</div>