Esempio n. 1
0
    /**
     * @brief 소스 브라우징
     **/
    function dispIssuetrackerViewSource()
    {
        // 접근 권한 체크
        if (!$this->grant->browser_source || !$this->module_info->svn_url) {
            return $this->dispIssuetrackerMessage('msg_not_permitted');
        }
        require_once $this->module_path . 'classes/svn.class.php';
        $path = urldecode(Context::get('path'));
        if (!$path) {
            $path = '/';
        }
        Context::set('path', $path);
        $revs = Context::get('revs');
        $erev = Context::get('erev');
        $brev = Context::get('brev');
        $oSvn = new Svn($this->module_info->svn_url, $this->module_info->svn_cmd);
        $current = $oSvn->getStatus($path);
        Context::set('current', $current);
        $type = Context::get('type');
        switch ($type) {
            case 'diff':
            case 'compare':
                $comp = $oSvn->getComp($path, $brev, $erev);
                Context::set('comp', $comp);
                $path_tree = Svn::explodePath($path, true);
                Context::set('path_tree', $path_tree);
                $this->setTemplateFile('source_compare');
                break;
            case 'log':
                if (!$erev) {
                    $erev = $current->revision;
                }
                $logs = $oSvn->getLog($path, $erev, $brev, false, 50);
                Context::set('logs', $logs);
                if (!$erev) {
                    $erev = $current->erev;
                }
                context::set('erev', $erev);
                context::set('brev', $brev);
                $path_tree = Svn::explodePath($path, true);
                Context::set('path_tree', $path_tree);
                $this->setTemplateFile('source_log');
                break;
            case 'file':
                if ($revs) {
                    $erev = $revs;
                }
                if (!$erev) {
                    $erev = $current->revision;
                }
                $content = $oSvn->getFileContent($path, $erev);
                Context::set('content', $content);
                $logs = $oSvn->getLog($path, $erev, $brev, false, 2);
                $erev = $logs[0]->revision;
                $brev = $logs[1]->revision;
                context::set('erev', $erev);
                context::set('brev', $brev);
                $path_tree = Svn::explodePath($path, true);
                Context::set('path_tree', $path_tree);
                $file_name = array_pop(array_keys($path_tree));
                $file_ext = array_pop(explode(".", $file_name));
                $extlist = array("document" => array("doc", "pdf", "hwp"), "image" => array("jpg", "jpeg", "jpe", "gif", "png", "bmp"), "sound" => array("mp3", "ogg", "wma", "wav"), "movie" => array("avi", "mpg", "mpeg", "mpe", "wmv", "asf", "asx", "mov", "flv", "swf"));
                foreach ($extlist as $key => $exts) {
                    foreach ($exts as $s_key => $ext) {
                        if (!strcasecmp($file_ext, $ext)) {
                            $file_type = $key;
                            break 2;
                        }
                    }
                }
                if (!$file_type) {
                    $file_type = "code";
                    $extToLang = array("h" => "Cpp", "cpp" => "Cpp", "csharp" => "CSharp", "css" => "Css", "html" => "Xml", "sql" => "Sql", "java" => "Java", "py" => "Python", "rb" => "Ruby", "js" => "JScript", "c" => "Cpp", "vb" => "Vb", "xml" => "Xml", "php" => "Php");
                    $file_ext_tmp = strtolower($file_ext);
                    if ($extToLang[$file_ext_tmp]) {
                        $file_ext = $extToLang[$file_ext_tmp];
                    }
                    if (file_exists("./common/js/plugins/code_highlighter/script/shBrush" . $file_ext . ".js")) {
                        Context::loadJavascriptPlugin("code_highlighter");
                        Context::addJsFile('./common/js/plugins/code_highlighter/script/shBrush' . $file_ext . '.js', false);
                        $js_code = <<<dpScript
                                    <script type="text/javascript">
                                        SyntaxHighlighter.config.clipboardSwf = './modules/editor/components/code_highlighter/script/clipboard.swf';
                                        SyntaxHighlighter.all();
                                    </script> 
dpScript;
                        Context::addHtmlFooter($js_code);
                        Context::set('file_ext', $file_ext_tmp);
                    }
                }
                Context::set('file_type', $file_type);
                $this->setTemplateFile('source_file_view');
                break;
            default:
                $path_tree = Svn::explodePath($path, false);
                Context::set('path_tree', $path_tree);
                $list = $oSvn->getList($path, $revs);
                Context::set('list', $list);
                $this->setTemplateFile('source_list');
                break;
        }
        Context::addJsFile($this->module_path . 'tpl/js/svn.js');
    }
Esempio n. 2
0
 function testHistory()
 {
     $Svn = new Svn($this->__repos[1]);
     $File = new File($Svn->working . '/branches/demo_1.0.x.x/index.php', true);
     $File->write("this is a new php file with plain text tha is being changed");
     $result = $Svn->run('commit', array($Svn->working, '--message "Updating index.php"'));
     $result = $Svn->find('all', array('path' => '/branches/demo_1.0.x.x/index.php'));
     $this->assertEqual($result[0]['Repo']['revision'], 3);
     $this->assertEqual($result[0]['Repo']['message'], 'Updating index.php');
     $this->assertEqual($result[1]['Repo']['revision'], 2);
     $this->assertEqual($result[1]['Repo']['message'], 'Adding index.php');
     //var_dump($result);
     //var_dump($Svn->debug);
     //var_dump($Svn->response);
 }
 function syncChangeset($module_info)
 {
     if (!$module_info->svn_url || !$module_info->svn_cmd) {
         return;
     }
     $lock_file = sprintf('%sfiles/cache/svn/%d.lock', _XE_PATH_, $module_info->module_srl);
     if (file_exists($lock_file) && filemtime($lock_file) > time() - 60 * 10) {
         return;
     }
     FileHandler::writeFile($lock_file, ' ');
     require_once $this->module_path . 'classes/svn.class.php';
     $oSvn = new Svn($module_info->svn_url, $module_info->svn_cmd, $module_info->svn_userid, $module_info->svn_passwd);
     $oModel =& getModel('issuetracker');
     $status = $oSvn->getStatus();
     if (!$status || !$status->revision) {
         return;
     }
     $latestRevision = $oModel->getLatestRevision($module_info->module_srl);
     $oController =& getController('issuetracker');
     while ($latestRevision < $status->revision) {
         $gap = $status->revision - $latestRevision;
         if ($gap > 500) {
             $gap = 500;
         }
         $logs = $oSvn->getLog("/", $latestRevision + 1, $status->revision, false, $gap, false);
         if (!$logs || !count($logs)) {
             return;
         }
         if (count($logs)) {
             foreach ($logs as $log) {
                 $obj = null;
                 $obj->revision = $log->revision;
                 $obj->author = $log->author;
                 $obj->date = date("YmdHis", strtotime($log->date));
                 $obj->message = trim($log->msg);
                 $obj->module_srl = $module_info->module_srl;
                 executeQuery("issuetracker.insertChangeset", $obj);
             }
         }
         $latestRevision = $oModel->getLatestRevision($module_info->module_srl);
     }
     FileHandler::removeFile($lock_file);
 }