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

Initial Commit

parents
# Amos News
News management.
### Installation
You need to require this package and enable the module in your configuration.
add to composer requirements in composer.json
```
"elitedivision/amos-news": "dev-master",
```
or run command bash:
```bash
composer require "elitedivision/amos-news:dev-master"
```
Enable the News modules in modules-amos.php, add :
```php
'news' => [
'class' => 'elitedivision\amos\news\AmosNews',
],
```
add news migrations to console modules (console/config/migrations-amos.php):
```
'@vendor/elitedivision/amos-news/src/migrations'
```
If a frontend or a public site are used in your project and news need to be visible outside backend, enable form/wizard fields to allow publication in frontend/home page with params:
```php
'news' => [
'class' => 'elitedivision\amos\news\AmosNews',
'params' => [
'site_publish_enabled' => true,
'site_featured_enabled' => true
]
],
```
The content is suitable to be used with cwh content management.
To do so:
- Activate cwh plugin
- Open cwh configuration wizard (admin privilege is required) url: <yourPlatformurl>/cwh/configuration/wizard
- search for news in content configuration section
- edit configuration of news and save
If tags are needed enable this module in "modules-amos.php" (backend/config folder in main project) in tag section. After that, enable the trees in tag manager.
If platform uses report and/or comments and you want to enable News to be commented/to report a content, add the model to the configuration in modules-amos.php:
for reports:
```
'report' => [
'class' => 'elitedivision\amos\report\AmosReport',
'modelsEnabled' => [
.
.
'elitedivision\amos\news\models\News', //line to add
.
.
]
],
```
for comments:
```
'comments' => [
'class' => 'elitedivision\amos\comments\AmosComments',
'modelsEnabled' => [
.
.
'elitedivision\amos\news\models\News', //line to add
.
.
],
],
```
### Configurable fields
Here the list of configurable fields, properties of module AmosNews.
If some property default is not suitable for your project, you can configure it in module, eg:
```php
'news' => [
'class' => 'elitedivision\amos\news\AmosNews',
'validatePublicationDate' => false, //changed property (default was true)
],
```
* **validatePublicationDate** - boolean, default = true
If this attribute is true the validation of the publication date is active.
By default, you can ONLY validate news with publication_date greater or equal than TODAY.
Set to false to allow validation for news with publication_date less than TODAY.
* **filterCategoriesByRole** - boolean, default = false
If true, enables category role check via table news_category_roles_mm.
By default news category are available to all users.
In case categories are in association with rbac roles, populate table 'news_category_roles_mm' and set to true the Module property filterCategoriesByRole in configurations:
```php
'news' => [
'class' => 'elitedivision\amos\news\AmosNews',
'filterCategoriesByRole' => true
]
```
* **hidePubblicationDate** - boolean, default = false
The news created are always visible, hide fields publication_from, publication_to
* **newsRequiredFields** - array, default = ['news_categorie_id', 'titolo', 'status', 'descrizione_breve']
Mandatory fields in news form: by default news category, title and status are mandatory.
If in your platform, for example, you don't want title to be a mandatory field, overwrite newsRequiredFields property as below:
```php
'news' => [
'class' => 'elitedivision\amos\news\AmosNews',
'newsRequiredFields' => ['news_categorie_id', 'status']
],
```
* **defaultCategory** - integer
The ID of the default category pre-selected for the new News
```php
'news' => [
'class' => 'elitedivision\amos\news\AmosNews',
'defaultCategory' => 3
],
```
* **autoUpdatePublicationDate** - boolean, default = false
This set the auto update of the publication date on the save if the news is published
```php
'news' => [
'class' => 'elitedivision\amos\news\AmosNews',
'autoUpdatePublicationDate' => true
],
```
{
"name": "arter/amos-news",
"description": "Sistema AMOS per le news",
"keywords": [
"amos",
"yii2",
"news"
],
"homepage": "http://www.elitedivision.it/",
"type": "component",
"license": "BSD-3-Clause",
"support": {
"issues": "http://www.example.com/",
"forum": "http://www.example.com/forum/",
"wiki": "http://www.example.com/wiki/",
"source": "https://github.com/elitedivision/amos-news"
},
"require": {
"php": ">=5.4.0",
"2amigos/yii2-ckeditor-widget": "~1.0",
"cornernote/yii2-workflow-manager": "*",
"arter/amos-admin": "^2.0",
"arter/amos-attachments": "^1.1.11",
"arter/amos-comments": "^1.1",
"arter/amos-core": "^1.9.60",
"arter/amos-dashboard": "^1.8.4",
"arter/amos-notify": "^1.4.13",
"arter/amos-report": "^1.0.5",
"arter/amos-workflow": "^1.0.5",
"arter/amos-seo": "*",
"raoul2000/yii2-workflow": "*",
"raoul2000/yii2-workflow-view": "*",
"yiidoc/yii2-redactor": "*",
"kv4nt/yii2-owl-carousel2": "*"
},
"config": {
"process-timeout": 1800,
"secure-http": false
},
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
},
"autoload": {
"psr-4": {
"elitedivision\\amos\\news\\": "src"
}
},
"require-dev": {
"yiisoft/yii2-faker": "*"
}
}
\ No newline at end of file
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\news
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\news;
use elitedivision\amos\core\interfaces\CmsModuleInterface;
use elitedivision\amos\core\interfaces\SearchModuleInterface;
use elitedivision\amos\core\module\AmosModule;
use elitedivision\amos\core\module\ModuleInterface;
use elitedivision\amos\news\widgets\graphics\WidgetGraphicsUltimeNews;
use elitedivision\amos\news\widgets\icons\WidgetIconAllNews;
use elitedivision\amos\news\widgets\icons\WidgetIconNews;
use elitedivision\amos\news\widgets\icons\WidgetIconNewsCategorie;
use elitedivision\amos\news\widgets\icons\WidgetIconNewsCreatedBy;
use elitedivision\amos\news\widgets\icons\WidgetIconNewsDashboard;
use elitedivision\amos\news\widgets\icons\WidgetIconNewsDaValidare;
use yii\helpers\ArrayHelper;
/**
* Class AmosNews
* @package elitedivision\amos\news
*/
class AmosNews extends AmosModule implements ModuleInterface, SearchModuleInterface, CmsModuleInterface
{
const
MAX_LAST_NEWS_ON_DASHBOARD = 3;
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';
/**
* @var string $name
*/
public $name = 'Notizie';
/**
* If this attribute is true the validation of the publication date is active
* @var boolean $validatePublicationDate
*/
public $validatePublicationDate = true;
/**
* @var bool|false $filterCategoriesByRole - if true, enables category role check via table news_category_roles_mm
*/
public $filterCategoriesByRole = false;
/**
* @var array
*/
public $whiteListRolesCategories = ['ADMIN', 'BASIC_USER'];
/**
* @var bool|false $hidePubblicationDate
*/
public $hidePubblicationDate = false;
/**
* Hide the Option wheel in the graphic widget
* @var bool|false $hideWidgetGraphicsActions
*/
public $hideWidgetGraphicsActions = false;
/**
* @var array $newsRequiredFields - mandatory fields in News form
*/
public $newsRequiredFields = [
'news_categorie_id',
'titolo',
'status',
'descrizione',
];
/**
* The ID of the default category pre-selected for the new News
* @var integer
*/
public $defaultCategory;
/**
* The default value for enable comments
* @var integer
*/
public $defaultEnableComments = 1;
/**
* @var bool $hideDataRimozioneView
*/
public $hideDataRimozioneView = false;
/**
* @var array $defaultListViews This set the default order for the views in lists
*/
public $defaultListViews = ['list', 'grid'];
/**
* This set the auto update of the publication date on the save if the news is published
* @var boolean $autoUpdatePublicationDate
*/
public $autoUpdatePublicationDate = false;
/**
*
* @var type
*/
public $defaultWidgetIndexUrl = '/news/news/own-interest-news';
/**
* @var bool
*/
public $enableCategoriesForCommunity = false;
/**
* @var bool
*/
public $showAllCategoriesForCommunity = true;
/*
* @var bool disableStandardWorkflow Disable standard worflow, direct publish
*/
public $disableStandardWorkflow = false;
/*
* @var int $numberListTag 10 default
*/
public $numberListTag = 10;
/**
* @inheritdoc
*/
public static function getModuleName()
{
return "news";
}
/**
* @inheritdoc
*/
public static function getModelSearchClassName()
{
return models\search\NewsSearch::className();
}
/**
* @inheritdoc
*/
public static function getModelClassName()
{
return models\News::className();
}
/**
* @inheritdoc
*/
public static function getModuleIconName()
{
return 'feed';
}
/**
* @inheritdoc
*/
public function init()
{
parent::init();
\Yii::setAlias('@elitedivision/amos/' . static::getModuleName() . '/controllers', __DIR__ . '/controllers');
//Configuration: merge default module configurations loaded from config.php with module configurations set by the application
$config = require(__DIR__ . DIRECTORY_SEPARATOR . self::$CONFIG_FOLDER . DIRECTORY_SEPARATOR . 'config.php');
\Yii::configure($this, ArrayHelper::merge($config, $this));
}
/**
* @inheritdoc
*/
public function getWidgetIcons()
{
return [
WidgetIconNews::className(),
WidgetIconNewsCategorie::className(),
WidgetIconNewsCreatedBy::className(),
WidgetIconNewsDaValidare::className(),
WidgetIconNewsDashboard::className(),
WidgetIconAllNews::className(),
];
}
/**
* @inheritdoc
*/
public function getWidgetGraphics()
{
return [
WidgetGraphicsUltimeNews::className(),
];
}
/**
* Get default model classes
*/
protected function getDefaultModels()
{
return [
'News' => __NAMESPACE__ . '\\' . 'models\News',
'NewsCategorie' => __NAMESPACE__ . '\\' . 'models\NewsCategorie',
'NewsSearch' => __NAMESPACE__ . '\\' . 'models\search\NewsSearch',
];
}
/**
* This method return the session key that must be used to add in session
* the url from the user have started the content creation.
* @return string
*/
public static function beginCreateNewSessionKey()
{
return 'beginCreateNewUrl_' . self::getModuleName();
}
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\news
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\news\assets;
use yii\web\AssetBundle;
use elitedivision\amos\core\widget\WidgetAbstract;
class ModuleNewsAsset extends AssetBundle
{
public $sourcePath = '@vendor/elitedivision/amos-news/src/assets/web';
public $css = [
'less/news.less',
];
public $js = [
'js/news-module.js',
'js/news.js'
];
public $depends = [
];
public function init()
{
$moduleL = \Yii::$app->getModule('layout');
if(!empty(\Yii::$app->params['dashboardEngine']) && \Yii::$app->params['dashboardEngine'] == WidgetAbstract::ENGINE_ROWS){
$this->css = ['less/news_fullsize.less'];
}
if(!empty($moduleL)){
$this->depends [] = 'elitedivision\amos\layout\assets\BaseAsset';
}else{
$this->depends [] = 'elitedivision\amos\core\views\assets\AmosCoreAsset';
}
parent::init();
}
}
\ No newline at end of file
$amos.newsModule = (function newsModule () {
const newsModule = {};
newsModule.init = function () {
watch();
};
function watch () {
$(document).on('initialized.owl.carousel, refreshed.owl.carousel', recalculateTop);
}
/* Per ogni gruppo di items sulla stessa cella da tre (solo su desktop quindi)
* calcola, sulla base dell'item più alto, lo spazio disponibile sopra
* ogni .abstract e allinea tutti gli altri di conseguenza.
*/
function recalculateTop () {
const $items = $('#newsOwlCarousel .owl-item');
$items.each(function () {
$abstracts = $(this).find('.abstract');
$abstracts.css('top', 'auto');
var maxHeight = Math.max.apply(null, $abstracts.map(function () {
return $(this).outerHeight();
}).get());
$abstracts.css('top', $(this).height() - maxHeight);
});
}
return newsModule;
})();
\ No newline at end of file
$amos.ready($amos.newsModule.init());
\ 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";
//-----------------------------------------------
// DASHBOARD WIDGET GRAPHIC
//-----------------------------------------------
.latest-news {
height: 100%;
overflow: hidden;
display: block;
background-color: @white-color;
section {
padding: 0;
height: 83%;
}
.widget-listbox-option {
margin-top: @margin-medium;
article {
padding: 0;
border: 1px solid @border-color-default;
.container-img {
float: none;
width: 100%;
overflow: hidden;
@media (min-width: 640px) {
height: 100px;
}
img {
width: 100%;
}
}
.container-text {
float: none !important;
width: 100% !important;
@media (min-width: 640px) {
height: 125px;
}
}
}
}
}
@media screen and (max-width: 939px) and (min-width: 640px) {
.latest-news {
.widget-listbox-option {
width: 33%;
}
}
}
.field-news-comments_enabled {
margin-top: 6px;
.comment-choice {
margin-top: 5px;
}
}
/**
NEWS VIEW
*/
.news-view {
.header-widget {
position: relative;
margin: @margin-medium 0;
.post-header .publication-date {
text-align: right;
}
.manage { /* override */
margin-top: 0;
}
.amos-tooltip {
float: right;
}
.reportflag-widget {
float: right;
a {
margin: 0px 12px;
position: relative;
bottom: 2px;
}
}
}
.header {
background-color: @light-background-color;
margin-bottom: @margin-default;
overflow: hidden;
max-height: 350px;
.img-responsive {
margin: 0 auto;
}
.title {
background-color: rgba(255, 255, 255, 0.8);
position: absolute;
bottom: 0px;
min-height: 80px;
.title-text {
font-weight: bold;
margin-top: @margin-medium;
margin-bottom: @margin-min;
color: @black-color;
& + .subtitle-text {
margin-top: 0;
color: @black-color;
font-style: italic;
font-size: 1.3em;
}
}
}
}
.text-content {
iframe {
width: 100%;
min-height: 350px;
margin-top: 20px;
}
}
}
/**
NEWS CARD
*/