public function clearDependedCache() { try { Pimcore_Model_Cache::clearTag("asset_" . $this->getId()); } catch (Exception $e) { } try { Pimcore_Model_Cache::clearTag("properties"); } catch (Exception $e) { } try { Pimcore_Model_Cache::clearTag("output"); } catch (Exception $e) { } }
public function updateChildsPaths($oldPath) { //get assets to empty their cache $assets = $this->db->fetchAll("SELECT id,path FROM assets WHERE path LIKE " . $this->db->quote($oldPath . "%")); //update assets child paths $this->db->query("update assets set path = replace(path," . $this->db->quote($oldPath) . "," . $this->db->quote($this->model->getFullPath()) . ") where path like " . $this->db->quote($oldPath . "/%") . ";"); //update assets child permission paths $this->db->query("update assets_permissions set cpath = replace(cpath," . $this->db->quote($oldPath) . "," . $this->db->quote($this->model->getFullPath()) . ") where cpath like " . $this->db->quote($oldPath . "/%") . ";"); //update assets child properties paths $this->db->query("update properties set cpath = replace(cpath," . $this->db->quote($oldPath) . "," . $this->db->quote($this->model->getFullPath()) . ") where cpath like " . $this->db->quote($oldPath . "/%") . ";"); foreach ($assets as $asset) { // empty assets cache try { Pimcore_Model_Cache::clearTag("asset_" . $asset["id"]); } catch (Exception $e) { } } }
public function glossaryAction() { if ($this->_getParam("data")) { if ($this->getUser()->isAllowed("glossary")) { Pimcore_Model_Cache::clearTag("glossary"); if ($this->_getParam("xaction") == "destroy") { $id = Zend_Json::decode($this->_getParam("data")); $glossary = Glossary::getById($id); $glossary->delete(); $this->_helper->json(array("success" => true, "data" => array())); } else { if ($this->_getParam("xaction") == "update") { $data = Zend_Json::decode($this->_getParam("data")); // save glossary $glossary = Glossary::getById($data["id"]); if ($data["link"]) { if ($doc = Document::getByPath($data["link"])) { $tmpLink = $data["link"]; $data["link"] = $doc->getId(); } } $glossary->setValues($data); $glossary->save(); if ($link = $glossary->getLink()) { if (intval($link) > 0) { if ($doc = Document::getById(intval($link))) { $glossary->setLink($doc->getFullPath()); } } } $this->_helper->json(array("data" => $glossary, "success" => true)); } else { if ($this->_getParam("xaction") == "create") { $data = Zend_Json::decode($this->_getParam("data")); unset($data["id"]); // save glossary $glossary = new Glossary(); if ($data["link"]) { if ($doc = Document::getByPath($data["link"])) { $tmpLink = $data["link"]; $data["link"] = $doc->getId(); } } $glossary->setValues($data); $glossary->save(); if ($link = $glossary->getLink()) { if (intval($link) > 0) { if ($doc = Document::getById(intval($link))) { $glossary->setLink($doc->getFullPath()); } } } $this->_helper->json(array("data" => $glossary, "success" => true)); } } } } else { Logger::err("user [" . $this->getUser()->getId() . "] attempted to modify static routes, but has no permission to do so."); } } else { // get list of routes $list = new Glossary_List(); $list->setLimit($this->_getParam("limit")); $list->setOffset($this->_getParam("start")); if ($this->_getParam("sort")) { $list->setOrderKey($this->_getParam("sort")); $list->setOrder($this->_getParam("dir")); } if ($this->_getParam("filter")) { $list->setCondition("`text` LIKE " . $list->quote("%" . $this->_getParam("filter") . "%")); } $list->load(); $glossaries = array(); foreach ($list->getGlossary() as $glossary) { if ($link = $glossary->getLink()) { if (intval($link) > 0) { if ($doc = Document::getById(intval($link))) { $glossary->setLink($doc->getFullPath()); } } } $glossaries[] = $glossary; } $this->_helper->json(array("data" => $glossaries, "success" => true, "total" => $list->getTotalCount())); } $this->_helper->json(false); }
/** * @return void */ public function delete() { // delete all objects using this class $list = new Object_List(); $list->setCondition("o_classId = ?", $this->getId()); $list->load(); foreach ($list->getObjects() as $o) { $o->delete(); } $this->deletePhpClasses(); // empty object cache try { Pimcore_Model_Cache::clearTag("class_" . $this->getId()); } catch (Exception $e) { } // empty output cache try { Pimcore_Model_Cache::clearTag("output"); } catch (Exception $e) { } $this->getResource()->delete(); }
public function clearDependedCache() { try { Pimcore_Model_Cache::clearTag("document_" . $this->getId()); } catch (Exception $e) { Logger::info($e); } try { Pimcore_Model_Cache::clearTag("properties"); } catch (Exception $e) { Logger::info($e); } try { Pimcore_Model_Cache::clearTag("output"); } catch (Exception $e) { Logger::info($e); } }
/** * @return void */ public function clearDependedCache() { // this is mostly called in Site_Resource not here try { Pimcore_Model_Cache::clearTag("site"); } catch (Exception $e) { Logger::info($e); } }
public function updateChildsPaths($oldPath) { //get documents to empty their cache $documents = $this->db->fetchAll("SELECT id,path FROM documents WHERE path LIKE ?", $oldPath . "%"); //update documents child paths $this->db->query("update documents set path = replace(path," . $this->db->quote($oldPath) . "," . $this->db->quote($this->model->getRealFullPath()) . ") where path like " . $this->db->quote($oldPath . "/%") . ";"); //update documents child permission paths $this->db->query("update users_workspaces_document set cpath = replace(cpath," . $this->db->quote($oldPath) . "," . $this->db->quote($this->model->getRealFullPath()) . ") where cpath like " . $this->db->quote($oldPath . "/%") . ";"); //update documents child properties paths $this->db->query("update properties set cpath = replace(cpath," . $this->db->quote($oldPath) . "," . $this->db->quote($this->model->getRealFullPath()) . ") where cpath like " . $this->db->quote($oldPath . "/%") . ";"); foreach ($documents as $document) { // empty documents cache try { Pimcore_Model_Cache::clearTag("document_" . $document["id"]); } catch (Exception $e) { } } }
public function save() { parent::save(); Pimcore_Model_Cache::clearTag("object_" . $this->internalGetBaseProduct()->getId()); }
/** * Updates the paths for children, children's properties and children's permissions in the database * * @param string $oldPath * @return void */ public function updateChildsPaths($oldPath) { if ($this->hasChilds()) { //get objects to empty their cache $objects = $this->db->fetchAll("SELECT o_id,o_path FROM objects WHERE o_path LIKE ?", $oldPath . "%"); //update object child paths $this->db->query("update objects set o_path = replace(o_path," . $this->db->quote($oldPath) . "," . $this->db->quote($this->model->getFullPath()) . ") where o_path like " . $this->db->quote($oldPath . "/%") . ";"); //update object child permission paths $this->db->query("update users_workspaces_object set cpath = replace(cpath," . $this->db->quote($oldPath) . "," . $this->db->quote($this->model->getFullPath()) . ") where cpath like " . $this->db->quote($oldPath . "/%") . ";"); //update object child properties paths $this->db->query("update properties set cpath = replace(cpath," . $this->db->quote($oldPath) . "," . $this->db->quote($this->model->getFullPath()) . ") where cpath like " . $this->db->quote($oldPath . "/%") . ";"); foreach ($objects as $object) { // empty object cache try { Pimcore_Model_Cache::clearTag("object_" . $object["o_id"]); } catch (Exception $e) { } } } }
public function abSaveAction() { // source-page $sourceDoc = Document::getById($this->_getParam("documentId")); $goalDoc = Document::getByPath($this->_getParam("conversionPage")); if (!$sourceDoc || !$goalDoc) { exit; } // clean properties $sourceDoc = $this->clearProperties($sourceDoc); $goalDoc = $this->clearProperties($goalDoc); // google stuff $credentials = $this->getAnalyticsCredentials(); $config = Pimcore_Google_Analytics::getSiteConfig($site); $gdata = $this->getService(); // create new experiment $entryResult = $gdata->insertEntry("\r\n <entry xmlns='http://www.w3.org/2005/Atom'\r\n xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'\r\n xmlns:app='http://www.w3.org/2007/app'\r\n xmlns:gd='http://schemas.google.com/g/2005'>\r\n <title>" . $this->_getParam("name") . "</title>\r\n <gwo:analyticsAccountId>" . $config->accountid . "</gwo:analyticsAccountId>\r\n <gwo:experimentType>AB</gwo:experimentType>\r\n <gwo:status>Running</gwo:status>\r\n <link rel='gwo:testUrl' type='text/html' href='http://" . Pimcore_Tool::getHostname() . $sourceDoc->getFullPath() . "' />\r\n <link rel='gwo:goalUrl' type='text/html' href='http://" . Pimcore_Tool::getHostname() . $goalDoc->getFullPath() . "' />\r\n </entry>\r\n ", "https://www.google.com/analytics/feeds/websiteoptimizer/experiments"); $e = $entryResult->getExtensionElements(); $data = array(); foreach ($e as $a) { $data[$a->rootElement] = $a->getText(); } // get tracking code $d = preg_match("/_getTracker\\(\"(.*)\"\\)/", $data["trackingScript"], $matches); $trackingId = $matches[1]; // get test id $d = preg_match("/_trackPageview\\(\"\\/([0-9]+)/", $data["trackingScript"], $matches); $testId = $matches[1]; // set original page $entryResult = $gdata->insertEntry("\r\n <entry xmlns='http://www.w3.org/2005/Atom'\r\n xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'\r\n xmlns:app='http://www.w3.org/2007/app'\r\n xmlns:gd='http://schemas.google.com/g/2005'>\r\n <title>Original</title>\r\n <content>http://" . Pimcore_Tool::getHostname() . $sourceDoc->getFullPath() . "</content>\r\n </entry>\r\n ", "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"] . "/abpagevariations"); // set testing pages for ($i = 1; $i < 100; $i++) { if ($this->_getParam("page_name_" . $i)) { $pageUrl = ""; if ($this->_getParam("page_url_" . $i)) { if ($variantDoc = Document::getByPath($this->_getParam("page_url_" . $i))) { $pageUrl = $this->getRequest()->getScheme() . "://" . Pimcore_Tool::getHostname() . $variantDoc->getFullPath(); // add properties to variant page $variantDoc = $this->clearProperties($variantDoc); $variantDoc->setProperty("google_website_optimizer_test_id", "text", $testId); $variantDoc->setProperty("google_website_optimizer_track_id", "text", $trackingId); $variantDoc->save(); } else { Logger::warn("Added a invalid URL to A/B test."); exit; } } /*if($this->_getParam("page_version_".$i)) { $pageUrl = "http://" . Pimcore_Tool::getHostname() . $sourceDoc->getFullPath() . "?v=" . $this->_getParam("page_version_".$i); } */ if ($pageUrl) { try { $entryResult = $gdata->insertEntry("\r\n <entry xmlns='http://www.w3.org/2005/Atom'\r\n xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'\r\n xmlns:app='http://www.w3.org/2007/app'\r\n xmlns:gd='http://schemas.google.com/g/2005'>\r\n <title>" . $this->_getParam("page_name_" . $i) . "</title>\r\n <content>" . $pageUrl . "</content>\r\n </entry>\r\n ", "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"] . "/abpagevariations"); } catch (Exception $e) { Logger::err($e); } } } else { break; } } // @todo START EXPERIMENT HERE //$entryResult = $gdata->getEntry("https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"]); //$gdata->updateEntry($entryResult->getXml(),"https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"]); /*$gdata->updateEntry(" <entry xmlns='http://www.w3.org/2005/Atom' xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009' xmlns:app='http://www.w3.org/2007/app' xmlns:gd='http://schemas.google.com/g/2005'> <gwo:status>Running</gwo:status> </entry> ","https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"]); */ // source-page $sourceDoc->setProperty("google_website_optimizer_test_id", "text", $testId); $sourceDoc->setProperty("google_website_optimizer_track_id", "text", $trackingId); $sourceDoc->setProperty("google_website_optimizer_original_page", "bool", true); $sourceDoc->save(); // conversion-page $goalDoc->setProperty("google_website_optimizer_test_id", "text", $testId); $goalDoc->setProperty("google_website_optimizer_track_id", "text", $trackingId); $goalDoc->setProperty("google_website_optimizer_conversion_page", "bool", true); $goalDoc->save(); // clear output cache Pimcore_Model_Cache::clearTag("output"); Pimcore_Model_Cache::clearTag("properties"); $this->_helper->json(array("success" => true)); }
if ($num != 1) { throw new Exception("Database query faulty response."); } // === FILESYSTEM === try { $putData = sha1(time()); file_put_contents(PIMCORE_TEMPORARY_DIRECTORY . '/check_write.tmp', $putData); $getData = file_get_contents(PIMCORE_TEMPORARY_DIRECTORY . '/check_write.tmp'); unlink(PIMCORE_TEMPORARY_DIRECTORY . '/check_write.tmp'); } catch (Exception $e) { throw new Exception('Unable to read/write a file. [' . $e->getCode() . ']'); } if ($putData !== $getData) { throw new Exception('Error writing/reading a file.'); } // === CACHE === try { Pimcore_Model_Cache::setForceImmediateWrite(true); Pimcore_Model_Cache::save($putData, $putData, array('check_write')); $getData = Pimcore_Model_Cache::load($putData); Pimcore_Model_Cache::clearTag("check_write"); } catch (Exception $e) { throw new Exception('Pimcore cache error [' . $e->getCode() . ']'); } if ($putData !== $getData) { throw new Exception('Pimcore cache failure - content mismatch.'); } echo "SUCCESS"; } catch (Exception $e) { echo "FAILURE: " . $e->getMessage(); }
public function tagManagementUpdateAction() { $tag = Tool_Tag_Config::getByName($this->_getParam("name")); $data = Zend_Json::decode($this->_getParam("configuration")); $data = array_htmlspecialchars($data); $items = array(); foreach ($data as $key => $value) { $setter = "set" . ucfirst($key); if (method_exists($tag, $setter)) { $tag->{$setter}($value); } if (strpos($key, "item.") === 0) { $cleanKeyParts = explode(".", $key); $items[$cleanKeyParts[1]][$cleanKeyParts[2]] = $value; } } $tag->resetItems(); foreach ($items as $item) { $tag->addItem($item); } // parameters get/post $params = array(); for ($i = 0; $i < 5; $i++) { $params[] = array("name" => $data["params.name" . $i], "value" => $data["params.value" . $i]); } $tag->setParams($params); $tag->save(); // clear cache tag Pimcore_Model_Cache::clearTag("tagmanagement"); $this->_helper->json(array("success" => true)); }