示例#1
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();
 }
示例#2
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)' ) );
 }
示例#3
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');
     }
 }
示例#4
0
 public static function init()
 {
     return new self(dibi::getConnection(), NEnvironment::getCache(self::MODULE_NAME));
 }
示例#5
0
 public static function init()
 {
     return new self(dibi::getConnection(), \NEnvironment::getCache(get_class()), \NEnvironment::getContext());
 }
示例#6
0
 function beforeRender()
 {
     //self::parseSparksCSV();
     //	ProductModel::repairSequenceProductParam();exit;
     $cache = NEnvironment::getCache('parse_xml');
     $this->all_product_param_db = dibi::query("SELECT code,id_product FROM [product_param]")->fetchPairs('code', 'id_product');
     $this->all_product_db = dibi::query("SELECT group_code,id_product FROM [product]")->fetchPairs('group_code', 'id_product');
     $this->all_categories_db = dibi::fetchAll("SELECT id_category,name,id_parent FROM [category] JOIN [category_lang] USING(id_category) WHERE id_lang = 1");
     //		print_r($this->all_categories_db);
     //zisti levely
     $category_1 = array();
     $category_2 = array();
     $category_3 = array();
     foreach ($this->all_categories_db as $k => $c) {
         //prvy
         if ($c['id_parent'] == NULL) {
             $this->all_categories_db[$k]['level'] = 0;
             $category_1[$c['id_category']] = $c['name'];
         }
     }
     foreach ($this->all_categories_db as $k => $c) {
         //prvy
         if ($c['id_parent'] != NULL) {
             foreach ($this->all_categories_db as $k1 => $c1) {
                 if ($c1['id_category'] == $c['id_parent']) {
                     if ($this->all_categories_db[$k1]['level'] == 0) {
                         $this->all_categories_db[$k]['level'] = 1;
                         $category_2[$c['id_category']] = $c['name'];
                     }
                 }
             }
         }
     }
     foreach ($this->all_categories_db as $k => $c) {
         if (!isset($c['level'])) {
             $this->all_categories_db[$k]['level'] = 2;
             $category_3[$c['id_category']] = $c['name'];
         }
     }
     $this->category_1 = $category_1;
     $this->category_2 = $category_2;
     $this->category_3 = $category_3;
     // stiahni a rozzipuj subor
     //		$link
     $zip_file_name = WWW_DIR . "/uploaded/xml/xml.zip";
     if (isset($cache['xml_file_name'])) {
         $xml_file = $cache['xml_file_name'];
     } else {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, 'http://www.sparks.sk/product/xml/SparksProducts.zip');
         curl_setopt($ch, CURLOPT_HEADER, false);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $zip = curl_exec($ch);
         curl_close($ch);
         $fp = fopen($zip_file_name, "w");
         fwrite($fp, $zip);
         fclose($fp);
         $archive = new PclZip($zip_file_name);
         $list = $archive->extract(WWW_DIR . '/uploaded/xml/');
         if ($list[0]['status'] != 'ok') {
             throw new Exception('Nastala chyba pri rozbalovani suboru: ' . $list[0]['stored_filename']);
         }
         $cache->save('xml_file_name', $list[0]['stored_filename'], array('expire' => time() + 60 * 1));
         $xml_file = $list[0]['stored_filename'];
     }
     $myXMLString = file_get_contents(WWW_DIR . '/uploaded/xml/' . $xml_file);
     $myXMLString = iconv('UTF-8', 'windows-1250', $myXMLString);
     $doc = new DOMDocument('1.0', 'windows-1250');
     $doc->loadXML($myXMLString);
     $x = $doc->documentElement;
     $c = 0;
     foreach ($x->childNodes as $item) {
         $product = array();
         foreach ($item->childNodes as $i) {
             $node_value = preg_replace('#!\\[CDATA\\[#', '', $i->nodeValue);
             $node_value = preg_replace('#\\]\\]#', '', $node_value);
             //				$product[$i->nodeName] = iconv("UTF-8",'ISO-8859-2', $node_value);;
             $product[$i->nodeName] = $node_value;
         }
         //if($c>4000)print_r($product);
         $this->add($product);
         if (++$c > 5000) {
             throw new Exception('prekroceni limit na import poloziek');
         }
     }
     //oprav category rewrite link
     CategoryModel::repairCategoryRewriteLink();
 }
示例#7
0
 protected static function getCache()
 {
     return NEnvironment::getCache('Nette.Template.Cache');
 }
示例#8
0
 static function getCache($key = false)
 {
     $cache = NEnvironment::getCache('Category');
     if ($key) {
         if (isset($cache[$key])) {
             return $cache[$key];
         } else {
             return false;
         }
     }
     return $cache;
 }
示例#9
0
$neon = new NConfigNeonAdapter();
$n = $neon->load(APP_NETTE_DIR . '/config/config.db.neon');
$database = $n['common']['parameters'];
foreach ($database as $k => $p) {
    NEnvironment::setVariable($k, $p);
}
//var_dump($d);exit;
//$config = NEnvironment::loadConfig(APP_NETTE_DIR.'/config/config.db.neon');
$session = NEnvironment::getSession();
//$session->setSavePath(APP_NETTE_DIR . '/sessions');
//$session->setExpiration("1 day");
$session->start();
try {
    dibi::connect(NEnvironment::getConfig()->database);
} catch (Exception $e) {
    // echo $e->getMessage();
    echo "Nepodarilo sa pripojit";
    exit;
}
$cache = NEnvironment::getCache();
if (!isset($cache['acl'])) {
    $cache['acl'] = new Acl();
}
//print_r($cache['acl']);
NEnvironment::getUser()->setAuthorizator($cache['acl']);
$user = NEnvironment::getUser();
$aclModel = new AclModel();
//NDebug::dump($aclModel->getRoles());
//NDebug::dump($aclModel->getResources());
//NDebug::fireLog($aclModel->getRules());
//Log::addGlobalLog();
示例#10
0
 public static function getCache()
 {
     //		dump( NEnvironment::getCache( self::MODULE_NAME ));exit;
     //		return NEnvironment::getService('MyMemcache');
     //		$mem = new NMemcachedStorage('localhost', 11211, '', $journal);
     ////		$journal = NEnvironment::getContext('nette.cacheJournal');
     //
     ////		dump($mem);exit;
     //		return new NCache($mem, self::MODULE_NAME);
     //		return new NCache(new NDevNullStorage());
     return NEnvironment::getCache(self::MODULE_NAME);
 }