function __construct($id_menu = NULL, $lang = NULL) { $this->session = NEnvironment::getSession('Menu'); $this->pageModel = PageModel::init(); if ($id_menu == NULL) { if (isset($_GET["id_menu"])) { $this->session['id_menu'] = $_GET["id_menu"]; } if (!isset($this->session['id_menu'])) { $this->session['id_menu'] = NEnvironment::getVariable('ADMIN_DEFAULT_IDMENU'); } $this->id_menu = $this->session['id_menu']; } else { $this->id_menu = $id_menu; } if (@$lang == NULL) { if (!isset(NEnvironment::getSession('Page')->lang)) { $this->lang = NEnvironment::getVariable('ADMIN_DEFAULT_LANG'); } $this->lang = NEnvironment::getSession('Page')->lang; } else { $this->lang = $lang; } $this->var = NEnvironment::getConfig('ADMINMENU'); }
/** * Create contact form controler * @return NAppForm */ public function createComponentPopForm() { $id = (int) $this->getParam('id'); $form = new NAppForm(); $form->addTextArea('body', 'Zpráva:', 40, 10)->addRule(NForm::FILLED, 'Vyplňte prosím obsah zprávy.'); $form->addText('contact', 'Kontakt na Vás (e-mail nebo telefon):')->addRule(NForm::FILLED, 'Nezapomeňte prosím uvést na sebe kontakt.'); $form->addImage('popsend', NEnvironment::getVariable('baseUri') . 'layout/img/form-send.jpg', 'Odeslat'); $form->addHidden('id', $id); $form->getElementPrototype()->class('ajax'); $form['body']->getControlPrototype()->class('s100 h140px'); $form['contact']->getControlPrototype()->class('s100'); $form->onSubmit[] = callback($this, 'popFormSubmited'); return $form; }
/** * Make relative url absolute * @param string image url * @param string single or double quote * @param string absolute css file path * @param string source path * @return string */ public static function absolutizeUrl($url, $quote, $cssFile, $sourcePath) { // is already absolute if (preg_match("/^([a-z]+:\\/)?\\//", $url)) { return $url; } $docroot = realpath(WWW_DIR); $basePath = rtrim(NEnvironment::getVariable("baseUri"), '/'); // inside document root if (NStrings::startsWith($cssFile, $docroot)) { $path = $basePath . substr(dirname($cssFile), strlen($docroot)) . DIRECTORY_SEPARATOR . $url; // outside document root } else { $path = $basePath . substr($sourcePath, strlen($docroot)) . DIRECTORY_SEPARATOR . $url; } $path = self::cannonicalizePath($path); return $quote === '"' ? addslashes($path) : $path; }
static function getCacheStorage() { if (self::$cacheStorage === NULL) { $dir = NEnvironment::getVariable('tempDir') . '/cache'; umask(00); @mkdir($dir, 0777); self::$cacheStorage = new NTemplateCacheStorage($dir); } return self::$cacheStorage; }
public static function renderBottom() { $t = clone self::getInstance()->template; $t->setFile(APP_DIR . '/templates/admin/bottom.phtml'); $t->version = NEnvironment::getVariable('QUIS_VERSION'); $t->project_name = NEnvironment::getVariable('project_name'); return (string) $t; }
public function renderBegin() { $response = NEnvironment::getHttpResponse(); if ($this->docType == self::XHTML_1_STRICT && $this->contentType == self::APPLICATION_XHTML && ($this->forceContentType || $this->isClientXhtmlCompatible())) { $contentType = self::APPLICATION_XHTML; if (!headers_sent()) { $response->setHeader('Vary', 'Accept'); } } else { $contentType = self::TEXT_HTML; } if (!headers_sent()) { $response->setContentType($contentType, 'utf-8'); } if ($contentType == self::APPLICATION_XHTML) { echo "<?xml version='1.0' encoding='utf-8'?>\n"; } echo $this->getDocTypeString() . "\n"; echo $this->getHtmlTag()->startTag() . "\n"; echo NHtml::el('head')->startTag() . "\n"; if ($this->docType != self::HTML_5) { $metaLanguage = NHtml::el('meta'); $metaLanguage->attrs['http-equiv'] = 'Content-Language'; $metaLanguage->content($this->language); echo $metaLanguage . "\n"; } $metaContentType = NHtml::el('meta'); $metaContentType->attrs['http-equiv'] = 'Content-Type'; $metaContentType->content($contentType . '; charset=utf-8'); echo $metaContentType . "\n"; echo NHtml::el('title', $this->getTitleString()) . "\n"; if ($this->favicon != '') { echo NHtml::el('link')->rel('shortcut icon')->href(NEnvironment::getVariable('baseUri') . $this->favicon) . "\n"; } foreach ($this->metaTags as $name => $content) { echo NHtml::el('meta')->name($name)->content($content) . "\n"; } }
//relative path to user template define('TEMPLATE_DIR', '/templates/pitrade'); //absolute path to the template define('ABS_TEMPLATE_DIR', WWW_DIR . TEMPLATE_DIR); // absolute filesystem path to the temporary files define('TEMP_DIR', APP_NETTE_DIR . '/temp'); define('BASEDIR', '/'); define('LOG_DIR', WWW_DIR . '/app/log'); require LIBS_DIR . '/fixSessionPhp7.php'; require APP_NETTE_DIR . '/bootstrap_admin.php'; //-----------jazyk--------------------- if (isset($_GET['lang'])) { NEnvironment::getSession('Page')->lang = $_GET['lang']; } if (NEnvironment::getSession('Page')->lang == '') { NEnvironment::getSession('Page')->lang = NEnvironment::getVariable('ADMIN_DEFAULT_LANG'); } //if(!isset($_SESSION['lang'])){$_SESSION['lang']=ADMIN_DEFAULT_LANG;} //-----------jazyk--------------------- //if(isset($_GET['id_menu'])){$_SESSION['id_menu']=$_GET['id_menu'];} //if(!isset($_SESSION['id_menu'])){$_SESSION['id_menu']=0;} MT::addCss('/templates/admin/css/index.css'); MT::addScripts('/jscripts/mootools/mootools-1.2.4-core-nc.js', 'mootools'); MT::addScripts('/jscripts/mootools/mootools-1.2.4.4-more.js', 'mootools_adds'); MT::addScripts('/jscripts/mootools/mootools_listener.js', 'mootools_listener'); MT::addScripts('/jscripts/tableHighlighter.js', 'tableHighlighter'); MT::addTextScripts(' function confl(message, url) { if(confirm(message)) location.href = url; } ', 'conf');
function handleSendReference(NAppForm $form) { $values = $form->getValues(); $product = ProductModel::get($values['id_product'], 1); if (!$product) { $this->getPresenter()->flashMessage('Pre daný produkt nemôžete odoslať referenciu.'); $this->getPresenter()->redirect('this'); } $template = $this->template; $template->setFile(dirname(__FILE__) . '/ReferenceEmail.phtml'); $template->product_name = $product['name']; $template->v = $values; $mail = new MyMail(); $mail->addTo(NEnvironment::getVariable('client_email')); $mail->setSubject(_('Pridanie referencie ')); $mail->setTemplate($template); $mail->send(); $this->getPresenter()->flashMessage('Referencia bola úspešne odoslaná.'); $this->getPresenter()->redirect('this'); }
function createComponent($name) { switch ($name) { case 'statusForm': $f = new NAppForm($this, $name); $renderer = $f->getRenderer(); $renderer->wrappers['pair']['container'] = ''; $renderer->wrappers['controls']['container'] = ''; $renderer->wrappers['control']['container'] = ''; $renderer->wrappers['label']['container'] = ''; $f->addSelect('order_status', 'Stav: ', OrderModel::getStatus()); $f->addSubmit('btn_submit', 'Uložiť'); $o = OrderModel::get($this->getParam('id')); $f->setDefaults($o); if ($f->isSubmitted() and $f->isValid()) { $values = $f->getValues(); OrderModel::updateStatus($this->getParam('id'), $values['order_status']); $o = OrderModel::get($this->getParam('id')); $template = $this->template; $template->setFile(APP_DIR . '/FrontModule/templates/Order/OrderChangeStatusEmail.phtml'); //print_r($o); $template->o = $o; $template->status = OrderModel::getStatus($o['order_status']); // echo $template->status;exit; $mail = new MyMail(); $mail->addTo($o['email']); $mail->addBcc(NEnvironment::getVariable('client_email')); $mail->setSubject(_('Objednávka č. ') . $o['id_order'] . ' zmena stavu.'); $mail->setTemplate($template); //echo $template;exit; $mail->send(); $this->flashMessage('Bol odoslaný email o zmene statusu.'); $this->redirect('this'); } return $f; break; case 'orderTabella': $grid = new Tabella(OrderModel::getDatasource(), array('sorting' => 'desc', 'order' => 'id_order')); $grid->addColumn("Číslo obj.", "id_order", array("width" => 50)); $grid->addColumn("Meno", "name", array("width" => 100)); $grid->addColumn("Priezvisko", "surname", array("width" => 100)); $grid->addColumn("Mesto", "city", array("width" => 100)); $grid->addColumn("Dátum vytvorenia", "add_date", array("width" => 100)); $grid->addColumn("Celková cena", "total_price", array("width" => 100)); $grid->addColumn("Stav", "order_status", array("width" => 50, 'type' => Tabella::SELECT, "editable" => true, "filter" => OrderModel::getStatus(), 'renderer' => function ($row) { $el = NHtml::el("td")->setHtml(OrderModel::getStatus($row['order_status'])); return $el; })); $grid->addColumn("Spôsob platby", "payment_method", array("width" => 90, 'type' => Tabella::SELECT, "editable" => false, "filter" => OrderModel::getPaymentMethod(), 'renderer' => function ($row) { $el = NHtml::el("td")->setHtml(OrderModel::getPaymentMethod($row['payment_method'])); return $el; })); $grid->addColumn("", "", array("width" => 30, 'filter' => NULL, "options" => '', "renderer" => function ($row) { $el = NHtml::el("td"); /* * link na zmazanie produktu */ $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('deleteOrder!', array('id' => $row->id_order)))->addClass('deleteIcon')); /* * link na editaciu produktu */ $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('view', array('id' => $row->id_order)))->addClass('editIcon')); /* * ikona aktivan polozka, neaktivan polozka */ $span = NHtml::el('span'); $el->add($span); return $el; })); $this->addComponent($grid, $name); break; default: return parent::createComponent($name); break; } }
/** TODO - upload a mazani souboru je fungujici, ale napsano naprosto zmatecne */ public function addReferenceSubmited(NAppForm $form) { if ($form['addref']->isSubmittedBy()) { $values = $form->getValues(); $size = NEnvironment::getVariable('sizes'); $id = (int) $this->getParam('id'); $ref = new Reference(array('id' => $id)); // (Re)upload files if ($this->newImage($values['pic_1'], $size[0])) { $ref->unlinkFile($ref->getFilename('pic_1')); } else { unset($values['pic_1']); } if ($this->newImage($values['pic_2'], $size[1])) { $ref->unlinkFile($ref->getFilename('pic_2')); } else { unset($values['pic_2']); } if ($this->newImage($values['pic_3'], $size[2])) { $ref->unlinkFile($ref->getFilename('pic_3')); } else { unset($values['pic_3']); } // Read checkboxes and create position mask $position_mask = 0; foreach ($values['pos'] as $key => $value) { if ($value) { $position_mask += $key; } } $values['pos'] = $position_mask; // Update or add new? if ($id > 0) { $ref->update($id, $values); } else { // Change sort of old items $ref->typ = $values['typ']; $this->model->resortAfterAdd($ref); $ref->insert($values); } $this->flashMessage('Refernce vložena.'); } $this->redirect('References:default'); }
function saveRegistration(NFORM $form) { $values = (array) $form->getValues(); $user = UserModel::getFluent(false)->where(' login = %s', $values['login'])->fetch(); try { if ($user and $user['login'] == $values['login']) { throw new InvalidStateException(_('Uživateľ pod týmto prihlasovacím meno už existuje.')); } // if($user AND $user['email'] == $values['email']) // throw new InvalidStateException( _('Emailová adresa sa už nachádza v databáze. ') ); // unset($values['passwordCheck']); unset($values['terms_and_conditions']); $values['activate'] = 1; //registrovany dostane automaticky 2% zlavu $values['discount'] = 2; UserModel::insert($values); $this->flashMessage("Registrácia je dokončená, účet aktivovaný a ste prihlásený na stránke."); $template = clone $this->template; $template->setFile(APP_DIR . '/FrontModule/templates/Profil/registrationConfirmEmail.phtml'); $template->values = $values; $mail = new MyMail(); $mail->addTo($values['login']); $mail->addBcc(NEnvironment::getVariable('error_email')); $mail->setSubject(_('Informácie o účte')); $mail->setTemplate($template); $mail->send(); $this->user->login($values['login'], $values['password']); if ($this->backlink != '') { $this->restoreRequest($this->backlink); } else { $this->redirect('Homepage:default'); } } catch (InvalidStateException $e) { $form->addError($e->getMessage()); // throw $e; } }
static function getCacheStorage() { if (self::$cacheStorage === NULL) { self::$cacheStorage = new NTemplateCacheStorage(NEnvironment::getVariable('tempDir')); } return self::$cacheStorage; }