AmosNews.php 6.11 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
<?php
Aster's avatar
Aster committed
2

Marcello Pivanti's avatar
Marcello Pivanti committed
3
/**
Aster's avatar
Aster committed
4
5
 * Lombardia Informatica S.p.A.
 * OPEN 2.0
Marcello Pivanti's avatar
Marcello Pivanti committed
6
 *
Aster's avatar
Aster committed
7
 * @see http://example.com Developers'community
8
9
 * @license GPLv3
 * @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
Marcello Pivanti's avatar
Marcello Pivanti committed
10
 *
Aster's avatar
Aster committed
11
 * @package    elitedivision\amos\news
Marcello Pivanti's avatar
Marcello Pivanti committed
12
 * @category   CategoryName
Aster's avatar
Aster committed
13
 * @author     Lombardia Informatica S.p.A.
Marcello Pivanti's avatar
Marcello Pivanti committed
14
15
 */

Aster's avatar
Aster committed
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
Marcello Pivanti's avatar
Marcello Pivanti committed
29
30
31
32
use yii\helpers\ArrayHelper;

/**
 * Class AmosNews
Aster's avatar
Aster committed
33
 * @package elitedivision\amos\news
Marcello Pivanti's avatar
Marcello Pivanti committed
34
 */
Aster's avatar
Aster committed
35
class AmosNews extends AmosModule implements ModuleInterface, SearchModuleInterface, CmsModuleInterface {
Marcello Pivanti's avatar
Marcello Pivanti committed
36

Aster's avatar
Aster committed
37
38
  const
    MAX_LAST_NEWS_ON_DASHBOARD = 3;
Marcello Pivanti's avatar
Marcello Pivanti committed
39

Aster's avatar
Aster committed
40
  public static $CONFIG_FOLDER = 'config';
Marcello Pivanti's avatar
Marcello Pivanti committed
41

Aster's avatar
Aster committed
42
43
44
45
46
47
  /**
   * @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';
Marcello Pivanti's avatar
Marcello Pivanti committed
48

Aster's avatar
Aster committed
49
50
51
52
  /**
   * @var string $name
   */
  public $name = 'Notizie';
Marcello Pivanti's avatar
Marcello Pivanti committed
53

Aster's avatar
Aster committed
54
55
56
57
58
  /**
   * If this attribute is true the validation of the publication date is active
   * @var boolean $validatePublicationDate
   */
  public $validatePublicationDate = true;
Marcello Pivanti's avatar
Marcello Pivanti committed
59

Aster's avatar
Aster committed
60
61
62
63
  /**
   * @var bool|false $filterCategoriesByRole - if true, enables category role check via table news_category_roles_mm
   */
  public $filterCategoriesByRole = false;
Marcello Pivanti's avatar
Marcello Pivanti committed
64

Aster's avatar
Aster committed
65
  /**
Marcello Pivanti's avatar
Marcello Pivanti committed
66
67
68
69
     * @var array
     */
    public $whiteListRolesCategories = ['ADMIN', 'BASIC_USER'];

Aster's avatar
Aster committed
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  /**
   * @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';
Marcello Pivanti's avatar
Marcello Pivanti committed
124
125
126
127
128
129
130
131
132
133
134
135


    /**
     * @var bool
     */
    public $enableCategoriesForCommunity = false;

    /**
     * @var bool
     */
    public $showAllCategoriesForCommunity = true;

Aster's avatar
Aster committed
136
137
138
139
    /**
     * @var array
     */
    public $viewPathEmailSummary = [
Aster's avatar
Aster committed
140
        'elitedivision\amos\news\models\News' => '@vendor/elitedivision/amos-news/src/views/email/notify_summary'
Aster's avatar
Aster committed
141
142
143
    ];

    public $viewPathEmailSummaryNetwork = [
Aster's avatar
Aster committed
144
        'elitedivision\amos\news\models\News' => '@vendor/elitedivision/amos-news/src/views/email/notify_summary_network'
Aster's avatar
Aster committed
145
    ];
Marcello Pivanti's avatar
Marcello Pivanti committed
146
147
148
149
    /*
     * @var bool disableStandardWorkflow Disable standard worflow, direct publish
     */
    public $disableStandardWorkflow = false;
Aster's avatar
Aster committed
150

Marcello Pivanti's avatar
Marcello Pivanti committed
151
152
153
154
155
    /*
     * @var int $numberListTag 10 default
     */
    public $numberListTag = 10;

Aster's avatar
Aster committed
156
157
158
159
160
161
  /**
   * @inheritdoc
   */
  public static function getModuleName() {
    return "news";
  }
Marcello Pivanti's avatar
Marcello Pivanti committed
162

Aster's avatar
Aster committed
163
   /**
Marcello Pivanti's avatar
Marcello Pivanti committed
164
165
166
167
     * @inheritdoc
     */
    public static function getModelSearchClassName()
    {
Aster's avatar
Aster committed
168
        return AmosNews::instance()->model('NewsSearch');
Marcello Pivanti's avatar
Marcello Pivanti committed
169
170
171
172
173
174
175
    }

    /**
     * @inheritdoc
     */
    public static function getModelClassName()
    {
Aster's avatar
Aster committed
176
        return AmosNews::instance()->model('News');
Marcello Pivanti's avatar
Marcello Pivanti committed
177
178
    }

Aster's avatar
Aster committed
179
180
181
182
183
184
185
186
187
188
189
190
191
  /**
   * @inheritdoc
   */
  public static function getModuleIconName() {
    return 'feed';
  }

  /**
   * @inheritdoc
   */
  public function init() {
    parent::init();

Aster's avatar
Aster committed
192
    \Yii::setAlias('@elitedivision/amos/' . static::getModuleName() . '/controllers', __DIR__ . '/controllers');
Aster's avatar
Aster committed
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231

    //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',
    ];
  }
Marcello Pivanti's avatar
Marcello Pivanti committed
232

Aster's avatar
Aster committed
233
234
235
236
237
238
239
240
  /**
   * 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();
  }
Marcello Pivanti's avatar
Marcello Pivanti committed
241
242
243
244



}