Permalink
Browse files

Added labels for cmsmodules

  • Loading branch information...
1 parent 3a6fcb8 commit 6e8d1814f256166955d6da6361777e5d89fd4db6 @dicabrio committed Apr 27, 2011
@@ -1,51 +0,0 @@
-<?php
-/**
- * Description of Blog
- *
- * Every blog is in fact a page. This page is of a type: 'blog' :)
- *
- * @author robertcabri
- */
-class Blog extends Page {
-
- public function __construct($id = null) {
- parent::__construct($id);
-
- if ($id > 0) {
- $this->setAttr('type', 'blog');
- }
- }
-
- public static function findAll() {
-
- $blogs = parent::findAll('Page', parent::ALL, new Criteria("type=:type", array('type' => 'blog')));
- return $blogs;
-
- }
-
- public static function findActive($numberIncrement=10, $numberStart=0) {
-
- $numberIncrement = intval($numberIncrement);
- if ($numberIncrement == 0) {
- $numberIncrement = 10;
- }
-
- $now = date('Y-m-d H:i:s');
- $crit = new Criteria("type=:type
- AND active = :active
- AND publishtime < :time
- AND (expiretime = '0000-00-00 00:00:00' OR expiretime > :time)", array('type' => 'blog', 'active' => 1, 'time' => $now));
-
- return parent::findAll('Page', parent::ALL, $crit, 'created DESC', intval($numberStart).','.$numberIncrement);
- }
-
- public function countAllActive() {
-
- $now = date('Y-m-d H:i:s');
- return (int)parent::countBySql("SELECT COUNT(1) FROM `page` WHERE type=:type
- AND active = :active
- AND publishtime < :time
- AND (expiretime = '0000-00-00 00:00:00' OR expiretime > :time)", array('type' => 'blog', 'active' => 1, 'time' => $now));
- }
-
-}
@@ -1,135 +0,0 @@
-<?php
-
-class BlogarchiveCmsModule implements CmsModuleController {
-
- /**
- * @var PageModule
- */
- private $oPageModule;
-
- /**
- * @var PageText
- */
- private $oTextContent;
-
- /**
- * @var Form
- */
- private $form;
-
- /**
- *
- * @var FormMapper
- */
- private $mapper;
-
- /**
- *
- * @var Input
- */
- private $amountElement;
-
- private $amount;
-
- /**
- * construct the text line module
- *
- * @param string $sIdentifier
- * @param Page $oPage
- * @return void
- */
- public function __construct(PageModule $oMod, Form $form) {
-
- $this->oPageModule = $oMod;
- $this->form = $form;
- $this->htmlEditor = false;
-
- // load the data
- $this->load();
- $this->defineForm();
- }
-
- /**
- * Load the data for this module
- */
- private function load() {
-
- $this->oTextContent = PageText::getByPageModule($this->oPageModule);
- $values = explode(',', $this->oTextContent->getContent());
-
- if (!isset($values[1])) {
- $this->amount = 10;
- $this->templateFile = $this->templateFile = new TemplateFile();
- } else {
- $this->amount = $values[0];
- $this->templateFile = $this->templateFile = new TemplateFile($values[1]);
- }
-
- $module = current(Module::getForTemplates('blog'));
- $this->options = TemplateFile::findByModule($module);
- }
-
- private function defineForm() {
-
- $this->amountElement = new Input('text', $this->oPageModule->getIdentifier().'_amount', $this->amount);
-
- $this->selectElement = new Select($this->oPageModule->getIdentifier());
- $this->selectElement->setValue($this->templateFile->getID());
- $this->selectElement->addOption(0, Lang::get('general.choose'));
-
- foreach ($this->options as $templateOption) {
- $this->selectElement->addOption($templateOption->getID(), $templateOption->getTitle());
- }
- $this->form->addFormElement($this->amountElement->getName(), $this->amountElement);
- $this->form->addFormElement($this->selectElement->getName(), $this->selectElement);
- }
-
- /**
- * add form mapping
- *
- * @param FormMapper $mapper
- */
- public function addFormMapping(FormMapper $mapper) {
-
- $this->mapper = $mapper;
- $this->mapper->addFormElementToDomainEntityMapping($this->selectElement->getName(), "TemplateFile");
-
- }
-
- /**
- * (non-PHPdoc)
- * @see modules/Module#getEditor()
- */
- public function getEditor() {
-
- $view = new View(Conf::get('general.dir.templates').'/blog/blogcmsmodule.php');
- $view->assign('form', $this->form);
- $view->assign('identifier', $this->oPageModule->getIdentifier());
-
- return $view;
-
- }
-
- /**
- *
- * @param $oReq
- * @return boolean
- */
- public function handleData() {
-
- $sModIdentifier = $this->oPageModule->getIdentifier();
- $templateFile = $this->mapper->getModel($sModIdentifier);
- $amount = $this->mapper->getModel($sModIdentifier.'_amount');
-
- $this->oTextContent->setContent($amount.','.$templateFile->getID());
- $this->oTextContent->setPageModule($this->oPageModule);
- $this->oTextContent->save();
-
- }
-
- public function getIdentifier() {
-
- return $this->oPageModule->getIdentifier();
-
- }
-}
@@ -1,110 +0,0 @@
-<?php
-
-class BlogarchivePageModule implements PageModuleController {
-
- /**
- * @var PageModule
- */
- private $pageModule;
- /**
- * @var Page
- */
- private $page;
- /**
- * @var Request
- */
- private $request;
- /**
- * @var PageModuleController
- */
- private $imageUploadModule;
- /**
- * @var PageModuleController
- */
- private $textBlockModule;
-
- /**
- *
- * @param PageModule $module
- * @param Page $oPage
- * @param Request $request
- * @return void
- */
- public function __construct(PageModule $module, Page $page, Request $request) {
-
- $this->pageModule = $module;
- $this->page = $page;
- $this->request = $request;
- }
-
- private function buildBlogArray(Page $blog) {
-
- $pageModule = $blog->getModule('subject');
- $pageTextSubject = PageText::getByPageModule($pageModule);
-
- $pageModule = $blog->getModule('summary');
- $pageTextSummary = PageText::getByPageModule($pageModule);
-
- return array('subject' => $pageTextSubject->getContent(), 'name' => $blog->getName(), 'summary' => $pageTextSummary->getContent());
-
- }
-
- /**
- * get contents for this module as a string or an object that has a __toString method implemented
- *
- * @return string
- */
- public function getContents() {
-
- $oTextContent = PageText::getByPageModule($this->pageModule);
- $formshizzle = explode(',', $oTextContent->getContent());
-
- $amountToStart = 0;
- $amountPerPage = intval($formshizzle[0]);
- $page = intval($this->request->get('page'));
-
- if ($page > 1) {
- $amountToStart = ($page * $amountPerPage) - $amountPerPage;
- } else {
- $page = 1;
- }
-
- $activeBlogs = Blog::findActive($amountPerPage, $amountToStart);
- $amountOfActiveBlogs = Blog::countAllActive();
-
- $blogArticlesForTemplate = array();
- foreach ($activeBlogs as $blog) {
- $blogArticlesForTemplate[] = $this->buildBlogArray($blog);
- }
-
- try {
-
- $tplFile = new TemplateFile($formshizzle[1]);
- $view = new View(Conf::get('upload.dir.templates').'/'.$tplFile->getFilename());
- $view->assign('wwwurl', Conf::get('general.url.www'));
- $view->assign('articles', $blogArticlesForTemplate);
-// $view->assign('pages', ceil($amountOfActiveBlogs / $amountPerPage));
-// $view->assign('page', $page);
-
- return $view;
- } catch (Exception $e) {
-
- $str = '<ul id="blogrecent">';
- foreach ($activeBlogs as $blog) {
- $str .= '<li><a href="'.$blog->getName().'">'.$blog->getTitle().'</a></li>';
- }
- $str .= '</ul>';
-
- return $str;
- }
- }
-
- /**
- * @return string
- */
- public function getIdentifier() {
-
- return '';
- }
-
-}
Oops, something went wrong.

0 comments on commit 6e8d181

Please sign in to comment.