protected function getService()
 {
     $credentials = $this->getWebmastertoolsCredentials();
     $client = Zend_Gdata_ClientLogin::getHttpClient($credentials["username"], $credentials["password"], "sitemaps", Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient"));
     $service = new Zend_Gdata_Analytics($client);
     return $service;
 }
Example #2
0
 public function lostpasswordAction()
 {
     $username = $this->_getParam("username");
     if ($username) {
         $user = User::getByName($username);
         if (!$user instanceof User) {
             $this->view->error = "user unknown";
         } else {
             if ($user->isActive()) {
                 if ($user->getEmail()) {
                     $token = Pimcore_Tool_Authentication::generateToken($username, $user->getPassword(), MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB);
                     $protocol = "http://";
                     if (strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "https") === 0) {
                         $protocol = "https://";
                     }
                     $uri = $protocol . $_SERVER['SERVER_NAME'];
                     $loginUrl = $uri . "/admin/login/login/?username="******"&token=" . $token;
                     try {
                         $mail = Pimcore_Tool::getMail(array($user->getEmail()), "Pimcore lost password service");
                         $mail->setBodyText("Login to pimcore and change your password using the following link. This temporary login link will expire in 30 minutes: \r\n\r\n" . $loginUrl);
                         $mail->send();
                         $this->view->success = true;
                     } catch (Exception $e) {
                         $this->view->error = "could not send email";
                     }
                 } else {
                     $this->view->error = "user has no email address";
                 }
             } else {
                 $this->view->error = "user inactive";
             }
         }
     }
 }
Example #3
0
 /**
  * @static
  * @param Element_Interface $object
  * @param string $type  "in" or "out"
  * @param  string $class
  * @return array
  */
 public static function map($object, $apiclass, $type)
 {
     if ($object instanceof Zend_Date) {
         $object = $object->toString();
     } else {
         if (is_object($object)) {
             if (Pimcore_Tool::classExists($apiclass)) {
                 $new = new $apiclass();
                 if (method_exists($new, "map")) {
                     $new->map($object);
                     $object = $new;
                 }
             } else {
                 throw new Exception("Webservice_Data_Mapper: Cannot map [ {$apiclass} ] - class does not exist");
             }
         } else {
             if (is_array($object)) {
                 $tmpArray = array();
                 foreach ($object as $v) {
                     $className = self::findWebserviceClass($v, $type);
                     $tmpArray[] = self::map($v, $className, $type);
                 }
                 $object = $tmpArray;
             }
         }
     }
     return $object;
 }
Example #4
0
 public function indexAction()
 {
     // check maintenance
     $maintenance_enabled = false;
     $manager = Schedule_Manager_Factory::getManager("maintenance.pid");
     $lastExecution = $manager->getLastExecution();
     if ($lastExecution) {
         if (time() - $lastExecution < 610) {
             // maintenance script should run at least every 10 minutes + a little tolerance
             $maintenance_enabled = true;
         }
     }
     $this->view->maintenance_enabled = Zend_Json::encode($maintenance_enabled);
     // configuration
     $this->view->config = Pimcore_Config::getSystemConfig();
     //mail settings
     $mailIncomplete = false;
     if ($this->view->config->email) {
         $emailSettings = $this->view->config->email->toArray();
         if ($emailSettings['method'] == "sendmail" and !empty($emailSettings['sender']['email'])) {
             $mailIncomplete = true;
         }
         if ($emailSettings['method'] == "smtp" and !empty($emailSettings['sender']['email']) and !empty($emailSettings['smtp']['host'])) {
             $mailIncomplete = true;
         }
     }
     $this->view->mail_settings_incomplete = Zend_Json::encode($mailIncomplete);
     // report configuration
     $this->view->report_config = Pimcore_Config::getReportConfig();
     // customviews config
     $cvConfig = Pimcore_Tool::getCustomViewConfig();
     $cvData = array();
     if ($cvConfig) {
         foreach ($cvConfig as $node) {
             $tmpData = $node;
             $rootNode = Object_Abstract::getByPath($tmpData["rootfolder"]);
             if ($rootNode) {
                 $tmpData["rootId"] = $rootNode->getId();
                 $tmpData["allowedClasses"] = explode(",", $tmpData["classes"]);
                 $tmpData["showroot"] = (bool) $tmpData["showroot"];
                 $cvData[] = $tmpData;
             }
         }
     }
     $this->view->customview_config = $cvData;
     // upload limit
     $max_upload = filesize2bytes(ini_get("upload_max_filesize") . "B");
     $max_post = filesize2bytes(ini_get("post_max_size") . "B");
     $memory_limit = filesize2bytes(ini_get("memory_limit") . "B");
     $upload_mb = min($max_upload, $max_post, $memory_limit);
     $this->view->upload_max_filesize = $upload_mb;
     // live connect
     $liveconnectToken = Pimcore_Liveconnect::getToken();
     $this->view->liveconnectToken = $liveconnectToken;
     // adding css minify filter because of IE issues with CkEditor and more than 31 stylesheets
     if (!PIMCORE_DEVMODE) {
         $front = Zend_Controller_Front::getInstance();
         $front->registerPlugin(new Pimcore_Controller_Plugin_CssMinify(), 800);
     }
 }
Example #5
0
 public function getWebmastertoolsSitesAction()
 {
     $credentials = $this->getWebmastertoolsCredentials();
     if ($credentials) {
         $username = $credentials["username"];
         $password = $credentials["password"];
     }
     if ($this->_getParam("username") && $this->_getParam("password")) {
         $username = $this->_getParam("username");
         $password = $this->_getParam("password");
     }
     try {
         $client = Zend_Gdata_ClientLogin::getHttpClient($username, $password, "sitemaps", Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient"));
         $service = new Zend_Gdata($client);
         $data = $service->getFeed("https://www.google.com/webmasters/tools/feeds/sites/");
         foreach ($data->getEntry() as $e) {
             $verification = "";
             // get verification filename
             foreach ($e->getExtensionElements() as $d) {
                 $a = $d->getExtensionAttributes();
                 if ($a["type"]["value"] == "htmlpage") {
                     $verification = $d->getText();
                     break;
                 }
             }
             $sites[] = array("profile" => (string) $e->getTitle(), "verification" => $verification);
         }
         $this->_helper->json(array("data" => $sites));
     } catch (Exception $e) {
         $this->_helper->json(false);
     }
 }
 public function adminCssAction()
 {
     // customviews config
     $cvData = Pimcore_Tool::getCustomViewConfig();
     $this->view->customviews = $cvData;
     $this->getResponse()->setHeader("Content-Type", "text/css; charset=UTF-8", true);
 }
Example #7
0
 public function getUpdateInformationAction()
 {
     $id = $this->_getParam("id");
     $type = $this->_getParam("type");
     if ($type == "plugin") {
         $extensionPath = PIMCORE_PLUGINS_PATH . "/" . $id;
     } else {
         if ($type = "brick") {
             $extensionPath = PIMCORE_WEBSITE_PATH . "/var/areas/" . $id;
         }
     }
     $remoteConfig = array("token" => Pimcore_Liveconnect::getToken(), "id" => $id, "type" => $type, "revision" => trim(file_get_contents($extensionPath . "/.pimcore_extension_revision")));
     $rawData = Pimcore_Tool::getHttpData("http://extensions.pimcore.org/update/getUpdateInformation.php", null, array("data" => base64_encode(serialize($remoteConfig))));
     if (!$rawData) {
         header('HTTP/1.1 403 Forbidden');
         exit;
     }
     $steps = array();
     $numberOfFiles = 0;
     $data = Zend_Json::decode($rawData);
     foreach ($data["revisions"] as $revision) {
         foreach ($revision["files"] as $file) {
             $steps[] = array("action" => $file["action"], "controller" => "download", "params" => array("id" => $id, "type" => $type, "path" => $file["path"], "revision" => $file["revision"]));
             $numberOfFiles++;
         }
         $steps[] = array("action" => "check-update-script", "controller" => "update", "params" => array("id" => $id, "type" => $type, "revision" => $revision["revision"]));
     }
     $this->_helper->json(array("steps" => $steps, "fileAmount" => $numberOfFiles));
 }
Example #8
0
 /**
  * @return void
  */
 public function update()
 {
     foreach ($this->fieldsToSave as $field) {
         if (in_array($field, $this->validColumns)) {
             $getter = 'get' . ucfirst($field);
             if (in_array($field, $this->localizedFields)) {
                 // handle localized Fields
                 $localizedValues = array();
                 foreach (Pimcore_Tool::getValidLanguages() as $lang) {
                     $localizedValues[$lang] = $value = $this->model->{$getter}($lang);
                 }
                 $value = $localizedValues;
             } else {
                 // normal case
                 $value = $this->model->{$getter}();
             }
             if (is_array($value) || is_object($value)) {
                 $value = serialize($value);
             } else {
                 if (is_bool($value)) {
                     $value = (int) $value;
                 }
             }
             $data[$field] = $value;
         }
     }
     $this->db->update(self::TABLE_NAME, $data, 'id=' . $this->db->quote($this->model->getId()));
 }
Example #9
0
 protected function getService()
 {
     $credentials = $this->getAnalyticsCredentials();
     $client = Zend_Gdata_ClientLogin::getHttpClient($credentials["username"], $credentials["password"], Zend_Gdata_Analytics::AUTH_SERVICE_NAME, Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient"));
     $service = new Zend_Gdata_Analytics($client, "pimcore-open-source-CMS-framework");
     return $service;
 }
Example #10
0
 /**
  * @static
  * @param $id - translation key
  * @param bool $create - creates an empty translation entry if the key doesn't exists
  * @param bool $returnIdIfEmpty - returns $id if no translation is available
  * @return Translation_Website
  */
 public static function getByKey($id, $create = false, $returnIdIfEmpty = false)
 {
     $translation = new self();
     try {
         $translation->getResource()->getByKey($id);
     } catch (Exception $e) {
         if (!$create) {
             throw new Exception($e->getMessage());
         } else {
             $translation->setKey($id);
             $translation->setDate(time());
             $translations = array();
             foreach (Pimcore_Tool::getValidLanguages() as $lang) {
                 $translations[$lang] = "";
             }
             $translation->setTranslations($translations);
             $translation->save();
         }
     }
     if ($returnIdIfEmpty) {
         $translations = $translation->getTranslations();
         foreach ($translations as $key => $value) {
             $translations[$key] = $value ?: $id;
         }
         $translation->setTranslations($translations);
     }
     return $translation;
 }
 public function getDataByIdAction()
 {
     // check for lock
     if (Element_Editlock::isLocked($this->_getParam("id"), "document")) {
         $this->_helper->json(array("editlock" => Element_Editlock::getByElement($this->_getParam("id"), "document")));
     }
     Element_Editlock::lock($this->_getParam("id"), "document");
     $page = Document_Page::getById($this->_getParam("id"));
     $page = $this->getLatestVersion($page);
     $page->getVersions();
     $page->getScheduledTasks();
     $page->idPath = Pimcore_Tool::getIdPathForElement($page);
     $page->userPermissions = $page->getUserPermissions();
     $page->setLocked($page->isLocked());
     // get depending redirects
     $redirectList = new Redirect_List();
     $redirectList->setCondition("target = ?", $page->getId());
     $page->redirects = $redirectList->load();
     // unset useless data
     $page->setElements(null);
     $page->childs = null;
     // cleanup properties
     $this->minimizeProperties($page);
     if ($page->isAllowed("view")) {
         $this->_helper->json($page);
     }
     $this->_helper->json(false);
 }
Example #12
0
 /**
  * @static
  * @return array
  */
 public static function createClassMappings()
 {
     $modelsDir = PIMCORE_PATH . "/models/";
     $files = rscandir($modelsDir);
     $includePatterns = array("/Webservice\\/Data/");
     foreach ($files as $file) {
         if (is_file($file)) {
             $file = str_replace($modelsDir, "", $file);
             $file = str_replace(".php", "", $file);
             $class = str_replace(DIRECTORY_SEPARATOR, "_", $file);
             if (Pimcore_Tool::classExists($class)) {
                 $match = false;
                 foreach ($includePatterns as $pattern) {
                     if (preg_match($pattern, $file)) {
                         $match = true;
                         break;
                     }
                 }
                 if (strpos($file, "Webservice" . DIRECTORY_SEPARATOR . "Data") !== false) {
                     $match = true;
                 }
                 if (!$match) {
                     continue;
                 }
                 $classMap[str_replace("Webservice_Data_", "", $class)] = $class;
             }
         }
     }
     return $classMap;
 }
Example #13
0
 public static function generateLayoutTreeFromArray($array)
 {
     if (is_array($array) && count($array) > 0) {
         $class = "Object_Class_" . ucfirst($array["datatype"]) . "_" . ucfirst($array["fieldtype"]);
         if (Pimcore_Tool::classExists($class)) {
             $item = new $class();
             if (method_exists($item, "addChild")) {
                 // allows childs
                 $item->setValues($array, array("childs"));
                 if ($array["childs"]["datatype"]) {
                     $childO = self::generateLayoutTreeFromArray($array["childs"]);
                     $item->addChild($childO);
                 } else {
                     if (is_array($array["childs"]) && count($array["childs"]) > 0) {
                         foreach ($array["childs"] as $child) {
                             $childO = self::generateLayoutTreeFromArray($child);
                             $item->addChild($childO);
                         }
                     }
                 }
             } else {
                 $item->setValues($array);
             }
             return $item;
         }
     }
     return false;
 }
Example #14
0
 protected function getLanguages()
 {
     if ($this->languages == null) {
         $languages = Pimcore_Tool::getValidLanguages();
         $this->languages = $languages;
     }
     return $this->languages;
 }
Example #15
0
 /**
  * @param string $module
  * @return void
  */
 public function registerModule($module)
 {
     if (Pimcore_Tool::classExists($module)) {
         $this->_systemModules[] = new $module();
     } else {
         throw new Exception("unknown module [ {$module} ].");
     }
 }
Example #16
0
 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     // removes the non-valid html attributes which are used by the wysiwyg editor for ID based linking
     $body = $this->getResponse()->getBody();
     $body = preg_replace("/ pimcore_(id|type)=\\\"([0-9a-z]+)\\\"/", "", $body);
     $this->getResponse()->setBody($body);
 }
Example #17
0
 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->enabled) {
         $body = $this->getResponse()->getBody();
         $body = Minify_HTML::minify($body);
         $this->getResponse()->setBody($body);
     }
 }
Example #18
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) {
             $styles = $html->find("link[rel=stylesheet], style[type=text/css]");
             $stylesheetContent = "";
             foreach ($styles as $style) {
                 if ($style->tag == "style") {
                     $stylesheetContent .= $style->innertext;
                 } else {
                     if ($style->media == "screen" || !$style->media) {
                         $source = $style->href;
                         $path = "";
                         if (is_file(PIMCORE_ASSET_DIRECTORY . $source)) {
                             $path = PIMCORE_ASSET_DIRECTORY . $source;
                         } else {
                             if (is_file(PIMCORE_DOCUMENT_ROOT . $source)) {
                                 $path = PIMCORE_DOCUMENT_ROOT . $source;
                             }
                         }
                         if (!empty($path) && is_file("file://" . $path)) {
                             $content = file_get_contents($path);
                             $content = $this->correctReferences($source, $content);
                             $stylesheetContent .= $content;
                             $style->outertext = "";
                         }
                     }
                 }
             }
             if (strlen($stylesheetContent) > 1) {
                 $stylesheetPath = PIMCORE_TEMPORARY_DIRECTORY . "/minified_css_" . md5($stylesheetContent) . ".css";
                 if (!is_file($stylesheetPath)) {
                     $stylesheetContent = Minify_CSS::minify($stylesheetContent);
                     // put minified contents into one single file
                     file_put_contents($stylesheetPath, $stylesheetContent);
                     chmod($stylesheetPath, 0766);
                 }
                 $head = $html->find("head", 0);
                 $head->innertext = $head->innertext . "\n" . '<link rel="stylesheet" media="screen" type="text/css" href="' . str_replace(PIMCORE_DOCUMENT_ROOT, "", $stylesheetPath) . '" />' . "\n";
             }
             $body = $html->save();
             $this->getResponse()->setBody($body);
         }
     }
 }
Example #19
0
 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->enabled) {
         include_once "simple_html_dom.php";
         if ($this->getRequest()->getParam("pimcore_editmode")) {
             $this->editmode();
         } else {
             $this->frontend();
         }
     }
 }
Example #20
0
 /**
  *
  */
 public function mail()
 {
     $conf = Pimcore_Config::getSystemConfig();
     if (!empty($conf->general->logrecipient)) {
         Logger::debug(get_class($this) . ": detected log recipient:" . $conf->general->logrecipient);
         $user = User::getById($conf->general->logrecipient);
         Logger::debug(get_class($this) . ": detected log recipient:" . $user->getEmail());
         if ($user instanceof User && $user->isAdmin()) {
             $email = $user->getEmail();
             Logger::debug(get_class($this) . ": user is valid");
             if (!empty($email)) {
                 if (is_dir(PIMCORE_LOG_MAIL_TEMP)) {
                     Logger::debug(get_class($this) . ": detected mail log dir");
                     Logger::debug(get_class($this) . ": opening dir " . PIMCORE_LOG_MAIL_TEMP);
                     if ($handle = opendir(PIMCORE_LOG_MAIL_TEMP)) {
                         Logger::debug(get_class($this) . ": reading dir " . PIMCORE_LOG_MAIL_TEMP);
                         while (false !== ($file = readdir($handle))) {
                             Logger::debug(get_class($this) . ": detected file " . $file);
                             if (is_file(PIMCORE_LOG_MAIL_TEMP . "/" . $file) and is_writable(PIMCORE_LOG_MAIL_TEMP . "/" . $file)) {
                                 $now = time();
                                 $threshold = 1 * 60 * 15;
                                 $fileModified = filemtime(PIMCORE_LOG_MAIL_TEMP . "/" . $file);
                                 Logger::debug(get_class($this) . ": file is writeable and was last modified: " . $fileModified);
                                 if ($fileModified !== FALSE and $fileModified < $now - $threshold) {
                                     $mail = Pimcore_Tool::getMail(array($email), "pimcore log notification - " . $file);
                                     $mail->setIgnoreDebugMode(true);
                                     $mail->setBodyText(file_get_contents(PIMCORE_LOG_MAIL_TEMP . "/" . $file));
                                     $mail->send();
                                     @unlink(PIMCORE_LOG_MAIL_TEMP . "/" . $file);
                                     Logger::debug(get_class($this) . ": sent mail and deleted temp log file " . $file);
                                 } else {
                                     if ($fileModified > $now - $threshold) {
                                         Logger::debug(get_class($this) . ": leaving temp log file alone because file [ {$file} ] was written to within the last 15 minutes");
                                     }
                                 }
                             }
                         }
                     }
                 }
             } else {
                 Logger::err(get_class($this) . ": Cannot send mail to configured log user [" . $user->getName() . "] because email is empty");
             }
         } else {
             Logger::err(get_class($this) . ": Cannot send mail to configured log user. User is either null or not an admin");
         }
     } else {
         Logger::debug(get_class($this) . ": No log recipient configured");
     }
 }
Example #21
0
 public function getDataByIdAction()
 {
     // check for lock
     if (Element_Editlock::isLocked($this->_getParam("id"), "document")) {
         $this->_helper->json(array("editlock" => Element_Editlock::getByElement($this->_getParam("id"), "document")));
     }
     Element_Editlock::lock($this->_getParam("id"), "document");
     $link = Document_Link::getById($this->_getParam("id"));
     $link->getPermissionsForUser($this->getUser());
     $link->setObject(null);
     $link->idPath = Pimcore_Tool::getIdPathForElement($link);
     $this->minimizeProperties($link);
     if ($link->isAllowed("view")) {
         $this->_helper->json($link);
     }
     $this->_helper->json(false);
 }
 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) {
             $scripts = $html->find("script[src]");
             $scriptContent = "";
             foreach ($scripts as $script) {
                 $source = $script->src;
                 $path = "";
                 if (is_file("file://" . PIMCORE_ASSET_DIRECTORY . $source)) {
                     $path = "file://" . PIMCORE_ASSET_DIRECTORY . $source;
                 } else {
                     if (is_file("file://" . PIMCORE_DOCUMENT_ROOT . $source)) {
                         $path = "file://" . PIMCORE_DOCUMENT_ROOT . $source;
                     }
                 }
                 if (is_file($path)) {
                     $scriptContent .= file_get_contents($path) . "\n\n";
                     if ($script->next_sibling()->tag != "script" || !$script->next_sibling()->src) {
                         $scriptPath = $this->writeJsTempFile($scriptContent);
                         $scriptContent = "";
                         $script->outertext = '<script type="text/javascript" src="' . str_replace(PIMCORE_DOCUMENT_ROOT, "", $scriptPath) . '"></script>' . "\n";
                     } else {
                         $script->outertext = "";
                     }
                 } else {
                     if ($script->prev_sibling()->tag == "script") {
                         if (strlen($scriptContent) > 0) {
                             $scriptPath = $this->writeJsTempFile($scriptContent);
                             $scriptContent = "";
                             $script->outertext = '<script type="text/javascript" src="' . str_replace(PIMCORE_DOCUMENT_ROOT, "", $scriptPath) . '"></script>' . "\n" . $script->outertext;
                         }
                     }
                 }
             }
             $body = $html->save();
             $this->getResponse()->setBody($body);
         }
     }
 }
 public function getDataByIdAction()
 {
     // check for lock
     if (Element_Editlock::isLocked($this->_getParam("id"), "document")) {
         $this->_helper->json(array("editlock" => Element_Editlock::getByElement($this->_getParam("id"), "document")));
     }
     Element_Editlock::lock($this->_getParam("id"), "document");
     $folder = Document_Folder::getById($this->_getParam("id"));
     $folder->idPath = Pimcore_Tool::getIdPathForElement($folder);
     $folder->userPermissions = $folder->getUserPermissions();
     $folder->setLocked($folder->isLocked());
     $this->minimizeProperties($folder);
     if ($folder->isAllowed("view")) {
         $this->_helper->json($folder);
     }
     $this->_helper->json(false);
 }
 public function getLanguagesAction()
 {
     $languagesJson = Pimcore_Tool::getHttpData("http://www.pimcore.org/community/translations/pimcore_download");
     echo $languagesJson;
     exit;
     $languagesData = Zend_Json_Decoder::decode($languagesJson);
     $languages = $languagesData["languages"];
     if (is_array($languages)) {
         for ($i = 0; $i < count($languages); $i++) {
             if (is_file($filesDir = PIMCORE_WEBSITE_PATH . "/var/config/texts/" . $languages[$i]['key'] . ".csv")) {
                 $languages[$i]["exists"] = true;
             } else {
                 $languages[$i]["exists"] = false;
             }
         }
     }
     $this->_helper->json(array("languages" => $languages));
 }
Example #25
0
 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->enabled && ($code = Pimcore_Google_Analytics::getCode())) {
         // analytics
         include_once "simple_html_dom.php";
         $body = $this->getResponse()->getBody();
         // search for the end <head> tag, and insert the google analytics code before
         // this method is much faster than using simple_html_dom and uses less memory
         $headEndPosition = strpos($body, "</head>");
         if ($headEndPosition !== false) {
             $body = substr_replace($body, $code . "</head>", $headEndPosition, 7);
         }
         $this->getResponse()->setBody($body);
     }
 }
Example #26
0
 public function configureOptions()
 {
     $validLanguages = (array) Pimcore_Tool::getValidLanguages();
     $languages = Zend_Locale::getTranslationList('language');
     asort($languages);
     $options = array();
     foreach ($languages as $short => $translation) {
         if ($this->getOnlySystemLanguages()) {
             if (!in_array($short, $validLanguages)) {
                 continue;
             }
         }
         if (strlen($short) == 2 or strlen($short) == 5 and strpos($short, "_") == 2) {
             $options[] = array("key" => $translation, "value" => $short);
         }
     }
     $this->setOptions($options);
 }
 protected function _handleError(Zend_Controller_Request_Abstract $request)
 {
     // remove zend error handler
     $front = Zend_Controller_Front::getInstance();
     $front->unregisterPlugin("Zend_Controller_Plugin_ErrorHandler");
     $response = $this->getResponse();
     if ($response->isException() && !$this->_isInsideErrorHandlerLoop) {
         // get errorpage
         try {
             // enable error handler
             $front->setParam('noErrorHandler', false);
             $siteKey = Pimcore_Tool_Frontend::getSiteKey();
             $errorPath = Pimcore_Config::getSystemConfig()->documents->error_pages->{$siteKey};
             if (empty($errorPath)) {
                 $errorPath = "/";
             }
             $document = Document::getByPath($errorPath);
             if (!$document instanceof Document_Page) {
                 // default is home
                 $document = Document::getById(1);
             }
             if ($document instanceof Document_Page) {
                 $params = Pimcore_Tool::getRoutingDefaults();
                 if ($module = $document->getModule()) {
                     $params["module"] = $module;
                 }
                 if ($controller = $document->getController()) {
                     $params["controller"] = $controller;
                     $params["action"] = "index";
                 }
                 if ($action = $document->getAction()) {
                     $params["action"] = $action;
                 }
                 $this->setErrorHandler($params);
                 $request->setParam("document", $document);
                 Zend_Registry::set("pimcore_error_document", $document);
             }
         } catch (Exception $e) {
             Logger::emergency("error page not found");
         }
     }
     // call default ZF error handler
     parent::_handleError($request);
 }
 private function walk_path($folder, $options = null, $path = "")
 {
     if (is_null($options)) {
         $options = array();
     }
     if ($folder) {
         $source = $this->_getParam("source_methodname");
         if (Pimcore_Version::getRevision() > 3303) {
             $object_name = "Pimcore\\Model\\Object\\" . ucfirst($this->_getParam("source_classname"));
         } else {
             $object_name = "Object_" . ucfirst($this->_getParam("source_classname"));
         }
         $children = $folder->getChilds();
         $usesI18n = sizeof($children) > 0 && $this->isUsingI18n($children[0], $source);
         $current_lang = $this->_getParam("current_language");
         if (!Pimcore_Tool::isValidLanguage($current_lang)) {
             $languages = Pimcore_Tool::getValidLanguages();
             $current_lang = $languages[0];
             // TODO: Is this sensible?
         }
         foreach ($children as $child) {
             $class = get_class($child);
             switch ($class) {
                 case "Object_Folder":
                     /**
                      * @var Object_Folder $child
                      */
                     $key = $child->getProperty("Taglabel") != "" ? $child->getProperty("Taglabel") : $child->getKey();
                     if ($this->_getParam("source_recursive") == "true") {
                         $options = $this->walk_path($child, $options, $path . $this->separator . $key);
                     }
                     break;
                 case $object_name:
                     $key = $usesI18n ? $child->{$source}($current_lang) : $child->{$source}();
                     $options[] = array("value" => $child->getId(), "key" => ltrim($path . $this->separator . $key, $this->separator));
                     if ($this->_getParam("source_recursive") == "true") {
                         $options = $this->walk_path($child, $options, $path . $this->separator . $key);
                     }
                     break;
             }
         }
     }
     return $options;
 }
Example #29
0
 /**
  * @static
  * @return null|Pimcore_Video_Adapter
  */
 public static function getInstance($adapter = null)
 {
     try {
         if ($adapter) {
             $adapterClass = "Pimcore_Video_Adapter_" . $adapter;
             if (Pimcore_Tool::classExists($adapterClass)) {
                 return new $adapterClass();
             } else {
                 throw new Exception("Video-transcode adapter `" . $adapter . "ยด does not exist.");
             }
         } else {
             return new Pimcore_Video_Adapter_Ffmpeg();
         }
     } catch (Exception $e) {
         Logger::crit("Unable to load video adapter: " . $e->getMessage());
         throw $e;
     }
     return null;
 }
Example #30
0
 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->enabled && Pimcore_Google_Analytics::isConfigured()) {
         // analytics
         include_once "simple_html_dom.php";
         $body = $this->getResponse()->getBody();
         // search for the end <head> tag, and insert the google analytics code before
         // this method is much faster than using simple_html_dom and uses less memory
         $headEndPosition = strpos($body, "</head>");
         if ($headEndPosition !== false) {
             $body = substr_replace($body, Pimcore_Google_Analytics::getCode() . "</head>", $headEndPosition, 7);
         }
         // website optimizer
         if ($this->document) {
             $top = Pimcore_Google_Analytics::getOptimizerTop($this->document);
             $bottom = Pimcore_Google_Analytics::getOptimizerBottom($this->document);
             $conversion = Pimcore_Google_Analytics::getOptimizerConversion($this->document);
             if ($top || $bottom || $conversion) {
                 $html = str_get_html($body);
                 if ($html) {
                     $body = $html->find("body", 0);
                     if ($top && $bottom) {
                         $body->innertext = $top . $body->innertext . $bottom;
                     } else {
                         if ($conversion) {
                             $body->innertext = $body->innertext . $conversion;
                         } else {
                             if ($bottom) {
                                 $body->innertext = $body->innertext . $bottom;
                             }
                         }
                     }
                     $body = $html->save();
                 }
             }
         }
         $this->getResponse()->setBody($body);
     }
 }