Skip to content

Commit

Permalink
debug #C23864 - да е от попъп прозорец
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuseinov committed Aug 20, 2018
1 parent 978297a commit 35b139d
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 46 deletions.
2 changes: 1 addition & 1 deletion cal/Tasks.class.php
Expand Up @@ -3183,7 +3183,7 @@ public function act_New()
$successMsg = 'Благодарим Ви за сигнала';

if ($isReportFromStream) {
echo tr($successMsg);
echo 'OK';
shutdown();
}

Expand Down
4 changes: 2 additions & 2 deletions cms/GalleryDialogWrapper.class.php
Expand Up @@ -86,8 +86,8 @@ public function on_AfterRenderDialog($mvc, &$res, $tpl)
/**
*
*
* @param unknown_type $mvc
* @param unknown_type $tabs
* @param core_Mvc $mvc
* @param array $tabs
*/
public function on_AfterGetGalleryTabsArr($mvc, &$tabs)
{
Expand Down
4 changes: 2 additions & 2 deletions core/Debug.class.php
Expand Up @@ -667,7 +667,7 @@ public static function getDebugPage($state)
$data['errTitle'] .= '|';
}

$data['errTitle'] .= ht::createLink(tr('сигнал'), array('log_Debug', 'report', 'debugFile' => $bName), false, array('title' => 'Изпращане на сигнал към разработчиците на bgERP'));
$data['errTitle'] .= log_Debug::getReportLink($bName, 'сигнал', false);
}

$data['errTitle'] .= '</span>';
Expand Down Expand Up @@ -705,7 +705,7 @@ private static function getErrorPage(&$state)

if (log_Debug::haveRightFor('report') && $state['_debugFileName']) {
$bName = basename($state['_debugFileName'], '.debug');
$state['signal'] = ht::createLink(tr('Сигнал'), array('log_Debug', 'report', 'debugFile' => $bName), false, array('title' => 'Изпращане на сигнал към разработчиците на bgERP', 'ef_icon' => 'img/16/headset.png', 'class' => 'signalLink'));
$state['signal'] = log_Debug::getReportLink($bName, 'Сигнал', 'img/16/headset.png', 'signalLink');
}

$page = $tpl->render($state);
Expand Down
23 changes: 23 additions & 0 deletions core/tpl/Debug.shtml
Expand Up @@ -193,6 +193,29 @@ div.simpleTabsContent.currentTab {
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('3 4={O:"Z",P:"10",9:"11",w:"12",x:"13",r:"14",Q:o(){5(!s.t)y E;5(!s.F)y E;3 b=s.t("G");u(3 i=0;i<b.7;i++){5(b[i].6==4.O){b[i].H("8",4.r+[i]);3 c=b[i].v("8");3 d=b[i].t("15");u(3 j=0;j<d.7;j++){5(d[j].6==4.P){3 a=d[j].t("a");u(3 k=0;k<a.7;k++){a[k].H("8",c+"I"+k);5(4.z(\'A\')){3 e=4.z(\'A\').J("K");3 f=e[1];3 g=e[2];5(a[k].p.p.p.v("8")==4.r+f){5(a[k].v("8")==4.r+f+"I"+g){a[k].6=4.w}q{a[k].6=""}}q{a[0].6=4.w}}q{a[0].6=4.w}a[k].16=o(){4.R(B,\'A\');y E}}}}3 h=b[i].t("G");3 m=0;u(3 l=0;l<h.7;l++){5(h[l].6==4.9){h[l].H("8",c+"L"+[m]);5(4.z(\'A\')){3 e=4.z(\'A\').J("K");3 f=e[1];3 g=e[2];5(h[l].p.v("8")==4.r+f){5(h[l].v("8")==4.r+f+"L"+g){h[l].6=4.9+" "+4.x}q{h[l].6=4.9}}q{h[0].6=4.9+" "+4.x}}q{h[0].6=4.9+" "+4.x}m++}}}}},R:o(a,b){B.S(b);3 c=a.p.p.p.v("8");3 d=c+"I";3 e=a.v("8").T(d,"");3 f=a.p.p.t("a");u(3 n=0;n<f.7;n++){f[n].6=""}a.6=4.w;3 g=s.F(c).t("G");3 h=M U(4.9);u(3 i=0;i<g.7;i++){5(h.17(g[i].6)){g[i].6=4.9}}s.F(c+"L"+e).6=4.9+" "+4.x;3 j=M U(4.r);3 k=c.T(j,"");B.N(b,\'18\'+k+\'K\'+e,1)},N:o(a,b,c){5(c){3 d=M 19();d.1a(d.1b()+(c*1c*V*V*1d));3 e="; 1e="+d.1f()}q 3 e="";s.W=a+"="+b+e+"; 1g=/"},z:o(a){3 b=a+"=";3 d=s.W.J(\';\');u(3 i=0;i<d.7;i++){3 c=d[i];1h(c.1i(0)==\' \')c=c.X(1,c.7);5(c.1j(b)==0)y c.X(b.7,c.7)}y 1k},S:o(a){B.N(a,"",-1)},Y:o(a){3 b=C.D;5(1l C.D!=\'o\'){C.D=a}q{C.D=o(){5(b){b()}a()}}}};4.Y(4.Q);',62,84,'|||var|kmrSimpleTabs|if|className|length|id|sbContentClass|||||||||||||||function|parentNode|else|sbIdPrefix|document|getElementsByTagName|for|getAttribute|sbCurrentNavClass|sbCurrentTabClass|return|readCookie|simpleTabsCookie|this|window|onload|false|getElementById|div|setAttribute|_a_|split|_|_div_|new|createCookie|sbContainerClass|sbNavClass|init|setCurrent|eraseCookie|replace|RegExp|60|cookie|substring|addLoadEvent|simpleTabs|simpleTabsNavigation|simpleTabsContent|current|currentTab|tabber|ul|onclick|test|simpleTabsCookie_|Date|setTime|getTime|24|1000|expires|toGMTString|path|while|charAt|indexOf|null|typeof'.split('|'),0,{}))

// Глобален масив за popup прозорците
popupWindows = new Array();

// Отваря диалогов прозорец
function openWindow(url, name, args) {
// Записваме всички popup прозорци в глобален масив
popupWindows[name] = window.open(url, '_blank', args);

var popup = popupWindows[name];

if (popup) {
// Ако браузърат е Chrome първо блърва главния прозорец,
// а след това фокусира на popUp прозореца
var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if (isChrome && popup.parent) {
popup.parent.blur();
}

// Фокусиране върху новия прозорец
popup.focus();
}
}
</script>
</body>

Expand Down
25 changes: 25 additions & 0 deletions core/tpl/Error.shtml
Expand Up @@ -107,6 +107,31 @@
</table>
</div>
</div>

<script>
// Глобален масив за popup прозорците
popupWindows = new Array();

// Отваря диалогов прозорец
function openWindow(url, name, args) {
// Записваме всички popup прозорци в глобален масив
popupWindows[name] = window.open(url, '_blank', args);

var popup = popupWindows[name];

if (popup) {
// Ако браузърат е Chrome първо блърва главния прозорец,
// а след това фокусира на popUp прозореца
var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if (isChrome && popup.parent) {
popup.parent.blur();
}

// Фокусиране върху новия прозорец
popup.focus();
}
}
</script>
</body>

</html>
4 changes: 2 additions & 2 deletions doc/DialogWrapper.class.php
Expand Up @@ -82,8 +82,8 @@ public function on_AfterRenderDialog($mvc, &$res, $tpl)
/**
*
*
* @param unknown_type $mvc
* @param unknown_type $tabs
* @param core_Mvc $mvc
* @param array $tabs
*/
public function on_AfterGetGalleryTabsArr($mvc, &$tabs)
{
Expand Down
2 changes: 1 addition & 1 deletion doc/Log.class.php
Expand Up @@ -214,7 +214,7 @@ public function prepareAddDocDialog(&$data)
/**
* Задаваме броя на всички елементи
*
* @param oject $data
* @param object $data
*/
public function setLimitAddDocDialogPager(&$data)
{
Expand Down
148 changes: 110 additions & 38 deletions log/Debug.class.php
Expand Up @@ -53,6 +53,50 @@ class log_Debug extends core_Manager
public $loadList = 'plg_SystemWrapper';


/**
* Връща линк към създаване на сигнал от грешката
*
* @param string $debugFile
* @param string $btnName
* @param string $icon
* @param NULL|string $class
*
* @return core_ET
*/
public static function getReportLink($debugFile, $btnName = 'Сигнал', $icon = 'img/16/debug_bug.png', $class = null)
{
$btnName = tr($btnName);

$urlArr = array('log_Debug', 'report', 'debugFile' => $debugFile, 'ret_url' => true);

$url = toUrl($urlArr);

// Ако е мобилен/тесем режим
if (Mode::is('screenMode', 'narrow')) {
// Парамтери към отварянето на прозореца
$args = 'resizable=yes,scrollbars=yes,status=no,location=no,menubar=no,location=no';
} else {
$args = 'width=450,height=600,resizable=yes,scrollbars=yes,status=no,location=no,menubar=no,location=no';
}

$attr = array('onClick' => "openWindow('{$url}', 'bgerp_tracer_report', '{$args}'); return false;", 'title' => 'Изпращане на сигнал към разработчиците на bgERP');

if ($icon) {
$attr['ef_icon'] = $icon;
}

if ($class) {
$attr['class'] = $class;
}

$attr['target'] = '_blank';

$link = ht::createLink($btnName, $urlArr, false, $attr);

return $link;
}


/**
* Показва дебъг лога
*/
Expand Down Expand Up @@ -202,6 +246,8 @@ public function act_Default()

$tpl->append('bgERP tracer', 'PAGE_TITLE');

$this->logInAct('Листване', null, 'read');

// Показва съдъражаниете на дебъга, ако е избран файла
if ($debugFile) {
$fPath = $this->getDebugFilePath($debugFile);
Expand All @@ -225,7 +271,8 @@ public function act_Default()
}

if ($this->haveRightFor('report')) {
$singal = ht::createLink(tr('Сигнал'), array('log_Debug', 'report', 'debugFile' => $debugFile, 'ret_url' => true), false, array('title' => 'Изпращане на сигнал към разработчиците на bgERP', 'ef_icon' => 'img/16/debug_bug.png'));
$singal = $this->getReportLink($debugFile);

$tpl->append($singal, 'SIGNAL');
}

Expand Down Expand Up @@ -271,7 +318,7 @@ public function act_Report()
$retUrl = array('Portal', 'Show');
}

$form->toolbar->addBtn('Отказ', $retUrl, 'id=cancel, ef_icon = img/16/close-red.png,title=Отказ');
$form->toolbar->addBtn('Отказ', $retUrl, 'id=cancel, ef_icon = img/16/close-red.png,title=Отказ, onclick=self.close();');

$email = email_Inboxes::getUserEmail();
if (!$email) {
Expand All @@ -289,6 +336,8 @@ public function act_Report()

$form->input();

Mode::set('wrapper', 'page_Dialog');

if ($form->isSubmitted()) {
$dataArr = array();

Expand Down Expand Up @@ -322,15 +371,26 @@ public function act_Report()
$url = help_Setup::get('BGERP_SUPPORT_URL', true);
$resStr = @file_get_contents($url, false, $context);

$msg = null;
if ($resStr && is_string($resStr)) {
$msg = str::limitLen($resStr, 500);

if ($resStr == 'OK') {
$tpl = new ET();
jquery_Jquery::run($tpl, 'self.close();');
} else {
$form->setError('description', 'Възникна грешка при изпращане на сигнала.');
$tpl = $form->renderHtml();
}

return new Redirect($retUrl, $msg);
$this->logInAct('Изпращане на сигнал');
} else {
$tpl = $form->renderHtml();
}

return $this->renderWrapping($form->renderHtml());
// Добавяме клас към бодито
$tpl->append('dialog-window', 'BODY_CLASS_NAME');

$tpl->append("<button onclick='javascript:window.close();' class='dialog-close'>X</button>");

return $tpl;
}


Expand Down Expand Up @@ -525,14 +585,18 @@ protected static function getDebugFilesArr(&$fName = null, $before = null, $afte

try {
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY);

$iterator->setFlags(FilesystemIterator::NEW_CURRENT_AND_KEY | FilesystemIterator::SKIP_DOTS);
} catch (ErrorException $e) {
self::logNotice('Не може да се обходи директорията', $dir);

return $fArr;
} catch (Throwable $e) {
self::logNotice('Не може да се обходи директорията', $dir);

return $fArr;
}

$iterator->setFlags(FilesystemIterator::NEW_CURRENT_AND_KEY | FilesystemIterator::SKIP_DOTS);

// Намираме шаблонното име от файла
$fNameTemplate = null;
if (isset($fName)) {
Expand All @@ -554,40 +618,46 @@ protected static function getDebugFilesArr(&$fName = null, $before = null, $afte

// Намираме всички файлове и им вземаме времето на създаване
while ($iterator->valid()) {
$mTime = null;
$fileName = $iterator->key();
$path = $iterator->current()->getPath();
@$currentDepth = $iterator->getDepth();

if (($currentDepth < 1) && !$iterator->isDir()) {
$canShow = true;

$search = trim($search);
try {
$mTime = null;
$fileName = $iterator->key();
$path = $iterator->current()->getPath();
@$currentDepth = $iterator->getDepth();

if ($search) {
if (strpos($fileName, $search) === false) {
$canShow = false;
if (($currentDepth < 1) && !$iterator->isDir()) {
$canShow = true;

$search = trim($search);

if ($search) {
if (strpos($fileName, $search) === false) {
$canShow = false;
}
}
}

// Ако се търси определен файл и отговаря на изискванията - го показваме
if ($canShow) {
$mTime = $iterator->current()->getMTime();
$fArr[$fileName] = $mTime . '|' . $fileName;
}

if ($fName) {
if (strpos($fileName, $fNameTemplate)) {
if ($fileName != $fName) {
if (!isset($mTime)) {
$mTime = $iterator->current()->getMTime();

// Ако се търси определен файл и отговаря на изискванията - го показваме
if ($canShow) {
$mTime = $iterator->current()->getMTime();
$fArr[$fileName] = $mTime . '|' . $fileName;
}

if ($fName) {
if (strpos($fileName, $fNameTemplate)) {
if ($fileName != $fName) {
if (!isset($mTime)) {
$mTime = $iterator->current()->getMTime();
}

// Ако има друг файл от същия хит
$otherFilesFromSameHitArr[$fileName] = $mTime . '|' . $fileName;
}

// Ако има друг файл от същия хит
$otherFilesFromSameHitArr[$fileName] = $mTime . '|' . $fileName;
}
}
}
} catch (Exception $e) {
// Не правим нищо
} catch (Throwable $e) {
// Не правим нищо
}

$iterator->next();
Expand Down Expand Up @@ -733,6 +803,8 @@ public static function cron_clearOldDebugFiles()

$cnt = 0;

$allCnt = count($fArr);

foreach ($fArr as $fName => $cDate) {
list($v) = explode('_', $fName, 2);

Expand Down Expand Up @@ -762,7 +834,7 @@ public static function cron_clearOldDebugFiles()
}

if ($cnt) {
$me->logNotice('Изтрити дебъг файлове: ' . $cnt);
$me->logNotice("Изтрити дебъг файлове {$cnt} от {$allCnt}");
}
}

Expand Down

0 comments on commit 35b139d

Please sign in to comment.