This commit is contained in:
Dennis Eichhorn 2015-11-29 21:57:18 +01:00
commit 133e8ad225
19 changed files with 1536 additions and 0 deletions

View File

@ -0,0 +1,38 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace Modules\News\Admin\Install;
/**
* Navigation class.
*
* @category Modules
* @package Modules\Admin
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Navigation
{
public static function install($dbPool)
{
$navData = json_decode(file_get_contents(__DIR__ . '/nav.install.json'), true);
$class = '\\Modules\\Navigation\\Admin\\Installer';
$class::installExternal($dbPool, $navData);
}
}

View File

@ -0,0 +1,78 @@
[
{
"id": 1000701001,
"pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd",
"type": 2,
"subtype": 1,
"name": "News",
"uri": "/{/lang}/backend/news/dashboard",
"target": "self",
"icon": null,
"order": 40,
"from": "News",
"permission": null,
"parent": 1000201001,
"children": [
{
"id": 1000702001,
"pid": "d7470914e19522acc310a55e5cb13a6f0f7ca000",
"type": 3,
"subtype": 1,
"name": "News",
"uri": "/{/lang}/backend/news/dashboard",
"target": "self",
"icon": null,
"order": 1,
"from": "News",
"permission": null,
"parent": 1000701001,
"children": []
},
{
"id": 1000703001,
"pid": "d7470914e19522acc310a55e5cb13a6f0f7ca000",
"type": 3,
"subtype": 1,
"name": "Archive",
"uri": "/{/lang}/backend/news/archive",
"target": "self",
"icon": null,
"order": 5,
"from": "News",
"permission": null,
"parent": 1000701001,
"children": []
},
{
"id": 1000704001,
"pid": "d7470914e19522acc310a55e5cb13a6f0f7ca000",
"type": 3,
"subtype": 1,
"name": "Create",
"uri": "/{/lang}/backend/news/create",
"target": "self",
"icon": null,
"order": 10,
"from": "News",
"permission": null,
"parent": 1000701001,
"children": []
},
{
"id": 1000705001,
"pid": "d7470914e19522acc310a55e5cb13a6f0f7ca000",
"type": 3,
"subtype": 1,
"name": "Draft",
"uri": "/{/lang}/backend/news/draft/list",
"target": "self",
"icon": null,
"order": 15,
"from": "News",
"permission": null,
"parent": 1000701001,
"children": []
}
]
}
]

100
Admin/Installer.php Normal file
View File

@ -0,0 +1,100 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace Modules\News\Admin;
use phpOMS\DataStorage\Database\DatabaseType;
use phpOMS\DataStorage\Database\Pool;
use phpOMS\Module\InstallerAbstract;
/**
* News install class.
*
* @category Modules
* @package Modules\News
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Installer extends InstallerAbstract
{
/**
* {@inheritdoc}
*/
public static function install(Pool $dbPool, array $info)
{
parent::install($dbPool, $info);
switch ($dbPool->get('core')->getType()) {
case DatabaseType::MYSQL:
$dbPool->get('core')->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'news` (
`news_id` int(11) NOT NULL AUTO_INCREMENT,
`news_title` varchar(250) NOT NULL,
`news_featured` tinyint(1) DEFAULT NULL,
`news_content` text NOT NULL,
`news_plain` text NOT NULL,
`news_type` tinyint(2) NOT NULL,
`news_status` tinyint(1) NOT NULL,
`news_lang` varchar(2) NOT NULL,
`news_publish` datetime NOT NULL,
`news_created` datetime NOT NULL,
`news_author` int(11) NOT NULL,
PRIMARY KEY (`news_id`),
KEY `news_author` (`news_author`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get('core')->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'news`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'news_ibfk_1` FOREIGN KEY (`news_author`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);'
)->execute();
$dbPool->get('core')->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'news_tag` (
`news_tag_id` int(11) NOT NULL AUTO_INCREMENT,
`news_tag_news` int(11) NOT NULL,
`news_tag_tag` varchar(20) NOT NULL,
PRIMARY KEY (`news_tag_id`),
KEY `news_tag_news` (`news_tag_news`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get('core')->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'news_tag`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'news_tag_ibfk_1` FOREIGN KEY (`news_tag_news`) REFERENCES `' . $dbPool->get('core')->prefix . 'news` (`news_id`);'
)->execute();
$dbPool->get('core')->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'news_group` (
`news_group_id` int(11) NOT NULL AUTO_INCREMENT,
`news_group_news` int(11) NOT NULL,
`news_group_group` int(11) NOT NULL,
PRIMARY KEY (`news_group_id`),
KEY `news_group_news` (`news_group_news`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get('core')->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'news_group`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'news_group_ibfk_1` FOREIGN KEY (`news_group_news`) REFERENCES `' . $dbPool->get('core')->prefix . 'news` (`news_id`);'
)->execute();
break;
}
}
}

284
Controller.php Normal file
View File

@ -0,0 +1,284 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace Modules\News;
use Modules\Navigation\Models\Navigation;
use Modules\Navigation\Views\NavigationView;
use Modules\News\Models\NewsArticle;
use Modules\News\Models\NewsArticleMapper;
use phpOMS\Account\Account;
use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\RequestDestination;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\WebInterface;
use phpOMS\Views\View;
use phpOMS\Views\ViewLayout;
/**
* News controller class.
*
* @category Modules
* @package Modules\News
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Controller extends ModuleAbstract implements WebInterface
{
/**
* Module name.
*
* @var \string
* @since 1.0.0
*/
protected static $module = 'News';
/**
* Localization files.
*
* @var \string
* @since 1.0.0
*/
protected static $localization = [
RequestDestination::BACKEND => ['backend'],
];
/**
* Providing.
*
* @var \string
* @since 1.0.0
*/
protected static $providing = [
'Content',
];
/**
* Dependencies.
*
* @var \string
* @since 1.0.0
*/
protected static $dependencies = [];
/**
* Routing elements.
*
* @var array
* @since 1.0.0
*/
protected static $routes = [
'^.*/backend/news/dashboard.*$' => [['dest' => '\Modules\News\Controller:viewNewsDashboard', 'method' => 'GET', 'type' => ViewLayout::MAIN],],
'^.*/backend/news/single.*$' => [['dest' => '\Modules\News\Controller:viewNewsArticle', 'method' => 'GET', 'type' => ViewLayout::MAIN],],
'^.*/backend/news/archive.*$' => [['dest' => '\Modules\News\Controller:viewNewsArchive', 'method' => 'GET', 'type' => ViewLayout::MAIN],],
'^.*/backend/news/create.*$' => [['dest' => '\Modules\News\Controller:viewNewsCreate', 'method' => 'GET', 'type' => ViewLayout::MAIN],],
];
/**
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function viewNewsDashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/News/Theme/backend/news-dashboard');
$view->addData('nav', $this->createNavigation(1000701001, $request, $response));
$news = $this->getNewsListR(20, 0, 'news.news_publish', 'DESC', $this->app->accountManager->get($request->getAccount()));
$headline = $this->getHeadlineListR(20, 0, 'news.news_publish', 'ASC', $this->app->accountManager->get($request->getAccount()));
$view->addData('newsList', $news);
$view->addData('headlineList', $headline);
return $view;
}
/**
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function viewNewsArticle(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/News/Theme/backend/news-single');
$view->addData('nav', $this->createNavigation(1000701001, $request, $response));
$newsArticleMapper = new NewsArticleMapper($this->app->dbPool->get());
$article = $newsArticleMapper->get((int) $request->getData('id'));
$view->addData('newsList', $article);
return $view;
}
/**
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function viewNewsArchive(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/News/Theme/backend/news-archive');
$view->addData('nav', $this->createNavigation(1000701001, $request, $response));
return $view;
}
/**
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function viewNewsCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/News/Theme/backend/news-create');
$view->addData('nav', $this->createNavigation(1000701001, $request, $response));
return $view;
}
/**
* Creating news.
*
* @param array $articleElements Article elements
*
* @return NewsArticle
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function createNews(...$articleElements)
{
$newsArticle = new NewsArticle();
$newsArticle->setAuthor($articleElements[0]);
$newsArticle->setCreated($articleElements[1]);
$newsArticle->setPublish($articleElements[2]);
$newsArticle->setTitle($articleElements[3]);
$newsArticle->setPlain($articleElements[4]);
$newsArticle->setContent($articleElements[5]);
$newsArticle->setLang($articleElements[6]);
$newsArticle->setType($articleElements[7]);
$newsArticle->setStatus($articleElements[8]);
$newsArticle->setFeatured($articleElements[9]);
$newsArticleMapper = new NewsArticleMapper($this->app->dbPool->get());
return $newsArticleMapper->create($newsArticle);
}
/**
* Get Newslists.
*
* @param array $articleElements Article elements
*
* @return array
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getNewsListR(\int $limit = 50, \int $offset = 0, \string $orderBy = 'news_created', \string $ordered = 'ASC', Account $account = null)
{
$newsArticleMapper = new NewsArticleMapper($this->app->dbPool->get());
$query = $newsArticleMapper->find('news.news_id', 'news.news_author', 'news.news_publish', 'news.news_title')
->where('news.news_type', '=', 1)
->where('news.news_status', '=', 1)
->orderBy($orderBy, $ordered)
->offset($offset)
->limit($limit);
if (isset($account)) {
$query->where('account_permission.account_permission_account', '=', $account->getId());
}
return $newsArticleMapper->getAllByQuery($query);
}
/**
* Get Headlinelist.
*
* @param array $articleElements Article elements
*
* @return array
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getHeadlineListR(\int $limit = 50, \int $offset = 0, \string $orderBy = 'news_created', \string $ordered = 'ASC', Account $account = null)
{
$newsArticleMapper = new NewsArticleMapper($this->app->dbPool->get());
$query = $newsArticleMapper->find('news.news_id', 'news.news_author', 'news.news_publish', 'news.news_title')
->where('news.news_type', '=', 0)
->where('news.news_status', '=', 1)
->orderBy($orderBy, $ordered)
->offset($offset)
->limit($limit);
if (isset($account)) {
$query->where('account_permission.account_permission_account', '=', $account->getId());
}
return $newsArticleMapper->getAllByQuery($query);
}
/**
* @param int $pageId Page/parent Id for navigation
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
*
* @return RenderableInterface
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
private function createNavigation(\int $pageId, RequestAbstract $request, ResponseAbstract $response)
{
$nav = Navigation::getInstance($request, $this->app->dbPool);
$navView = new NavigationView($this->app, $request, $response);
$navView->setTemplate('/Modules/Navigation/Theme/backend/mid');
$navView->setNav($nav->getNav());
$navView->setLanguage($request->getL11n()->language);
$navView->setParent($pageId);
return $navView;
}
}

398
Models/NewsArticle.php Normal file
View File

@ -0,0 +1,398 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace Modules\News\Models;
use phpOMS\Localization\ISO639Enum;
/**
* News article class.
*
* @category Module
* @package Framework
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class NewsArticle
{
/**
* Article ID.
*
* @var \int
* @since 1.0.0
*/
private $id = 0;
/**
* Author ID.
*
* @var \int
* @since 1.0.0
*/
private $author = 0;
/**
* Title.
*
* @var \string
* @since 1.0.0
*/
private $title = '';
/**
* Content.
*
* @var \string
* @since 1.0.0
*/
private $content = '';
/**
* Plain.
*
* @var \string
* @since 1.0.0
*/
private $plain = '';
/**
* News type.
*
* @var \int
* @since 1.0.0
*/
private $type = NewsType::ARTICLE;
/**
* News status.
*
* @var \int
* @since 1.0.0
*/
private $status = NewsStatus::VISIBLE;
/**
* Language.
*
* @var \string
* @since 1.0.0
*/
private $lang = ISO639Enum::_EN;
/**
* Created.
*
* @var \DateTime
* @since 1.0.0
*/
private $created = null;
/**
* Publish.
*
* @var \DateTime
* @since 1.0.0
*/
private $publish = null;
/**
* Featured.
*
* @var \bool
* @since 1.0.0
*/
private $featured = false;
/**
* Constructor.
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct()
{
$this->created = new \DateTime('NOW');
$this->publish = new \DateTime('NOW');
}
/**
* @return \int
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getAuthor() : \int
{
return $this->author;
}
/**
* @return \string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getContent() : \string
{
return $this->content;
}
/**
* @param \string $content
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setContent(\string $content)
{
$this->content = $content;
}
/**
* @return null
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getCreated() : \DateTime
{
return $this->created;
}
/**
* @return \int
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getId() : \int
{
return $this->id;
}
/**
* @param \int $id Id
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setId(\int $id)
{
$this->id = $id;
}
/**
* @return \string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getLanguage() : \string
{
return $this->lang;
}
/**
* @return \string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getPlain() : \string
{
return $this->plain;
}
/**
* @param \string $plain
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setPlain(\string $plain)
{
$this->plain = $plain;
}
/**
* @return null
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getPublish() : \DateTime
{
return $this->publish;
}
/**
* @param \string $lang
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setLang(\string $lang)
{
$this->lang = $lang;
}
/**
* @param \DateTime $publish
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setPublish(\DateTime $publish)
{
$this->publish = $publish;
}
/**
* @param \DateTime $created
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setCreated(\DateTime $created)
{
$this->created = $created;
}
/**
* @param \int $author
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setAuthor(\int $author)
{
$this->author = $author;
}
/**
* @return \string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getTitle() : \string
{
return $this->title;
}
/**
* @param \string $title
*
* @return mixed
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setTitle(\string $title)
{
$this->title = $title;
}
/**
* @return null
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getType() : \int
{
return $this->type;
}
/**
* @param \int $type
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setType(\int $type)
{
$this->type = $type;
}
/**
* @return null
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getStatus() : \int
{
return $this->status;
}
/**
* @param \int $status
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setStatus(\int $status)
{
$this->status = $status;
}
/**
* @return \bool
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function isFeatured() : \bool
{
return $this->featured;
}
/**
* @param \bool $featured
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setFeatured(\bool $featured)
{
$this->featured = $featured;
}
}

View File

@ -0,0 +1,117 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace Modules\News\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\DataStorage\Database\Query\Column;
class NewsArticleMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array>
* @since 1.0.0
*/
static protected $columns = [
'news_id' => ['name' => 'news_id', 'type' => 'int', 'internal' => 'id'],
'news_author' => ['name' => 'news_author', 'type' => 'string', 'internal' => 'author'],
'news_publish' => ['name' => 'news_publish', 'type' => 'DateTime', 'internal' => 'publish'],
'news_title' => ['name' => 'news_title', 'type' => 'string', 'internal' => 'title'],
'news_plain' => ['name' => 'news_plain', 'type' => 'string', 'internal' => 'plain'],
'news_content' => ['name' => 'news_content', 'type' => 'string', 'internal' => 'content'],
'news_status' => ['name' => 'news_status', 'type' => 'int', 'internal' => 'status'],
'news_type' => ['name' => 'news_type', 'type' => 'int', 'internal' => 'type'],
'news_featured' => ['name' => 'news_featured', 'type' => 'bool', 'internal' => 'featured'],
'news_created' => ['name' => 'news_created', 'type' => 'DateTime', 'internal' => 'created'],
];
/**
* Primary table.
*
* @var \string
* @since 1.0.0
*/
protected static $table = 'news';
/**
* Primary field name.
*
* @var \string
* @since 1.0.0
*/
protected static $primaryField = 'id';
/**
* Create article.
*
* @param mixed $obj News article
*
* @return \bool
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function create(&$obj)
{
try {
$objId = parent::create($obj);
$query = new Builder($this->db);
$query->prefix($this->db->getPrefix())
->insert(
'account_permission_account',
'account_permission_from',
'account_permission_for',
'account_permission_id1',
'account_permission_id2',
'account_permission_r',
'account_permission_w',
'account_permission_m',
'account_permission_d',
'account_permission_p'
)
->into('account_permission')
->values($obj->getAuthor(), 'news', 'news', 1, $objId, 1, 1, 1, 1, 1);
$this->db->con->prepare($query->toSql())->execute();
} catch (\Exception $e) {
return false;
}
return $objId;
}
/**
* Find.
*
* @param array $columns Columns to select
*
* @return Builder
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function find(...$columns) : Builder
{
return parent::find(...$columns)->from('account_permission')
->where('account_permission.account_permission_for', '=', 'news')
->where('account_permission.account_permission_id1', '=', 1)
->where('news.news_id', '=', new Column('account_permission.account_permission_id2'))
->where('account_permission.account_permission_r', '=', 1);
}
}

106
Models/NewsList.php Normal file
View File

@ -0,0 +1,106 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace Modules\News\Models;
use phpOMS\DataStorage\Database\DatabaseType;
/**
* News list class.
*
* @category Modules
* @package Modules\News
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class NewsList
{
/**
* Database instance.
*
* @var \phpOMS\DataStorage\Database\Database
* @since 1.0.0
*/
private $dbPool = null;
/**
* Constructor.
*
* @param \phpOMS\DataStorage\Database\Pool $dbPool Database pool instance
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct($dbPool)
{
$this->dbPool = $dbPool;
}
/**
* Get all news.
*
* This function gets all accounts in a range
*
* @param array $filter Filter for search results
* @param \int $offset Offset for first account
* @param \int $limit Limit for results
*
* @return array
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getList($filter = null, $offset = 0, $limit = 100)
{
$result = null;
switch ($this->dbPool->get('core')->getType()) {
case DatabaseType::MYSQL:
$search = $this->dbPool->get('core')->generate_sql_filter($filter, true);
// SQL_CALC_FOUND_ROWS
$sth = $this->dbPool->get('core')->con->prepare(
'SELECT DISTINCT
`' . $this->dbPool->get('core')->prefix . 'news`.*,
`' . $this->dbPool->get('core')->prefix . 'account_data`.`name1`,
`' . $this->dbPool->get('core')->prefix . 'account_data`.`name2`,
`' . $this->dbPool->get('core')->prefix . 'account_data`.`name3`
FROM
`' . $this->dbPool->get('core')->prefix . 'news`
LEFT JOIN `' . $this->dbPool->get('core')->prefix . 'account_data`
ON `' . $this->dbPool->get('core')->prefix . 'news`.`news_author` = `' . $this->dbPool->get('core')->prefix . 'account_data`.`account`
GROUP BY `' . $this->dbPool->get('core')->prefix . 'news`.`news_id` '
. $search . 'LIMIT ' . $offset . ',' . $limit
);
$sth->execute();
$result['list'] = $sth->fetchAll();
$sth = $this->dbPool->get('core')->con->prepare(
'SELECT FOUND_ROWS();'
);
$sth->execute();
$result['count'] = $sth->fetchAll()[0][0];
break;
}
return $result;
}
}

36
Models/NewsStatus.php Normal file
View File

@ -0,0 +1,36 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace Modules\News\Models;
use phpOMS\Datatypes\Enum;
/**
* News type status.
*
* @category Module
* @package Modules\News
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
abstract class NewsStatus extends Enum
{
const VISIBLE = 0;
const DRAFT = 1;
}

38
Models/NewsType.php Normal file
View File

@ -0,0 +1,38 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace Modules\News\Models;
use phpOMS\Datatypes\Enum;
/**
* News type enum.
*
* @category Module
* @package Modules\News
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
abstract class NewsType extends Enum
{
const ARTICLE = 0;
const LINK = 1;
const HEADLINE = 2;
}

1
README.md Normal file
View File

@ -0,0 +1 @@
# News #

View File

@ -0,0 +1,45 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
/**
* @var \phpOMS\Views\View $this
*/
$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response);
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
$footerView->setPages(20);
$footerView->setPage(1);
echo $this->getData('nav')->render(); ?>
<section class="box w-100">
<table class="table">
<caption><?= $this->l11n->lang['News']['Archive'] ?></caption>
<thead>
<tr>
<td><?= $this->l11n->lang['News']['Type']; ?>
<td class="wf-100"><?= $this->l11n->lang['News']['Title']; ?>
<td><?= $this->l11n->lang['News']['Author']; ?>
<td><?= $this->l11n->lang['News']['Date']; ?>
<tfoot>
<tr>
<td colspan="4"><?= $footerView->render(); ?>
<tbody>
<?php $count = 0; foreach([] as $key => $value) : $count++; ?>
<?php endforeach; ?>
<?php if($count === 0) : ?>
<tr><td colspan="4" class="empty"><?= $this->l11n->lang[0]['Empty']; ?>
<?php endif; ?>
</table>
</section>

View File

@ -0,0 +1,115 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
/**
* @var \phpOMS\Views\View $this
*/
echo $this->getData('nav')->render(); ?>
<section class="wf-75 floatLeft">
<section class="box w-100">
<div class="inner">
<input type="text" placeholder="&#xf040; This is a news title" form="newsForm">
</div>
</section>
<section class="box w-100">
<div class="inner">
<i class="fa fa-header"></i>
<i class="fa fa-link"></i>
<i class="fa fa-image"></i>
<i class="fa fa-bold"></i>
<i class="fa fa-italic"></i>
<i class="fa fa-underline"></i>
<i class="fa fa-strikethrough"></i>
<i class="fa fa-list-ol"></i>
<i class="fa fa-list-ul"></i>
<i class="fa fa-quote-right"></i>
<i class="fa fa-subscript"></i>
<i class="fa fa-superscript"></i>
<i class="fa fa-question-circle floatRight"></i>
</div>
</section>
<section class="box w-100">
<div class="tabular">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->l11n->lang['News']['Plain'] ?></label>
<li><label for="c-tab-2"><?= $this->l11n->lang['News']['Preview'] ?></label>
</ul>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-1" checked>
<div class="tab">
<textarea style="height: 300px" placeholder="&#xf040;" form="newsForm"></textarea><input type="hidden" id="iParsed" name="parsed">
</div>
<input type="radio" id="c-tab-2" name="tabular-1">
<div class="tab">
</div>
</div>
</div>
</section>
</section>
<section class="wf-25 floatLeft">
<section class="box w-100">
<div class="inner">
<form id="newsForm">
<table class="layout wf-100">
<tr><td colspan="2"><label for="publish"><?= $this->l11n->lang['News']['Status'] ?></label>
<tr><td colspan="2"><select>
<option selected><?= $this->l11n->lang['News']['Draft'] ?>
<option><?= $this->l11n->lang['News']['Visible'] ?>
<tr><td colspan="2"><label for="publish"><?= $this->l11n->lang['News']['Publish'] ?></label>
<tr><td colspan="2"><input type="datetime-local" id="publish" value="<?= (new \DateTime('NOW'))->format('Y-m-d\TH:i:s') ?>">
<tr><td><input type="submit" value="<?= $this->l11n->lang[0]['Delete'] ?>"><td class="rightText"><input type="submit" value="<?= $this->l11n->lang[0]['Save'] ?>"> <input type="submit" value="<?= $this->l11n->lang['News']['Publish'] ?>">
</table>
</form>
</div>
</section>
<section class="box w-100">
<div class="inner">
<form id="newsForm">
<table class="layout wf-100">
<tr><td colspan="2"><label><?= $this->l11n->lang['News']['Type'] ?></label>
<tr><td colspan="2"><span class="radio"><input type="radio" name="type" form="newsForm" value="1" id="news" checked><label for="news"><?= $this->l11n->lang['News']['News'] ?></label></span>
<tr><td colspan="2"><span class="radio"><input type="radio" name="type" form="newsForm" value="2" id="headline"><label for="headline"><?= $this->l11n->lang['News']['Headline'] ?></label></span>
<tr><td colspan="2"><span class="radio"><input type="radio" name="type" form="newsForm" value="3" id="link"><label for="link"><?= $this->l11n->lang['News']['Link'] ?></label></span>
</table>
</form>
</div>
</section>
<section class="box w-100">
<div class="inner">
<form id="newsForm">
<table class="layout wf-100">
<tr><td colspan="2"><label for="permission"><?= $this->l11n->lang['News']['Permissions'] ?></label>
<tr><td><input type="text" id="permission"><input type="hidden" form="newsForm" name="permission"><td><button><?= $this->l11n->lang[0]['Add'] ?></button>
</table>
</form>
</div>
</section>
<section class="box w-100">
<div class="inner">
<form id="newsForm">
<table class="layout wf-100">
<tr><td colspan="2"><label for="groups"><?= $this->l11n->lang['News']['Groups'] ?></label>
<tr><td><input type="text" id="groups"><input type="hidden" form="newsForm" name="groups"><td><button><?= $this->l11n->lang[0]['Add'] ?></button>
</table>
</form>
</div>
</section>
</section>

View File

@ -0,0 +1,57 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
/**
* @var \phpOMS\Views\View $this
*/
$newsList = $this->getData('newsList');
$headlineList = $this->getData('headlineList');
echo $this->getData('nav')->render(); ?>
<section class="box w-50 floatLeft">
<table class="table">
<caption><?= $this->l11n->lang['News']['News'] ?></caption>
<thead>
<tr>
<td class="wf-100"><?= $this->l11n->lang['News']['Title']; ?>
<td><?= $this->l11n->lang['News']['Author']; ?>
<td><?= $this->l11n->lang['News']['Date']; ?>
<tbody>
<?php $count = 0; foreach([] as $key => $value) : $count++; ?>
<?php endforeach; ?>
<?php if($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->l11n->lang[0]['Empty']; ?>
<?php endif; ?>
</table>
</section>
<section class="box w-50 floatLeft">
<table class="table">
<caption><?= $this->l11n->lang['News']['Headlines'] ?></caption>
<thead>
<tr>
<td class="wf-100"><?= $this->l11n->lang['News']['Title']; ?>
<td><?= $this->l11n->lang['News']['Author']; ?>
<td><?= $this->l11n->lang['News']['Date']; ?>
<tbody>
<?php $count = 0; foreach([] as $key => $value) : $count++; ?>
<?php endforeach; ?>
<?php if($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->l11n->lang[0]['Empty']; ?>
<?php endif; ?>
</table>
</section>

View File

View File

@ -0,0 +1,13 @@
<div class="b b-5 c7-1 c7" id="i7-1-1">
<h1>
<?= /** @var \Modules\News\Article $article */
$article->getTitle(); ?>
<i class="fa fa-minus min"></i>
<i class="fa fa-plus max vh"></i>
</h1>
<div class="bc-1">
<span><?= $article->getPublish()->format('Y-m-d H:i:s'); ?></span> <span><?= $article->getAuthor(); ?></span>
<?= $article->getContent(); ?>
</div>
</div>

View File

@ -0,0 +1,37 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
$MODLANG['News'] = [
'Additional' => 'Additional',
'Archive' => 'Archive',
'Author' => 'Author',
'Date' => 'Date',
'Draft' => 'Draft',
'Featured' => 'Featured',
'Groups' => 'Groups',
'Headline' => 'Headline',
'Headlines' => 'Headlines',
'Link' => 'Link',
'News' => 'News',
'Permissions' => 'Permissions',
'Plain' => 'Plain',
'Preview' => 'Preview',
'Publish' => 'Publish',
'Settings' => 'Settings',
'Status' => 'Status',
'Title' => 'Title',
'Type' => 'Type',
'Visible' => 'Visible',
];

View File

@ -0,0 +1,21 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
$MODLANG['Navigation'] = [
'Archive' => 'Archive',
'Create' => 'Create',
'Draft' => 'Draft',
'News' => 'News',
];

BIN
img/module_teaser_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

52
info.json Normal file
View File

@ -0,0 +1,52 @@
{
"name": {
"id": 1000600000,
"internal": "News",
"external": "OMS News"
},
"version": "1.0.0",
"requirements": {
"phpOMS": "1.0.0",
"phpOMS-db": "1.0.0"
},
"creator": {
"name": "Orange Management",
"website": "www.spl1nes.com"
},
"description": "News module.",
"directory": "News",
"dependencies": {},
"providing": {
"Navigation": "*"
},
"load": [
{
"pid": [
"d7470914e19522acc310a55e5cb13a6f0f7ca000",
"0ac9153b72f8659e3c4b370f56bbcdf0eba86d6a"
],
"type": 4,
"for": 0,
"from": "News",
"file": "News"
},
{
"pid": [
"754a08ddf8bcb1cf22f310f09206dd783d42f7dd"
],
"type": 5,
"from": "News",
"for": "Navigation",
"file": "nav.backend"
},
{
"pid": [
"d7470914e19522acc310a55e5cb13a6f0f7ca000"
],
"type": 5,
"for": "Content",
"file": "backend",
"from": "News"
}
]
}