Skip to content

Instantly share code, notes, and snippets.

View metalagman's full-sized avatar

Alexey Samoylov metalagman

View GitHub Profile
@metalagman
metalagman / UI.php
Last active November 15, 2017 08:55
Yii2 asset url resolving
/**
* @param $url
* @return string
* @throws \yii\base\InvalidConfigException
*/
public static function getAssetUrl($url)
{
$class = ArrayHelper::getValue([
'app-frontend' => \frontend\assets\AppAsset::class,
], \Yii::$app->id);
<?php
/**
* @author Alexey Samoylov <alexey.samoylov@gmail.com>
*/
namespace common\components;
use yii\data\DataProviderInterface;
class MapDataProvider implements DataProviderInterface
{
Options FollowSymLinks
AddDefaultCharset utf-8
<IfModule mod_rewrite.c>
RewriteEngine On
# the main rewrite rule for the frontend application
RewriteCond %{REQUEST_URI} !^/(backend/web|admin)
RewriteRule !^frontend/web /frontend/web%{REQUEST_URI} [L]
ymaps.ready(init);
var myMap, myPlaceMark;
function init() {
myMap = new ymaps.Map("map", {
center: [<?=$model->latitude?>, <?=$model->longitude?>],
zoom: <?=$city->defaultZoom?>,
minZoom: <?=$city->minZoom?>,
maxZoom: <?=$city->maxZoom?>,
controls: ['searchControl', 'typeSelector', 'zoomControl', 'geolocationControl']
});
public static function getAssetUrl($url)
{
return \Yii::$app->assetManager->getBundle('frontend\assets\AppAsset')->baseUrl . $url;
}
<?php
namespace common\components;
/**
* Class ActiveRecord
* @package common\components
*/
class ActiveRecord extends \yii\db\ActiveRecord
{
/**
<?php
/**
* @author Alexey Samoylov <alexey.samoylov@gmail.com>
*/
use yii\web\JsExpression;
use yii\helpers\Url;
use yii\helpers\Html;
Url::remember();
$this->title = 'Иерархия';
<?php
namespace common\traits;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
/**
* Trait for default status column
*
* Class StatusTrait
$js = <<<JS
// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
window.location.hash = e.target.hash;
})
// Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#')) {
$('.nav-tabs a[href=#'+url.split('#')[1]+']').tab('show') ;
server {
listen 80;
server_name yiidreamteam.com;
charset utf-8;
root /var/www/yiidreamteam/frontend/web;
location / {
index index.php;