fix cs
This commit is contained in:
@@ -138,4 +138,4 @@ class TlogDestinationFile extends AbstractTlogDestination
|
||||
|
||||
$this->fh = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,27 +25,29 @@ namespace Thelia\Log\Destination;
|
||||
|
||||
use Thelia\Log\AbstractTlogDestination;
|
||||
|
||||
class TlogDestinationJavascriptConsole extends AbstractTlogDestination {
|
||||
class TlogDestinationJavascriptConsole extends AbstractTlogDestination
|
||||
{
|
||||
public function getTitle()
|
||||
{
|
||||
return "Browser's Javascript console";
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
return "Browser's Javascript console";
|
||||
}
|
||||
public function getDescription()
|
||||
{
|
||||
return "The Thelia logs are displayed in your browser's Javascript console.";
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return "The Thelia logs are displayed in your browser's Javascript console.";
|
||||
}
|
||||
public function write(&$res)
|
||||
{
|
||||
$content = '<script>try {'."\n";
|
||||
|
||||
public function write(&$res) {
|
||||
foreach ($this->_logs as $line) {
|
||||
$content .= "console.log('".str_replace("'", "\\'", str_replace(array("\r\n", "\r", "\n"), '\\n', $line))."');\n";
|
||||
}
|
||||
|
||||
$content = '<script>try {'."\n";
|
||||
$content .= '} catch (ex) { alert("Les logs Thelia ne peuvent être affichés dans la console javascript:" + ex); }</script>'."\n";
|
||||
|
||||
foreach($this->_logs as $line) {
|
||||
$content .= "console.log('".str_replace("'", "\\'", str_replace(array("\r\n", "\r", "\n"), '\\n', $line))."');\n";
|
||||
}
|
||||
|
||||
$content .= '} catch(ex) { alert("Les logs Thelia ne peuvent être affichés dans la console javascript:" + ex); }</script>'."\n";
|
||||
|
||||
if (preg_match("|</body>|i", $res))
|
||||
$res = preg_replace("|</body>|i", "$content</html>", $res);
|
||||
if (preg_match("|</body>|i", $res))
|
||||
$res = preg_replace("|</body>|i", "$content</html>", $res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,86 +26,88 @@ namespace Thelia\Log\Destination;
|
||||
use Thelia\Log\AbstractTlogDestination;
|
||||
use Thelia\Log\TlogDestinationConfig;
|
||||
|
||||
class TlogDestinationPopup extends AbstractTlogDestination {
|
||||
class TlogDestinationPopup extends AbstractTlogDestination
|
||||
{
|
||||
// Nom des variables de configuration
|
||||
// ----------------------------------
|
||||
const VAR_POPUP_WIDTH = "tlog_destinationpopup_width";
|
||||
const VALEUR_POPUP_WIDTH_DEFAUT = "600";
|
||||
|
||||
// Nom des variables de configuration
|
||||
// ----------------------------------
|
||||
const VAR_POPUP_WIDTH = "tlog_destinationpopup_width";
|
||||
const VALEUR_POPUP_WIDTH_DEFAUT = "600";
|
||||
const VAR_POPUP_HEIGHT = "tlog_destinationpopup_height";
|
||||
const VALEUR_POPUP_HEIGHT_DEFAUT = "600";
|
||||
|
||||
const VAR_POPUP_HEIGHT = "tlog_destinationpopup_height";
|
||||
const VALEUR_POPUP_HEIGHT_DEFAUT = "600";
|
||||
const VAR_POPUP_TPL = "tlog_destinationpopup_template";
|
||||
// Ce fichier doit se trouver dans le même répertoire que TlogDestinationPopup.class.php
|
||||
const VALEUR_POPUP_TPL_DEFAUT = "TlogDestinationPopup.tpl";
|
||||
|
||||
const VAR_POPUP_TPL = "tlog_destinationpopup_template";
|
||||
// Ce fichier doit se trouver dans le même répertoire que TlogDestinationPopup.class.php
|
||||
const VALEUR_POPUP_TPL_DEFAUT = "TlogDestinationPopup.tpl";
|
||||
public function getTitle()
|
||||
{
|
||||
return "Javascript popup window";
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
return "Javascript popup window";
|
||||
}
|
||||
public function getDescription()
|
||||
{
|
||||
return "Display logs in a popup window, separate from the main window .";
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return "Display logs in a popup window, separate from the main window .";
|
||||
}
|
||||
public function getConfigs()
|
||||
{
|
||||
return array(
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_TPL,
|
||||
"Popup windows template",
|
||||
"Put #LOGTEXT in the template text where you want to display logs..",
|
||||
file_get_contents(__DIR__.DS. self::VALEUR_POPUP_TPL_DEFAUT),
|
||||
TlogDestinationConfig::TYPE_TEXTAREA
|
||||
),
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_HEIGHT,
|
||||
"Height of the popup window",
|
||||
"In pixels",
|
||||
self::VALEUR_POPUP_HEIGHT_DEFAUT,
|
||||
TlogDestinationConfig::TYPE_TEXTFIELD
|
||||
),
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_WIDTH,
|
||||
"Width of the popup window",
|
||||
"In pixels",
|
||||
self::VALEUR_POPUP_WIDTH_DEFAUT,
|
||||
TlogDestinationConfig::TYPE_TEXTFIELD
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getConfigs() {
|
||||
return array(
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_TPL,
|
||||
"Popup windows template",
|
||||
"Put #LOGTEXT in the template text where you want to display logs..",
|
||||
file_get_contents(__DIR__.DS. self::VALEUR_POPUP_TPL_DEFAUT),
|
||||
TlogDestinationConfig::TYPE_TEXTAREA
|
||||
),
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_HEIGHT,
|
||||
"Height of the popup window",
|
||||
"In pixels",
|
||||
self::VALEUR_POPUP_HEIGHT_DEFAUT,
|
||||
TlogDestinationConfig::TYPE_TEXTFIELD
|
||||
),
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_WIDTH,
|
||||
"Width of the popup window",
|
||||
"In pixels",
|
||||
self::VALEUR_POPUP_WIDTH_DEFAUT,
|
||||
TlogDestinationConfig::TYPE_TEXTFIELD
|
||||
)
|
||||
);
|
||||
}
|
||||
public function write(&$res)
|
||||
{
|
||||
$content = ""; $count = 1;
|
||||
|
||||
public function write(&$res) {
|
||||
foreach ($this->_logs as $line) {
|
||||
$content .= "<div class=\"".($count++ % 2 ? "paire" : "impaire")."\">".htmlspecialchars($line)."</div>";
|
||||
}
|
||||
|
||||
$content = ""; $count = 1;
|
||||
$tpl = $this->getConfig(self::VAR_POPUP_TPL);
|
||||
|
||||
foreach($this->_logs as $line) {
|
||||
$content .= "<div class=\"".($count++ % 2 ? "paire" : "impaire")."\">".htmlspecialchars($line)."</div>";
|
||||
}
|
||||
$tpl = str_replace('#LOGTEXT', $content, $tpl);
|
||||
$tpl = str_replace(array("\r\n", "\r", "\n"), '\\n', $tpl);
|
||||
|
||||
$tpl = $this->getConfig(self::VAR_POPUP_TPL);
|
||||
$wop = sprintf('
|
||||
<script>
|
||||
_thelia_console = window.open("","thelia_console","width=%s,height=%s,resizable,scrollbars=yes");
|
||||
if (_thelia_console == null) {
|
||||
alert("The log popup window could not be opened. Please disable your popup blocker for this site.");
|
||||
} else {
|
||||
_thelia_console.document.write("%s");
|
||||
_thelia_console.document.close();
|
||||
}
|
||||
</script>',
|
||||
$this->getConfig(self::VAR_POPUP_WIDTH),
|
||||
$this->getConfig(self::VAR_POPUP_HEIGHT),
|
||||
str_replace('"', '\\"', $tpl)
|
||||
);
|
||||
|
||||
$tpl = str_replace('#LOGTEXT', $content, $tpl);
|
||||
$tpl = str_replace(array("\r\n", "\r", "\n"), '\\n', $tpl);
|
||||
|
||||
$wop = sprintf('
|
||||
<script>
|
||||
_thelia_console = window.open("","thelia_console","width=%s,height=%s,resizable,scrollbars=yes");
|
||||
if (_thelia_console == null) {
|
||||
alert("The log popup window could not be opened. Please disable your popup blocker for this site.");
|
||||
}
|
||||
else {
|
||||
_thelia_console.document.write("%s");
|
||||
_thelia_console.document.close();
|
||||
}
|
||||
</script>',
|
||||
$this->getConfig(self::VAR_POPUP_WIDTH),
|
||||
$this->getConfig(self::VAR_POPUP_HEIGHT),
|
||||
str_replace('"', '\\"', $tpl)
|
||||
);
|
||||
|
||||
if (preg_match("|</body>|i", $res))
|
||||
$res = preg_replace("|</body>|i", "$wop\n</body>", $res);
|
||||
else
|
||||
$res .= $wop;
|
||||
if (preg_match("|</body>|i", $res))
|
||||
$res = preg_replace("|</body>|i", "$wop\n</body>", $res);
|
||||
else
|
||||
$res .= $wop;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,8 @@ class Tlog Implements LoggerInterface
|
||||
*
|
||||
* @return array of directories
|
||||
*/
|
||||
public function getDestinationsDirectories() {
|
||||
public function getDestinationsDirectories()
|
||||
{
|
||||
return $this->dir_destinations;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Log;
|
||||
use Thelia\Model\Config;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
class TlogDestinationConfig
|
||||
|
||||
Reference in New Issue
Block a user