public function tearDown()
 {
     colesoApplication::setEnvironment($this->savedEnvironment);
     colesoToken::testReset();
     if ($this->cachePath) {
         colesoApplication::setConfigVal('/system/cacheDir', $this->savedSystemCachePath);
     }
 }
 protected function getRealPath($path)
 {
     $realPath = $path;
     if (!colesoApplication::getConfigVal('/system/useStandaloneTheme')) {
         $realPath = $this->libPath . $path;
     }
     return $realPath;
 }
示例#3
0
 protected function registerTestConn()
 {
     $targetFile = colesoApplication::getConfigVal('/system/cacheDir') . 'test/' . $this->cachePath . $this->sqliteDbFileName;
     colesoApplication::setConfigVal('/system/db/default/dbType', 'Pdo_Sqlite');
     colesoApplication::setConfigVal('/system/db/default/dbHost', 'localhost');
     colesoApplication::setConfigVal('/system/db/default/dbName', $targetFile);
     $this->dbConn = colesoDB::getConnection();
 }
 function testShowTocForm()
 {
     $env = colesoApplication::getEnvironment();
     $env->method = 'GET';
     $bookLoader = new bookLoader();
     $parameters = array('bookKey' => 'bulldoc_book', 'bookLoader' => $bookLoader, 'book' => $bookLoader->getBook('bulldoc_book'), 'url' => 'introduction.html');
     $controller = new tocEditController();
     $controller->addParameters($parameters);
     $result = $controller->run();
     $examinator = $this->getContentExaminator($result->content);
     echo $examinator->display();
     $this->assertEqual($examinator->getMD5(), 'd9d5461896709de200ad36613e63f7d0', 'TOC Edit form rendered');
 }
示例#5
0
function colesoSubstr($str, $start, $length = null)
{
    $localeData = colesoApplication::getConfigVal('/system/localeData');
    if (isset($localeData['isMultiByte'])) {
        if (is_null($length)) {
            $length = mb_strlen($str);
        }
        return mb_substr($str, $start, $length, $localeData['encoding']);
    }
    if (is_null($length)) {
        $length = strlen($str);
    }
    return substr($str, $start, $length);
}
 public function __construct($book)
 {
     $this->render = $book->getBookRenderer();
     $this->render->setMode('static');
     $this->book = $book;
     $this->booKey = $book->getBookKey();
     if ($this->book->getBookLanguage()) {
         colesoApplication::setLanguage($this->book->getBookLanguage(), $this->book->getBookLocale());
         colesoApplication::loadMessages('bulldoc/messages');
     }
     $this->toc = $this->render->getToc();
     $this->outputPath = rtrim($book->getBookDest(), '\\/') . '/';
     $this->mediaExt = 'gif,jpg,jpeg,png,pdf,zip,gz,tgz,css,js';
     $this->themeManager = $this->render->getThemeManager();
 }
示例#7
0
 private static function obtainCurrentLanguage()
 {
     if (colesoApplication::getConfigVal('/system/language')) {
         return colesoApplication::getConfigVal('/system/language');
     }
     $language = self::$defaultLang;
     $environment = colesoApplication::getEnvironment();
     $url = $environment->getRequestURL();
     foreach (self::$languageList as $language) {
         if (preg_match('/^\\/' . $language . '/', $url)) {
             return $language;
         }
     }
     return $language;
 }
 function testBook()
 {
     $sourcePath = colesoApplication::getConfigVal('/bulldoc/source');
     $outputPath = colesoApplication::getConfigVal('/bulldoc/output');
     $themesPath = colesoApplication::getConfigVal('/bulldoc/themeDir');
     $myBookLoader = new bookLoader();
     $myBook = $myBookLoader->getBook('bulldoc_book');
     $this->assertEqual($myBook->getBookDest(), $outputPath . 'bulldoc_book/', 'Correct Output Dest obtained');
     $this->assertEqual($myBook->getBookKey(), 'bulldoc_book', 'Book key Ok');
     $this->assertEqual($myBook->getBookData(), array('source' => $sourcePath . 'bulldoc_book/', 'title' => 'Bull Doc', 'author' => 'Dmitry Smirnov', 'copyright' => 'H-type, 2008', 'site' => 'www.bulldoc.ru', 'bookShelfTitle' => 'Bull Doc', 'outputMode' => 'html'), 'Correct book data array obtained');
     $this->assertEqual($myBook->getBookTitle(), 'Bull Doc', 'Book title Ok');
     $this->assertEqual($myBook->getBookSource(), $sourcePath . 'bulldoc_book/', 'Book source Ok');
     $this->assertEqual($myBook->getBookTheme(), array('themePath' => $themesPath . 'blueprint', 'themeUrl' => 'support/workshop/themes/blueprint'), 'Correct Theme data obtained');
     $this->assertEqual($myBook->getTocFileName(), $sourcePath . 'bulldoc_book/toc.yml', 'Correct TOC filename obtained');
     $this->assertIsA($myBook->getBookRenderer(), 'renderDocPage', 'book rendrer obtained');
 }
示例#9
0
function colesoEchoDebugHeader()
{
    $sysImgPath = colesoApplication::getConfigVal('/system/urlRoot') . 'lib/coleso/web/img/';
    $jsPath = colesoApplication::getConfigVal('/system/urlRoot') . 'lib/coleso/web/js/';
    $richeditPath = colesoApplication::getConfigVal('/system/richedit/url');
    ?>
<script type='text/javascript' language='JavaScript'>
colesoSystemImagesPath='<?php 
    echo $sysImgPath;
    ?>
';
colesoSystemRicheditPath='<?php 
    echo $richeditPath;
    ?>
';
colesoSkipCookie='skip';
</script>
<script language='JavaScript' src="<?php 
    echo $jsPath;
    ?>
calendar_popup.js">
</script>
<script language='JavaScript' src="<?php 
    echo $jsPath;
    ?>
coleso_core.js">
</script>
<style type='text/css'>
div.calendar
{
  position: absolute;
  visibility: hidden;
  width: 150px;
  background-color: #F5EFD6;
}

div.formerr,span.formerrLabel {
font-weight: bold;
color: red;
}
</style>
    <?php 
}
示例#10
0
    public function buildTOC()
    {
        $pathBuilder = new pathBuilder('/');
        $sectionData = $this->structureHolder->getPageSection($pathBuilder, 'current');
        $section = $sectionData['curSection'];
        $level = 0;
        $iterator = new RecursiveIteratorIterator(new contentTreeRecursiveIterator($section), RecursiveIteratorIterator::SELF_FIRST);
        $file_list = '';
        $html = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
<!-- Sitemap 1.0 -->
</HEAD><BODY><UL><LI><OBJECT type="text/sitemap">
		                <param name="Name" value="ќбложка">
		                <param name="Local" value="index.html">
		               </OBJECT>';
        foreach ($iterator as $topic) {
            $href = ltrim($iterator->getPath() . '/' . $topic['href'], '\\/');
            $file_list .= "{$href}\n";
            $title = $topic['title'];
            if ($iterator->getDepth() > $level) {
                $html .= '<UL>';
                $level = $iterator->getDepth();
            }
            if ($iterator->getDepth() < $level) {
                $html .= '</UL>';
                $level = $iterator->getDepth();
            }
            $icon = basename($href) == 'index.html' ? '' : '<param name="ImageNumber" value="11">';
            $html .= '<LI> <OBJECT type="text/sitemap">
		                <param name="Name" value="' . $title . '">
		                <param name="Local" value="' . $href . '">
                    ' . $icon . '
		               </OBJECT>';
        }
        $html = $html . '</UL></BODY></HTML>';
        $file_list = "[OPTIONS]\nCompatibility=1.1 or later\nCompiled file={$this->bookKey}.chm\nContents file={$this->bookKey}.hhc\nDefault Font=Verdana,8,204\nDefault topic=index.html\nDisplay compile progress=No\nIndex file={$this->bookKey}.hhk\nLanguage=" . colesoApplication::getMessage('bulldoc', 'chm_encoding') . "\nTitle={$this->bookTitle}\n\n\n[FILES]\n{$file_list}\n\n[INFOTYPES]\n\n";
        return array($html, $file_list);
    }
 protected function saveBook($data, $bookKey)
 {
     $text = '';
     foreach ($data as $key => $val) {
         $text .= "{$key}: {$val}\n";
     }
     $bookDir = colesoApplication::getConfigVal('/bulldoc/source') . "{$bookKey}/";
     if (file_exists($bookDir)) {
         throw new bookCreationException('This folder allready exists: ' . $bookDir);
     }
     mkdir($bookDir, 0777);
     mkdir($bookDir . 'pages', 0777);
     file_put_contents($bookDir . 'book_data.yml', $text);
     $tocText = 'introduction.html: ' . colesoApplication::getMessage('bulldoc', 'introduction');
     file_put_contents($bookDir . 'toc.yml', $tocText);
 }
<?php

colesoApplication::loadMessages('bulldoc/messages');
require_once 'coleso/toolkit/toolkit.php';
require_once 'coleso/locale_strings/strings.php';
require_once 'bulldoc/exceptions.php';
require_once 'bulldoc/path_builder.php';
require_once 'bulldoc/page_builder.php';
require_once 'bulldoc/book_loader.php';
$configSet = colesoApplication::getConfigVal('/system/localConfig');
colesoApplication::setConfigVal('/bulldoc/themeDir', colesoApplication::getConfigVal('/system/docRoot') . 'workshop/themes/');
colesoApplication::setConfigVal('/bulldoc/themeUrl', colesoApplication::getConfigVal('/system/urlRoot') . 'workshop/themes/');
colesoApplication::setConfigVal('/bulldoc/output', colesoApplication::getConfigVal('/system/docRoot') . 'workshop/output/');
colesoApplication::setConfigVal('/bulldoc/rootUrl', colesoApplication::getConfigVal('/system/urlRoot'));
colesoApplication::setConfigVal('/bulldoc/systemTemplates', colesoApplication::getConfigVal('/system/docRoot') . 'workshop/themes/system/');
colesoApplication::setConfigVal('/bulldoc/rootIndexLevel', 2);
//---------------------------------------------------------------------------------------------------
$customSource = $configSet->get('bulldoc::source', colesoApplication::getConfigVal('/system/docRoot') . 'workshop/source/');
colesoApplication::setConfigVal('/bulldoc/source', rtrim($customSource, '\\/') . '/');
//---------------------------------------------------------------------------------------------------
$customBookShelf = $configSet->get('bulldoc::bookshelf', colesoApplication::getConfigVal('/system/docRoot') . 'workshop/source/bookshelf.yml');
colesoApplication::setConfigVal('/bulldoc/bookshelfConfig', $customBookShelf);
//---------------------------------------------------------------------------------------------------
$customTextProcessingClass = $configSet->get('bulldoc::defaultTextProcessingClass', 'docTemplateSet');
colesoApplication::setConfigVal('/bulldoc/textProcessingClass', $customTextProcessingClass);
//---------------------------------------------------------------------------------------------------
$customDefaultTheme = $configSet->get('bulldoc::defaultTheme', 'blueprint');
colesoApplication::setConfigVal('/bulldoc/defaultTheme', $customDefaultTheme);
//for standalone bulldoc application
colesoApplication::setConfigVal('/system/useStandaloneTheme', true);
 private function getTopSection()
 {
     return array('curSection' => false, 'parentSection' => null, 'upTitle' => array(), 'curTitle' => colesoApplication::getMessage('bulldoc', 'toc'), 'level' => colesoApplication::getConfigVal('/bulldoc/rootIndexLevel'));
 }
示例#14
0
 static function formGetDateOrder()
 {
     return colesoApplication::getConfigVal('/form/FormDateOrder');
 }
 function __construct()
 {
     $this->Environment = colesoApplication::getEnvironment();
     $this->parameters = new colesoDataSet();
 }
示例#16
0
 private function getContent($pathBuilder)
 {
     $templateClass = colesoApplication::getConfigVal('/bulldoc/textProcessingClass');
     $t = new $templateClass();
     $t->setOutputMode($this->book->getOutputMode());
     $fileName = $this->sourcePath . $pathBuilder;
     $params = array('root' => $pathBuilder->getRootPath(), 'path' => $pathBuilder, 'structure' => $this->structureHolder);
     $pageData = $this->structureHolder->getPage($pathBuilder);
     if ($pathBuilder->isIndex()) {
         $content = '';
         if (file_exists($fileName)) {
             $content .= $t->parseFile($fileName, $params);
         }
         $content .= $this->navTemplate->parseItem('toc', $this->buildIndex($pathBuilder));
         return $content;
     } elseif ($pageData['type'] == 'index') {
         $myIndexBuilder = new IndexBuilder($this->sourcePath, $this->structureHolder->getToc());
         $myIndexRender = new IndexRender($myIndexBuilder, $this->book, $this->themeManager);
         return $myIndexRender->render($pathBuilder);
     } elseif (file_exists($fileName)) {
         return $t->parseFile($fileName, $params);
     } else {
         return colesoApplication::getMessage('bulldoc', 'underconstruction');
     }
 }
示例#17
0
 function errdie($errno = 0)
 {
     if (!colesoApplication::getConfigVal('/system/errorReporting/DisplayErrors')) {
         echo file_get_contents(colesoApplication::getConfigVal('/system/errorReporting/ErrTemplate'));
     }
     die;
 }
示例#18
0
 function setTestTokenReq()
 {
     $tokenKey = colesoApplication::getConfigVal('/system/tokenName');
     $this->setReqVar($tokenKey, 'test_env_token');
 }
示例#19
0
 public function run()
 {
     $shelfTemplateFile = colesoApplication::getConfigVal('/bulldoc/systemTemplates') . 'bookshelf.tset.phtml';
     $template = new colesoPHPTemplateSet($shelfTemplateFile);
     $res = '';
     $books = $this->parameters->bookLoader->getBooks();
     foreach ($books as $book => $data) {
         if (isset($data['separatorTitle'])) {
             $res .= $template->parseItem('separator', array('title' => $data['separatorTitle']));
         } else {
             $data['key'] = $book;
             if (file_exists($data['source'] . 'pages/cover.png')) {
                 $data['cover'] = 'cover.png';
             } elseif (file_exists($data['source'] . 'pages/cover.jpg')) {
                 $data['cover'] = 'cover.jpg';
             } else {
                 $data['cover'] = false;
             }
             $res .= $template->parseItem('item', $data);
         }
     }
     $html = $template->parseItem('layout', $res);
     return new colesoControllerExecResult($html);
 }
示例#20
0
 function colesoControlLoginSession()
 {
     $this->dbConn = colesoDB::getConnection();
     $this->tPrefix = colesoApplication::getConfigVal('/system/db/tablePrefix');
     $this->environment = colesoApplication::getEnvironment();
     //obsolete ref
 }
示例#21
0
 function readController($fileName)
 {
     $prefix = colesoApplication::getConfigVal('/system/db/tablePrefix');
     require $fileName;
     $this->packages[$CONFIG['keyword']] = array('title' => $CONFIG['name'], 'keyword' => $CONFIG['keyword'], 'tables' => $CONFIG['tables'], 'file' => $fileName, 'dump' => dirname($fileName) . '/dump.sql');
 }
示例#22
0
 static function getTokenKey()
 {
     return colesoApplication::getConfigVal('/system/tokenName', 'colesoToken');
 }
示例#23
0
 private function getIndexCacheFileName()
 {
     return colesoApplication::getConfigVal('/system/cacheDir') . "bulldoc/{$this->bookKey}/book_index.cache";
 }
示例#24
0
<?php

colesoApplication::setConfigVal('/bulldoc/systemTemplates', dirname(__FILE__) . '/support/templates/system/');
colesoApplication::setConfigVal('/bulldoc/bookshelfConfig', dirname(__FILE__) . '/support/workshop/bookshelf.yml');
colesoApplication::setConfigVal('/bulldoc/textProcessingClass', 'docTemplateSet');
colesoApplication::setConfigVal('/bulldoc/rootIndexLevel', 2);
colesoApplication::setConfigVal('/bulldoc/themeDir', dirname(__FILE__) . '/support/workshop/themes/');
colesoApplication::setConfigVal('/bulldoc/themeUrl', 'support/workshop/themes/');
colesoApplication::setConfigVal('/bulldoc/output', dirname(__FILE__) . '/support/workshop/output/');
colesoApplication::setConfigVal('/bulldoc/source', dirname(__FILE__) . '/support/workshop/source/');
示例#25
0
 function render()
 {
     $curVal = $this->getEscapedValue();
     $name = $this->params['name'];
     $widgetType = isset($this->params['widget']) ? $this->params['widget'] : 'picture';
     $salt = isset($this->params['salted']) ? '?salt=' . md5(time()) : '';
     $deltext = colesoApplication::getMessage('form', 'deltext');
     $image_url = $this->getField($name . '_url');
     $res = '';
     if ($curVal) {
         if ($widgetType == 'picture') {
             $res .= "<img src='{$image_url}{$salt}'><br/>";
         }
         $res .= "<a href='{$image_url}'>{$curVal}</a>,\n" . "{$deltext} <input type='checkbox' name='del{$name}'><br/><br/>";
     }
     $res .= "<input type='file' name='upld{$name}'/>";
     $res .= "<br><input name='{$name}' type='hidden' value='{$curVal}' />\n";
     return $res;
 }
示例#26
0
 public function getStructureHolder()
 {
     $cacheFile = colesoApplication::getConfigVal('/system/cacheDir') . "bulldoc/{$this->bookKey}/toc.cache";
     $TOC = colesoYMLLoader::load($this->tocFileName, $cacheFile);
     $structureHolder = new structureHolder($TOC);
     return $structureHolder;
 }
示例#27
0
 function colesoCache()
 {
     $this->filePath = colesoApplication::getConfigVal('/system/cacheDir');
 }
示例#28
0
 function setUpDB()
 {
     colesoApplication::setConfigVal('/system/db/default/dbHost', $this->CONFIG['dbHost']);
     colesoApplication::setConfigVal('/system/db/default/dbLogin', $this->CONFIG['dbLogin']);
     colesoApplication::setConfigVal('/system/db/default/dbPassword', $this->CONFIG['dbPassword']);
     colesoApplication::setConfigVal('/system/db/default/dbBaseName', $this->CONFIG['dbBaseName']);
     colesoApplication::setConfigVal('/system/db/default/DBType', $this->CONFIG['DBType']);
     colesoApplication::setConfigVal('/system/db/default/Encoding', $this->locale['db_encoding']);
     colesoApplication::setConfigVal('/system/db/default/tablePrefix', $this->CONFIG->get('tablePrefix', 'htp_'));
 }
 function getCacheFileName()
 {
     return colesoApplication::getConfigVal('/system/cacheDir') . "bulldoc/bulldoc_book/book_index.cache";
 }
 function getPageFileName()
 {
     return colesoApplication::getConfigVal('/bulldoc/bookshelfConfig');
 }