コード例 #1
0
 /**
  * Run Mage_Connect_Command with html output console style
  *
  * @throws Maged_Exception
  * @param array|string|Maged_Model $runParams command, options, params, comment, success_callback, failure_callback
  * @return bool|Mage_Connect_Error
  */
 public function runHtmlConsole($runParams)
 {
     if (function_exists('apache_setenv')) {
         apache_setenv('no-gzip', '1');
     }
     @ini_set('zlib.output_compression', 0);
     @ini_set('implicit_flush', 1);
     for ($i = 0; $i < ob_get_level(); $i++) {
         ob_end_flush();
     }
     ob_implicit_flush();
     $fe = $this->getFrontend();
     $oldLogStream = $fe->getLogStream();
     $fe->setLogStream('stdout');
     if ($runParams instanceof Maged_Model) {
         $run = $runParams;
     } elseif (is_array($runParams)) {
         $run = new Maged_Model_Connect_Request($runParams);
     } elseif (is_string($runParams)) {
         $run = new Maged_Model_Connect_Request(array('comment' => $runParams));
     } else {
         throw Maged_Exception("Invalid run parameters");
     }
     if (!$run->get('no-header')) {
         $this->_consoleHeader();
     }
     echo htmlspecialchars($run->get('comment')) . '<br/>';
     if ($command = $run->get('command')) {
         $result = $this->run($command, $run->get('options'), $run->get('params'));
         if ($this->getFrontend()->hasErrors()) {
             echo "<br/>CONNECT ERROR: ";
             foreach ($this->getFrontend()->getErrors(false) as $error) {
                 echo nl2br($error[1]);
                 echo '<br/>';
             }
         }
         echo '<script type="text/javascript">';
         if ($this->getFrontend()->hasErrors()) {
             if ($callback = $run->get('failure_callback')) {
                 if (is_array($callback)) {
                     call_user_func_array($callback, array($result));
                 } else {
                     echo $callback;
                 }
             }
         } else {
             if (!$run->get('no-footer')) {
                 if ($callback = $run->get('success_callback')) {
                     if (is_array($callback)) {
                         call_user_func_array($callback, array($result));
                     } else {
                         echo $callback;
                     }
                 }
             }
         }
         echo '</script>';
     } else {
         $result = false;
     }
     if ($this->getFrontend()->getErrors() || !$run->get('no-footer')) {
         //$this->_consoleFooter();
         $fe->setLogStream($oldLogStream);
     }
     return $result;
 }
コード例 #2
0
ファイル: Connect.php プロジェクト: jpbender/mage_virtual
    /**
     * Run Mage_COnnect_Command with html output console style
     *
     * @param array|Maged_Model $runParams command, options, params,
     *        comment, success_callback, failure_callback
     */
    public function runHtmlConsole($runParams)
    {
        @apache_setenv('no-gzip', '1');
        @ini_set('zlib.output_compression', 0);
        @ini_set('implicit_flush', 1);
        for ($i = 0; $i < ob_get_level(); $i++) {
            ob_end_flush();
        }
        ob_implicit_flush();
        $fe = $this->getFrontend();
        $oldLogStream = $fe->getLogStream();
        $fe->setLogStream('stdout');
        if ($runParams instanceof Maged_Model) {
            $run = $runParams;
        } elseif (is_array($runParams)) {
            $run = new Maged_Model_Connect_Request($runParams);
        } elseif (is_string($runParams)) {
            $run = new Maged_Model_Connect_Request(array('comment' => $runParams));
        } else {
            throw Maged_Exception("Invalid run parameters");
        }
        if (!$run->get('no-header')) {
            ?>
<html><head><style type="text/css">
body { margin:0px;
    padding:3px;
    background:black;
    color:#2EC029;
    font:normal 11px Lucida Console, Courier New, serif;
    }
</style></head><body>
<script type="text/javascript">
if (parent && parent.disableInputs) {
    parent.disableInputs(true);
}
if (typeof auto_scroll=='undefined') {
    var auto_scroll = window.setInterval(console_scroll, 10);
}
function console_scroll()
{
    if (typeof top.$!='function') {
        return;
    }
    if (top.$('connect_iframe_scroll').checked) {
        document.body.scrollTop+=3;
    }
}
</script>
<?php 
        }
        echo htmlspecialchars($run->get('comment'));
        if ($command = $run->get('command')) {
            $result = $this->run($command, $run->get('options'), $run->get('params'));
            if ($this->getFrontend()->hasErrors()) {
                echo "<br/>CONNECT ERROR: ";
                foreach ($this->getFrontend()->getErrors(false) as $error) {
                    echo nl2br($error[1]);
                    echo '<br/>';
                }
            }
            echo '<script type="text/javascript">';
            if ($this->getFrontend()->hasErrors()) {
                if ($callback = $run->get('failure_callback')) {
                    if (is_array($callback)) {
                        call_user_func_array($callback, array($result));
                    } else {
                        echo $callback;
                    }
                }
            } else {
                if (!$run->get('no-footer')) {
                    if ($callback = $run->get('success_callback')) {
                        if (is_array($callback)) {
                            call_user_func_array($callback, array($result));
                        } else {
                            echo $callback;
                        }
                    }
                }
            }
            echo '</script>';
        } else {
            $result = false;
        }
        if ($this->getFrontend()->getErrors() || !$run->get('no-footer')) {
            ?>
<script type="text/javascript">
if (parent && parent.disableInputs) {
    parent.disableInputs(false);
}
</script>
</body></html>
<?php 
            $fe->setLogStream($oldLogStream);
        }
        return $result;
    }
コード例 #3
0
ファイル: Connect.php プロジェクト: hirentricore/devmagento
    /**
     * Run Mage_Connect_Command with html output console style
     *
     * @param array|Maged_Model $runParams command, options, params,
     *        comment, success_callback, failure_callback
     */
    public function runHtmlConsole($runParams)
    {
        if (function_exists('apache_setenv')) {
            apache_setenv('no-gzip', '1');
        }
        @ini_set('zlib.output_compression', 0);
        @ini_set('implicit_flush', 1);
        for ($i = 0; $i < ob_get_level(); $i++) {
            ob_end_flush();
        }
        ob_implicit_flush();
        $fe = $this->getFrontend();
        $oldLogStream = $fe->getLogStream();
        $fe->setLogStream('stdout');
        if ($runParams instanceof Maged_Model) {
            $run = $runParams;
        } elseif (is_array($runParams)) {
            $run = new Maged_Model_Connect_Request($runParams);
        } elseif (is_string($runParams)) {
            $run = new Maged_Model_Connect_Request(array('comment' => $runParams));
        } else {
            throw Maged_Exception("Invalid run parameters");
        }
        if (!$run->get('no-header')) {
            ?>
<html><head><style type="text/css">
body { margin:0px;
    padding:3px;
    background:black;
    color:#2EC029;
    font:normal 11px Lucida Console, Courier New, serif;
    }
</style></head><body>
<script type="text/javascript">
if (parent && parent.disableInputs) {
    parent.disableInputs(true);
}
if (typeof auto_scroll=='undefined') {
    var auto_scroll = window.setInterval(console_scroll, 10);
}
function console_scroll()
{
    if (typeof top.$ != 'function') {
        return;
    }
    if (top.$('connect_iframe_scroll').checked) {
        document.body.scrollTop+=3;
    }
}
function show_message(message, newline)
{
    var bodyElement = document.getElementsByTagName('body')[0];
    if (typeof newline == 'undefined') {
        newline = true
    }
    if (newline) {
        bodyElement.innerHTML += '<br/>';
    }
    bodyElement.innerHTML += message;
}
function clear_cache(callbacks)
{
    if (typeof top.Ajax != 'object') {
        return;
    }
    var message = 'Exception during cache and session cleaning';
    var url = window.location.href.split('?')[0] + '?A=cleanCache';
    var intervalID = setInterval(function() {show_message('.', false); }, 500);
    var clean = 0;
    var maintenance = 0;
    if (window.location.href.indexOf('clean_sessions') >= 0) {
        clean = 1;
    }
    if (window.location.href.indexOf('maintenance') >= 0) {
        maintenance = 1;
    }

    new top.Ajax.Request(url, {
        method: 'post',
        parameters: {clean_sessions:clean, maintenance:maintenance},
        onCreate: function() {
            show_message('Cleaning cache');
            show_message('');
        },
        onSuccess: function(transport, json) {
            var result = true;
            try{
                var response = eval('(' + transport.responseText + ')');
                if (typeof response.result != 'undefined') {
                    result = response.result;
                } else {
                    result = false;
                }
                if (typeof response.message != 'undefined') {
                    if (response.message.length > 0) {
                        message = response.message;
                    } else {
                        message = 'Cache cleaned successfully';
                    }
                }
            } catch (ex){
                result = false;
            }
            if (result) {
                callbacks.success();
            } else {
                callbacks.fail();
            }
        },
        onFailure: function() {
            callbacks.fail();
        },
        onComplete: function(transport) {
            clearInterval(intervalID);
            show_message(message);
        }
    });
}
</script>
<?php 
        }
        echo htmlspecialchars($run->get('comment'));
        if ($command = $run->get('command')) {
            $result = $this->run($command, $run->get('options'), $run->get('params'));
            if ($this->getFrontend()->hasErrors()) {
                echo "<br/>CONNECT ERROR: ";
                foreach ($this->getFrontend()->getErrors(false) as $error) {
                    echo nl2br($error[1]);
                    echo '<br/>';
                }
            }
            echo '<script type="text/javascript">';
            if ($this->getFrontend()->hasErrors()) {
                if ($callback = $run->get('failure_callback')) {
                    if (is_array($callback)) {
                        call_user_func_array($callback, array($result));
                    } else {
                        echo $callback;
                    }
                }
            } else {
                if (!$run->get('no-footer')) {
                    if ($callback = $run->get('success_callback')) {
                        if (is_array($callback)) {
                            call_user_func_array($callback, array($result));
                        } else {
                            echo $callback;
                        }
                    }
                }
            }
            echo '</script>';
        } else {
            $result = false;
        }
        if ($this->getFrontend()->getErrors() || !$run->get('no-footer')) {
            ?>
<script type="text/javascript">
if (parent && parent.disableInputs) {
    parent.disableInputs(false);
}
</script>
</body></html>
<?php 
            $fe->setLogStream($oldLogStream);
        }
        return $result;
    }