本文整理汇总了PHP中CategoryModel::repairCategoryRewriteLink方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::repairCategoryRewriteLink方法的具体用法?PHP CategoryModel::repairCategoryRewriteLink怎么用?PHP CategoryModel::repairCategoryRewriteLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CategoryModel
的用法示例。
在下文中一共展示了CategoryModel::repairCategoryRewriteLink方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeRender
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();
}
示例2: categoryAction
function categoryAction(NForm $form)
{
$values = $form->getValues();
$langs = Setting::getLangs();
switch ($this->mode) {
case 'edit':
$id_category = $values['id_category'];
foreach ($langs as $l) {
$lang_val = array();
foreach ($values as $k => $v) {
if (strpos($k, self::$_separator . $l['iso'])) {
list($name) = explode(self::$_separator . $l['iso'], $k);
$lang_val[$name] = $v;
//pridanie linky rewrite
if ($name == 'link_rewrite' and $v == '') {
$lang_val[$name] = NStrings::webalize($values['name' . self::$_separator . $l['iso']]);
} elseif ($name == 'link_rewrite') {
$lang_val[$name] = NStrings::webalize($lang_val[$name]);
}
// unset($values[$k]);
}
}
$lang_val += array('id_parent' => $values['id_parent'], 'active' => $values['active'], 'show_on_bottom' => $values['show_on_bottom']);
$c = new CategoryModel($l['id_lang']);
$c->save($lang_val, $id_category);
}
$c = new CategoryModel(1);
$c->repairSequence();
// print_r($values);
CategoryModel::repairCategoryRewriteLink();
CategoryModel::invalidateCache();
$this->getPresenter()->flashMessage(_('Kategória bola upravená.'));
$this->getPresenter()->redirect("this");
break;
case 'add':
$id_category = CategoryModel::add(array('id_parent' => $values['id_parent'], 'active' => $values['active']));
unset($values['id_parent'], $values['active']);
foreach ($langs as $l) {
$lang_val = array();
foreach ($values as $k => $v) {
if (strpos($k, self::$_separator . $l['iso'])) {
list($name) = explode(self::$_separator . $l['iso'], $k);
$lang_val[$name] = $v;
//pridanie linky rewrite
if ($name == 'link_rewrite' and $v == '') {
$lang_val[$name] = NStrings::webalize($values['name' . self::$_separator . $l['iso']]);
}
}
}
$lang_val += array('id_category' => $id_category, 'id_lang' => $l['id_lang']);
CategoryModel::addCategoryLang($lang_val);
}
$c = new CategoryModel(1);
$c->repairSequence();
// prepisanie file_node na novy id_category
dibi::query("UPDATE [file_node] SET id_module = %i", $id_category, "WHERE id_module = 999999 AND type_module = 'category'");
CategoryModel::repairCategoryRewriteLink();
CategoryModel::invalidateCache();
// print_r($values);
$this->getPresenter()->flashMessage(_('Kategória bola pridaná.'));
$this->getPresenter()->redirect("Eshop:default");
break;
}
}