Пример #1
1
    /**
     *
     */
    public function dispatchLoopShutdown()
    {
        if (!Tool::isHtmlResponse($this->getResponse())) {
            return;
        }
        $siteKey = \Pimcore\Tool\Frontend::getSiteKey();
        $reportConfig = \Pimcore\Config::getReportConfig();
        if ($this->enabled && isset($reportConfig->tagmanager->sites->{$siteKey}->containerId)) {
            $containerId = $reportConfig->tagmanager->sites->{$siteKey}->containerId;
            if ($containerId) {
                $code = <<<CODE
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id={$containerId}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{$containerId}');</script>
<!-- End Google Tag Manager -->
CODE;
                $body = $this->getResponse()->getBody();
                // insert code after the opening <body> tag
                $body = preg_replace("@<body(>|.*?[^?]>)@", "<body\$1\n\n" . $code, $body);
                $this->getResponse()->setBody($body);
            }
        }
    }
Пример #2
0
 /**
  * @throws \Exception
  */
 public function init()
 {
     $conf = Config::getSystemConfig();
     if (!$conf->webservice->enabled) {
         throw new \Exception("Webservice API isn't enabled");
     }
     if (!$this->getParam("apikey") && $_COOKIE["pimcore_admin_sid"]) {
         $user = Authentication::authenticateSession();
         if (!$user instanceof User) {
             throw new \Exception("User is not valid");
         }
     } else {
         if (!$this->getParam("apikey")) {
             throw new \Exception("API key missing");
         } else {
             $apikey = $this->getParam("apikey");
             $userList = new User\Listing();
             $userList->setCondition("apiKey = ? AND type = ? AND active = 1", array($apikey, "user"));
             $users = $userList->load();
             if (!is_array($users) or count($users) !== 1) {
                 throw new \Exception("API key error.");
             }
             if (!$users[0]->getApiKey()) {
                 throw new \Exception("Couldn't get API key for user.");
             }
             $user = $users[0];
         }
     }
     \Zend_Registry::set("pimcore_admin_user", $user);
     parent::init();
 }
Пример #3
0
 /**
  * @param array $config
  */
 public function config($config = [])
 {
     $settings = null;
     // check for an initial configuration template
     // used eg. by the demo installer
     $configTemplatePath = PIMCORE_CONFIGURATION_DIRECTORY . "/system.template.php";
     if (file_exists($configTemplatePath)) {
         try {
             $configTemplate = new \Zend_Config(include $configTemplatePath);
             if ($configTemplate->general) {
                 // check if the template contains a valid configuration
                 $settings = $configTemplate->toArray();
                 // unset database configuration
                 unset($settings["database"]["params"]["host"]);
                 unset($settings["database"]["params"]["port"]);
             }
         } catch (\Exception $e) {
         }
     }
     // set default configuration if no template is present
     if (!$settings) {
         // write configuration file
         $settings = ["general" => ["timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "debugloglevel" => "debug", "custom_php_logfile" => "1", "extjs6" => "1"], "database" => ["adapter" => "Mysqli", "params" => ["username" => "root", "password" => "", "dbname" => ""]], "documents" => ["versions" => ["steps" => "10"], "default_controller" => "default", "default_action" => "default", "error_pages" => ["default" => "/"], "createredirectwhenmoved" => "", "allowtrailingslash" => "no", "generatepreview" => "1"], "objects" => ["versions" => ["steps" => "10"]], "assets" => ["versions" => ["steps" => "10"]], "services" => [], "cache" => ["excludeCookie" => ""], "httpclient" => ["adapter" => "Zend_Http_Client_Adapter_Socket"]];
     }
     $settings = array_replace_recursive($settings, $config);
     // create initial /website/var folder structure
     // @TODO: should use values out of startup.php (Constants)
     $varFolders = ["areas", "assets", "backup", "cache", "classes", "config", "email", "log", "plugins", "recyclebin", "search", "system", "tmp", "versions", "webdav"];
     foreach ($varFolders as $folder) {
         \Pimcore\File::mkdir(PIMCORE_WEBSITE_VAR . "/" . $folder);
     }
     $configFile = \Pimcore\Config::locateConfigFile("system.php");
     File::putPhpFile($configFile, to_php_data_file_format($settings));
 }
Пример #4
0
 /**
  * @param $documentId
  * @param $config
  * @throws \Exception
  */
 public function preparePdfGeneration($documentId, $config)
 {
     $document = $this->getPrintDocument($documentId);
     if (Model\Tool\TmpStore::get($document->getLockKey())) {
         throw new \Exception("Process with given document alredy running.");
     }
     Model\Tool\TmpStore::add($document->getLockKey(), true);
     $jobConfig = new \stdClass();
     $jobConfig->documentId = $documentId;
     $jobConfig->config = $config;
     $this->saveJobConfigObjectFile($jobConfig);
     $this->updateStatus($documentId, 0, "prepare_pdf_generation");
     $args = ["-p " . $jobConfig->documentId];
     $env = \Pimcore\Config::getEnvironment();
     if ($env !== false) {
         $args[] = "--environment=" . $env;
     }
     $cmd = Tool\Console::getPhpCli() . " " . realpath(PIMCORE_PATH . DIRECTORY_SEPARATOR . "cli" . DIRECTORY_SEPARATOR . "console.php") . " web2print:pdf-creation " . implode(" ", $args);
     Logger::info($cmd);
     if (!$config['disableBackgroundExecution']) {
         Tool\Console::execInBackground($cmd, PIMCORE_LOG_DIRECTORY . DIRECTORY_SEPARATOR . "web2print-output.log");
     } else {
         Processor::getInstance()->startPdfGeneration($jobConfig->documentId);
     }
 }
Пример #5
0
 public function addLanguage($languageToAdd)
 {
     // Check if language is not already added
     if (in_array($languageToAdd, Tool::getValidLanguages())) {
         $result = false;
     } else {
         // Read all the documents from the first language
         $availableLanguages = Tool::getValidLanguages();
         $firstLanguageDocument = \Pimcore\Model\Document::getByPath('/' . reset($availableLanguages));
         \Zend_Registry::set('SEI18N_add', 1);
         // Add the language main folder
         $document = Page::create(1, array('key' => $languageToAdd, "userOwner" => 1, "userModification" => 1, "published" => true, "controller" => 'default', "action" => 'go-to-first-child'));
         $document->setProperty('language', 'text', $languageToAdd);
         // Set the language to this folder and let it inherit to the child pages
         $document->setProperty('isLanguageRoot', 'text', 1, false, false);
         // Set as language root document
         $document->save();
         // Add Link to other languages
         $t = new Keys();
         $t->insert(array("document_id" => $document->getId(), "language" => $languageToAdd, "sourcePath" => $firstLanguageDocument->getFullPath()));
         // Lets add all the docs
         $this->addDocuments($firstLanguageDocument->getId(), $languageToAdd);
         \Zend_Registry::set('SEI18N_add', 0);
         $oldConfig = Config::getSystemConfig();
         $settings = $oldConfig->toArray();
         $languages = explode(',', $settings['general']['validLanguages']);
         $languages[] = $languageToAdd;
         $settings['general']['validLanguages'] = implode(',', $languages);
         $config = new \Zend_Config($settings, true);
         $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
         $writer->write();
         $result = true;
     }
     return $result;
 }
 public function init()
 {
     // Disable plugin if the allowed domain is not yet set
     $settingDomain = WebsiteSetting::getByName("subdomainAdmin");
     if (!is_object($settingDomain) || $settingDomain->getData() == "") {
         return;
     }
     // Create temporary request object - not available yet in front controller
     $currentUrl = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
     $request = new \Zend_Controller_Request_Http($currentUrl);
     // Disable main domain setting to allow admin access on another domain
     $conf = Config::getSystemConfig();
     $mainDomain = $conf->general->domain;
     if (Tool::isRequestToAdminBackend($request) && Tool::isDomainAllowedToAdminBackend($request)) {
         $confArr = $conf->toArray();
         $mainDomain = $confArr['general']['domain'];
         $confArr['general']['domain'] = "";
         Config::setSystemConfig(new \Zend_Config($confArr));
     }
     // Register plugin
     \Pimcore::getEventManager()->attach("system.startup", function ($event) use(&$mainDomain) {
         $front = \Zend_Controller_Front::getInstance();
         $frontControllerPlugin = new FrontControllerPlugin();
         $front->registerPlugin($frontControllerPlugin);
         // Restore main domain
         $conf = Config::getSystemConfig();
         $confArr = $conf->toArray();
         $confArr['general']['domain'] = $mainDomain;
         Config::setSystemConfig(new \Zend_Config($confArr));
     });
 }
Пример #7
0
 public function saveAction()
 {
     $this->checkPermission("system_settings");
     $values = \Zend_Json::decode($this->getParam("data"));
     $configFile = \Pimcore\Config::locateConfigFile("reports.php");
     File::put($configFile, to_php_data_file_format($values));
     $this->_helper->json(array("success" => true));
 }
Пример #8
0
 /**
  * @param null $site
  * @return bool
  */
 public static function getSiteConfig($site = null)
 {
     $siteKey = \Pimcore\Tool\Frontend::getSiteKey($site);
     if (Config::getReportConfig()->webmastertools->sites->{$siteKey}->verification) {
         return Config::getReportConfig()->webmastertools->sites->{$siteKey};
     }
     return false;
 }
Пример #9
0
 /**
  * @param \Zend_Controller_Request_Abstract $request
  * @throws mixed
  */
 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);
             $errorPath = Config::getSystemConfig()->documents->error_pages->default;
             if (Site::isSiteRequest()) {
                 $site = Site::getCurrentSite();
                 $errorPath = $site->getErrorDocument();
             }
             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 = 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);
                 // ensure that a viewRenderer exists, and is enabled
                 if (!\Zend_Controller_Action_HelperBroker::hasHelper("viewRenderer")) {
                     $viewRenderer = new \Pimcore\Controller\Action\Helper\ViewRenderer();
                     \Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
                 }
                 $viewRenderer = \Zend_Controller_Action_HelperBroker::getExistingHelper("viewRenderer");
                 $viewRenderer->setNoRender(false);
                 if ($viewRenderer->view === null) {
                     $viewRenderer->initView(PIMCORE_WEBSITE_PATH . "/views");
                 }
             }
         } catch (\Exception $e) {
             \Logger::emergency("error page not found");
         }
     }
     // call default ZF error handler
     parent::_handleError($request);
 }
Пример #10
0
 public function setSystemInstanceIdentifier()
 {
     $instanceIdentifier = \Pimcore\Config::getSystemConfig()->general->instanceIdentifier;
     if (!$instanceIdentifier) {
         throw new \Exception("No instance identifier set in system config!");
     }
     $this->setInstanceIdentifier($instanceIdentifier);
     return $this;
 }
Пример #11
0
    /**
     *
     */
    public function dispatchLoopShutdown()
    {
        $config = \Pimcore\Config::getSystemConfig();
        if (!$config->general->show_cookie_notice || !Tool::useFrontendOutputFilters($this->getRequest()) || !Tool::isHtmlResponse($this->getResponse())) {
            return;
        }
        $template = file_get_contents(__DIR__ . "/EuCookieLawNotice/template.html");
        # cleanup code
        $template = preg_replace('/[\\r\\n\\t]+/', ' ', $template);
        #remove new lines, spaces, tabs
        $template = preg_replace('/>[\\s]+</', '><', $template);
        #remove new lines, spaces, tabs
        $template = preg_replace('/[\\s]+/', ' ', $template);
        #remove new lines, spaces, tabs
        $translations = $this->getTranslations();
        foreach ($translations as $key => &$value) {
            $value = htmlentities($value, ENT_COMPAT, "UTF-8");
            $template = str_replace("%" . $key . "%", $value, $template);
        }
        $linkContent = "";
        if (array_key_exists("linkTarget", $translations)) {
            $linkContent = '<a href="' . $translations["linkTarget"] . '" data-content="' . $translations["linkText"] . '"></a>';
        }
        $template = str_replace("%link%", $linkContent, $template);
        $templateCode = \Zend_Json::encode($template);
        $code = '
            <script>
                (function () {
                    var ls = window["localStorage"];
                    if(ls && !ls.getItem("pc-cookie-accepted")) {

                        var code = ' . $templateCode . ';
                        var ci = window.setInterval(function () {
                            if(document.body) {
                                clearInterval(ci);
                                document.body.insertAdjacentHTML("beforeend", code);

                                document.getElementById("pc-button").onclick = function () {
                                    document.getElementById("pc-cookie-notice").style.display = "none";
                                    ls.setItem("pc-cookie-accepted", "true");
                                };
                            }
                        }, 100);
                    }
                })();
            </script>
        ';
        $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 = stripos($body, "</head>");
        if ($headEndPosition !== false) {
            $body = substr_replace($body, $code . "</head>", $headEndPosition, 7);
        }
        $this->getResponse()->setBody($body);
    }
Пример #12
0
 public function adminerAction()
 {
     $conf = \Pimcore\Config::getSystemConfig()->database->params;
     if (empty($_SERVER["QUERY_STRING"])) {
         $this->redirect("/admin/external_adminer/adminer/?username="******"&db=" . $conf->dbname);
         exit;
     }
     chdir($this->adminerHome . "adminer");
     include $this->adminerHome . "adminer/index.php";
     $this->removeViewRenderer();
 }
Пример #13
0
 /**
  * @return PdfReactor8|WkHtmlToPdf
  * @throws \Exception
  */
 public static function getInstance()
 {
     $config = Config::getWeb2PrintConfig();
     if ($config->generalTool == "pdfreactor") {
         return new PdfReactor8();
     } elseif ($config->generalTool == "wkhtmltopdf") {
         return new WkHtmlToPdf();
     } else {
         throw new \Exception("Invalid Configuation - " . $config->generalTool);
     }
 }
Пример #14
0
 /**
  * @param null $site
  * @return bool
  */
 public static function getSiteConfig($site = null)
 {
     $siteKey = \Pimcore\Tool\Frontend::getSiteKey($site);
     $config = Config::getReportConfig();
     if (!$config->analytics) {
         return false;
     }
     if ($config->analytics->sites->{$siteKey}) {
         return Config::getReportConfig()->analytics->sites->{$siteKey};
     }
     return false;
 }
 private function getErrorDocument()
 {
     $config = Config::getSystemConfig();
     $errorDocPath = $config->documents->error_pages->default;
     if (Site::isSiteRequest()) {
         $site = Site::getCurrentSite();
         $errorDocPath = $site->getErrorDocument();
     }
     $errorDoc = Document::getByPath($errorDocPath);
     \Zend_Registry::set("pimcore_error_document", $errorDoc);
     return $errorDoc;
 }
Пример #16
0
 /**
  * @return mixed|null
  * @throws \Exception
  */
 public static function getConfiguration()
 {
     $config = null;
     $configFile = \Pimcore\Config::locateConfigFile("hybridauth.php");
     if (is_file($configFile)) {
         $config = (include $configFile);
         $config["base_url"] = \Pimcore\Tool::getHostUrl() . "/hybridauth/endpoint";
     } else {
         throw new \Exception("HybridAuth configuration not found. Please place it into this file: {$configFile}");
     }
     return $config;
 }
Пример #17
0
 /**
  * @param \Zend_Controller_Request_Abstract $request
  * @return bool|void
  */
 public function routeStartup(\Zend_Controller_Request_Abstract $request)
 {
     $this->conf = \Pimcore\Config::getSystemConfig();
     if ($request->getParam('disable_less_compiler') || $_COOKIE["disable_less_compiler"]) {
         return $this->disable();
     }
     if (!$this->conf->outputfilters) {
         return $this->disable();
     }
     if (!$this->conf->outputfilters->less) {
         return $this->disable();
     }
 }
Пример #18
0
 /**
  * @param bool $raw
  * @param bool $writeOnly
  * @return Wrapper|\Zend_Db_Adapter_Abstract
  * @throws \Exception
  * @throws \Zend_Db_Profiler_Exception
  */
 public static function getConnection($raw = false, $writeOnly = false)
 {
     // just return the wrapper (for compatibility reasons)
     // the wrapper itself get's then the connection using $raw = true
     if (!$raw) {
         return new Wrapper();
     }
     $charset = "UTF8";
     // explicit set charset for connection (to the adapter)
     $config = Config::getSystemConfig()->database->toArray();
     // write only handling
     if ($writeOnly && isset($config["writeOnly"])) {
         // overwrite params with write only configuration
         $config["params"] = $config["writeOnly"]["params"];
     } else {
         if ($writeOnly) {
             throw new \Exception("writeOnly connection is requested but not configured");
         }
     }
     $config["params"]["charset"] = $charset;
     try {
         $db = \Zend_Db::factory($config["adapter"], $config["params"]);
         $db->query("SET NAMES " . $charset);
     } catch (\Exception $e) {
         \Logger::emerg($e);
         \Pimcore\Tool::exitWithError("Database Error! See debug.log for details");
     }
     // try to set innodb as default storage-engine
     try {
         $db->query("SET storage_engine=InnoDB;");
     } catch (\Exception $e) {
         \Logger::warn($e);
     }
     // try to set mysql mode
     try {
         $db->query("SET sql_mode = '';");
     } catch (\Exception $e) {
         \Logger::warn($e);
     }
     $connectionId = $db->fetchOne("SELECT CONNECTION_ID()");
     // enable the db-profiler if the devmode is on and there is no custom profiler set (eg. in system.xml)
     if (PIMCORE_DEVMODE && !$db->getProfiler()->getEnabled() || array_key_exists("pimcore_log", $_REQUEST) && \Pimcore::inDebugMode()) {
         $profiler = new \Pimcore\Db\Profiler('All DB Queries');
         $profiler->setEnabled(true);
         $profiler->setConnectionId($connectionId);
         $db->setProfiler($profiler);
     }
     \Logger::debug(get_class($db) . ": Successfully established connection to MySQL-Server, Process-ID: " . $connectionId);
     return $db;
 }
Пример #19
0
 public function init()
 {
     parent::init();
     if (is_file(\Pimcore\Config::locateConfigFile("system.php"))) {
         // session authentication, only possible if user is logged in
         $user = \Pimcore\Tool\Authentication::authenticateSession();
         if (!$user instanceof User) {
             die("Authentication failed!<br />If you don't have access to the admin interface any more, and you want to find out if the server configuration matches the requirements you have to rename the the system.php for the time of the check.");
         }
     } elseif ($this->getParam("mysql_adapter")) {
     } else {
         die("Not possible... no database settings given.<br />Parameters: mysql_adapter,mysql_host,mysql_username,mysql_password,mysql_database");
     }
 }
Пример #20
0
 /**
  * @param $id
  * @param bool $create
  * @param bool $returnIdIfEmpty
  * @param null $language
  * @return array
  * @throws \Exception
  * @throws \Zend_Exception
  */
 public static function getByKeyLocalized($id, $create = false, $returnIdIfEmpty = false, $language = null)
 {
     if ($user = Tool\Admin::getCurrentUser()) {
         $language = $user->getLanguage();
     } elseif ($user = Tool\Authentication::authenticateSession()) {
         $language = $user->getLanguage();
     } elseif (\Zend_Registry::isRegistered("Zend_Locale")) {
         $language = (string) \Zend_Registry::get("Zend_Locale");
     }
     if (!in_array($language, Tool\Admin::getLanguages())) {
         $config = \Pimcore\Config::getSystemConfig();
         $language = $config->general->language;
     }
     return self::getByKey($id, $create, $returnIdIfEmpty)->getTranslation($language);
 }
Пример #21
0
 public static function getInstance()
 {
     if (!self::$instance) {
         if (\Pimcore\Tool::classExists("\\Elements\\Logging\\Log")) {
             $logger = new \Elements\Logging\Log();
             $logger->addWriter(new \Elements\Logging\Writer\LogWriterDb(\Zend_Log::DEBUG));
             $logger->addWriter(new \Zend_Log_Writer_Stream(PIMCORE_WEBSITE_PATH . "/var/log/trustedshop.log"));
             $systemConfig = \Pimcore\Config::getSystemConfig();
             $debugAddresses = explode(',', $systemConfig->email->debug->emailaddresses);
             $logger->addWriter(new \Elements\Logging\Writer\LogWriterMail($debugAddresses, "TrustedShop-Importer", "", \Zend_Log::ERR));
             self::$instance = $logger;
         }
     }
     return self::$instance;
 }
Пример #22
0
 public function init()
 {
     parent::init();
     $maxExecutionTime = 300;
     @ini_set("max_execution_time", $maxExecutionTime);
     set_time_limit($maxExecutionTime);
     error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
     @ini_set("display_errors", "On");
     $front = \Zend_Controller_Front::getInstance();
     $front->throwExceptions(true);
     \Zend_Controller_Action_HelperBroker::addPrefix('Pimcore_Controller_Action_Helper');
     if (is_file(\Pimcore\Config::locateConfigFile("system.php"))) {
         $this->redirect("/admin");
     }
 }
Пример #23
0
 /**
  *
  */
 protected function update()
 {
     $oldPath = $this->getDao()->getCurrentFullPath();
     parent::update();
     $config = \Pimcore\Config::getSystemConfig();
     if ($oldPath && $config->documents->createredirectwhenmoved && $oldPath != $this->getFullPath()) {
         // create redirect for old path
         $redirect = new Redirect();
         $redirect->setTarget($this->getId());
         $redirect->setSource("@" . $oldPath . "/?@");
         $redirect->setStatusCode(301);
         $redirect->setExpiry(time() + 86400 * 60);
         // this entry is removed automatically after 60 days
         $redirect->save();
     }
 }
Пример #24
0
 /**
  * @param \Zend_Controller_Request_Abstract $request
  */
 public function routeStartup(\Zend_Controller_Request_Abstract $request)
 {
     $conf = \Pimcore\Config::getReportConfig();
     if (!is_null($conf->webmastertools) && isset($conf->webmastertools->sites)) {
         $sites = $conf->webmastertools->sites->toArray();
         if (is_array($sites)) {
             foreach ($sites as $site) {
                 if ($site["verification"]) {
                     if ($request->getRequestUri() == "/" . $site["verification"]) {
                         echo "google-site-verification: " . $site["verification"];
                         exit;
                     }
                 }
             }
         }
     }
 }
Пример #25
0
 public function getProcessingOptions()
 {
     include_once 'Pimcore/Web2Print/Processor/api/v' . Config::getWeb2PrintConfig()->get('pdfreactorVersion', '8.0') . '/PDFreactor.class.php';
     $options = [];
     $options[] = ["name" => "author", "type" => "text", "default" => ""];
     $options[] = ["name" => "title", "type" => "text", "default" => ""];
     $options[] = ["name" => "printermarks", "type" => "bool", "default" => ""];
     $options[] = ["name" => "links", "type" => "bool", "default" => true];
     $options[] = ["name" => "bookmarks", "type" => "bool", "default" => true];
     $options[] = ["name" => "tags", "type" => "bool", "default" => true];
     $options[] = ["name" => "javaScriptMode", "type" => "select", "values" => [\JavaScriptMode::ENABLED, \JavaScriptMode::DISABLED, \JavaScriptMode::ENABLED_NO_LAYOUT], "default" => \JavaScriptMode::ENABLED];
     $options[] = ["name" => "viewerPreference", "type" => "select", "values" => [\ViewerPreferences::PAGE_LAYOUT_SINGLE_PAGE, \ViewerPreferences::PAGE_LAYOUT_TWO_COLUMN_LEFT, \ViewerPreferences::PAGE_LAYOUT_TWO_COLUMN_RIGHT], "default" => \ViewerPreferences::PAGE_LAYOUT_SINGLE_PAGE];
     $options[] = ["name" => "colorspace", "type" => "select", "values" => [\ColorSpace::CMYK, \ColorSpace::RGB], "default" => \ColorSpace::CMYK];
     $options[] = ["name" => "encryption", "type" => "select", "values" => [\Encryption::NONE, \Encryption::TYPE_40, \Encryption::TYPE_128], "default" => \Encryption::NONE];
     $options[] = ["name" => "loglevel", "type" => "select", "values" => [\LogLevel::FATAL, \LogLevel::WARN, \LogLevel::INFO, \LogLevel::DEBUG, \LogLevel::PERFORMANCE], "default" => \LogLevel::FATAL];
     return $options;
 }
Пример #26
0
 /**
  * @return bool
  */
 public static function getWkhtmltoimageBinary()
 {
     if (Config::getSystemConfig()->documents->wkhtmltoimage) {
         if (@is_executable(Config::getSystemConfig()->documents->wkhtmltoimage)) {
             return (string) Config::getSystemConfig()->documents->wkhtmltoimage;
         } else {
             \Logger::critical("wkhtmltoimage binary: " . Config::getSystemConfig()->documents->wkhtmltoimage . " is not executable");
         }
     }
     $paths = array("/usr/bin/wkhtmltoimage-amd64", "/usr/local/bin/wkhtmltoimage-amd64", "/bin/wkhtmltoimage-amd64", "/usr/bin/wkhtmltoimage", "/usr/local/bin/wkhtmltoimage", "/bin/wkhtmltoimage", realpath(PIMCORE_DOCUMENT_ROOT . "/../wkhtmltox/wkhtmltoimage.exe"));
     foreach ($paths as $path) {
         if (@is_executable($path)) {
             return $path;
         }
     }
     return false;
 }
Пример #27
0
 public function saveAction()
 {
     if ($this->getParam("id")) {
         $page = Document\Printpage::getById($this->getParam("id"));
         $page = $this->getLatestVersion($page);
         $page->setUserModification($this->getUser()->getId());
         // save to session
         $key = "document_" . $this->getParam("id");
         $session = new \Zend_Session_Namespace("pimcore_documents");
         $session->{$key} = $page;
         if ($this->getParam("task") == "unpublish") {
             $page->setPublished(false);
         }
         if ($this->getParam("task") == "publish") {
             $page->setPublished(true);
         }
         // only save when publish or unpublish
         if ($this->getParam("task") == "publish" && $page->isAllowed("publish") or $this->getParam("task") == "unpublish" && $page->isAllowed("unpublish")) {
             //check, if to cleanup existing elements of document
             $config = Config::getWeb2PrintConfig();
             if ($config->generalDocumentSaveMode == "cleanup") {
                 $page->setElements([]);
             }
             $this->setValuesToDocument($page);
             try {
                 $page->save();
                 $this->_helper->json(["success" => true]);
             } catch (\Exception $e) {
                 Logger::err($e);
                 $this->_helper->json(["success" => false, "message" => $e->getMessage()]);
             }
         } else {
             if ($page->isAllowed("save")) {
                 $this->setValuesToDocument($page);
                 try {
                     $page->saveVersion();
                     $this->_helper->json(["success" => true]);
                 } catch (\Exception $e) {
                     Logger::err($e);
                     $this->_helper->json(["success" => false, "message" => $e->getMessage()]);
                 }
             }
         }
     }
     $this->_helper->json(false);
 }
Пример #28
0
    /**
     *
     */
    public function dispatchLoopShutdown()
    {
        if (!Tool::isHtmlResponse($this->getResponse())) {
            return;
        }
        $siteKey = \Pimcore\Tool\Frontend::getSiteKey();
        $reportConfig = \Pimcore\Config::getReportConfig();
        if ($this->enabled && isset($reportConfig->tagmanager->sites->{$siteKey}->containerId)) {
            $containerId = $reportConfig->tagmanager->sites->{$siteKey}->containerId;
            if ($containerId) {
                $codeHead = <<<CODE


<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{$containerId}');</script>
<!-- End Google Tag Manager -->


CODE;
                $codeBody = <<<CODE


<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={$containerId}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->


CODE;
                $body = $this->getResponse()->getBody();
                // search for the end <head> tag, and insert the google tag manager code before
                // this method is much faster than using simple_html_dom and uses less memory
                $headEndPosition = stripos($body, "</head>");
                if ($headEndPosition !== false) {
                    $body = substr_replace($body, $codeHead . "</head>", $headEndPosition, 7);
                }
                // insert code after the opening <body> tag
                $body = preg_replace("@<body(>|.*?[^?]>)@", "<body\$1\n\n" . $codeBody, $body);
                $this->getResponse()->setBody($body);
            }
        }
    }
Пример #29
0
 /**
  * @return mixed
  * @throws \Exception
  */
 public static function getPhpCli()
 {
     if (Config::getSystemConfig()->general->php_cli) {
         if (@is_executable(Config::getSystemConfig()->general->php_cli)) {
             return (string) Config::getSystemConfig()->general->php_cli;
         } else {
             \Logger::critical("PHP-CLI binary: " . Config::getSystemConfig()->general->php_cli . " is not executable");
         }
     }
     $paths = array("/usr/bin/php", "/usr/local/bin/php", "/usr/local/zend/bin/php", "/bin/php", realpath(PIMCORE_DOCUMENT_ROOT . "/../php/php.exe"));
     foreach ($paths as $path) {
         if (@is_executable($path)) {
             return $path;
         }
     }
     throw new \Exception("No php executable found, please configure the correct path in the system settings");
 }
Пример #30
0
 /**
  * @return mixed
  * @throws \Exception
  */
 public static function getFfmpegCli()
 {
     $ffmpegPath = \Pimcore\Config::getSystemConfig()->assets->ffmpeg;
     if ($ffmpegPath) {
         if (@is_executable($ffmpegPath)) {
             return $ffmpegPath;
         } else {
             \Logger::critical("FFMPEG binary: " . $ffmpegPath . " is not executable");
         }
     }
     $paths = array("/usr/local/bin/ffmpeg", "/usr/bin/ffmpeg", "/bin/ffmpeg", realpath(PIMCORE_DOCUMENT_ROOT . "/../ffmpeg/bin/ffmpeg.exe"));
     foreach ($paths as $path) {
         if (@is_executable($path)) {
             return $path;
         }
     }
     throw new \Exception("No ffmpeg executable found, please configure the correct path in the system settings");
 }