added some useful models and controllers

This commit is contained in:
Logsol 2013-07-08 21:02:22 +02:00
parent a6873ee6c8
commit 57c0436f14
45 changed files with 6456 additions and 0 deletions

View file

@ -0,0 +1,32 @@
<?php
class AdminController extends Katharsis_Controller_Abstract
{
public function indexAction()
{
if(!Access::isLogged()) $this->_location('gate');
}
public function gateAction()
{
}
public function loginAction()
{
if($this->_getParam('password') == 'holzmitloch')
{
$_SESSION['logged'] = 1;
$this->_location('index');
}
else
{
$this->_location('gate', null, array('wrongpassword' => ''));
}
}
public function logoutAction()
{
$_SESSION['logged'] = 0;
$this->_location('gate');
}
}

View file

@ -0,0 +1,53 @@
<?php
class AdminNavigationController extends Katharsis_Controller_Abstract
{
protected $_navi;
public function init()
{
$this->_navi = new Navigation();
}
public function indexAction()
{
$this->_view->list = $this->_navi->getAllItems();
}
public function editAction()
{
$this->_view->mainItems = $this->_navi->getMainItems();
$this->_view->item = $this->_navi->getItem($this->_getParam('id'));
$this->_view->sites = $this->_navi->getSites();
}
public function deleteAction()
{
$this->_navi->delete($this->_getParam('id'));
DidgeridooArtwork_Notice::add('Navigationseintrag wurde erfolgreich gelöscht!');
$this->_location('index');
}
public function saveAction()
{
$params = $this->_getAllParams();
$params['active'] = 0;
if($this->_getParam('active') && $this->_getParam('active') == 'on')
{
$params['active'] = 1;
}
$params['parentId'] = ($params['parentId'] == '0') ? null : $params['parentId'];
$this->_navi->save($params);
DidgeridooArtwork_Notice::add('Navigationseintrag wurde erfolgreich gespeichert!');
$this->_location('index');
}
public function moveAction()
{
$this->_navi->move($this->_getParam('direction'), $this->_getParam('id'));
DidgeridooArtwork_Notice::add('Navigationseintrag wurde erfolgreich verschoben!');
$this->_location('index');
}
}

View file

@ -0,0 +1,79 @@
<?php
class AdminPageController extends Katharsis_Controller_Abstract
{
protected $_page;
public function init()
{
$this->_page = new Page();
}
public function indexAction()
{
$this->_view->pages = $this->_page->getPages();
}
public function editAction()
{
$this->_view->page = $this->_page->getPage($this->_getParam('pageId'));
}
public function imageAction()
{
if(isset($_FILES['myfile']))
{
$upload = new Upload();
$upload->page($_FILES['myfile']);
echo 'Das Hochladen war erfolgreich.<br><br>';
}
if(isset($_GET['delete']))
{
$deleteFile = getcwd() . '/img/page/' . $_GET['delete'];
if(file_exists($deleteFile)) {
unlink($deleteFile);
}
}
if ($handle = opendir(getcwd().'/img/page/'))
{
$ar = array();
while (false !== ($file = readdir($handle))) {
if(is_dir($file)) continue;
$ar[] = $file;
}
$this->_view->files = $ar;
closedir($handle);
}
echo $this->_view->render('AdminPage/image');
die();
}
public function saveAction()
{
$params = $this->_getAllParams();
$params['active'] = 0;
if($this->_getParam('active') && $this->_getParam('active') == 'on')
{
$params['active'] = 1;
}
$this->_page->save($params);
DidgeridooArtwork_Notice::add('Page wurde erfolgreich gespeichert!');
$this->_location('index');
}
public function deleteAction()
{
$this->_page->delete($this->_getParam('pageId'));
DidgeridooArtwork_Notice::add('Page wurde erfolgreich gelöscht!');
$this->_location('index');
}
}

View file

@ -0,0 +1,33 @@
<?php
class AdminUploadController extends Katharsis_Controller_Abstract
{
public function indexAction()
{
}
public function productAction()
{
$shop = new Product();
$this->_view->item = $shop->getProduct($this->_getParam('productId'));
}
public function processAction()
{
$upload = new Upload();
if($this->_getParam('productId'))
{
if($_FILES['small']['type'] != $_FILES['big']['type'])
{
throw new DidgeridooArtwork_Exception('Beide Bilder müssen vom selben Dateityp sein.');
}
$filename = $upload->product($this->_getParam('productId'), $_FILES);
$product = new Product();
$product->addImage($this->_getParam('productId'), $filename);
DidgeridooArtwork_Notice::add('Das Hochladen war erfolgreich.');
$this->_location('edit', 'adminShop', array('productId' => $this->_getParam('productId')));
}
}
}

View file

@ -0,0 +1,27 @@
<?php
class PageController extends Katharsis_Controller_Abstract
{
protected $_page;
public function init()
{
$this->_page = new Page();
}
public function __call($method, $args)
{
$preview = false;
if(array_key_exists('preview', $this->_getAllParams()) && Access::isLogged())
{
$preview = true;
}
$method = substr($method, 0, -6);
$content = $this->_page->render($method, $preview);
$content = DidgeridooArtwork_Page_Plugin::render($content);
$this->_view->stageContent = $content;
echo $this->_view->render('main');
die();
}
}