示例#1
0
文件: article.php 项目: oaki/demoshop
 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();
 }
示例#2
0
 static function get($id_product, $id_lang)
 {
     $key = 'get(' . $id_product . ',' . $id_lang . ')';
     $r = self::loadCache($key);
     if ($r) {
         return $r;
     }
     $r = dibi::fetch("\n\t\t\tSELECT *\n\t\t\tFROM\n\t\t\t[product]\n\t\t\tLEFT JOIN [product_lang] USING(id_product)\n\t\t\tWHERE id_product = %i", $id_product, "AND id_lang = %i", $id_lang);
     $r['product_template_group'] = NEnvironment::getService('ProductTemplateGroupModel')->fetchAssocAllParam($r['id_product_template_group'], $without_checked = true);
     return self::saveCache($key, $r);
 }
示例#3
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")));
     }
 }
示例#4
0
 final function getAuthorizationHandler()
 {
     if ($this->authorizationHandler === NULL) {
         $this->authorizationHandler = NEnvironment::getService('Nette\\Security\\IAuthorizator');
     }
     return $this->authorizationHandler;
 }
示例#5
0
 */
$page = NEnvironment::getService('Page');
NRoute::addStyle('#page');
NRoute::setStyleProperty('#page', NRoute::PATTERN, '[\\/a-z0-9^-]+');
//NRoute::setStyleProperty('#page', NRoute::PATTERN, '.*?');
NRoute::setStyleProperty('#page', NRoute::FILTER_IN, function ($url) use($page) {
    return $page->slugToId($url);
});
NRoute::setStyleProperty('#page', NRoute::FILTER_OUT, function ($url) use($page) {
    return $page->idToSlug($url);
});
$container->router[] = new NRoute('[<lang>/]<id #page>', array('module' => 'Front', 'presenter' => 'Page', 'action' => 'default', 'lang' => 'sk'));
/*
 * ARTICLE
 */
$article = NEnvironment::getService('Article');
NRoute::addStyle('#article');
NRoute::setStyleProperty('#article', NRoute::PATTERN, '[a-z0-9^-]+');
NRoute::setStyleProperty('#article', NRoute::FILTER_IN, function ($url) use($article) {
    return $article->slugToId($url);
});
NRoute::setStyleProperty('#article', NRoute::FILTER_OUT, function ($url) use($article) {
    return $article->idToSlug($url);
});
//tuto niekedy moze byt lomitko, asi ak upravim route pre page a nebude koncit lomitkom
$container->router[] = new NRoute('[<lang>/]<id_menu_item #page>/<id #article>.html', array('module' => 'Front', 'presenter' => 'Article', 'action' => 'default', 'lang' => 'sk'));
//
//
//
$container->router[] = new NRoute('[<lang>/]vyhladavanie/[<q>][/strana-<paginator-page>]', array('module' => 'Front', 'presenter' => 'Search', 'action' => 'default', 'id' => NULL, 'lang' => 'sk', 'paginator-page' => NULL));
//POZOR pre vymenenie id_product_template_group je pouzita tato routa, lebo tabella neviem pracovat dobre s parametrami