Commit dc13e863 authored by Marcello Pivanti's avatar Marcello Pivanti
Browse files

Initial Commit

parents
amos-slideshow
\ No newline at end of file
{
"name": "arter/amos-slideshow",
"description": "Sistema AMOS per lo slideshow",
"keywords": [
"amos",
"yii2",
"slideshow"
],
"homepage": "http://git.elitedivision.it/elitedivision/amos-slideshow",
"type": "component",
"license": "BSD-3-Clause",
"support": {
"issues": "http://git.elitedivision.it/elitedivision/amos-slideshow/issues",
"forum": "http://www.example.com/forum/",
"wiki": "http://git.elitedivision.it/elitedivision/amos-slideshow/wikis/home",
"source": "http://git.elitedivision.it/elitedivision/amos-slideshow/tree/master"
},
"require": {
"php": ">=5.4.0",
"arter/amos-admin": ">=1.8",
"arter/amos-core": "^1.9.50",
"arter/amos-dashboard": "^1.8.15",
"yiidoc/yii2-redactor": "*"
},
"autoload": {
"psr-4": {
"elitedivision\\amos\\slideshow\\": "src"
}
}
}
\ No newline at end of file
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\slideshow
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\slideshow;
use elitedivision\amos\core\module\AmosModule;
use elitedivision\amos\core\module\ModuleInterface;
use elitedivision\amos\slideshow\widgets\icons\WidgetIconSlideshow;
use elitedivision\amos\slideshow\widgets\icons\WidgetIconSlideshowConf;
use Yii;
/**
* Class AmosSlideshow
* @package elitedivision\amos\slideshow
*/
class AmosSlideshow extends AmosModule implements ModuleInterface
{
public static $CONFIG_FOLDER = 'config';
/**
* @var string|boolean the layout that should be applied for views within this module. This refers to a view name
* relative to [[layoutPath]]. If this is not set, it means the layout value of the [[module|parent module]]
* will be taken. If this is false, layout will be disabled within this module.
*/
public $layout = 'main';
public $name = 'Slideshow';
public static function getModuleName()
{
return "slideshow";
}
public function init()
{
parent::init();
\Yii::setAlias('@elitedivision/amos/' . static::getModuleName() . '/controllers/', __DIR__ . '/controllers/');
// initialize the module with the configuration loaded from config.php
Yii::configure($this, require(__DIR__ . DIRECTORY_SEPARATOR . self::$CONFIG_FOLDER . DIRECTORY_SEPARATOR . 'config.php'));
}
public function getWidgetIcons()
{
return [
WidgetIconSlideshow::className(),
WidgetIconSlideshowConf::className(),
];
}
public function getWidgetGraphics()
{
return [];
}
protected function getDefaultModels()
{
}
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\slideshow
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\slideshow\assets;
use yii\web\AssetBundle;
/**
* Class ModuleSlideshowAsset
* @package elitedivision\amos\slideshow\assets
*/
class ModuleSlideshowAsset extends AssetBundle
{
public $sourcePath = '@vendor/elitedivision/amos-slideshow/src/assets/web';
public $css = [
'less/slideshow.less'
];
public $js = [
];
public $depends = [
];
public function init()
{
$moduleL = \Yii::$app->getModule('layout');
if(!empty($moduleL))
{ $this->depends [] = 'elitedivision\amos\layout\assets\BaseAsset'; }
else
{ $this->depends [] = 'elitedivision\amos\core\views\assets\AmosCoreAsset'; }
parent::init(); // TODO: Change the autogenerated stub
}
}
$(document).ready(function () {
//inizializza la dashboard
// Dashboard.init('primary', '.bk-sortableIcon', $('#saveDashboardUrl').val());
//console.log("ciao");
IntroSlideshow = {
id: 'amos-slideshow',
selector: '.introduzioneSlideshow',
cookie: Cookie,
intro: Introduzione,
show: function () {
$(this.selector).modal({
/*type: 'html',*/
// maxWidth: 800,
// maxHeight: 600,
// fitToView: false,
// width: '70%',
// height: 'auto',
// autoSize: false,
// closeClick: false,
// loop: false
});
$(this.selector).first().trigger('click');
this.setIntroShow(this.id);
},
init: function () {
},
setIntroShow: function (tipo_introduzione) {
var cookie_val = this.cookie.getCookie(this.intro.cookie_name);
if (!cookie_val) {
cookie_val = {};
}
else {
cookie_val = JSON.parse(cookie_val);
}
cookie_val[tipo_introduzione] = true;
this.cookie.setCookie(this.intro.cookie_name, JSON.stringify(cookie_val), 365 * 10);
},
isIntroShow: function (tipo_introduzione) {
var cookie_val = this.cookie.getCookie(this.intro.cookie_name);
if (!cookie_val) {
return false;
}
else {
cookie_val = JSON.parse(cookie_val);
return (cookie_val[tipo_introduzione] && (cookie_val[tipo_introduzione] == true || cookie_val[tipo_introduzione] == "true") ? true : false);
}
}
};
// if (!IntroSlideshow.isIntroShow(IntroSlideshow.id)) {
IntroSlideshow.show();
// }
});
\ No newline at end of file
/**
IMPORT AMOS-LAYOUT VARIABLES
*/
@import (optional) "../../vendor/elitedivision/amos-layout/src/assets/resources/base/less/variables.less";
@import (optional) "../../vendor/elitedivision/amos-layout/src/assets/resources/base/less/utility.less";
/**
IMPORT STYLE-CUSTOM
*/
@import (optional) "../../backend/web/less/style_custom.less";
/**
SLIDESHOW WIDGET
*/
.modal-slideshow {
.modal-content {
padding: 0;
.modal-body .carousel {
.carousel-inner {
padding: 0 @padding-large;
.item {
img {
max-width: 100%;
height: auto;
}
}
}
.carousel-control {
background-image: none;
width: auto;
> .glyphicon {
color: @primary-color;
}
}
.carousel-indicators {
position: initial;
width: 100%;
margin: @margin-large 0 0;
left: 0;
> li {
border-color: @primary-color;
&.active {
background-color: @primary-color;
}
}
}
}
}
}
\ No newline at end of file
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\slideshow
* @category CategoryName
* @author Elite Division S.r.l.
*/
return [
'params' => [
'img-default' => 'img/defaultProfilo.jpg',
//active the search
'searchParams' => [
'slideshow' => true,
],
/**
* Configurazione finestra modale
*/
/** Visualizza del titolo dello slideshow in testa alla finestra modale **/
'headerModal' => TRUE,
//'footerModal' => TRUE,
]
];
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\slideshow
* @category CategoryName
* @author Elite Division S.r.l.
*/
/**
* This is the configuration for generating message translations
* for the Yii framework. It is used by the 'yiic message' command.
*/
return [
'translator' => 'AmosNews::t',
'sourcePath' => __DIR__ . '/../',
'messagePath' => __DIR__ . '/../messages',
'languages' => [
'it-IT',
'en-US'
],
'fileTypes' => ['php'],
'overwrite' => true,
'exclude' => [
'.svn',
'.gitignore',
'messages'
]
];
\ No newline at end of file
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\slideshow\controllers
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\slideshow\controllers;
use elitedivision\amos\dashboard\controllers\base\DashboardController;
use yii\helpers\Url;
/**
* Class DefaultController
* @package elitedivision\amos\slideshow\controllers
*/
class DefaultController extends DashboardController
{
/**
* @var string $layout Layout per la dashboard interna.
*/
public $layout = 'dashboard_interna';
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->setUpLayout();
}
/**
* @return mixed
*/
public function actionIndex()
{
Url::remember();
$params = [
'currentDashboard' => $this->getCurrentDashboard()
];
return $this->render('index', $params);
}
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\slideshow\controllers
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\slideshow\controllers;
use elitedivision\amos\slideshow\models\SlideshowRoute;
use elitedivision\amos\slideshow\models\SlideshowUserflag;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\helpers\ArrayHelper;
use yii\helpers\Json;
/**
* Class SlideshowController
* @package elitedivision\amos\slideshow\controllers
*
* This is the class for controller "SlideshowController".
*/
class SlideshowController extends \elitedivision\amos\slideshow\controllers\base\SlideshowController
{
/**
* @inheritdoc
*/
public function behaviors()
{
$behaviors = ArrayHelper::merge(parent::behaviors(), [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'actions' => [
'cambia',
'route-by-role',
],
'roles' => ['@']
]
]
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'route-by-role' => ['post']
]
]
]);
return $behaviors;
}
/**
* @return bool
*/
public function actionCambia()
{
if (\Yii::$app->request->isAjax) {
if (!\Yii::$app->getUser()->isGuest) {
$data = \Yii::$app->request->post();
if (isset($data['set']) && $data['set'] == 'true') {
$routeId = $data['value'];
$userId = \Yii::$app->getUser()->getId();
$slideshowUserflag = SlideshowUserflag::findOne(['user_id' => $userId, 'slideshow_route_id' => $routeId]);
if (!$slideshowUserflag) {
$slideshowUserflag = new SlideshowUserflag();
$slideshowUserflag->slideshow_route_id = $routeId;
$slideshowUserflag->user_id = $userId;
$slideshowUserflag->save(FALSE);
}
} else {
$routeId = $data['value'];
$userId = \Yii::$app->getUser()->getId();
$slideshowUserflag = SlideshowUserflag::deleteAll(['user_id' => $userId, 'slideshow_route_id' => $routeId]);
}
}
}
return TRUE;
}
public function actionRouteByRole()
{
$out = [];
if (isset($_POST['depdrop_parents'])) {
$id = end($_POST['depdrop_parents']);
$id_selected = end($_POST['depdrop_params']);
$slideshow = new SlideshowRoute();
$routes = $slideshow->getRotte(NULL, $id);
$selected = null;
if ($id != null && count($routes) > 0) {
$selected = '';
foreach ($routes as $i => $route) {
$out[] = ['id' => $i, 'name' => $route];
if ($id_selected) {
$selected = $id_selected;
} elseif ($i == 0) {
$selected = $i;
}
}
// Shows how you can preselect a value
echo Json::encode(['output' => $out, 'selected' => $selected]);
return;
}
}
echo Json::encode(['output' => '', 'selected' => '']);
}
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\slideshow\controllers
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\slideshow\controllers;
use elitedivision\amos\slideshow\AmosSlideshow;
use elitedivision\amos\slideshow\controllers\base\SlideshowPageController as BaseSlideshowPageController;
use elitedivision\amos\slideshow\models\Slideshow;
use elitedivision\amos\slideshow\models\SlideshowPage;
use Yii;
use yii\filters\AccessControl;
use yii\filters\AccessRule;
use yii\filters\VerbFilter;
use yii\helpers\ArrayHelper;
use yii\helpers\StringHelper;
use yii\helpers\Url;
/**
* Class SlideshowPageController
*
* This is the class for controller "SlideshowPageController".
*
* @package elitedivision\amos\slideshow\controllers
*/
class SlideshowPageController extends BaseSlideshowPageController
{
/**
* @inheritdoc
*/
public function behaviors()
{
$behaviors = ArrayHelper::merge(parent::behaviors(),
[
'access' => [
'class' => AccessControl::className(),
'ruleConfig' => [
'class' => AccessRule::className(),
],
'rules' => [
[
'allow' => true,
'actions' => [
'create-for-specific-slideshow',
],
'roles' => [strtoupper(StringHelper::basename(SlideshowPage::className())).'_CREATE',
'ADMIN']
]
]
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post', 'get']
]
]
]);
return $behaviors;
}
/**
* Lists all SlideshowPage models.
* @param null|string $layout
* @return mixed|string
*/
public function actionIndex($layout = NULL)
{
$this->setUpLayout('list');
Url::remember();
$params = Yii::$app->request->getQueryParams();
$this->setDataProvider($this->getModelSearch()->searchSlideshowPages($params));
//Yii::$app->view->params['breadcrumbs'][] = ['label' => AmosSlideshow::t('amosslideshow', 'Slideshow'), 'url' => '/slideshow/slideshow/index'];
$slideshowName = "";
if (isset($params['slideshowId'])) {
Yii::$app->view->params['slideshowId'] = $params['slideshowId'];
$slideshow = Slideshow::findOne($params['slideshowId']);
if (!is_null($slideshow)) {
$slideshowName = ": ".$slideshow->name;
}
Yii::$app->view->title = AmosSlideshow::t('amosslideshow',
'Pagine dello slideshow'.$slideshowName);
} else {
Yii::$app->view->title = AmosSlideshow::t('amosslideshow',
'Pagine degli slideshow');
}
//Yii::$app->view->params['breadcrumbs'][] = Yii::$app->view->title;
Yii::$app->view->params['createNewBtnParams'] = [
'urlCreateNew' => [
'create-for-specific-slideshow',
'slideshow_id' => $params['slideshowId']
]
];
return $this->render('index',
[
'dataProvider' => $this->getDataProvider(),
'model' => $this->getModelSearch(),
'currentView' => $this->getCurrentView(),
'availableViews' => $this->getAvailableViews(),
'url' => ($this->url) ? $this->url : NULL,
'parametro' => ($this->parametro) ? $this->parametro : NULL
]);
}
/**
* Creates a new SlideshowPage model for a specific slideshow.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreateForSpecificSlideshow()
{
$this->setUpLayout('form');
$this->model = new SlideshowPage();
$params = Yii::$app->request->getQueryParams();
$this->model->slideshow_id = $params['slideshow_id'];
Yii::$app->view->params['breadcrumbs'][] = ['label' => AmosSlideshow::t('amosslideshow',
'Slideshow'), 'url' => '/slideshow'];
Yii::$app->view->params['breadcrumbs'][] =