public function actionDefault()
 {
     $google_config = NEnvironment::getConfig()->google;
     require_once LIBS_DIR . '/google-api-php-client/src/apiClient.php';
     require_once LIBS_DIR . '/google-api-php-client/src/contrib/apiOauth2Service.php';
     require_once LIBS_DIR . '/google-api-php-client/src/contrib/apiAnalyticsService.php';
     $client = new apiClient();
     $client->setApplicationName('Google+ PHP Starter Application');
     // Visit https://code.google.com/apis/console?api=plus to generate your
     // client id, client secret, and to register your redirect uri.
     //		$client->setClientId( $google_config['client_id'] );
     //		$client->setClientSecret( $google_config['client_secret'] );
     $client->setRedirectUri($google_config['redirect_url']);
     //		$client->setDeveloperKey('AIzaSyCrViGDrmXAiLsQAoW1aOzkHddH9gHYzzs');
     //		[8] => Array
     //        (
     //            [title] => www.propagacnepredmety.sk
     //            [entryid] => http://www.google.com/analytics/feeds/accounts/ga:43556790
     //            [accountId] => 17205615
     //            [accountName] => www.vizion.sk
     //            [profileId] => 43556790
     //            [webPropertyId] => UA-17205615-3
     //            [tableId] => ga:43556790
     //        )
     $ga = new apiAnalyticsService($client);
     if (isset($_GET['code'])) {
         $ga->authenticate();
         $_SESSION['token'] = $client->getAccessToken();
         header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
     }
     if (isset($_SESSION['token'])) {
         $client->setAccessToken($_SESSION['token']);
     }
     if ($client->getAccessToken()) {
         $activities = $plus->activities->listActivities('me', 'public');
         print 'Your Activities: <pre>' . print_r($activities, true) . '</pre>';
         // The access token may have been updated.
         $_SESSION['token'] = $client->getAccessToken();
     } else {
         $authUrl = $client->createAuthUrl();
         print "<a class='login' href='{$authUrl}'>Connect Me!</a>";
     }
     //		$_SESSION['token'] = $client->getAccessToken();
     $data = $ga->data_ga;
     $d = $data->get('17205615', date('Y-m-d', time() - 60 * 60 * 24 * 40), date('Y-m-d', time() - 60 * 60 * 24 * 1), 'ga:visits,ga:pageviews');
     print_r($d);
     exit;
 }
Example #2
0
 function saveArticle($values, $id_node)
 {
     $tmp = dibi::fetch("SELECT * FROM article WHERE id_node=%i", $id_node);
     unset($values['id_node']);
     //odstranenie premennych ktore niesu v databaze
     $values = Tools::getValuesForTable('article', $values);
     $name = NStrings::webalize($values['url_identifier']);
     $newname = "";
     $i = 0;
     while ($i < 50) {
         if ($i == 0) {
             $newname = $name;
         } else {
             $newname = NStrings::webalize($name . $i);
         }
         $s = dibi::fetchSingle("SELECT COUNT(id_node) FROM article WHERE url_identifier=%s", $newname, " AND id_node!=%i", $id_node);
         if ($s == 0) {
             break;
         } else {
             $i++;
         }
     }
     $values['url_identifier'] = $newname;
     dibi::query("UPDATE article SET ", $values, " WHERE id_node=%i", $id_node);
     NEnvironment::getService('Article')->invalidateCache();
 }
Example #3
0
 protected function createComponentSupplierTabella($name)
 {
     $datasource = SupplierModel::getFluent()->toDatasource()->orderBy('name');
     $grid = new Tabella($datasource, array('id_table' => 'id_product_supplier', 'sorting' => 'id_product_supplier', 'order' => 'id_product_supplier', 'truncate' => 0, "onSubmit" => function ($post) {
         SupplierModel::save($post, $post['id_product_supplier']);
     }));
     $grid->addColumn("Názov", "name", array("width" => 300, "editable" => true));
     $grid->addColumn("Počet produktov", "product_count", array("width" => 80, "editable" => false));
     $grid->addColumn("", "action", array("width" => 100, 'type' => Tabella::SELECT, "filter" => false, "options" => false, "editable" => true, "renderer" => function ($row) {
         $el = NHtml::el("td");
         /*
          * link na zmazanie produktu
          */
         $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('delete!', array('id' => $row->id_product_supplier)))->addClass('deleteIcon'));
         /*
          * link na editaciu produktu
          */
         //			    $el->add(
         //				NHtml::el( 'a' )->href(
         //				    NEnvironment::getApplication()->getPresenter()->link( 'Product:edit' , array('id'=>$row->id_product_supplier))
         //				)->addClass( 'editIcon' )
         //			    );
         /*
          * ikona aktivan polozka, neaktivan polozka
          */
         return $el;
     }));
     $this->addComponent($grid, $name);
 }
Example #4
0
 function startup()
 {
     parent::startup();
     $cache = NEnvironment::getCache();
     if (!isset($cache['acl'])) {
         $cache['acl'] = new Acl();
     }
     NEnvironment::getUser()->setAuthorizator($cache['acl']);
     $user = NEnvironment::getUser();
     $aclModel = new AclModel();
     // user authentication
     if (!$this->user->isLoggedIn()) {
         $backlink = $this->application->storeRequest();
         $this->redirect(':Admin:Login:default', array('backlink' => $backlink, 'lang' => $this->lang));
     }
     if (!$this->user->isAllowed('cms', 'edit')) {
         $this->flashMessage('Nemáte dostatočné prava.');
         $backlink = $this->application->storeRequest();
         $this->redirect(':Admin:Login:default', array('backlink' => $backlink, 'lang' => $this->lang));
     }
     //		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
     $this['header']['css']->addFile('../templates/admin/css/index.css');
     $this['header']['css']->addFile('ajax.css');
     $this['header']['css']->addFile('../jscripts/jquery/flick/jquery-ui-1.8.6.custom.css');
     $this['header']['css']->addFile('../jscripts/jquery/tags/jquery.tagsinput.css');
     $this['header']['js']->addFile('jquery/tags/jquery.tagsinput.js');
     //		$this['header']['js']->addFile('/jquery/jquery-1.4.2.js');
     $this['header']['js']->addFile('/jquery/jquery.nette.js');
     $this['header']['js']->addFile('/jquery/jquery.livequery.js');
     $this['header']['js']->addFile('jquery/jquery-ui-1.8.5.custom.min.js');
     $this['header']['js']->addFile('jquery/jquery.highlight.js');
     $this['header']['js']->addFile('jquery/jquery.easy-confirm-dialog.js');
     $this['header']['js']->addFile('confl.js');
     //		$this['header']->setHtmlTag( NHtml::el('script type="text/javacript"')->add( 'alert(1)' ) );
 }
Example #5
0
 /**
  * (non-phpDoc)
  *
  * @see Nette\Application\Presenter#startup()
  */
 public function startup()
 {
     parent::startup();
     $this['header']['css']->addFile('acl/acl.css');
     $this['header']['js']->addFile('acl/create-key.js');
     $this->cache = NEnvironment::getCache();
 }
Example #6
0
 public function send()
 {
     $conf = NEnvironment::getContext()->parameters['common.mailer'];
     $this->setFrom($conf['from']);
     //nastavení nSMTPMaileru (z config.ini)
     $mailer = new SmtpMailer($conf['host'], $conf['port'], $conf['transport'], $conf['username'], $conf['password'], NULL, NULL, NULL);
     $this->setMailer($mailer);
     //důležité!!!
     //        $undelivered = array();
     //        foreach ($recipients as $email) {
     //            try {
     //        //tady můžeme prohnat zadané adresy nějakým úžasným regexem
     //                if (!preg_match('/^\s*$/', $email)) {
     //            //můžeme použít i addCC a addBcc
     //                    $mail->addTo($email);
     //        } else {
     //            $undelivered[] = $email;
     //        }
     //            } catch (InvalidArgumentException $e) {
     //                $undelivered[] = $email;
     //            }
     //        }
     if (isset($this->template)) {
         $this->setHtmlBody((string) $this->template);
     }
     try {
         parent::send();
     } catch (InvalidStateException $e) {
         $this->result = FALSE;
     }
 }
Example #7
0
 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');
 }
Example #8
0
 function showUsers()
 {
     $user = NEnvironment::getUser();
     if (!$user->isAllowed('manage_user', 'edit')) {
         throw new LogicException('Nemáte dostatočné oprávnenie na túto sekciu');
     }
     try {
         //uprava uzivatela
         if (isset($_GET['id_auth_user']) and $_GET['id_auth_user'] != "") {
             $form = new NForm();
             $form->addText('name', 'Meno');
             $form->addText('surname', 'Priezvisko');
             $form->addText('email', 'Email');
             $form->addText('login', 'Login')->addRule(NFORM::FILLED, 'Login musí byť vyplnený');
             $form->addPassword('password', 'Heslo');
             $role = dibi::query('SELECT id_auth_role, key_name FROM auth_role ORDER BY key_name')->fetchPairs('id_auth_role', 'key_name');
             $form->addPassword('password2', 'Znova heslo')->addConditionOn($form['password'], NForm::FILLED)->addRule(NForm::FILLED, 'Zadejte heslo pro kontrolu')->addRule(NForm::EQUAL, 'Hesla se musi shodovat', $form['password']);
             $form->addSelect('id_auth_role', 'Uživateľská skupina:', $role);
             $form->addSubmit('addUser', 'Upravit');
             $form->onSubmit[] = array($this, 'changeUser');
             if (!$form->isSubmitted()) {
                 // 	první zobrazení, nastavíme výchozí hodnoty
                 $form->setDefaults(dibi::fetch("SELECT *, id_auth_role FROM auth_user LEFT JOIN [auth_user_role] USING(id_auth_user) WHERE auth_user.id_auth_user=%i", $_GET['id_auth_user']));
             }
             $form->fireEvents();
             MT::addTemplate(APP_DIR . '/require_modules/authentication/editUser.phtml', 'editUser');
             MT::addVar('editUser', 'form', (string) $form);
         }
     } catch (Exception $e) {
         ?>
   <div style="border:2px solid red;padding:5px;">
     <?php 
         echo $e->getMessage();
         ?>
   </div><?php 
     }
     if (!isset($_GET['id_auth_user'])) {
         if (isset($_GET['id_delete_user'])) {
             $this->deleteUser();
         }
         $form = new NForm();
         $form->getElementPrototype()->id = 'formAddUser';
         $form->addText('name', 'Meno');
         $form->addText('surname', 'Priezvisko');
         $form->addText('email', 'Email');
         $form->addText('login', 'Login')->addRule(NFORM::FILLED, 'Login musí byť vyplnený');
         $form->addPassword('password', 'Heslo')->addRule(NForm::FILLED, 'Zadejte heslo');
         $role = dibi::query('SELECT id_auth_role, key_name FROM [auth_role] ORDER BY key_name')->fetchPairs('id_auth_role', 'key_name');
         $form->addPassword('password2', 'Znova heslo')->addRule(NForm::FILLED, 'Zadejte heslo pro kontrolu')->addRule(NForm::EQUAL, 'Hesla se musi shodovat', $form['password']);
         $form->addSelect('id_auth_role', 'Uživateľská skupina:', $role);
         $form->addSubmit('addUser', 'Pridať použivateľa');
         $form->onSubmit[] = array($this, 'addUser');
         $form->fireEvents();
         MT::addTemplate(APP_DIR . '/require_modules/authentication/showUsers.phtml', 'showUsers');
         $list = dibi::fetchAll("\n      \tSELECT \n      \t\t*\n      \tFROM \n      \t\tauth_user\n      \tORDER BY login");
         MT::addVar('showUsers', 'list', $list);
         MT::addVar('showUsers', 'form', $form);
     }
 }
Example #9
0
 public function getUrl()
 {
     if ($this->isAutoUrl()) {
         return (string) NEnvironment::getHttpRequest()->getUri();
     } else {
         return $this->url;
     }
 }
Example #10
0
 public function handleGetData()
 {
     $this->template->ajax = true;
     //$this->template->presenter = $this;
     $this->render();
     //		NDebug::disableProfiler();
     NEnvironment::getApplication()->getPresenter()->terminate();
 }
Example #11
0
 private function __construct()
 {
     $this->cache = NEnvironment::getCache('lang');
     if ($this->cache['data']) {
         $this->data = $this->cache['data'];
     } else {
         $this->data = $this->cache['data'] = dibi::query("SELECT * FROM [lang]")->fetchAssoc('id_lang');
     }
 }
Example #12
0
 function __construct(IComponentContainer $parent = NULL, $name = NULL)
 {
     NForm::extensionMethod('addDateTimePicker', 'MyForm::Form_addDateTimePicker');
     parent::__construct($parent, $name);
     $t = NEnvironment::getApplication()->getPresenter()->getService('translator');
     $t->setLang(NEnvironment::getApplication()->getPresenter()->lang);
     $this->setTranslator($t);
     NFormContainer::extensionMethod('NFormContainer::addRecaptcha', array('reCAPTCHA', 'addRecaptcha'));
 }
Example #13
0
 public function removeFromCache($filename)
 {
     $list = scandir(NEnvironment::getConfig()->gallery['dir_abs'] . '/temp/');
     foreach ($list as $l) {
         $pom = explode('|', $l);
         if ($filename == $pom[0]) {
             unlink(NEnvironment::getConfig()->gallery['dir_abs'] . '/temp/' . $l);
         }
     }
 }
Example #14
0
 /**
  * (non-phpDoc)
  *
  * @see Nette\Application\Control#render()
  */
 public function render($params = array())
 {
     $order_info = NEnvironment::getSession('user_order_info');
     $this->template->delivery = (isset($params['delivery']) and $params['delivery'] == true) ? $order_info['values']['id_delivery'] : false;
     $this->template->payment = (isset($params['delivery']) and $params['delivery'] == true) ? $order_info['values']['id_payment'] : false;
     $this->template->cart_info = OrderModel::getCartInfo($this->session->products, $this->template->delivery, $this->template->payment, $this->getPresenter()->context, $isCache = true);
     //		dump($this->template->cart_info);
     $this->template->controls = (isset($params['controls']) and $params['controls'] == false) ? false : true;
     $this->template->setFile(dirname(__FILE__) . '/default.phtml');
     $this->template->render();
     //	$session = NEnvironment::getSession('cart');
 }
Example #15
0
 function renderList($categories)
 {
     $this->template->blog_box = dibi::fetchAll("SELECT * FROM `menu_item` \nLEFT JOIN node USING (id_menu_item)\nLEFT JOIN article USING (id_node)\nWHERE \nmenu_item.url_identifier = %s", $categories, "\nORDER BY id_node DESC\n");
     foreach ($this->template->blog_box as $article) {
         $article['url'] = $this->getPresenter()->link('Blog:current', array('categories' => $categories, 'url_identifier' => $article->url_identifier));
         if ($image = FilesNode::getOneFirstFile('article', $article->id_node)) {
             $article['image_url'] = Files::gURL($image->src, $image->ext, 220, 160, 6);
         }
     }
     $session = NEnvironment::getSession("Front_List");
     $session['back_url'] = $_SERVER['REQUEST_URI'];
 }
Example #16
0
 /**
  * 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;
 }
Example #17
0
 function createComponent($name)
 {
     switch ($name) {
         case 'userTabella':
             $model = new UserModel();
             $grid = new Tabella($model->getFluent(false)->toDatasource(), array('sorting' => 'desc', 'order' => 'id_gui_user'));
             $grid->addColumn("Login/Email", "login", array("width" => 100));
             $grid->addColumn("Meno", "name", array("width" => 100));
             $grid->addColumn("Priezvisko", "surname", array("width" => 100));
             $grid->addColumn("Naposledy prihlásený", "lastvisit", array("width" => 100));
             $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('deleteUser!', array('id' => $row->id_gui_user)))->addClass('deleteIcon ajax'));
                 /*
                  * link na editaciu produktu
                  */
                 $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('edit', array('id' => $row->id_gui_user)))->addClass('editIcon'));
                 /*
                  * ikona aktivan polozka, neaktivan polozka
                  */
                 $span = NHtml::el('span');
                 if ($row->activate) {
                     $span->addClass('activeIcon active');
                 } else {
                     $span->addClass('unactiveIcon active ');
                 }
                 $el->add($span);
                 return $el;
             }));
             $this->addComponent($grid, $name);
             break;
         case 'userForm':
             $form = UserModel::baseForm(false);
             $form->addGroup('');
             $form->addText('discount', 'Zľava použivateľa');
             $form->addHidden('id');
             $form->addSubmit('btn_submit', 'Uložiť');
             $form->onSuccess[] = array($this, 'saveUser');
             $form->setDefaults(UserModel::get($this->getParam('id')));
             return $form;
             break;
         default:
             return parent::createComponent($name);
             break;
     }
 }
Example #18
0
 function save($values, $id_node)
 {
     $tmp = dibi::fetch("SELECT * FROM " . self::TABLE . " WHERE id_node=%i", $id_node);
     //  	print_r($tmp);
     unset($values['id_node']);
     //odstranenie premennych ktore niesu v databaze
     foreach ($values as $key => $v) {
         if (!array_key_exists($key, $tmp)) {
             unset($values[$key]);
         }
     }
     //  	print_r($values);
     dibi::query("UPDATE " . self::TABLE . " SET ", $values, " WHERE id_node=%i", $id_node);
     Log::addLog($this, "Uprava contact form", "Menil:" . NEnvironment::getSession('Authentication')->login_form, '', $id_node);
 }
Example #19
0
 /**
  * Handles an incomuing request and saves the data if necessary.
  */
 private function processRequest()
 {
     $request = NEnvironment::getService('httpRequest');
     if ($request->isPost() && $request->isAjax() && $request->getHeader('x-callback-client')) {
         $data = json_decode(file_get_contents('php://input'), TRUE);
         if (count($data) > 0) {
             foreach ($data as $key => $value) {
                 if (isset($this->items[$key]) && isset($this->items[$key]['callback']) && $value === TRUE) {
                     $this->items[$key]['callback']->invokeArgs($this->items[$key]['args']);
                 }
             }
         }
         die(json_encode(array('status' => "OK")));
     }
 }
Example #20
0
 public function render()
 {
     $template = new NFileTemplate();
     $template->registerFilter(new NLatteFilter());
     $template->setFile(dirname(__FILE__) . '/default.phtml');
     $template->id = 'Multiupload_' . $this->type_module;
     if (_NETTE_MODE) {
         $template->action = NEnvironment::getApplication()->getPresenter()->link('Homepage:upload');
     } else {
         $template->action = '/admin.php';
     }
     $template->imageList = $this->renderImageList();
     $template->parsed_url = $this->parsed_url;
     $template->list = self::getAllFiles($this->type_module, $this->id_module, $this->type);
     return $template;
 }
Example #21
0
 function add($values)
 {
     $arr = array('name' => $values['name'], 'text' => $values['text'], 'id_node' => $values['id_node'], 'addDate' => new DateTime(), 'status' => 1, 'comment_parent' => (isset($values['comment_parent']) and $values['comment_parent'] != '') ? $values['comment_parent'] : NULL);
     dibi::query("INSERT INTO [comment] ", $arr);
     $l = dibi::fetch("\n\t\t\tSELECT \n\t\t\t\tmenu_item.url_identifier AS menu_url_identifier,\n\t\t\t\tarticle.url_identifier\n\t\t\tFROM \n\t\t\t\t[node]\n\t\t\t\tJOIN [menu_item] USING(id_menu_item)\n\t\t\t\tJOIN article USING(id_node)\n\t\t\tWHERE \n\t\t\t\tnode.id_node = %i", $values['id_node'], "\n\t\t");
     $template = $this->template;
     $template->setFile(dirname(__FILE__) . '/CommentEmailNotification.phtml');
     $template->values = $l;
     $uri = NEnvironment::getHttpRequest()->getUri();
     $template->url = $uri->scheme . '://' . $uri->host . $this->getPresenter()->link(":Homepage:article", $l['menu_url_identifier'], $l['url_identifier']);
     //		$mail = new MyMail();
     //        $mail->addTo( '*****@*****.**' );
     //        $mail->addBcc('*****@*****.**');
     //
     //        $mail->setSubject('Sprievodca ockovanim - Nový komentár.');
     //        if(NEnvironment::isProduction())
     //        	$mail->send($template);
 }
Example #22
0
 /**
  * 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;
 }
Example #23
0
 function showLog()
 {
     $session = NEnvironment::getSession('Log');
     if (isset($_GET['order_by'])) {
         if ($_GET['order_by'] != "date" and $_GET['order_by'] != "id_user" and $_GET['order_by'] != "description" and $_GET['order_by'] != "value" and $_GET['order_by'] != "value" and $_GET['order_by'] != "id_type_modul" and $_GET['order_by'] != "ip") {
             $session['log_order_by'] = "date";
         } else {
             $session['log_order_by'] = $_GET['order_by'];
         }
     }
     if (!isset($session['log_order_by'])) {
         $session['log_order_by'] = "date";
     }
     $source = dibi::dataSource("\n\t\t\tSELECT log.*, user.login  \n\t\t\tFROM log LEFT JOIN user USING(id_user) \n\t\t\tWHERE\n\t\t\t\t%if", @$_GET['input_id_user'] != '', "login LIKE %s", '%' . @$_GET['input_id_user'] . '%', " AND %end\n\t\t      \t%if", @$_GET['input_date'] != '', "[date] > %s", @$_GET['input_date'], " AND %end\n\t\t\t    %if", @$_GET['input_description'] != '', "description LIKE %s", '%' . @$_GET['input_description'] . '%', " AND %end\n\t\t\t    %if", @$_GET['input_value'] != '', "value LIKE %s", '%' . @$_GET['input_value'] . '%', " AND %end\n\t\t\t    %if", @$_GET['input_id_type_modul'] != '', "name_modul LIKE %s", '%' . @$_GET['input_id_type_modul'] . '%', " AND %end\n\t\t\t    ip LIKE %s", '%' . @$_GET['input_ip'] . '%', " \n\t\t    \n\t\t    ORDER BY " . $session['log_order_by'] . " DESC");
     $p = new MyPaginator($source);
     MT::addTemplate(dirname(__FILE__) . '/log.phtml', 'log');
     MT::addVar('log', 'paginator', $p);
     MT::addVar('log', 'list', $p->getDataSourceItem()->fetchAll());
 }
Example #24
0
 function createComponentWeightTabella($name)
 {
     $grid = new Tabella(ProductWeightModel::getFluent()->toDataSource(), array('sorting' => 'asc', 'order' => 'weight_to', 'id_table' => 'id_product_weight', 'limit' => 50, "onSubmit" => function ($post) {
         //						print_r($post);exit;
         ProductWeightModel::edit($post, $post['id_product_weight']);
     }, "onDelete" => function ($id) {
         ProductWeightModel::delete($id);
     }));
     $el = NHtml::el("div");
     $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('addEmptyWeight!'))->addClass('addIcon ajax'));
     //$grid->addColumn($el, '', array('width'=>20,  'filter'=>NULL, "editable" => false ) );
     $grid->addColumn("Váha do", "weight_to", array("width" => 50, "editable" => true));
     $grid->addColumn("Cena poštovného", "weight_price", array("editable" => true));
     $grid->addColumn($el, "", array("width" => 30, 'filter' => NULL, "options" => '', "renderer" => function ($row) {
         $el = NHtml::el("td");
         $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('deleteWeight!', array('id_product_weight' => $row->id_product_weight)))->addClass('deleteIcon ajax'));
         return $el;
     }));
     $this->addComponent($grid, $name);
 }
Example #25
0
 function onSubmitAuthenticate(NFORM $form)
 {
     $values = $form->getValues();
     $this->invalidateControl('login');
     $this->invalidateControl('minilogin');
     //		$this->invalidateControl('classs');
     $user = NEnvironment::getUser();
     try {
         $user->setExpiration('+ 2 days', FALSE);
         //			$user->setAuthenticationHandler ( new UserModel() );
         $user->login($values['login'], $values['password']);
         $form->setValues(array(), TRUE);
         if ($values['backlink'] != '') {
             $this->getPresenter()->redirectUrl($values['backlink']);
         } else {
             //$this->getPresenter()->redirect('this');
         }
     } catch (NAuthenticationException $e) {
         $form->addError($e->getMessage());
     }
 }
Example #26
0
 static function getTotalPrice($products, $payment_method, $id_lang, $user)
 {
     $param = array('price' => 0, 'price_with_tax' => 0, 'weight' => 0, 'payment_price' => 0, 'delivery_price' => 0);
     foreach ($products as $id_product_param => $count) {
         $product = ProductModel::getProductIdentifyByParam($id_product_param, $id_lang, $user);
         $param['price'] += $product['price_array']['price'] * $count;
         $param['price_with_tax'] += $product['price_array']['price_with_tax'] * $count;
         $param['weight'] += $product['weight'] * $count;
     }
     ///$payment_method
     $param['payment_price'] = self::getPaymentPrice($payment_method, $param['price']);
     //		$delivery_price = ProductWeightModel::getPrice($weight);
     $param['delivery_price'] = ProductWeightModel::getPrice($param['weight']);
     $conf = NEnvironment::getContext()->parameters;
     if ($conf['DELIVERY_IS_WITH_TAX'] == 1) {
         $param['price'] += $param['delivery_price'] / (1 + $conf['DELIVERY_TAX'] / 100);
         $param['price_with_tax'] += $param['delivery_price'];
     } else {
         $param['price'] += $param['delivery_price'];
         $param['price_with_tax'] += $param['delivery_price'] * (1 + $conf['DELIVERY_TAX'] / 100);
     }
     return $param;
 }
 function createComponentVatTabella($name)
 {
     $vat = VatModel::init();
     $grid = new Tabella($vat->getFluent()->toDataSource(), array('sorting' => 'asc', 'order' => 'id_vat', 'id_table' => 'id_vat', 'limit' => 50, "onSubmit" => function ($post) use($vat) {
         if ($post['id_vat'] == 0) {
             $vat->insert($post);
         } else {
             $vat->update($post['id_vat'], $post);
         }
     }, "onDelete" => function ($id) use($vat) {
         $vat->delete($id);
     }));
     $el = NHtml::el("div");
     $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('addEmptyWeight!'))->addClass('addIcon ajax'));
     //$grid->addColumn($el, '', array('width'=>20,  'filter'=>NULL, "editable" => false ) );
     $grid->addColumn("Názov", "name", array("width" => 50, "editable" => true));
     $grid->addColumn("Hodnota", "value", array("editable" => true));
     $grid->addColumn("Prednadstavená?", "is_default", array("width" => 50, 'type' => Tabella::SELECT, "editable" => true, "filter" => NULL, 'renderer' => function ($row) {
         $el = NHtml::el("td")->setHtml($row['is_default'] == 1 ? 'áno' : 'nie');
         return $el;
     }));
     $grid->addColumn("+", Tabella::ADD, array("type" => Tabella::DELETE));
     $this->addComponent($grid, $name);
 }
Example #28
0
 public function render()
 {
     $template = new NFileTemplate();
     $template->registerFilter(new NLatteFilter());
     $template->setFile(dirname(__FILE__) . '/promo.phtml');
     $template->id = 'Multiupload_' . $this->type_module;
     //		$template->css = file_get_contents(dirname(__FILE__).'/fileuploader.css');
     //		$template->js = file_get_contents(dirname(__FILE__).'/fileuploader.js');
     if (_NETTE_MODE) {
         $template->action = NEnvironment::getApplication()->getPresenter()->link('Homepage:upload');
     } else {
         $template->action = '/admin.php';
     }
     $template->parsed_url = $this->parsed_url;
     $template->list = self::getAllFiles($this->type_module, $this->id_module, $this->type);
     foreach ($template->list as $k => $l) {
         $i = dibi::fetch("SELECT title, link, alt, link_name FROM [promo_text] WHERE id_file = %i", $l['id_file']);
         $template->list[$k]['title'] = $i['title'];
         $template->list[$k]['link'] = $i['link'];
         $template->list[$k]['alt'] = $i['alt'];
         $template->list[$k]['link_name'] = $i['link_name'];
     }
     return $template;
 }
Example #29
0
 public static function init()
 {
     return new self(dibi::getConnection(), NEnvironment::getCache(self::MODULE_NAME));
 }
Example #30
0
 public static function init()
 {
     return new self(dibi::getConnection(), \NEnvironment::getCache(get_class()), \NEnvironment::getContext());
 }