edited page mechanism

This commit is contained in:
Logsol 2013-07-10 12:15:34 +02:00
parent 4c21bbcefd
commit 79a0690fad
8 changed files with 51 additions and 37 deletions

View file

@ -20,12 +20,23 @@ class AdminPageController extends Katharsis_Controller_Abstract
public function imageAction()
{
if($this->_getParam('type') == 'header') {
$type = 'header';
} else {
$type = 'page';
}
$path = getcwd().'/img/' . $type . '/';
if(isset($_FILES['myfile']))
{
$upload = new Upload();
$upload->page($_FILES['myfile']);
if($type == 'header') {
$upload->header($_FILES['myfile']);
} else {
$upload->page($_FILES['myfile']);
}
echo 'Das Hochladen war erfolgreich.<br><br>';
}
@ -33,25 +44,25 @@ class AdminPageController extends Katharsis_Controller_Abstract
if(isset($_GET['delete']))
{
$deleteFile = getcwd() . '/img/page/' . $_GET['delete'];
$deleteFile = $path . $_GET['delete'];
if(file_exists($deleteFile)) {
unlink($deleteFile);
}
}
if ($handle = opendir(getcwd().'/img/page/'))
$ar = array();
if (is_readable($path) && $handle = opendir())
{
$ar = array();
while (false !== ($file = readdir($handle))) {
if(is_dir($file)) continue;
$ar[] = $file;
}
$this->_view->files = $ar;
closedir($handle);
}
$this->_view->files = $ar;
echo $this->_view->render('AdminPage/image');
die();
}

View file

@ -1,16 +1,5 @@
<?php
class AdminUploadController extends Katharsis_Controller_Abstract
{
public function indexAction()
{
}
public function headerAction()
{
$upload = new Upload();
$filename = $upload->header($this->_getParam('pageId'), $_FILES);
DidgeridooArtwork_Notice::add('Das Hochladen war erfolgreich. Dateiname: ' . $filename);
}
// check adminPageController and Upload model
}

View file

@ -15,11 +15,23 @@ class PageController extends Katharsis_Controller_Abstract
{
$preview = true;
}
$method = substr($method, 0, -6);
$content = $this->_page->render($method, $preview);
$url = substr($method, 0, -6);
$content = DidgeridooArtwork_Page_Plugin::render($content);
$pageId = $this->_page->getIdByUrl($url);
if(!$pageId) {
throw new DidgeridooArtwork_Exception('Page konnte nicht geladen werden.');
}
$pageData = $this->_page->getPage($pageId);
foreach($pageData as $key => $value) {
$this->_view->{$key} = $value;
}
$this->_view->content = DidgeridooArtwork_Page_Plugin::render($this->_view->content);
$content = $this->_view->render('page/post');
$this->_view->stageContent = $content;
echo $this->_view->render('main');
die();

View file

@ -5,21 +5,18 @@ class Page extends Katharsis_Model_Abstract
{
}
public function render($url, $preview)
public function getIdByUrl($url, $preview = false)
{
$activeTerm = '';
if(!$preview)
{
$activeTerm = 'AND active = 1';
}
$sql = $this->_con->createStatement("SELECT * FROM page WHERE url = :url " . $activeTerm, array("url" => $url));
if($result = $this->_con->fetchOne($sql))
{
return $result['content'];
}
else
{
throw new DidgeridooArtwork_Exception('Die von Ihnen angeforderte Seite (Page) "' . $url . '" konnte nicht gefunden werden.');
$sql = $this->_con->createStatement("SELECT id FROM page WHERE url = :url " . $activeTerm, array("url" => $url));
if($result = $this->_con->fetchOne($sql)){
return $result['id'];
}
}

View file

@ -6,10 +6,10 @@ class Upload extends Katharsis_Model_Abstract
}
public function header($id, $file)
public function header($file)
{
$dir = getcwd() . '/img/header';
return $this->_uploadFile($id, $file, $dir);
return $this->_uploadFile(null, $file, $dir);
}
public function page($file)
@ -33,7 +33,9 @@ class Upload extends Katharsis_Model_Abstract
}
$handle = new Verot_Upload($file);
return;
$handle->file_new_name_body = $name;
if ($handle->uploaded)
{
$handle->Process($dir);

View file

@ -79,8 +79,8 @@
<dl>
<dt>Header&nbsp;Bild</dt>
<dd>
<input class="textfield" type="text" name="header_image" value="<?php echo $this->page['header_image'] ?>" readonly="readonly" />
<a onclick="alert('choose');">Auswählen</a> | <a onclick="alert('upload');">Hochladen</a>
<input class="textfield" type="text" name="header_image" value="<?php echo $this->page['header_image'] ?>"/>
<a href="javascript: void(0);" onclick="window.open('/adminPage/image/type/header', 'fenster1', 'width=600,height=400,status=yes,scrollbars=yes,resizable=yes');">Auswählen</a>
</dd>
</dl>
<dl>

View file

@ -10,7 +10,7 @@
<div style="padding: 10px;">
<h3 style="color:white; padding: 3px;background-color: #CB3829;">Bild Hochladen</h3>
<p><form method="post" enctype="multipart/form-data">
<input name="myfile" type="file" size="50" maxlength="100000" accept="text/*"> <input type="submit" value="Go" />
<input name="myfile" type="file" size="50" maxlength="100000"> <input type="submit" value="Go" />
</form>
</p>
<h3 style="color:white; padding: 3px;background-color: #CB3829;">Bild Ausw&auml;hlen</h3>

View file

@ -0,0 +1,3 @@
this is my site
Title (<?php echo $this->title; ?>)