Your IP : 216.73.217.72
<?php
if (!defined('LOADED_AS_ADMIN_MODULE'))
{
require_once('../../core/Dobi.php');
Dobi::exception('dobiExcDirectAccess', 1, '', 'direct');
}
class IPageAdmin implements DobiAdminModule, action_show, action_add
{
private $ipage_current_action_to_run;
public function __construct($ipage_current_action_to_run)
{
$this->ipage_current_action_to_run = $ipage_current_action_to_run;
}
public function _defaultAction()
{
return $this->show();
}
public function _executeAction()
{
if (!Registry::getObject('session')->getUserAccess(LA_CONTENT))
{
echo '<span style="font-weight: bold;">'._ACCESS_DENIED_.'</span> ' . _ACCESS_DENIED_MSG_;
return;
}
$go = $this->ipage_current_action_to_run;
$this->$go();
}
public function show()
{
$dbRC = Registry::getObject('dbRC');
$dbC = Registry::getObject('dbC');
$amount = $dbC->getAmount('ipages');
$per_page = 15;
$dataRequest = Registry::getObject('dataRequest');
if (!($start = $dataRequest->getValue('start'))) $start = 0;
$pages = new pages($start, $amount, $per_page, 'show', 'admin.php');
// 570px - il. komórek
echo '<div class="table">
<div style="width: 40px;" class="top"> '._IPAGE_ID_.' </div>
<div style="width: 100px;" class="top"> '._WORD_TITLE_.' </div>
<div style="width: 80px;" class="top"> '._WORD_AUTHOR_.' </div>
<div style="width: 85px;" class="top"> '._IPAGE_ADDD_.' </div>
<div style="width: 87px;" class="top"> '._IPAGE_UPDD_.' </div>
<div style="width: 70px;" class="top"> '._IPAGE_VIEWS_.' </div>
<div style="width: 100px;" class="top"> '._WORD_ACTION_.' </div>';
if ($amount > 0)
{
$dbRC->rowCache( 'ipages', '*', 'ipages', '', 'page_id DESC', $start . ',' . ($start + $per_page));
$dbRC->setName('ipages');
while ($dbRC->rowExists())
{
$page_id = $dbRC->getRow('page_id');
echo '<div style="width: 40px;" class="action3"> '.$page_id.' </div>
<div style="width: 100px;" class="action3"> '.$dbRC->getRow('page_title').' </div>
<div style="width: 80px;" class="action3"> '.$dbRC->getRow('page_author').' </div>
<div style="width: 85px;" class="action3"> '.date('d.m.y, H:i', $dbRC->getRow('page_add_date')).'</div>
<div style="width: 87px;" class="action3"> '.date('d.m.y, H:i', $dbRC->getRow('page_edit_date')).'</div>
<div style="width: 70px;" class="action3"> '.$dbRC->getRow('page_views').'</div>
<div style="width: 100px;" class="action3"><a href="admin.php?module=IPage&action=delete&id='.$page_id.'">'._WORD_DELETE_.'</a>
<a href="admin.php?module=IPage&action=edit&id='.$page_id.'">'._WORD_EDIT_.'</a>
<a href="index.php?module=IPage&id='.$page_id.'">'._WORD_SEE_.'</a></div>
';
$dbRC->increment();
}
$dbRC->clear();
}
else
{
echo '<div style="width: 569px;">'._IPAGE_NO_IPAGES_.'</div>';
}
echo '</div><div style="padding-top: 10px; padding-bottom: 10px; text-align: center;">' . $pages->getPages() . '</div>';
}
public function add()
{
new tinyMCE();
echo '<div class="form">';
$form = new form('new_ipage', Registry::getObject('dataRequest')->getActionLink('executeAdd'));
$form->setSize(10);
$form->setMaxlen(100);
$form->fieldset('normal');
$form->legend(_IPAGE_ADD_IPAGE_);
$form->addContent('<div class="help"><h4>'._WORD_HELP_.'</h4><p>'._HELP_1_.'</p></div>');
$form->addContent('<div class="left">');
$form->text(_IPAGE_TITLE_, 'ipage_title', '', '', 'required');
$form->text(_IPAGE_AUTHOR_, 'ipage_author', Registry::getObject('session')->getUserLogin(), '', 'required');
$form->textarea(_IPAGE_CONTENT_, 'ipage_content', '', 60, 20, '', 'required');
$form->addContent('</div>');
$form->addContent('<div class="submit">');
$form->submit(_WORD_ADD_, 'inputSubmit');
$form->reset(_WORD_CLEAR_, 'inputSubmit');
$form->addContent('</div>');
$form->eFieldset();
echo $form->getForm();
echo '</div>';
}
public function executeAdd()
{
$error = Registry::getObject('error', new error());
$error->addAction('show');
$error->setTrueMessage(_IPAGE_ADD_SUCC_);
$error->setFalseMessage(_IPAGE_ADD_FAIL_ . _ERRORS_OCCURRED_);
$dataRequest = Registry::getObject('dataRequest');
$dbUDECA = Registry::getObject('dbUDECA');
$dbUDECA->setMapper(true);
$dbUDECA->mapper( IS_REQUIRED, array(0 =>'ipage_author', 'ipage_title'));
$dbUDECA->mapper( IS_REQUIRED, array(0 => 'ipage_content'), array('rewrite' => 'yes'));
$dbUDECA->insert('ipages', array('page_title' => $dataRequest->getValue('ipage_title'),
'page_content' => $dbUDECA->getMapped('ipage_content'),
'page_add_date' => time(),
'page_edit_date' => time(),
'page_views' => '1',
'page_author' => $dataRequest->getValue('ipage_author')));
$dbUDECA->execute();
$dbUDECA->clear();
if (!$error->errorExists())
{
$dbC = Registry::getObject('dbC');
$dbC->updateCounter('ipages');
}
$error->getErrors();
}
public function edit()
{
$dbRC = Registry::getObject('dbRC');
$dbRC->rowCache( 'one_ipage', 'page_id, page_title, page_author, page_content', 'ipages', 'page_id="' . Registry::getObject('dataRequest')->getValue('id') . '"');
$dbRC->setName('one_ipage');
if ($dbRC->getRowsAmount() > 0)
{
new tinyMCE();
echo '<div class="form">';
$form = new form('edit_ipage', Registry::getObject('dataRequest')->getActionLink('updateEdit'));
$form->setSize(10);
$form->setMaxlen(100);
$form->fieldset('normal');
$form->legend(_IPAGE_EDIT_);
$form->addContent('<div class="help"><h4>'._WORD_HELP_.'</h4><p>'._HELP_1_.'</p></div>');
$form->addContent('<div class="left">');
$form->text( _IPAGE_TITLE_, 'ipage_title', $dbRC->getRow('page_title'), '', 'required');
$form->text( _IPAGE_AUTHOR_, 'ipage_author', $dbRC->getRow('page_author'), '', 'required');
$form->textarea( _IPAGE_CONTENT_, 'ipage_content', $dbRC->getRow('page_content'), 60, 20, '', 'required');
$form->addContent('</div>');
$form->hidden('id', $dbRC->getRow('page_id'));
$form->addContent('<div class="submit">');
$form->submit(_WORD_UPDATE_, 'inputSubmit');
$form->reset(_WORD_CLEAR_, 'inputSubmit');
$form->addContent('</div>');
$form->eFieldset();
echo $form->getForm();
echo '</div>';
}
else
{
$error = Registry::getObject('error', new error());
$error->addAction('show');
$error->setFalseMessage(_IPAGE_SHOW_FAIL_ . _ERRORS_OCCURRED_);
$error->addError(_IPAGE_ERR_1_);
$error->getErrors();
}
}
public function updateEdit()
{
$error = Registry::getObject('error', new error());
$error->addAction('show');
$error->setTrueMessage(_IPAGE_UPDATE_SUCC_);
$error->setFalseMessage(_IPAGE_UPDATE_FAIL_ . _ERRORS_OCCURRED_);
$dataRequest = Registry::getObject('dataRequest');
$dbUDECA = Registry::getObject('dbUDECA');
$dbUDECA->setMapper(true);
$dbUDECA->mapper( IS_REQUIRED, array(0 =>'ipage_author', 'ipage_title', 'id'));
$dbUDECA->mapper( IS_REQUIRED, array(0 => 'ipage_content'), array('rewrite' => 'yes'));
$dbUDECA->setWhere('page_id="'. $dataRequest->getValue('id') .'"');
$dbUDECA->update('ipages', array('page_title' => $dataRequest->getValue('ipage_title'),
'page_content' => $dbUDECA->getMapped('ipage_content'),
'page_author' => $dataRequest->getValue('ipage_author'),
'page_edit_date' => time()));
$dbUDECA->execute();
$dbUDECA->clear();
$error->getErrors();
}
public function delete()
{
$dataRequest = Registry::getObject('dataRequest');
if (!$dataRequest->accept(_IPAGE_ACCEPT_ . $dataRequest->getValue('id') . ' ?'))
{
return;
}
$error = Registry::getObject('error', new error());
$error->addAction('show');
$error->setTrueMessage(_IPAGE_DELETE_SUCC_);
$dbUDECA = Registry::getObject('dbUDECA');
$dbUDECA->setMapper(false);
$dbUDECA->setWhere('page_id="' . $dataRequest->getValue('id') . '"');
$dbUDECA->delete('ipages');
$dbUDECA->execute();
$dbUDECA->clear();
if (!$error->errorExists())
{
$dbC = Registry::getObject('dbC');
$dbC->updateCounter('ipages', -1);
}
$error->getErrors();
}
}
?>