Пример #1
0
 public function jobProceduralAction()
 {
     $status = array("success" => true);
     if ($this->_getParam("type") == "files") {
         Pimcore_Update::installData($this->_getParam("revision"));
     } else {
         if ($this->_getParam("type") == "clearcache") {
             Pimcore_Model_Cache::clearAll();
         } else {
             if ($this->_getParam("type") == "preupdate") {
                 $status = Pimcore_Update::executeScript($this->_getParam("revision"), "preupdate");
             } else {
                 if ($this->_getParam("type") == "postupdate") {
                     $status = Pimcore_Update::executeScript($this->_getParam("revision"), "postupdate");
                 } else {
                     if ($this->_getParam("type") == "cleanup") {
                         Pimcore_Update::cleanup();
                     } else {
                         if ($this->_getParam("type") == "languages") {
                             Pimcore_Update::downloadLanguage();
                         }
                     }
                 }
             }
         }
     }
     $this->_helper->json($status);
 }
Пример #2
0
 public function end()
 {
     if ($this->captureEnabled) {
         $this->captureEnabled = false;
         $tags = array("in_template");
         if (!$this->lifetime) {
             $tags[] = "output";
         }
         $content = ob_get_clean();
         Pimcore_Model_Cache::save($content, $this->key, $tags, $this->lifetime, 996);
         echo $content;
     }
 }
Пример #3
0
 /**
  * @param string $table
  * @param bool $cache
  * @return array|mixed
  */
 protected function getValidTableColumns($table, $cache = true)
 {
     $cacheKey = "system_resource_columns_" . $table;
     if (Zend_Registry::isRegistered($cacheKey)) {
         $columns = Zend_Registry::get($cacheKey);
     } else {
         $columns = Pimcore_Model_Cache::load($cacheKey);
         if (!$columns || !$cache) {
             $columns = array();
             $data = $this->db->fetchAll("SHOW COLUMNS FROM " . $table);
             foreach ($data as $d) {
                 $columns[] = $d["Field"];
             }
             Pimcore_Model_Cache::save($columns, $cacheKey, array("system", "resource"), null, 997);
         }
         Zend_Registry::set($cacheKey, $columns);
     }
     return $columns;
 }
Пример #4
0
 /**
  *
  */
 public function load()
 {
     $client = Pimcore_Google_Api::getSimpleClient();
     $config = $this->getConfig();
     $perPage = $this->getPerPage();
     $offset = $this->getOffset();
     $query = $this->getQuery();
     if ($client) {
         $search = new apiCustomsearchService($client);
         // determine language
         $language = "";
         if (Zend_Registry::isRegistered("Zend_Locale")) {
             $locale = Zend_Registry::get("Zend_Locale");
             $language = $locale->getLanguage();
         }
         if (!array_key_exists("hl", $config) && !empty($language)) {
             $config["hl"] = $language;
         }
         if (!array_key_exists("lr", $config) && !empty($language)) {
             $config["lr"] = "lang_" . $language;
         }
         if ($query) {
             if ($offset) {
                 $config["start"] = $offset + 1;
             }
             if ($perPage) {
                 $config["num"] = $perPage;
             }
             $cacheKey = "google_cse_" . md5($query . serialize($config));
             if (!($result = Pimcore_Model_Cache::load($cacheKey))) {
                 $result = $search->cse->listCse($query, $config);
                 Pimcore_Model_Cache::save($result, $cacheKey, array("google_cse"), 3600, 999);
             }
             $this->readGoogleResponse($result);
             return $this->getResults();
         }
         return array();
     } else {
         throw new Exception("Google Simple API Key is not configured in System-Settings.");
     }
 }
Пример #5
0
 public function getAllTranslations()
 {
     $cacheKey = static::getTableName() . "_data";
     if (!($translations = Pimcore_Model_Cache::load($cacheKey))) {
         $itemClass = static::getItemClass();
         $translations = array();
         $translationsData = $this->db->fetchAll("SELECT * FROM " . static::getTableName());
         foreach ($translationsData as $t) {
             if (!$translations[$t["key"]]) {
                 $translations[$t["key"]] = new $itemClass();
                 $translations[$t["key"]]->setKey($t["key"]);
             }
             $translations[$t["key"]]->addTranslation($t["language"], $t["text"]);
             if ($translations[$t["key"]]->getDate() < $t["date"]) {
                 $translations[$t["key"]]->setDate($t["date"]);
             }
         }
         Pimcore_Model_Cache::save($translations, $cacheKey, array("translator", "translate"), 999);
     }
     return $translations;
 }
Пример #6
0
 public function translateAdmin($key = "")
 {
     if ($key) {
         $locale = $_REQUEST["systemLocale"];
         if (!$locale) {
             if (Zend_Registry::isRegistered("Zend_Locale")) {
                 $locale = Zend_Registry::get("Zend_Locale");
             } else {
                 $locale = new Zend_Locale("en");
             }
         }
         if ($locale) {
             $cacheKey = "translator_admin";
             if (!($translate = Pimcore_Model_Cache::load($cacheKey))) {
                 $translate = new Pimcore_Translate_Admin($locale);
                 Pimcore_Model_Cache::save($translate, $cacheKey, array("translator", "translator_admin", "translate"), null, 804);
             }
             $this->setTranslator($translate);
             $this->setLocale($locale);
             return call_user_func_array(array($this, "translate"), func_get_args());
         }
     }
     return $key;
 }
Пример #7
0
 /**
  * this method is called with register_shutdown_function() and writes all data queued into the cache
  * @static
  * @return void
  */
 public static function shutdown()
 {
     // set inShutdown to true so that the output-buffer knows that he is allowed to send the headers
     self::$inShutdown = true;
     // flush all custom output buffers
     while (@ob_end_flush()) {
     }
     // flush everything
     flush();
     // clear tags scheduled for the shutdown
     Pimcore_Model_Cache::clearTagsOnShutdown();
     // write collected items to cache backend
     Pimcore_Model_Cache::write();
 }
Пример #8
0
$conf = new Zend_Config_Xml(TESTS_PATH . "/config/testconfig.xml");
Zend_Registry::set("pimcore_config_test", $conf);
try {
    $conf = Zend_Registry::get("pimcore_config_system");
} catch (Exception $e) {
    die("config not present");
}
// set timezone
if ($conf instanceof Zend_Config) {
    if ($conf->general->timezone) {
        date_default_timezone_set($conf->general->timezone);
    }
}
// add the tests, which still reside in the original development unit, not in pimcore_phpunit to the include path
$includePaths = array(get_include_path());
$includePaths[] = TESTS_PATH . "/models";
$includePaths[] = TESTS_PATH . "/lib";
set_include_path(implode(PATH_SEPARATOR, $includePaths));
// register the tests namespace
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Test');
//set the pimcore_phpunit to admin mode
define("PIMCORE_ADMIN", true);
// disable all caching for the tests
// @TODO: Do we really want that? Wouldn't we want to test with cache enabled?
Pimcore_Model_Cache::disable();
/**
 * bootstrap is done, phpunit_pimcore is up and running.
 * It has a database, admin user and a complete config.
 * We can start running our tests against the phpunit_pimcore instance
 */
Пример #9
0
 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->enabled) {
         include_once "simple_html_dom.php";
         $body = $this->getResponse()->getBody();
         $html = str_get_html($body);
         if ($html) {
             $elements = $html->find("link[rel=stylesheet], img, script[src]");
             foreach ($elements as $element) {
                 if ($element->tag == "link") {
                     if ($this->pathMatch($element->href)) {
                         $element->href = $this->rewritePath($element->href);
                     }
                 } else {
                     if ($element->tag == "img") {
                         if ($this->pathMatch($element->src)) {
                             $element->src = $this->rewritePath($element->src);
                         }
                     } else {
                         if ($element->tag == "script") {
                             if ($this->pathMatch($element->src)) {
                                 $element->src = $this->rewritePath($element->src);
                             }
                         }
                     }
                 }
             }
             $body = $html->save();
             $this->getResponse()->setBody($body);
             // save storage
             Pimcore_Model_Cache::save($this->cachedItems, self::cacheKey, array(), 3600);
         }
     }
 }
Пример #10
0
 /**
  * Checks for a suitable redirect
  * @throws Exception
  * @param bool $override
  * @return void
  */
 protected function checkForRedirect($override = false)
 {
     try {
         $cacheKey = "system_route_redirect";
         if (empty($this->redirects) && !($this->redirects = Pimcore_Model_Cache::load($cacheKey))) {
             $list = new Redirect_List();
             $list->setOrder("DESC");
             $list->setOrderKey("priority");
             $this->redirects = $list->load();
             Pimcore_Model_Cache::save($this->redirects, $cacheKey, array("system", "redirect", "route"), null, 998);
         }
         foreach ($this->redirects as $redirect) {
             // if override is true the priority has to be 99 which means that overriding is ok
             if (!$override || $override && $redirect->getPriority() == 99) {
                 if (@preg_match($redirect->getSource(), $_SERVER["REQUEST_URI"], $matches)) {
                     array_shift($matches);
                     $target = $redirect->getTarget();
                     if (is_numeric($target)) {
                         $d = Document::getById($target);
                         if ($d instanceof Document_Page) {
                             $target = $d->getFullPath();
                         } else {
                             throw new Exception("Target of redirect no found!");
                         }
                     }
                     // replace escaped % signs so that they didn't have effects to vsprintf (PIMCORE-1215)
                     $target = str_replace("\\%", "###URLENCODE_PLACEHOLDER###", $target);
                     $url = vsprintf($target, $matches);
                     $url = str_replace("###URLENCODE_PLACEHOLDER###", "%", $url);
                     header($redirect->getHttpStatus());
                     header("Location: " . $url, true, $redirect->getStatusCode());
                     // log all redirects to the redirect log
                     Pimcore_Log_Simple::log("redirect", Pimcore_Tool::getClientIp() . " \t Source: " . $_SERVER["REQUEST_URI"] . " -> " . $url);
                     exit;
                 }
             }
         }
     } catch (Exception $e) {
         // no suitable route found
     }
 }
Пример #11
0
 /**
  * Checks for a suitable redirect
  * @throws Exception
  * @param bool $override
  * @return void
  */
 protected function checkForRedirect($override = false)
 {
     try {
         $cacheKey = "system_route_redirect";
         if (empty($this->redirects) && !($this->redirects = Pimcore_Model_Cache::load($cacheKey))) {
             $list = new Redirect_List();
             $list->setOrder("DESC");
             $list->setOrderKey("priority");
             $this->redirects = $list->load();
             Pimcore_Model_Cache::save($this->redirects, $cacheKey, array("system", "redirect", "route"), null, 998);
         }
         foreach ($this->redirects as $redirect) {
             // if override is true the priority has to be 99 which means that overriding is ok
             if (!$override || $override && $redirect->getPriority() == 99) {
                 if (@preg_match($redirect->getSource(), $_SERVER["REQUEST_URI"], $matches)) {
                     array_shift($matches);
                     $target = $redirect->getTarget();
                     if (is_numeric($target)) {
                         $d = Document::getById($target);
                         if ($d instanceof Document_Page) {
                             $target = $d->getFullPath();
                         } else {
                             throw new Exception("Target of redirect no found!");
                         }
                     }
                     $url = vsprintf($target, $matches);
                     header($redirect->getHttpStatus());
                     header("Location: " . $url);
                     exit;
                 }
             }
         }
     } catch (Exception $e) {
         // no suitable route found
     }
 }
Пример #12
0
 public static function compile($path, $source = null)
 {
     $conf = Pimcore_Config::getSystemConfig();
     $compiledContent = "";
     // check if the file is already compiled in the cache
     $cacheKey = "less_file_" . md5_file($path);
     if ($contents = Pimcore_Model_Cache::load($cacheKey)) {
         return $contents;
     }
     // use the original less compiler if configured
     if ($conf->outputfilters->lesscpath) {
         $output = array();
         exec($conf->outputfilters->lesscpath . " " . $path, $output);
         $compiledContent = implode($output);
         // add a comment to the css so that we know it's compiled by lessc
         if (!empty($compiledContent)) {
             $compiledContent = "\n\n/**** compiled with lessc (node.js) ****/\n\n" . $compiledContent;
         }
     }
     // use php implementation of lessc if it doesn't work
     if (empty($compiledContent)) {
         $less = new lessc();
         $less->importDir = dirname($path);
         $compiledContent = $less->parse(file_get_contents($path));
         // add a comment to the css so that we know it's compiled by lessphp
         $compiledContent = "\n\n/**** compiled with lessphp ****/\n\n" . $compiledContent;
     }
     if ($source) {
         // correct references inside the css
         $compiledContent = self::correctReferences($source, $compiledContent);
     }
     // put the compiled contents into the cache
     Pimcore_Model_Cache::save($compiledContent, $cacheKey, array("less"));
     return $compiledContent;
 }
Пример #13
0
 /**
  * @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();
 }
Пример #14
0
 public function initTranslation()
 {
     if (Zend_Registry::isRegistered("Zend_Translate")) {
         $translator = Zend_Registry::get("Zend_Translate");
     } else {
         // setup Zend_Translate
         try {
             $locale = Zend_Registry::get("Zend_Locale");
             $cacheKey = "translator_website";
             if (!($translate = Pimcore_Model_Cache::load($cacheKey))) {
                 $translate = new Pimcore_Translate_Website($locale);
                 Pimcore_Model_Cache::save($translate, $cacheKey, array("translator", "translator_website", "translate"), null, 999);
             }
             if (Pimcore_Tool::isValidLanguage($locale)) {
                 $translate->setLocale($locale);
             } else {
                 Logger::error("You want to use an invalid language which is not defined in the system settings: " . $locale);
                 // fall back to the first (default) language defined
                 $languages = Pimcore_Tool::getValidLanguages();
                 if ($languages[0]) {
                     Logger::error("Using '" . $languages[0] . "' as a fallback, because the language '" . $locale . "' is not defined in system settings");
                     $translate->setLocale($languages[0]);
                 } else {
                     throw new Exception("You have not defined a language in the system settings (Website -> Frontend-Languages), please add at least one language.");
                 }
             }
             // register the translator in Zend_Registry with the key "Zend_Translate" to use the translate helper for Zend_View
             Zend_Registry::set("Zend_Translate", $translate);
         } catch (Exception $e) {
             Logger::error("initialization of Pimcore_Translate failed");
             Logger::error($e);
         }
     }
     return $translator;
 }
Пример #15
0
 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     $cacheKey = "outputfilter_tagmngt";
     $tags = Pimcore_Model_Cache::load($cacheKey);
     if (!is_array($tags)) {
         $dir = Tool_Tag_Config::getWorkingDir();
         $tags = array();
         $files = scandir($dir);
         foreach ($files as $file) {
             if (strpos($file, ".xml")) {
                 $name = str_replace(".xml", "", $file);
                 $tags[] = Tool_Tag_Config::getByName($name);
             }
         }
         Pimcore_Model_Cache::save($tags, $cacheKey, array("tagmanagement"), null, 100);
     }
     if (empty($tags)) {
         return;
     }
     include_once "simple_html_dom.php";
     $body = $this->getResponse()->getBody();
     $html = str_get_html($body);
     $requestParams = array_merge($_GET, $_POST);
     if ($html) {
         foreach ($tags as $tag) {
             $method = strtolower($tag->getHttpMethod());
             $pattern = $tag->getUrlPattern();
             $textPattern = $tag->getTextPattern();
             if (($method == strtolower($this->getRequest()->getMethod()) || empty($method)) && (empty($pattern) || @preg_match($pattern, $this->getRequest()->getRequestUri())) && (empty($textPattern) || strpos($body, $textPattern) !== false)) {
                 $paramsValid = true;
                 foreach ($tag->getParams() as $param) {
                     if (!empty($param["name"])) {
                         if (!empty($param["value"])) {
                             if (!array_key_exists($param["name"], $requestParams) || $requestParams[$param["name"]] != $param["value"]) {
                                 $paramsValid = false;
                             }
                         } else {
                             if (!array_key_exists($param["name"], $requestParams)) {
                                 $paramsValid = false;
                             }
                         }
                     }
                 }
                 if (is_array($tag->getItems()) && $paramsValid) {
                     foreach ($tag->getItems() as $item) {
                         if (!empty($item["element"]) && !empty($item["code"]) && !empty($item["position"])) {
                             $element = $html->find($item["element"], 0);
                             if ($element) {
                                 if ($item["position"] == "end") {
                                     $element->innertext = $element->innertext . "\n\n" . $item["code"] . "\n\n";
                                 } else {
                                     // beginning
                                     $element->innertext = "\n\n" . $item["code"] . "\n\n" . $element->innertext;
                                 }
                                 // we havve to reinitialize the html object, otherwise it causes problems with nested child selectors
                                 $body = $html->save();
                                 $html = str_get_html($body);
                             }
                         }
                     }
                 }
             }
         }
         $this->getResponse()->setBody($body);
     }
 }
Пример #16
0
 /**
  * @static
  * @return mixed|Zend_Config
  */
 public static function getWebsiteConfig()
 {
     try {
         $config = Zend_Registry::get("pimcore_config_website");
     } catch (Exception $e) {
         $cacheKey = "website_config";
         if (!($config = Pimcore_Model_Cache::load($cacheKey))) {
             $websiteSettingFile = PIMCORE_CONFIGURATION_DIRECTORY . "/website.xml";
             $settingsArray = array();
             if (is_file($websiteSettingFile)) {
                 $rawConfig = new Zend_Config_Xml($websiteSettingFile);
                 $arrayData = $rawConfig->toArray();
                 foreach ($arrayData as $key => $value) {
                     $s = null;
                     if ($value["type"] == "document") {
                         $s = Document::getByPath($value["data"]);
                     } else {
                         if ($value["type"] == "asset") {
                             $s = Asset::getByPath($value["data"]);
                         } else {
                             if ($value["type"] == "object") {
                                 $s = Object_Abstract::getByPath($value["data"]);
                             } else {
                                 if ($value["type"] == "bool") {
                                     $s = (bool) $value["data"];
                                 } else {
                                     if ($value["type"] == "text") {
                                         $s = (string) $value["data"];
                                     }
                                 }
                             }
                         }
                     }
                     if ($s) {
                         $settingsArray[$key] = $s;
                     }
                 }
             }
             $config = new Zend_Config($settingsArray, true);
             Pimcore_Model_Cache::save($config, $cacheKey, array("websiteconfig", "system", "config"), null, 998);
         }
         self::setWebsiteConfig($config);
     }
     return $config;
 }
Пример #17
0
 public function dispatchLoopShutdown()
 {
     if ($this->enabled && $this->getResponse()->getHttpResponseCode() == 200) {
         try {
             if ($this->lifetime && $this->addExpireHeader) {
                 // add cache control for proxies and http-caches like varnish, ...
                 $this->getResponse()->setHeader("Cache-Control", "public, max-age=" . $this->lifetime, true);
                 // add expire header
                 $this->getResponse()->setHeader("Expires", Zend_Date::now()->add($this->lifetime)->get(Zend_Date::RFC_1123));
             }
             $cacheItem = array("headers" => $this->getResponse()->getHeaders(), "rawHeaders" => $this->getResponse()->getRawHeaders(), "content" => $this->getResponse()->getBody(), "date" => Zend_Date::now()->getIso());
             Pimcore_Model_Cache::save($cacheItem, $this->cacheKey, array("output"), $this->lifetime, 1000);
         } catch (Exception $e) {
             Logger::error($e);
             return;
         }
     }
 }
Пример #18
0
 /**
  * @static
  * @return void
  */
 public static function enable()
 {
     self::$enabled = true;
 }
Пример #19
0
 /**
  * @return void
  */
 public function clearDependedCache()
 {
     Pimcore_Model_Cache::clearTags(array("translator", "translate"));
 }
Пример #20
0
<?php

// flush cache
\Pimcore_Model_Cache::clearAll();
// delete the autoload class map
$file = PIMCORE_CONFIGURATION_DIRECTORY . "/autoload-classmap.php";
if (file_exists($file)) {
    unlink($file);
}
// clear the opcache (as of PHP 5.5)
if (function_exists("opcache_reset")) {
    opcache_reset();
}
// clear the APC opcode cache (<= PHP 5.4)
if (function_exists("apc_clear_cache")) {
    apc_clear_cache();
}
// clear the Zend Optimizer cache (Zend Server <= PHP 5.4)
if (function_exists('accelerator_reset')) {
    return accelerator_reset();
}
Пример #21
0
 /**
  * @static
  * @param Pimcore_Model_List_Abstract $list
  * @return void
  */
 protected static function loadToCache(Pimcore_Model_List_Abstract $list)
 {
     $totalCount = $list->getTotalCount();
     $iterations = ceil($totalCount / self::getPerIteration());
     Logger::info("New list of elements queued for storing into the cache with " . $iterations . " iterations and " . $totalCount . " total items");
     for ($i = 0; $i < $iterations; $i++) {
         Logger::info("Starting iteration " . $i . " with offset: " . self::getPerIteration() * $i);
         $list->setLimit(self::getPerIteration());
         $list->setOffset(self::getPerIteration() * $i);
         $elements = $list->load();
         foreach ($elements as $element) {
             $cacheKey = Element_Service::getElementType($element) . "_" . $element->getId();
             Pimcore_Model_Cache::storeToCache($element, $cacheKey);
         }
         Pimcore::collectGarbage();
         sleep(self::getTimoutBetweenIteration());
     }
 }
Пример #22
0
 /**
  *
  */
 public function delete()
 {
     $this->getResource()->delete();
     Pimcore_Model_Cache::clearAll();
 }
Пример #23
0
 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) {
         }
     }
 }
Пример #24
0
 /**
  * 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) {
             }
         }
     }
 }
Пример #25
0
 public function websiteSaveAction()
 {
     $data = Zend_Json::decode($this->_getParam("data"));
     // convert all special characters to their entities to ensure that Zend_Config can write it
     foreach ($data as &$setting) {
         $setting["data"] = htmlspecialchars($setting["data"], ENT_COMPAT, "UTF-8");
     }
     $config = new Zend_Config($data, true);
     $writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_DIRECTORY . "/website.xml"));
     $writer->write();
     // clear cache
     Pimcore_Model_Cache::clearTags(array("output", "system"));
     $this->_helper->json(array("success" => true));
 }
Пример #26
0
 public function save()
 {
     parent::save();
     Pimcore_Model_Cache::clearTag("object_" . $this->internalGetBaseProduct()->getId());
 }
Пример #27
0
 /**
  * @return Property[]
  */
 public function getProperties()
 {
     if ($this->properties === null) {
         // try to get from cache
         $cacheKey = "asset_properties_" . $this->getId();
         if (!($properties = Pimcore_Model_Cache::load($cacheKey))) {
             $properties = $this->getResource()->getProperties();
             Pimcore_Model_Cache::save($properties, $cacheKey, array("asset_properties", "properties"));
         }
         $this->setProperties($properties);
     }
     return $this->properties;
 }
Пример #28
0
 /**
  * @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);
     }
 }
Пример #29
0
 public function portletFeedAction()
 {
     $config = $this->getCurrentConfiguration();
     $cache = Pimcore_Model_Cache::getInstance();
     if ($cache) {
         $cache->setLifetime(10);
         Zend_Feed_Reader::setCache($cache);
     }
     $feedUrl = self::$defaultFeed;
     if ($config["settings"]["pimcore.layout.portlets.feed"]["url"]) {
         $feedUrl = $config["settings"]["pimcore.layout.portlets.feed"]["url"];
     }
     $feed = Zend_Feed_Reader::import($feedUrl);
     $count = 0;
     foreach ($feed as $entry) {
         // display only the latest 11 entries
         $count++;
         if ($count > 10) {
             break;
         }
         $entries[] = array("title" => $entry->getTitle(), "description" => $entry->getDescription(), 'authors' => $entry->getAuthors(), 'link' => $entry->getLink(), 'content' => $entry->getContent());
     }
     $this->_helper->json(array("entries" => $entries));
 }
Пример #30
0
 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) {
         }
     }
 }