本文整理汇总了PHP中Pimcore::inDebugMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Pimcore::inDebugMode方法的具体用法?PHP Pimcore::inDebugMode怎么用?PHP Pimcore::inDebugMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore
的用法示例。
在下文中一共展示了Pimcore::inDebugMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatchLoopShutdown
public function dispatchLoopShutdown()
{
if (!Tool::isHtmlResponse($this->getResponse())) {
return;
}
if (!Tool::useFrontendOutputFilters($this->getRequest()) && !$this->getRequest()->getParam("pimcore_preview")) {
return;
}
if (\Pimcore::inDebugMode()) {
return;
}
if ($this->enabled) {
include_once "simple_html_dom.php";
$body = $this->getResponse()->getBody();
$html = str_get_html($body);
if ($html) {
$html = $this->searchForScriptSrcAndReplace($html);
$html = $this->searchForInlineScriptAndReplace($html);
$body = $html->save();
$html->clear();
unset($html);
}
$this->getResponse()->setBody($body);
}
}
示例2: dispatchLoopShutdown
public function dispatchLoopShutdown()
{
if (!Tool::isHtmlResponse($this->getResponse())) {
return;
}
if (\Pimcore::inDebugMode()) {
return;
}
if (!Tool::useFrontendOutputFilters($this->getRequest()) && !$this->getRequest()->getParam("pimcore_preview")) {
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 {
$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);
if ($style->media && $style->media != "all") {
$content = "@media " . $style->media . " {" . $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" type="text/css" href="' . str_replace(PIMCORE_DOCUMENT_ROOT, "", $stylesheetPath) . '" />' . "\n";
}
$body = $html->save();
$html->clear();
unset($html);
$this->getResponse()->setBody($body);
}
}
}
示例3: includeTemplateFile
/**
* @param string $script
*/
public function includeTemplateFile($script)
{
$showTemplatePaths = isset($_REQUEST["pimcore_show_template_paths"]);
if ($showTemplatePaths && \Pimcore::inDebugMode()) {
echo "\n<!-- start template inclusion: " . $script . " -->\n";
}
include $script;
if ($showTemplatePaths && \Pimcore::inDebugMode()) {
echo "\n<!-- finished template inclusion: " . $script . " -->\n";
}
}
示例4: getConnection
/**
* @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;
}
示例5: init
/**
* @throws \Zend_Controller_Router_Exception
*/
public function init()
{
// this is only executed once per request (first request)
if (self::$isInitial) {
\Pimcore::getEventManager()->trigger("frontend.controller.preInit", $this);
}
parent::init();
// log exceptions if handled by error_handler
$this->checkForErrors();
// general definitions
if (self::$isInitial) {
\Pimcore::unsetAdminMode();
Document::setHideUnpublished(true);
Object\AbstractObject::setHideUnpublished(true);
Object\AbstractObject::setGetInheritedValues(true);
Object\Localizedfield::setGetFallbackValues(true);
}
// assign variables
$this->view->controller = $this;
// init website config
$config = Config::getWebsiteConfig();
$this->config = $config;
$this->view->config = $config;
$document = $this->getParam("document");
if (!$document instanceof Document) {
\Zend_Registry::set("pimcore_editmode", false);
$this->editmode = false;
$this->view->editmode = false;
self::$isInitial = false;
// check for a locale first, and set it if available
if ($this->getParam("pimcore_parentDocument")) {
// this is a special exception for renderlets in editmode (ajax request), because they depend on the locale of the parent document
// otherwise there'll be notices like: Notice: 'No translation for the language 'XX' available.'
if ($parentDocument = Document::getById($this->getParam("pimcore_parentDocument"))) {
if ($parentDocument->getProperty("language")) {
$this->setLocaleFromDocument($parentDocument->getProperty("language"));
}
}
}
// no document available, continue, ...
return;
} else {
$this->setDocument($document);
// register global locale if the document has the system property "language"
if ($this->getDocument()->getProperty("language")) {
$this->setLocaleFromDocument($this->getDocument()->getProperty("language"));
}
if (self::$isInitial) {
// append meta-data to the headMeta() view helper, if it is a document-request
if (!Model\Staticroute::getCurrentRoute() && $this->getDocument() instanceof Document\Page) {
if (is_array($this->getDocument()->getMetaData())) {
foreach ($this->getDocument()->getMetaData() as $meta) {
// only name
if (!empty($meta["idName"]) && !empty($meta["idValue"]) && !empty($meta["contentValue"])) {
$method = "append" . ucfirst($meta["idName"]);
$this->view->headMeta()->{$method}($meta["idValue"], $meta["contentValue"]);
}
}
}
}
}
}
// this is only executed once per request (first request)
if (self::$isInitial) {
// contains the logged in user if necessary
$user = null;
// default is to set the editmode to false, is enabled later if necessary
\Zend_Registry::set("pimcore_editmode", false);
if (Tool::isFrontentRequestByAdmin()) {
$this->disableBrowserCache();
// start admin session & get logged in user
$user = Authentication::authenticateSession();
}
if (\Pimcore::inDebugMode()) {
$this->disableBrowserCache();
}
if (!$this->document->isPublished()) {
if (Tool::isFrontentRequestByAdmin()) {
if (!$user) {
throw new \Zend_Controller_Router_Exception("access denied for " . $this->document->getFullPath());
}
} else {
throw new \Zend_Controller_Router_Exception("access denied for " . $this->document->getFullPath());
}
}
// logged in users only
if ($user) {
// set the user to registry so that it is available via \Pimcore\Tool\Admin::getCurrentUser();
\Zend_Registry::set("pimcore_admin_user", $user);
// document editmode
if ($this->getParam("pimcore_editmode")) {
\Zend_Registry::set("pimcore_editmode", true);
// check if there is the document in the session
$docKey = "document_" . $this->getDocument()->getId();
$docSession = Session::getReadOnly("pimcore_documents");
if ($docSession->{$docKey}) {
// if there is a document in the session use it
//.........这里部分代码省略.........
示例6: routeStartup
/**
* @param \Zend_Controller_Request_Abstract $request
* @return bool|void
*/
public function routeStartup(\Zend_Controller_Request_Abstract $request)
{
$requestUri = $request->getRequestUri();
$excludePatterns = array();
// only enable GET method
if (!$request->isGet()) {
return $this->disable();
}
// disable the output-cache if browser wants the most recent version
// unfortunately only Chrome + Firefox if not using SSL
if (!$request->isSecure()) {
if (isset($_SERVER["HTTP_CACHE_CONTROL"]) && $_SERVER["HTTP_CACHE_CONTROL"] == "no-cache") {
return $this->disable("HTTP Header Cache-Control: no-cache was sent");
}
if (isset($_SERVER["HTTP_PRAGMA"]) && $_SERVER["HTTP_PRAGMA"] == "no-cache") {
return $this->disable("HTTP Header Pragma: no-cache was sent");
}
}
try {
$conf = \Pimcore\Config::getSystemConfig();
if ($conf->cache) {
$conf = $conf->cache;
if (!$conf->enabled) {
return $this->disable();
}
if (\Pimcore::inDebugMode()) {
return $this->disable("in debug mode");
}
if ($conf->lifetime) {
$this->setLifetime((int) $conf->lifetime);
}
if ($conf->excludePatterns) {
$confExcludePatterns = explode(",", $conf->excludePatterns);
if (!empty($confExcludePatterns)) {
$excludePatterns = $confExcludePatterns;
}
}
if ($conf->excludeCookie) {
$cookies = explode(",", strval($conf->excludeCookie));
foreach ($cookies as $cookie) {
if (!empty($cookie) && isset($_COOKIE[trim($cookie)])) {
return $this->disable("exclude cookie in system-settings matches");
}
}
}
// output-cache is always disabled when logged in at the admin ui
if (isset($_COOKIE["pimcore_admin_sid"])) {
return $this->disable("backend user is logged in");
}
} else {
return $this->disable();
}
} catch (\Exception $e) {
\Logger::error($e);
return $this->disable("ERROR: Exception (see debug.log)");
}
foreach ($excludePatterns as $pattern) {
if (@preg_match($pattern, $requestUri)) {
return $this->disable("exclude path pattern in system-settings matches");
}
}
$deviceDetector = Tool\DeviceDetector::getInstance();
$device = $deviceDetector->getDevice();
$deviceDetector->setWasUsed(false);
$this->defaultCacheKey = "output_" . md5($request->getHttpHost() . $requestUri);
$cacheKeys = [$this->defaultCacheKey . "_" . $device, $this->defaultCacheKey];
$cacheItem = null;
foreach ($cacheKeys as $cacheKey) {
$cacheItem = CacheManager::load($cacheKey, true);
if ($cacheItem) {
break;
}
}
if (is_array($cacheItem) && !empty($cacheItem)) {
header("X-Pimcore-Output-Cache-Tag: " . $cacheKey, true, 200);
header("X-Pimcore-Output-Cache-Date: " . $cacheItem["date"]);
foreach ($cacheItem["rawHeaders"] as $header) {
header($header);
}
foreach ($cacheItem["headers"] as $header) {
header($header['name'] . ': ' . $header['value'], $header['replace']);
}
echo $cacheItem["content"];
exit;
} else {
// set headers to tell the client to not cache the contents
// this can/will be overwritten in $this->dispatchLoopShutdown() if the cache is enabled
$date = new \Zend_Date(1);
$this->getResponse()->setHeader("Expires", $date->get(\Zend_Date::RFC_1123), true);
$this->getResponse()->setHeader("Cache-Control", "max-age=0, no-cache", true);
}
}
示例7: frontend
/**
* @see Document\Tag\TagInterface::frontend
* @return string
*/
public function frontend()
{
if ($this->getView() instanceof \Zend_View) {
try {
if ($this->snippet instanceof Document\Snippet) {
$params = $this->options;
$params["document"] = $this->snippet;
if ($this->snippet->isPublished()) {
// check if output-cache is enabled, if so, we're also using the cache here
$cacheKey = null;
if ($cacheConfig = \Pimcore\Tool\Frontend::isOutputCacheEnabled()) {
// cleanup params to avoid serializing Element\ElementInterface objects
$cacheParams = $params;
array_walk($cacheParams, function (&$value, $key) {
if ($value instanceof Model\Element\ElementInterface) {
$value = $value->getId();
}
});
$cacheKey = "tag_snippet__" . md5(serialize($cacheParams));
if ($content = Cache::load($cacheKey)) {
return $content;
}
}
$content = $this->getView()->action($this->snippet->getAction(), $this->snippet->getController(), $this->snippet->getModule(), $params);
// write contents to the cache, if output-cache is enabled
if ($cacheConfig) {
Cache::save($content, $cacheKey, ["output", "output_inline"], $cacheConfig["lifetime"]);
}
return $content;
}
return "";
}
} catch (\Exception $e) {
if (\Pimcore::inDebugMode()) {
return "ERROR: " . $e->getMessage() . " (for details see debug.log)";
}
\Logger::error($e);
}
} else {
return null;
}
}
示例8: frontend
/**
* @see Document\Tag\TagInterface::frontend
* @return string
*/
public function frontend()
{
if (!$this->options["controller"] && !$this->options["action"]) {
$this->options["controller"] = Config::getSystemConfig()->documents->default_controller;
$this->options["action"] = Config::getSystemConfig()->documents->default_action;
}
$document = null;
if ($this->o instanceof Document) {
$document = $this->o;
}
if (method_exists($this->o, "isPublished")) {
if (!$this->o->isPublished()) {
return "";
}
}
if ($this->o instanceof Element\ElementInterface) {
$blockparams = array("action", "controller", "module", "template");
$params = array("template" => isset($this->options["template"]) ? $this->options["template"] : null, "object" => $this->o, "element" => $this->o, "document" => $document, "id" => $this->id, "type" => $this->type, "subtype" => $this->subtype, "pimcore_request_source" => "renderlet", "disableBlockClearing" => true);
foreach ($this->options as $key => $value) {
if (!array_key_exists($key, $params) && !in_array($key, $blockparams)) {
$params[$key] = $value;
}
}
if ($this->getView() != null) {
try {
$content = $this->getView()->action($this->options["action"], $this->options["controller"], isset($this->options["module"]) ? $this->options["module"] : null, $params);
// we need to add a component id to all first level html containers
$componentId = 'document:' . $this->getDocumentId() . '.type:tag-renderlet.name:' . $this->type . "-" . $this->subtype . "-" . $this->id;
$content = \Pimcore\Tool\Frontend::addComponentIdToHtml($content, $componentId);
return $content;
} catch (\Exception $e) {
if (\Pimcore::inDebugMode()) {
return "ERROR: " . $e->getMessage() . " (for details see debug.log)";
}
\Logger::error($e);
}
}
}
}
示例9:
?>
",
maintenance_active: <?php
echo $this->maintenance_enabled;
?>
,
maintenance_mode: <?php
echo \Pimcore\Tool\Admin::isInMaintenanceMode() ? "true" : "false";
?>
,
mail: <?php
echo $this->mail_settings_complete;
?>
,
debug: <?php
echo \Pimcore::inDebugMode() ? "true" : "false";
?>
,
devmode: <?php
echo PIMCORE_DEVMODE ? "true" : "false";
?>
,
google_analytics_enabled: <?php
echo \Zend_Json::encode((bool) \Pimcore\Google\Analytics::isConfigured());
?>
,
google_webmastertools_enabled: <?php
echo \Zend_Json::encode((bool) \Pimcore\Google\Webmastertools::isConfigured());
?>
,
customviews: <?php
示例10: isEnabled
/**
* Checks if Output Cache is enabled in Pimcore.
*
* @return bool
*/
protected function isEnabled()
{
if ($this->config->cache) {
$this->config = $this->config->cache;
if (!$this->config->enabled) {
return false;
}
if (\Pimcore::inDebugMode()) {
return false;
}
}
return true;
}
示例11: array
<?php
$image = $this->image($this->name, array("thumbnail" => "contentImage", "class" => "img-responsive"));
if ($this->editmode) {
echo $image;
} else {
if (Pimcore::inDebugMode()) {
if ($image && $image->getImage() instanceof Asset_Image) {
?>
<img data-width="<?php
echo $image->getImage()->getWidth();
?>
" data-height="<?php
echo $image->getImage()->getHeight();
?>
"
data-text="<?php
echo $image->getImage()->getAlt();
?>
"/>
<?php
} else {
?>
<img src="debug"/>
<?php
}
} else {
echo $image;
}
}
示例12: __toString
/**
* direct output to the frontend
*
* @return string
*/
public function __toString()
{
$return = "";
try {
if ($this->editmode) {
$return = $this->admin();
} else {
$return = $this->frontend();
}
} catch (\Exception $e) {
if (\Pimcore::inDebugMode()) {
// the __toString method isn't allowed to throw exceptions
$return = '<b style="color:#f00">' . $e->getMessage() . '</b><br/>' . $e->getTraceAsString();
}
\Logger::error("to string not possible - " . $e->getMessage());
}
if (is_string($return) || is_numeric($return)) {
// we have to cast to string, because int/float is not auto-converted and throws an exception
return (string) $return;
}
return '';
}
示例13: checkDebugMode
/**
* Checks if the debug mode is enabled in "Settings" -> "System" -> "Debug"
* If the debug mode is enabled, all emails will be sent to the debug email addresses given the system settings
* and the debug information is appended
*
* @return void
*/
protected function checkDebugMode()
{
if (Pimcore::inDebugMode()) {
if (empty(self::$debugEmailAddresses)) {
throw new Exception('No valid debug email address given in "Settings" -> "System" -> "Email Settings"');
}
if ($this->preventDebugInformationAppending != true) {
//adding the debug information to the html email
$html = $this->getBodyHtml();
if ($html instanceof Zend_Mime_Part) {
$rawHtml = $html->getRawContent();
$debugInformation = Pimcore_Helper_Mail::getDebugInformation('html', $this);
$debugInformationStyling = Pimcore_Helper_Mail::getDebugInformationCssStyle();
$rawHtml = preg_replace("!(</\\s*body\\s*>)!is", "{$debugInformation}\\1", $rawHtml);
$rawHtml = preg_replace("!(<\\s*head\\s*>)!is", "\\1{$debugInformationStyling}", $rawHtml);
$this->setBodyHtml($rawHtml);
}
$text = $this->getBodyText();
if ($text instanceof Zend_Mime_Part) {
$rawText = $text->getRawContent();
$debugInformation = Pimcore_Helper_Mail::getDebugInformation('text', $this);
$rawText .= $debugInformation;
$this->setBodyText($rawText);
}
//setting debug subject
$subject = $this->getSubject();
$this->clearSubject();
$this->setSubject('Debug email: ' . $subject);
}
$this->clearRecipients();
$this->addTo(self::$debugEmailAddresses);
}
}
示例14: frontend
/**
* @see Document\Tag\TagInterface::frontend
* @return string
*/
public function frontend()
{
if (!$this->options["controller"] && !$this->options["action"]) {
$this->options["controller"] = Config::getSystemConfig()->documents->default_controller;
$this->options["action"] = Config::getSystemConfig()->documents->default_action;
}
$document = null;
if ($this->o instanceof Document) {
$document = $this->o;
}
if (method_exists($this->o, "isPublished")) {
if (!$this->o->isPublished()) {
return "";
}
}
if ($this->o instanceof Element\ElementInterface) {
$blockparams = ["action", "controller", "module", "template"];
$params = ["template" => isset($this->options["template"]) ? $this->options["template"] : null, "object" => $this->o, "element" => $this->o, "document" => $document, "id" => $this->id, "type" => $this->type, "subtype" => $this->subtype, "pimcore_request_source" => "renderlet", "disableBlockClearing" => true];
foreach ($this->options as $key => $value) {
if (!array_key_exists($key, $params) && !in_array($key, $blockparams)) {
$params[$key] = $value;
}
}
if ($this->getView() != null) {
try {
$content = $this->getView()->action($this->options["action"], $this->options["controller"], isset($this->options["module"]) ? $this->options["module"] : null, $params);
return $content;
} catch (\Exception $e) {
if (\Pimcore::inDebugMode()) {
return "ERROR: " . $e->getMessage() . " (for details see debug.log)";
}
Logger::error($e);
}
}
}
}
示例15: _loadOnce
/**
* @throws \Doctrine\ORM\ORMException
*/
protected function _loadOnce()
{
if (!\Zend_Registry::isRegistered('doctrine.em')) {
$isDevMode = \Pimcore::inDebugMode();
$pluginConfig = $this->_loadConfiguration();
$doctrineConfig = $pluginConfig['doctrine'];
//Connection Settings
if (!empty($doctrineConfig['connection'])) {
$dbParams = $doctrineConfig['connection']['orm_default'];
} else {
$config = Config::getSystemConfig()->toArray();
$params = $config['database']['params'];
// the connection configuration
$dbParams = ['driver' => strtolower($config['database']['adapter']), 'user' => $params['username'], 'password' => $params['password'], 'dbname' => $params['dbname']];
}
//Table Prefix
$evm = new EventManager();
if (!empty($doctrineConfig['table_prefix'])) {
$tablePrefix = new TablePrefix($doctrineConfig['table_prefix']);
$evm->addEventListener(Events::loadClassMetadata, $tablePrefix);
}
//Entity Paths
$paths = ['website/models/Website/Entity/'];
if (is_array($doctrineConfig['paths'])) {
$paths = $doctrineConfig['paths'];
}
$setup = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode, null, null, false);
$em = EntityManager::create($dbParams, $setup, $evm);
$em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
\Zend_Registry::set('doctrine.em', $em);
}
}