public function editAction()
 {
     if (Zend_Auth::getInstance()->getIdentity()->role != 'admin') {
         $this->_forms['edit']->removeElement('path');
     }
     $id = $this->_request->getParam('id');
     $page = $this->_modelMapper->find($id, new Pages_Model_Pages());
     if (is_null($page)) {
         $this->_redirector->gotoSimpleAndExit('index');
     }
     if ($this->_request->getParam('dataPage')) {
         $dataPage = $this->_request->getParam('dataPage');
         $page->setOptions($dataPage);
         $this->setUploadImage($page);
         $markdown = $dataPage['contentMarkdown'];
         $context_html = Michelf\MarkdownExtra::defaultTransform($markdown);
         $page->setContentHtml($context_html);
         $this->_modelMapper->save($page);
         $this->_redirector->gotoUrlAndExit($this->_request->getParam('currentUrl'));
     }
     parent::editAction();
     $config = array(Zend_Navigation_Page_Mvc::factory(array('label' => 'На сайт', 'uri' => $page->getPath() != 'home' ? '/' . $page->getPath() . '/' : '/')));
     $containerNav = new Zend_Navigation($config);
     $this->view->container_nav = $containerNav;
 }
 public function saveFormData(Zend_Form $form)
 {
     $item = $this->_model;
     $item->setOptions($form->getValues());
     if ($this->_request->getParam('contentMarkdown')) {
         $context_html = Michelf\MarkdownExtra::defaultTransform($this->_request->getParam('contentMarkdown'));
         $item->setContentHtml($context_html);
     }
     $fullPath = $this->_request->getParam('path');
     if ($this->_request->getParam('parentId') != 0) {
         $parentCategory = $this->_modelMapper->find($this->_request->getParam('parentId'), new Pipeline_Model_PipelineCategories());
         if ($parentCategory) {
             $fullPath = $parentCategory->getFullPath();
         }
     }
     $item->setFullPath($fullPath);
     $this->setMetaData($item);
     $this->getModelMapper()->save($item);
     if ($item->getId() && $item->getId() != '') {
         $id = $item->getId();
     } else {
         $id = $this->getModelMapper()->getDbTable()->getAdapter()->lastInsertId();
     }
     $item = $this->getModelMapper()->find($id, $this->getModel());
     foreach ($form->getElements() as $key => $element) {
         if ($element instanceof Zend_Form_Element_File && $element->isUploaded()) {
             $item = $this->saveUploadFile($element, $item);
         }
     }
     return $item;
 }
 public function itRendersMarkdownFilesInSubDirectory()
 {
     $files_names = array("subdir/readme.md");
     stub($this->git_exec)->lsTree('commit', 'subdir/')->returns($files_names);
     $test_md_content = "Content of readme.text";
     stub($this->git_exec)->getFileContent('commit', 'subdir/readme.md')->returns($test_md_content);
     $expected_result = array('file_name' => "subdir/readme.md", 'file_content' => Michelf\MarkdownExtra::defaultTransform($test_md_content));
     $this->assertEqual($this->git_markdown_file->getReadmeFileContent('subdir/', 'commit'), $expected_result);
 }
 public function testGetMarkdownFilesContent()
 {
     $files_names = array("test.java", "test.markdown", "readme.md", "test.c", "test.mkd");
     stub($this->git_exec)->lsTree('commit', 'node')->returns($files_names);
     $test_md_content = "Content of test.md\n==========";
     stub($this->git_exec)->getFileContent('commit', 'readme.md')->returns($test_md_content);
     $expected_result = array('file_name' => "readme.md", 'file_content' => Michelf\MarkdownExtra::defaultTransform($test_md_content));
     $this->assertEqual($this->git_markdown_file->getReadmeFileContent('path', 'node', 'commit'), $expected_result);
 }
Beispiel #5
0
function get_page($pageid)
{
    global $config;
    $connection = new MongoClient($config["database"]["connectionstring"]);
    $connection->connect();
    $blog = $connection->selectDB($config["database"]["dbname"]);
    $pages = $blog->pages;
    $page = $pages->findOne(array("_id" => $pageid));
    $connection->close();
    if (!is_null($page)) {
        $page["content"] = Michelf\MarkdownExtra::defaultTransform($page["content"]);
    }
    return $page;
}
Beispiel #6
0
 /**
  * Parse Markdown and convert to HTML.
  * Use PHP Markdown & Markdown Extra: http://michelf.ca/projects/php-markdown/
  *
  * @param    string $text  Text to parse Markdown.
  * @param    string $extra Use MarkdownExtra: http://michelf.ca/projects/php-markdown/extra/ .
  *
  * @return   string     Parsed Text.
  */
 public static function markdown($text, $extra = true, $option = array())
 {
     require_once AKPATH_HTML . "/php-markdown/Markdown.php";
     $text = str_replace("\t", '    ', $text);
     if ($extra) {
         require_once AKPATH_HTML . "/php-markdown/MarkdownExtra.php";
         $result = Michelf\MarkdownExtra::defaultTransform($text);
     } else {
         $result = Michelf\Markdown::defaultTransform($text);
     }
     if (JArrayHelper::getValue($option, 'highlight_enable', 1)) {
         self::highlight(JArrayHelper::getValue($option, 'highlight', 'default'));
     }
     return $result;
 }
 public function editAction()
 {
     if ($this->_request->getParam('dataPage')) {
         $dataPage = $this->_request->getParam('dataPage');
         $id = $this->_request->getParam('id');
         $categories = $this->_modelMapper->find($id, $this->_model);
         $categories->setOptions($dataPage);
         $this->setUploadImage($categories);
         $markdown = $dataPage['contentMarkdown'];
         $context_html = Michelf\MarkdownExtra::defaultTransform($markdown);
         $categories->setContentHtml($context_html);
         $this->_modelMapper->save($categories);
         $this->_redirector->gotoUrlAndExit('/manufacture/' . $categories->getPath());
     }
     parent::editAction();
 }
 function parseExtra()
 {
     return Michelf\MarkdownExtra::defaultTransform($this->content);
 }
 public function parsing($text)
 {
     $parser = new Michelf\MarkdownExtra();
     $text = $parser->defaultTransform($text);
     return $text;
 }
Beispiel #10
0
<?php

$app->get('/', function ($req, $res, $args) use($app) {
    $sales = new BrownPaperTickets\APIv2\SalesInfo(DEV_ID);
    $content = file_get_contents(ROOT_DIR . '/README.md');
    return $this->view->render($res, 'index.html', ['content' => Michelf\MarkdownExtra::defaultTransform($content), 'messages' => $this->flash->getMessages()]);
})->setName('home');
Beispiel #11
0
function ExplainMarkdownExtra($path)
{
    $text = file_get_contents($path);
    return Michelf\MarkdownExtra::defaultTransform($text);
}
 public static function getMarkdownContentInForm($content)
 {
     return Michelf\MarkdownExtra::defaultTransform($content);
 }
 public function editAction()
 {
     $categoryId = $this->_request->getParam('id');
     if (is_null($categoryId)) {
         $this->_redirector->gotoSimpleAndExit('index');
     }
     $category = $this->_modelMapper->find($categoryId, new Catalog_Model_Categories());
     if (is_null($category)) {
         throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
     }
     $parentCategoryId = $category->getParentId();
     if ($this->_request->isPost()) {
         //Zend_Debug::dump($this->_request->getParams());
         $url = $this->_request->getParam('currentUrl');
         if ($this->_request->getParam('dataFormCategory')) {
             $dataCategory = $this->_request->getParam('dataFormCategory');
             $category->setOptions($dataCategory);
             $category->setModDate(date("Y-m-d H:i:s"));
             $context_html = Michelf\MarkdownExtra::defaultTransform($dataCategory['contentMarkdown']);
             $category->setContentHtml($context_html);
             $parentFullPath = $this->_modelMapper->generateFullPath($dataCategory['parentId']);
             $fullPath = !is_null($parentFullPath) ? $parentFullPath . '/' . $category->getPath() : $category->getPath();
             $category->setFullPath($fullPath);
             $url = '/catalog/' . $fullPath;
             $productsRel = $this->_modelMapper->fetchProductsRel($categoryId);
             if ($productsRel) {
                 $productsMapper = new Catalog_Model_Mapper_Products();
                 /** @var Catalog_Model_Products $product */
                 foreach ($productsRel as $product) {
                     $product->setFullPath($fullPath . '/' . $product->getPath());
                     $productsMapper->save($product);
                 }
             }
             $upload = new Zend_File_Transfer();
             if ($upload->isUploaded()) {
                 $imageFile = $this->_uploadFiles($categoryId, $upload);
                 $category->setUploadPath('/upload/categories/' . $categoryId . '/');
                 $category->setImage($imageFile['fileLoad']['name']);
             }
             $this->_modelMapper->save($category);
         }
         $this->clearCache('CatalogCategories');
         $this->_redirector->gotoUrlAndExit($url);
     }
 }
 public function editAction()
 {
     $itemId = $this->_request->getParam('id');
     if (is_null($itemId)) {
         $this->_redirector->gotoUrlAndExit($this->getCurrentUrl());
         return;
     }
     $item = $this->_modelMapper->find($itemId, new Forum_Model_Forum());
     $oldContent = $item->getContent();
     $markdown = $this->_request->getParam('contentMarkdown');
     if ($markdown && $markdown != '') {
         $context_html = Michelf\MarkdownExtra::defaultTransform($markdown);
         $item->setContent($context_html);
         $item->setContentMarkdown($markdown);
         $item->setTimestamp(date("Y-m-d H:i:s"));
         if ($this->_userAuth->email != $item->getEmail()) {
             $item->setAuthor($this->_userAuth->name);
             $item->setEmail($this->_userAuth->email);
             $this->sendEditMail($item, $oldContent);
         }
         $this->_modelMapper->save($item);
     }
     $cacheName = !$item->getParentId() ? 'forumQuestions' : 'forumReply';
     $this->clearCache($cacheName);
     $this->_redirector->gotoUrlAndExit($this->getCurrentUrl());
 }