public function importPagescheme($file) { $file = ROOTPATH . 'themes' . DS . $file; require_once ROOTPATH . 'lib' . DS . 'zip' . DS . 'zip.php'; $archive = new PclZip($file); $this->targetFolder = 'temp' . date('YmdHis'); $archive->extract(PCLZIP_OPT_PATH, ROOTPATH . 'themes' . DS . $this->targetFolder); $info = $this->getMainInfo(); $seo = Core::clearUTF(trim($info['name'])); $seo = preg_replace('/[^A-Za-z0-9\\-\\s\\s+]/', '', $seo); $seo = Core::clearSeoUTF($seo); $this->templateFolder = str_replace('/', '', strtolower($seo)); if (is_dir(ROOTPATH . 'themes' . DS . $this->templateFolder)) { $this->templateFolder = $this->templateFolder . date('YmdHis'); $info['name'] = $info['name'] . ' (Kopia ' . date('Y-m-d H:i:s') . ')'; } rename(ROOTPATH . 'themes' . DS . $this->targetFolder, ROOTPATH . 'themes' . DS . $this->templateFolder); $this->getImportData(); Db::getInstance()->beginTransaction(); if (!empty($this->importData)) { $this->pageSchemeId = App::getModel('pagescheme')->addPageScheme(array('name' => $info['name'], 'templatefolder' => $this->templateFolder)); $this->saveBoxes($this->importData['boxes'], $this->pageSchemeId); $this->saveSubpages($this->importData['layouts'], $this->pageSchemeId); } Db::getInstance()->commit(); $this->clearCache(ROOTPATH . DS . 'serialization', false); $this->clearCache(ROOTPATH . DS . 'cache', false); }
public function doRefreshSeoCategory() { Db::getInstance()->beginTransaction(); $sql = 'SELECT idcategory FROM category'; $stmt = $stmt = Db::getInstance()->prepare($sql); $stmt->execute(); while ($rs = $stmt->fetch()) { $sql2 = 'SELECT CT.languageid, GROUP_CONCAT(SUBSTRING(IF(CT.categoryid = :id, CT.name, LOWER(CT.name)), 1) ORDER BY C.order DESC SEPARATOR \'/\') AS seo FROM categorytranslation CT LEFT JOIN categorypath C ON C.ancestorcategoryid = CT.categoryid WHERE C.categoryid = :id GROUP BY C.categoryid, CT.languageid '; $stmt2 = Db::getInstance()->prepare($sql2); $stmt2->bindValue('id', $rs['idcategory']); $stmt2->execute(); $rs2 = $stmt2->fetch(); if ($rs2) { $seo = Core::clearSeoUTF($rs2['seo']); $sql3 = 'UPDATE categorytranslation SET seo = :seo WHERE categoryid = :categoryid AND languageid = :languageid '; $stmt3 = Db::getInstance()->prepare($sql3); $stmt3->bindValue('categoryid', $rs['idcategory']); $stmt3->bindValue('languageid', $rs2['languageid']); $stmt3->bindValue('seo', strtolower($seo)); $stmt3->execute(); } } Db::getInstance()->commit(); App::getModel('category')->flushCache(); }