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);
    }
 private function getTopSection()
 {
     return array('curSection' => false, 'parentSection' => null, 'upTitle' => array(), 'curTitle' => colesoApplication::getMessage('bulldoc', 'toc'), 'level' => colesoApplication::getConfigVal('/bulldoc/rootIndexLevel'));
 }
 static function setLanguage($language, $locale = null)
 {
     colesoApplication::setConfigVal('/system/language', $language);
     colesoApplication::loadMessages("coleso/messages");
     if (is_null($locale)) {
         $locale = colesoApplication::getMessage('system', 'default_locale');
     }
     $localeData = parse_ini_file('coleso/locales/' . $locale . '.ini');
     colesoApplication::setConfigVal('/system/lngEncoding', $localeData['encoding']);
     colesoApplication::setConfigVal('/system/localeData', $localeData);
     if (isset($localeData['locale_name'])) {
         setlocale(LC_ALL, $localeData['locale_name']);
     }
 }
Example #4
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;
 }
 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);
 }
Example #6
0
 public function run()
 {
     if ($this->Environment->getReqVar('result') == 'ok') {
         $themeParams = $this->parameters['book']->getBookTheme();
         $html = colesoPHPTemplate::parseFile($themeParams['themePath'] . '/template/message.tpl.phtml', array('bookTitle' => $this->parameters['book']->getBookTitle(), 'assetsURL' => $themeParams['themeUrl'] . '/web/', 'message' => colesoApplication::getMessage('bulldoc', 'index_cleared'), 'errstatus' => 'success', 'backLink' => colesoApplication::getConfigVal('/bulldoc/rootUrl') . $this->parameters['bookKey'] . '/' . $this->Environment->getReqVar('path')));
         return new colesoControllerExecResult($html);
     } else {
         $cacheFile = colesoApplication::getConfigVal('/system/cacheDir') . "bulldoc/{$this->parameters['bookKey']}/book_index.cache";
         if (file_exists($cacheFile)) {
             unlink($cacheFile);
         }
         return new colesoControllerRedirect($this->parameters->url . '?result=ok&path=' . $this->Environment->getReqVar('path'));
     }
 }
 public function run()
 {
     $this->title = colesoApplication::getMessage('bulldoc', 'bookshelf_edit_title');
     $this->backToViewLink = './';
     return parent::run();
 }
 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');
     }
 }
 function getLocale()
 {
     if ($this->CONFIG->get('locale')) {
         $locale = $this->CONFIG->get('locale');
     } else {
         $locale = colesoApplication::getMessage('system', 'default_locale');
     }
     $this->locale = parse_ini_file('coleso/locales/' . $locale . '.ini');
 }