Esempio n. 1
0
 /**
  * Markdown to html
  *
  * @access public
  */
 public function display_markdown_to_html()
 {
     $parser = new \Michelf\MarkdownExtra();
     $output = $parser->transform($_POST['markdown']);
     echo $output;
     $this->template = false;
 }
Esempio n. 2
0
 function compileMarkdown($str)
 {
     require_once '../extend/Michelf/MarkdownExtra.inc.php';
     $parser = new Michelf\MarkdownExtra();
     $parser->fn_id_prefix = "mmd-";
     return $parser->transform($str);
 }
Esempio n. 3
0
function markdown($text)
{
    require_once __DIR__ . '/../vendor/Michelf/MarkdownExtra.inc.php';
    $parser = new \Michelf\MarkdownExtra();
    $parser->no_markup = true;
    $parser->no_entities = true;
    return $parser->transform($text);
}
Esempio n. 4
0
File: Post.php Progetto: ospii/oblog
 /**
  * Get html of the post.
  *
  * @return string Html
  */
 public function getHtml()
 {
     if ($this->html === null) {
         $markDowner = new \Michelf\MarkdownExtra();
         $this->html = $markDowner->transform($this->md);
     }
     return $this->html;
 }
 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;
 }
Esempio n. 7
0
 function _doAnchors_reference_callback($matches)
 {
     if (!$this->_skipAnchors) {
         return parent::_doAnchors_inline_callback($matches);
     }
     $link_text = $matches[2];
     return $link_text;
 }
 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  * 		http://example.com/index.php/welcome
  *	- or -
  * 		http://example.com/index.php/welcome/index
  *	- or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
 public function index($page = 'main')
 {
     $data = array();
     $docs_path = $this->config->item('docs_path') ? $this->config->item('docs_path') : 'https://raw.githubusercontent.com/GSA/project-open-data-dashboard/master/documentation/';
     $docs_path = $docs_path . $page . '.md';
     $docs = @file_get_contents($docs_path);
     if ($docs) {
         $markdown_extra = new Michelf\MarkdownExtra();
         $markdown_text = $docs;
         $markdown_text = $markdown_extra->transform($markdown_text);
         $markdown_text = linkToAnchor($markdown_text);
         $data['docs_html'] = $markdown_text;
     } else {
         $data['docs_html'] = "The documentation file is unavailable";
     }
     $this->load->view('docs', $data);
 }
 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);
 }
 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 __construct($htmlPurifierCachePath)
 {
     $markdown = new \Michelf\MarkdownExtra();
     $htmlPurifierConfig = \HTMLPurifier_Config::createDefault();
     $htmlPurifierConfig->set('Cache.SerializerPath', $htmlPurifierCachePath);
     $htmlPurifier = new \HTMLPurifier($htmlPurifierConfig);
     $this->converter = function ($description) use($markdown, $htmlPurifier) {
         $description = Strings::replace($description, '/([^#]*)(#{1,6})(.*)/', function ($matches) {
             return $matches[1] . (strlen($matches[2]) < 6 ? '#' : '') . $matches[2] . $matches[3];
         });
         $description = Strings::replace($description, '/```(php|neon|javascript|js|css|html|htmlcb|latte|sql)?\\h*\\v(.+?)\\v```/s', function ($matches) {
             $fshl = new Highlighter(new Html(), Highlighter::OPTION_TAB_INDENT);
             switch (strtolower($matches[1])) {
                 case 'php':
                     $fshl->setLexer(new Lexer\Php());
                     break;
                 case 'neon':
                     $fshl->setLexer(new Lexer\Neon());
                     break;
                 case 'javascript':
                 case 'js':
                     $fshl->setLexer(new Lexer\Javascript());
                     break;
                 case 'css':
                     $fshl->setLexer(new Lexer\Css());
                     break;
                 case 'html':
                 case 'htmlcb':
                 case 'latte':
                     $fshl->setLexer(new Lexer\Html());
                     break;
                 case 'sql':
                     $fshl->setLexer(new Lexer\Sql());
                     break;
                 default:
                     $fshl->setLexer(new Lexer\Minimal());
                     break;
             }
             return '<pre' . ($matches[1] ? ' class="src-' . strtolower($matches[1]) . '"' : '') . '><code>' . $fshl->highlight(ltrim($matches[2])) . '</code></pre>';
         });
         return $htmlPurifier->purify($markdown->transform($description));
     };
 }
Esempio n. 12
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;
}
Esempio n. 13
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();
 }
Esempio n. 15
0
function updateArticleById($id, $update)
{
    $sql = connectSQL();
    $sqlstr = "UPDATE pache_article SET ";
    foreach ($update as $key => $value) {
        if ($key == 'type') {
            switch (strtolower($value)) {
                case 'markdown':
                    require 'extend/Michelf/MarkdownExtra.inc.php';
                    require_once 'extend/Michelf/MarkdownExtra.inc.php';
                    //use Michelf\MarkdownExtra;
                    $parser = new Michelf\MarkdownExtra();
                    $parser->fn_id_prefix = "mmd-";
                    //Michelf markdown
                    $my_html = $parser->transform($update->article);
                    $sqlstr = $sqlstr . "" . mysql_escape_string('format') . "" . ' = ' . "'" . mysql_escape_string($my_html) . "'" . ', ';
                    break;
                case 'text':
                    $ftext = nl2br($update->article);
                    $sqlstr = $sqlstr . "" . mysql_escape_string('format') . "" . ' = ' . "'" . $ftext . "'" . ', ';
                    break;
                case 'html':
                    $sqlstr = $sqlstr . "" . mysql_escape_string('format') . "" . ' = ' . "'" . mysql_escape_string($update->article) . "'" . ', ';
                    break;
                default:
            }
        }
        if ($key == 'tag') {
        } else {
            $sqlstr = $sqlstr . "" . mysql_escape_string($key) . "" . ' = ' . "'" . mysql_escape_string($value) . "'" . ', ';
        }
    }
    $sqlstr = $sqlstr . ' ltime = now() ';
    $sqlstr = $sqlstr . ' WHERE id = ' . (int) $id;
    $sqlresult = mysql_query($sqlstr, $sql->con);
    if ($sqlresult) {
        mysql_close($sql->con);
    } else {
        mysql_close($sql->con);
        die(mysql_error($sql->con));
    }
    return true;
}
Esempio n. 16
0
 public function getHelp($callName, $input, $params = array())
 {
     if (!isset($this->config['MAIN']['externalUrl'])) {
         return Model::isProblem();
     }
     array_unshift($params['path'], $params['language']);
     $fileName = array_pop($params['path']);
     $path_parts = pathinfo($fileName);
     $cacheFolder = dirname(__FILE__) . '/cache/' . implode('/', $params['path']);
     self::generatepath($cacheFolder);
     $realExtension = isset($path_parts['extension']) ? '.' . strtolower($path_parts['extension']) : '';
     $params['path'][] = $path_parts['filename'] . $realExtension;
     $cacheExtension = $realExtension;
     if ($cacheExtension == '.md') {
         $cacheExtension = '.html';
     }
     $cachePath = dirname(__FILE__) . '/cache/' . implode('/', $params['path']) . $cacheExtension;
     if (false && file_exists($cachePath)) {
         Model::header('Content-Length', filesize($cachePath));
         return Model::isOk(file_get_contents($cachePath));
     }
     $order = implode('/', $params['path']);
     $order = '/help/' . $order;
     $positive = function ($input, $cachePath, $realExtension, $negativeMethod, $cacheFilename) {
         if (empty($input)) {
             // wenn die zurückgegebene Datei leer ist, wird nicht gecached und die negative Methode aufgerufen
             return call_user_func_array($negativeMethod, array());
         }
         if ($realExtension == '.md') {
             $parser = new \Michelf\MarkdownExtra();
             $input = $this->umlaute($input);
             $my_html = $parser->transform($input);
             $input = '<html><head></head><body><link rel="stylesheet" href="' . $this->config['MAIN']['externalUrl'] . '/UI/css/github-markdown.css" type="text/css"><span class="markdown-body">' . $my_html . '</span></body></html>';
         }
         Model::header('Content-Length', strlen($input));
         // die Hilfedatei wird lokal gespeichert
         @file_put_contents($cachePath, $input);
         return Model::isOk($input);
     };
     $negative = function () {
         $input = '#### !!!Kein Inhalt!!!';
         $parser = new \Michelf\MarkdownExtra();
         $input = $this->umlaute($input);
         $my_html = $parser->transform($input);
         $input = '<html><head></head><body><link rel="stylesheet" href="' . $this->config['MAIN']['externalUrl'] . '/UI/css/github-markdown.css" type="text/css"><span class="markdown-body">' . $my_html . '</span></body></html>';
         Model::header('Content-Length', strlen($input));
         return Model::isOk($input);
     };
     return $this->_component->callByURI('request', $order, array('language' => $params['language']), '', 200, $positive, array('cachePath' => $cachePath, 'realExtension' => $realExtension, 'negativeMethod' => $negative, 'cacheFilename' => $path_parts['filename'] . $cacheExtension), $negative, array());
 }
Esempio n. 17
0
function twig_markdown_filter(Twig_Environment $env, $value)
{
    $markdownParser = new \Michelf\MarkdownExtra();
    return $markdownParser->transform($value);
}
Esempio n. 18
0
 /**
  * Display the API Documentation in Html (parsed from markdown)
  *
  * @param $file      string    relative path of documentation file
  **/
 public function inlineDocumentation($file)
 {
     global $CFG_GLPI;
     self::header(true, __("API Documentation"));
     echo Html::css($CFG_GLPI['root_doc'] . "/lib/prism/prism.css");
     echo Html::script($CFG_GLPI['root_doc'] . "/lib/prism/prism.js");
     echo "<div class='documentation'>";
     $documentation = file_get_contents(GLPI_ROOT . '/' . $file);
     $md = new Michelf\MarkdownExtra();
     $md->code_class_prefix = "language-";
     $md->header_id_func = function ($headerName) {
         $headerName = str_replace(array('(', ')'), '', $headerName);
         return rawurlencode(strtolower(strtr($headerName, [' ' => '-'])));
     };
     echo $md->transform($documentation);
     echo "</div>";
     Html::nullFooter();
 }
Esempio n. 19
0
 public function parsing($text)
 {
     $parser = new Michelf\MarkdownExtra();
     $text = $parser->defaultTransform($text);
     return $text;
 }
Esempio n. 20
0
 function formatReplies($sqlcasedata, $allUserArr, $frmt, $cq, $tz, $dt)
 {
     $CSrepcount = 0;
     foreach ($sqlcasedata as $caseKey => $getdata) {
         $caseDtUid = $getdata['Easycase']['user_id'];
         $csUsrDtlArr = $cq->getUserDtlsArr($caseDtUid, $allUserArr);
         $by_photo = $csUsrDtlArr['User']['photo'];
         $csUsrDtlArr['User']['photo_exist'] = 0;
         if (trim($by_photo)) {
             $csUsrDtlArr['User']['photo_exist'] = 1;
             //$frmt->pub_file_exists(DIR_USER_PHOTOS_S3_FOLDER,$by_photo);
         }
         $sqlcasedata[$caseKey]['Easycase']['userArr'] = $csUsrDtlArr;
         $getdata['Easycase']['message'] = preg_replace('/<script.*>.*<\\/script>/ims', '', $frmt->convert_ascii($getdata['Easycase']['message']));
         if ($getdata['Easycase']['legend'] == 6) {
             $sqlcasedata[$caseKey]['Easycase']['wrap_msg'] = '';
         } else {
             if ($getdata['Easycase']['message']) {
                 $CSrepcount++;
             }
             $reply = $getdata['Easycase']['message'];
             # Remove html from loading. If they put in html this will just display it as text
             # to the user.
             $strippedReply = htmlspecialchars($reply);
             # convert markdown to html. This must be performced AFTER htmlspecialchars
             # Since we have already run htmlspecialchars, we need to configure the parser to not
             # run this method on code blocks by setting the code_block_content_func to return
             # the input.
             $parser = new \Michelf\MarkdownExtra();
             $parser->code_block_content_func = function ($input) {
                 return $input;
             };
             $convertedReply = $parser->transform($strippedReply);
             $sqlcasedata[$caseKey]['Easycase']['wrap_msg'] = $convertedReply;
         }
         $caseDtId = $getdata['Easycase']['id'];
         $rplyFilesArr = $this->getCaseFiles($caseDtId);
         foreach ($rplyFilesArr as $fkey => $getFiles) {
             $caseFileName = $getFiles['CaseFile']['file'];
             $rplyFilesArr[$fkey]['CaseFile']['is_exist'] = 0;
             if (trim($caseFileName)) {
                 $rplyFilesArr[$fkey]['CaseFile']['is_exist'] = 1;
             }
             if (stristr($getFiles['CaseFile']['downloadurl'], 'www.dropbox.com')) {
                 $rplyFilesArr[$fkey]['CaseFile']['format_file'] = 'db';
             } elseif (stristr($getFiles['CaseFile']['downloadurl'], 'docs.google.com')) {
                 $rplyFilesArr[$fkey]['CaseFile']['format_file'] = 'gd';
             } else {
                 $rplyFilesArr[$fkey]['CaseFile']['format_file'] = substr(strrchr(strtolower($caseFileName), "."), 1);
             }
             $rplyFilesArr[$fkey]['CaseFile']['is_ImgFileExt'] = $frmt->validateImgFileExt($caseFileName);
             if ($rplyFilesArr[$fkey]['CaseFile']['is_ImgFileExt']) {
                 if (USE_S3 == 0) {
                     $rplyFilesArr[$fkey]['CaseFile']['fileurl'] = HTTP_CASE_FILES . $caseFileName;
                 } else {
                     $rplyFilesArr[$fkey]['CaseFile']['fileurl'] = $frmt->generateTemporaryURL(DIR_CASE_FILES_S3 . $caseFileName);
                 }
             }
             $rplyFilesArr[$fkey]['CaseFile']['file_size'] = $frmt->getFileSize($getFiles['CaseFile']['file_size']);
         }
         $sqlcasedata[$caseKey]['Easycase']['rply_files'] = $rplyFilesArr;
         $caseReplyType = $getdata['Easycase']['reply_type'];
         $caseDtMsg = $getdata['Easycase']['message'];
         $caseDtLegend = $getdata['Easycase']['legend'];
         $caseAssignTo = $getdata['Easycase']['assign_to'];
         $taskhourspent = $getdata['Easycase']['hours'];
         $taskcompleted = $getdata['Easycase']['completed_task'];
         $replyCap = '';
         $asgnTo = '';
         $sts = '';
         $hourspent = '';
         $completed = '';
         if ($caseReplyType == 0 && $caseDtMsg != '') {
             if ($caseDtLegend == 1) {
                 $sts = '<b class="new">New</b>';
             } elseif ($caseDtLegend == 2 || $caseDtLegend == 4) {
                 $sts = '<b class="wip">In Progress</b>';
             } elseif ($caseDtLegend == 3) {
                 $sts = '<b class="closed">Closed</b>';
             } elseif ($caseDtLegend == 5) {
                 $sts = '<b class="resolved">Resolved</b>';
             }
             $userArr1 = $cq->getUserDtlsArr($caseAssignTo, $allUserArr);
             $by_id1 = $userArr1['User']['id'];
             $by_email1 = $userArr1['User']['email'];
             $by_name_assign1 = $userArr1['User']['name'];
             $by_photo1 = $userArr1['User']['photo'];
             $short_name_assign1 = $userArr1['User']['short_name'];
             $asgnTo = $by_name_assign1;
             if ($taskhourspent != "0.0") {
                 $hourspent = $taskhourspent;
             }
             if ($taskcompleted != "0") {
                 $completed = $taskcompleted;
             }
         }
         if ($caseReplyType == 0 && ($caseDtMsg == '' || $caseDtLegend == 6)) {
             if ($caseDtLegend == 3) {
                 $replyCap = '<b class="closed">Closed</b> the Task';
             } elseif ($caseDtLegend == 4) {
                 $replyCap = '<b class="wip">Started</b> the Task';
             } elseif ($caseDtLegend == 5) {
                 $replyCap = '<b class="resolved">Resolved</b> the Task';
             } elseif ($caseDtLegend == 6) {
                 $replyCap = '<b class="resolved">Modified</b> the Task';
             }
         } else {
             if ($caseReplyType == 1) {
                 $caseDtTyp = $getdata['Easycase']['type_id'];
                 $prjtype_name = $cq->getTypeArr($caseDtTyp, $GLOBALS['TYPE']);
                 $name = $prjtype_name['Type']['name'];
                 $sname = $prjtype_name['Type']['short_name'];
                 $image = $frmt->todo_typ($sname, $name);
                 $replyCap = 'Task Type changed to ' . $image . ' <b>' . $name . '</b>';
             } elseif ($caseReplyType == 2) {
                 $userArr = $cq->getUserDtlsArr($caseAssignTo, $allUserArr);
                 $by_id = $userArr['User']['id'];
                 $by_email = $userArr['User']['email'];
                 $by_name_assign = $userArr['User']['name'];
                 $by_last_name_assign = $userArr['User']['last_name'];
                 $by_photo = $userArr['User']['photo'];
                 $replyCap = 'Task re-assigned to <b class="ttc">' . $by_name_assign . ' ' . $by_last_name_assign . '</b>';
             } elseif ($caseReplyType == 3) {
                 $caseDtDue = $getdata['Easycase']['due_date'];
                 $curCreated = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, GMT_DATETIME, "datetime");
                 if ($caseDtDue != "NULL" && $caseDtDue != "0000-00-00" && $caseDtDue != "" && $caseDtDue != "1970-01-01") {
                     $due_date = $dt->dateFormatOutputdateTime_day($caseDtDue, $curCreated, 'week');
                     $replyCap = 'Due Date changed to <b>' . $due_date . '</b>';
                 } else {
                     $replyCap = 'Due Date: <i>No Due Date</i>';
                 }
             } elseif ($caseReplyType == 4) {
                 $casePriority = $getdata['Easycase']['priority'];
                 if ($casePriority == 0) {
                     $replyCap = 'Priority changed to <b class="pr_high">High</b><br/>';
                 } elseif ($casePriority == 1) {
                     $replyCap = 'Priority changed to <b class="pr_medium">Medium</b><br/>';
                 } elseif ($casePriority == 2) {
                     $replyCap = 'Priority changed to <b class="pr_low">Low</b><br/>';
                 }
             }
         }
         $sqlcasedata[$caseKey]['Easycase']['sts'] = $sts;
         $sqlcasedata[$caseKey]['Easycase']['asgnTo'] = $asgnTo;
         $sqlcasedata[$caseKey]['Easycase']['hourspent'] = $hourspent;
         $sqlcasedata[$caseKey]['Easycase']['completed'] = $completed;
         $sqlcasedata[$caseKey]['Easycase']['replyCap'] = $replyCap;
         $caseDtActdT = $getdata['Easycase']['dt_created'];
         //$updated_by = $getdata['Easycase']['updated_by'];
         $replyDt = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, $caseDtActdT, "datetime");
         $curDate = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, GMT_DATETIME, "date");
         if ($caseDtUid == SES_ID && 0) {
             $usrName = "me";
         } else {
             $usrName = $csUsrDtlArr['User']['name'];
         }
         $sqlcasedata[$caseKey]['Easycase']['usrName'] = $usrName;
         $sqlcasedata[$caseKey]['Easycase']['rply_dt'] = $dt->dateFormatOutputdateTime_day($replyDt, $curDate);
         unset($sqlcasedata[$caseKey]['Easycase']['case_no'], $sqlcasedata[$caseKey]['Easycase']['case_count'], $sqlcasedata[$caseKey]['Easycase']['updated_by'], $sqlcasedata[$caseKey]['Easycase']['type_id'], $sqlcasedata[$caseKey]['Easycase']['priority'], $sqlcasedata[$caseKey]['Easycase']['title'], $sqlcasedata[$caseKey]['Easycase']['reply_type'], $sqlcasedata[$caseKey]['Easycase']['assign_to'], $sqlcasedata[$caseKey]['Easycase']['completed_task'], $sqlcasedata[$caseKey]['Easycase']['hours'], $sqlcasedata[$caseKey]['Easycase']['due_date'], $sqlcasedata[$caseKey]['Easycase']['istype'], $sqlcasedata[$caseKey]['Easycase']['status'], $sqlcasedata[$caseKey]['Easycase']['isactive'], $sqlcasedata[$caseKey]['Easycase']['dt_created'], $sqlcasedata[$caseKey]['Easycase']['actual_dt_created'], $sqlcasedata[$caseKey]['Easycase']['caseReplyType'], $sqlcasedata[$caseKey]['Easycase']['userArr']['User']['id'], $sqlcasedata[$caseKey]['Easycase']['userArr']['User']['email'], $sqlcasedata[$caseKey]['Easycase']['userArr']['User']['istype']);
     }
     $arr['CSrepcount'] = $CSrepcount;
     $arr['sqlcasedata'] = $sqlcasedata;
     return $arr;
 }
Esempio n. 21
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');
Esempio n. 22
0
            if (trim($text) != '') {
                $text3 .= Design::erstelleZeileShort(false, $text, 'break');
            }
            if (trim($text2) != '') {
                $text3 .= Design::erstelleZeileShort(false, $text2, 'break');
            }
            $addLink = '';
            if (file_exists($mdFile) || file_exists($mdFileResult)) {
                $addLink = '<br><a style="font-size: 75%" href="' . $data['name'] . '.html' . '">Beschreibung ></a>';
            }
            $body .= Design::erstelleBlock(false, $data['name'] . $addLink, $text3);
            $body .= '</body></html>';
            // speichert die Knotendaten im Verzeichnis des Aufrufs
            file_put_contents(dirname(__FILE__) . '/path/' . $elem . '/' . substr($file, 0, strlen($file) - 5) . '.html', $body);
            if (!file_exists($mdFileResult) && file_exists($mdFile)) {
                $parser = new \Michelf\MarkdownExtra();
                $input = umlaute(file_get_contents($mdFile));
                $my_html = $parser->transform($input);
                file_put_contents($mdFileResult, '<link rel="stylesheet" href="github-markdown.css" type="text/css"><span class="markdown-body">' . $my_html . '</span>');
                //@unlink($mdFile);
            }
            // entferne nun die bearbeitete Datei
            @unlink(dirname(__FILE__) . '/path/' . $elem . '/' . $file);
        }
    }
}
function umlaute($text)
{
    $search = array('ä', 'Ä', 'ö', 'Ö', 'ü', 'Ü', 'ß');
    $replace = array('&auml;', '&Auml;', '&ouml;', '&Ouml;', '&uuml;', '&Uuml;', '&szlig;');
    return str_replace($search, $replace, $text);
Esempio n. 23
0
function ExplainMarkdownExtra($path)
{
    $text = file_get_contents($path);
    return Michelf\MarkdownExtra::defaultTransform($text);
}
 function case_details($oauth_arg = NULL)
 {
     $this->layout = 'ajax';
     $details = 0;
     $oauth_return = 0;
     if (isset($oauth_arg) && !empty($oauth_arg)) {
         $oauth_return = 1;
     }
     $caseUniqId = isset($oauth_arg['caseUniqId']) ? $oauth_arg['caseUniqId'] : $this->params['data']['caseUniqId'];
     if (isset($this->params['data']['details'])) {
         $details = $this->params['data']['details'];
     }
     if (isset($this->params['data']['sorting'])) {
         $sorting = $this->params['data']['sorting'];
         $this->Cookie->write('SORT_THREAD', $sorting, '365 days');
     } elseif ($_COOKIE['REPLY_SORT_ORDER']) {
         if ($_COOKIE['REPLY_SORT_ORDER'] == 'ASC') {
             $sort_cookie = 1;
         }
         $sorting = $_COOKIE['REPLY_SORT_ORDER'] . " LIMIT 0,5";
     } else {
         $sorting = "DESC LIMIT 0,5";
     }
     $ProjId = NULL;
     $ProjName = NULL;
     $curCaseNo = NULL;
     $curCaseId = NULL;
     ######## get case number from case uniq ID ################
     $getCaseNoPjId = $this->Easycase->getEasycase($caseUniqId);
     if ($getCaseNoPjId) {
         $curCaseNo = $getCaseNoPjId['Easycase']['case_no'];
         $curCaseId = $getCaseNoPjId['Easycase']['id'];
         $prjid = $getCaseNoPjId['Easycase']['project_id'];
         $is_active = intval($getCaseNoPjId['Easycase']['isactive']) ? 1 : 0;
     } else {
         # No task with uniq_id $caseUniqId
         die;
     }
     ######## Checking user_project ################
     $this->loadModel('ProjectUser');
     $cond1 = array('conditions' => array('ProjectUser.user_id' => SES_ID, 'ProjectUser.company_id' => SES_COMP, 'Project.isactive' => 1, 'Project.id' => $prjid), 'fields' => array('DISTINCT Project.id', 'Project.uniq_id', 'Project.name'));
     $this->ProjectUser->unbindModel(array('belongsTo' => array('User')));
     $getProjId = $this->ProjectUser->find('first', $cond1);
     if ($getProjId) {
         $ProjId = $getProjId['Project']['id'];
         $projUniqId = $getProjId['Project']['uniq_id'];
         $ProjName = $getProjId['Project']['name'];
     } else {
         # Session user not assigned the project $prjid
         die;
     }
     $sqlcasedata = array();
     $getPostCase = array();
     if ($ProjId && $curCaseNo) {
         ######## get all cases
         $sqlcasedata = $this->Easycase->query("SELECT SQL_CALC_FOUND_ROWS Easycase.* FROM easycases as Easycase WHERE project_id='" . $ProjId . "' AND case_no=" . $curCaseNo . " AND istype='2'  ORDER BY dt_created " . $sorting);
         $countall = $this->Easycase->query("SELECT FOUND_ROWS() as total");
         if ($countall[0][0]['total'] > 5 && isset($sort_cookie)) {
             $limit1 = $countall[0][0]['total'] - 5;
             $sqlcasedata = $this->Easycase->query("SELECT  Easycase.* FROM easycases as Easycase WHERE project_id='" . $ProjId . "' AND case_no=" . $curCaseNo . " AND istype='2'  ORDER BY dt_created ASC LIMIT " . $limit1 . ",5");
         }
         $allMemsArr = $this->Easycase->getMemebersid($ProjId);
         $allMems = array();
         foreach ($allMemsArr as $k => $getAllMems) {
             if (intval($oauth_return)) {
                 $allMemsArr[$k]['User']['id'] = $allMemsArr[$k]['User']['uniq_id'];
             }
             $allMemsArr[$k]['User']['name'] = $this->Format->formatText($getAllMems['User']['name']);
             unset($allMemsArr[$k]['User']['email'], $allMemsArr[$k]['User']['istype'], $allMemsArr[$k]['User']['short_name'], $allMemsArr[$k]['User']['uniq_id']);
             $allMems[$getAllMems['User']['id']] = $allMemsArr[$k];
         }
         $getPostCase = $this->Easycase->query("SELECT * FROM easycases as Easycase WHERE project_id='" . $ProjId . "' AND case_no=" . $curCaseNo . " AND istype='1' ");
         $estimated_hours = isset($getPostCase['0']['Easycase']) && !empty($getPostCase['0']['Easycase']) ? $getPostCase['0']['Easycase']['estimated_hours'] : '0.0';
         $getHours = $this->Easycase->query("SELECT SUM(hours) as hours FROM easycases as Easycase WHERE project_id='" . $ProjId . "' AND case_no=" . $curCaseNo . " AND reply_type=0");
         $hours = $getHours[0][0]['hours'];
         $getcompletedtask = $this->Easycase->query("SELECT completed_task  FROM easycases as Easycase WHERE project_id='" . $ProjId . "' AND case_no=" . $curCaseNo . "  and completed_task != 0 ORDER BY id DESC LIMIT 1");
         $completedtask = $getcompletedtask[0]['Easycase']['completed_task'];
     } else {
         # $ProjId and $curCaseNo not found. This step should not, b'cos it handeled previously.
         die;
     }
     $this->loadModel('CaseRecent');
     $getCurCase = $this->CaseRecent->find('first', array('conditions' => array('CaseRecent.easycase_id' => $curCaseId, 'CaseRecent.user_id' => SES_ID, 'CaseRecent.project_id' => $ProjId), 'fields' => array('CaseRecent.id')));
     if (isset($getCurCase['CaseRecent']) && count($getCurCase['CaseRecent'])) {
         $post_caserecent['CaseRecent']['id'] = $getCurCase['CaseRecent']['id'];
     }
     $post_caserecent['CaseRecent']['easycase_id'] = $curCaseId;
     $post_caserecent['CaseRecent']['user_id'] = SES_ID;
     $post_caserecent['CaseRecent']['project_id'] = $ProjId;
     $post_caserecent['CaseRecent']['company_id'] = SES_COMP;
     if ($details == "0") {
         $post_caserecent['CaseRecent']['dt_created'] = GMT_DATETIME;
     }
     $this->CaseRecent->save($post_caserecent);
     ######## get easycase case members ################
     $usrDtlsAll = $this->Easycase->getTaskUser($ProjId, $curCaseNo);
     $allUserArr = array();
     foreach ($usrDtlsAll as $ud) {
         $allUserArr[$ud['User']['id']] = $ud;
     }
     ######## End get easycase case members ################
     $view = new View($this);
     $tz = $view->loadHelper('Tmzone');
     $dt = $view->loadHelper('Datetime');
     $cq = $view->loadHelper('Casequery');
     /* @var $frmt FormatHelper */
     $frmt = $view->loadHelper('Format');
     $sqlcasedata1 = $this->Easycase->formatReplies($sqlcasedata, $allUserArr, $frmt, $cq, $tz, $dt);
     $sqlcasedata = $sqlcasedata1['sqlcasedata'];
     if (intval($oauth_return)) {
         foreach ($sqlcasedata as $key => $csdata) {
             $sqlcasedata[$key]['Easycase']['id'] = $sqlcasedata[$key]['Easycase']['uniq_id'];
             unset($sqlcasedata[$key]['Easycase']['uniq_id'], $sqlcasedata[$key]['Easycase']['user_id'], $sqlcasedata[$key]['Easycase']['project_id']);
         }
     }
     # add mahavir
     $caseStatus = $getPostCase['0']['Easycase']['status'];
     $caseLegendRep = $getPostCase['0']['Easycase']['legend'];
     $caseAutoId = $getPostCase['0']['Easycase']['id'];
     $caseTypeRep = $getPostCase['0']['Easycase']['type_id'];
     $casePriRep = $getPostCase['0']['Easycase']['priority'];
     $caseTitleRep = $getPostCase['0']['Easycase']['title'];
     $caseUniqId = $getPostCase['0']['Easycase']['uniq_id'];
     $caseUserDtls = $getPostCase['0']['Easycase']['user_id'];
     $actualDt = $getPostCase['0']['Easycase']['actual_dt_created'];
     $caseMsgRep = $getPostCase['0']['Easycase']['message'];
     $caseUserAsgn = $getPostCase['0']['Easycase']['assign_to'];
     $caseFormat = $getPostCase['0']['Easycase']['format'];
     $caseDtCreated = $getPostCase['0']['Easycase']['dt_created'];
     $caseId = $getPostCase['0']['Easycase']['id'];
     $caseDuDate = $getPostCase['0']['Easycase']['due_date'];
     $caseUpdBy = $getPostCase['0']['Easycase']['updated_by'];
     $curDateTz = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, GMT_DATETIME, "datetime");
     $curdtT = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, GMT_DATETIME, "date");
     $locDT1 = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, $actualDt, "datetime");
     $created_on = $dt->facebook_style_date_time($locDT1, $curDateTz);
     $created_on_ttl = $dt->facebook_datetimestyle($locDT1);
     $updTzDate = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, $caseDtCreated, "datetime");
     $last_upddtm = $dt->dateFormatOutputdateTime_day($updTzDate, $curDateTz);
     $last_updated_ttl = $dt->facebook_datetimestyle($updTzDate);
     $getMlstnFromCsId = $this->Easycase->getMilestoneName($caseId);
     if ($getMlstnFromCsId) {
         $milestone = $getMlstnFromCsId;
     } else {
         $milestone = '';
     }
     $protyCls = '';
     $protyTtl = '';
     if ($casePriRep == 0) {
         $protyCls = 'high_priority';
         $protyTtl = 'High';
     } elseif ($casePriRep == 1) {
         $protyCls = 'medium_priority';
         $protyTtl = 'Medium';
     } elseif ($casePriRep == 2) {
         $protyCls = 'low_priority';
         $protyTtl = 'LOW';
     }
     # getting case_by
     $postuserArr = $cq->getUserDtlsArr($caseUserDtls, $allUserArr);
     $post_id = $postuserArr['User']['id'];
     $post_name = $postuserArr['User']['name'];
     $post_photo = $postuserArr['User']['photo'];
     $short_name = $postuserArr['User']['short_name'];
     if ($post_name && $caseUserDtls != SES_ID) {
         $case_by = $this->Format->shortLength($post_name, 20);
     } else {
         $case_by = "me";
     }
     # getting assignTo
     $assignTo = "";
     $assignUid = 0;
     if ($caseUserAsgn == SES_ID || $caseUserDtls == SES_ID && $caseUserAsgn == 0) {
         $assignUid = SES_ID;
     } elseif ($caseUserDtls != SES_ID && $caseUserAsgn == 0) {
         $assignUid = $caseUserDtls;
     } else {
         $assignUid = $caseUserAsgn;
     }
     $assigned = $cq->getUserDtlsArr($assignUid, $allUserArr);
     $assignTo = ucwords($frmt->formatText($assigned['User']['name'] . ' ' . $assigned['User']['last_name']));
     $asgnPic = $assigned['User']['photo'];
     $asgnEmail = $assigned['User']['email'];
     $csDuDtFmtT = $csDuDtFmt = '';
     if ($caseTypeRep == 10 || $caseLegendRep == 3 || $caseLegendRep == 5) {
         if ($caseDuDate != "NULL" && $caseDuDate != "0000-00-00" && $caseDuDate != "" && $caseDuDate != "1970-01-01") {
             $csDuDtFmtT = $dt->facebook_datestyle($caseDuDate);
             $csDuDtFmt = $dt->dateFormatOutputdateTime_day($caseDuDate, $curDateTz, 'week');
             if (strpos($csDuDtFmt, 'Today')) {
                 $csDuDtFmt = 'Due ' . $csDuDtFmt;
             } else {
                 $csDuDtFmt = 'Due On ' . $csDuDtFmt;
             }
         } else {
             $csDuDtFmtT = '';
             $csDuDtFmt = '';
         }
     } else {
         if ($caseDuDate != "NULL" && $caseDuDate != "0000-00-00" && $caseDuDate != "" && $caseDuDate != "1970-01-01") {
             if ($caseDuDate < $curdtT) {
                 $csDuDtFmtT = $dt->facebook_datestyle($caseDuDate);
                 $csDuDtFmt = '<div class="fl over-due"><span class="due-txt">Overdue</span><div class="cb" style="height:4px;"></div><div class="fl">' . $dt->dateFormatOutputdateTime_day($caseDuDate, $curDateTz, 'week') . '</div></div>';
             } else {
                 $csDuDtFmtT = $dt->facebook_datestyle($caseDuDate);
                 $csDuDtFmt = $dt->dateFormatOutputdateTime_day($caseDuDate, $curDateTz, 'week');
                 if (strpos($csDuDtFmt, 'Today') !== false) {
                     $csDuDtFmt = '<span class="due-txt">Due ' . $csDuDtFmt . '</span>';
                 } else {
                     $csDuDtFmt = '<span class="due-txt">Due On ' . $csDuDtFmt . '</span>';
                 }
             }
         } else {
             $csDuDtFmtT = '';
             $csDuDtFmt = '';
         }
     }
     # Title Caption start
     if ($caseUpdBy) {
         $getlastUid = $caseUpdBy;
     } else {
         $getlastUid = $caseUserDtls;
     }
     if ($getlastUid && $getlastUid != SES_ID) {
         $usrDtls = $cq->getUserDtlsArr($getlastUid, $allUserArr);
         $lstUpdBy = ucwords($frmt->formatText($usrDtls['User']['name'] . ' ' . $usrDtls['User']['last_name']));
     } else {
         $lstUpdBy = "me";
     }
     # getting case type image
     $sql = "SELECT Type.* FROM types AS Type WHERE Type.company_id = 0 OR Type.company_id =" . SES_COMP;
     $this->loadModel('Type');
     $typeArr = $this->Type->query($sql);
     $prjtype_name = $cq->getTypeArr($caseTypeRep, $typeArr);
     # getting case desc, img
     $countdata = count($sqlcasedata);
     $details = 0;
     if (trim(strip_tags(str_replace("&nbsp;", "", $caseMsgRep))) != "") {
         $details = 1;
     }
     $caseFiles = 0;
     if ($caseFormat != 2) {
         $filesArr = $this->Easycase->getCaseFiles($caseAutoId);
         if (count($filesArr)) {
             $caseFiles = 1;
             foreach ($filesArr as $fkey => $getFiles) {
                 $caseFileName = $getFiles['CaseFile']['file'];
                 $filesArr[$fkey]['CaseFile']['is_exist'] = 0;
                 if (trim($caseFileName)) {
                     $filesArr[$fkey]['CaseFile']['is_exist'] = 1;
                 }
                 $downloadurl = $getFiles['CaseFile']['downloadurl'];
                 if (isset($downloadurl) && trim($downloadurl)) {
                     if (stristr($downloadurl, 'www.dropbox.com')) {
                         $filesArr[$fkey]['CaseFile']['format_file'] = 'db';
                     } else {
                         $filesArr[$fkey]['CaseFile']['format_file'] = 'gd';
                     }
                 } else {
                     $filesArr[$fkey]['CaseFile']['format_file'] = substr(strrchr(strtolower($caseFileName), "."), 1);
                     $filesArr[$fkey]['CaseFile']['is_ImgFileExt'] = $frmt->validateImgFileExt($caseFileName);
                     if ($filesArr[$fkey]['CaseFile']['is_ImgFileExt']) {
                         if (USE_S3 == 0) {
                             $filesArr[$fkey]['CaseFile']['fileurl'] = HTTP_CASE_FILES . $caseFileName;
                         } else {
                             $filesArr[$fkey]['CaseFile']['fileurl'] = $frmt->generateTemporaryURL(DIR_CASE_FILES_S3 . $caseFileName);
                         }
                     }
                     $filesArr[$fkey]['CaseFile']['file_size'] = $frmt->getFileSize($getFiles['CaseFile']['file_size']);
                 }
             }
         }
     }
     $allCaseFiles = $this->Easycase->getAllCaseFiles($ProjId, $curCaseNo);
     $allCaseFiles = $this->Easycase->formatFiles($allCaseFiles, $frmt, $tz, $dt);
     $displaySection = 1;
     if (!$details && !$caseFiles) {
         $displaySection = 0;
     }
     $displayCreated = 1;
     if (!$countdata) {
         $displayCreated = 0;
     }
     $pstFileExst = 0;
     if (trim($post_photo)) {
         $pstFileExst = 1;
     }
     #  get case message
     if (false) {
         $caseMsgRep = $frmt->formatCms($caseMsgRep);
         #$caseMsgRep = $frmt->html_wordwrap($caseMsgRep, 80);
         $caseMsgRep = preg_replace('/<script.*>.*<\\/script>/ims', '', $frmt->html_wordwrap($caseMsgRep, 80));
     }
     # Remove html from loading. If they put in html this will just display it as text
     # to the user.
     $caseMsgRep = htmlspecialchars($caseMsgRep);
     # convert markdown to html. This must be performced AFTER htmlspecialchars
     # Since we have already run htmlspecialchars, we need to configure the parser to not
     # run this method on code blocks by setting the code_block_content_func to return the input
     $parser = new \Michelf\MarkdownExtra();
     $parser->code_block_content_func = function ($input) {
         return $input;
     };
     $caseMsgRep = $parser->transform($caseMsgRep);
     if ($post_id == SES_ID) {
         $usrName = "me";
     } else {
         $usrName = $post_name;
     }
     $crtdBy = $this->Format->formatText($usrName);
     $frmtCrtdDt = $dt->dateFormatOutputdateTime_day($locDT1, $curDateTz);
     # get cases sort order
     $thread_sortorder = isset($_COOKIE['REPLY_SORT_ORDER']) ? trim($_COOKIE['REPLY_SORT_ORDER']) : 'DESC';
     if (isset($_COOKIE['REPLY_SORT_ORDER']) && trim($_COOKIE['REPLY_SORT_ORDER']) == 'ASC') {
         $ascStyle = 'style="display:inline"';
         $descStyle = 'style="display:none"';
     } else {
         $ascStyle = 'style="display:none"';
         $descStyle = 'style="display:inline"';
     }
     $usrCurArr = $cq->getUserDtlsArr(SES_ID, $allUserArr);
     if (!$usrCurArr) {
         $usrCurArr = $cq->getUserDtlsArr(SES_ID, $allMems);
     }
     $userPhoto = $usrCurArr['User']['photo'];
     $user_name = $usrCurArr['User']['name'] . ' ' . $usrCurArr['User']['last_name'];
     $usrFileExst = 0;
     if (trim($userPhoto)) {
         $usrFileExst = 1;
     }
     $userIds = $this->Easycase->getUserEmail($caseAutoId);
     $usrArr = array();
     if (count($userIds)) {
         foreach ($userIds as $usId) {
             array_push($usrArr, $usId['CaseUserEmail']['user_id']);
         }
     }
     # get assign option
     if ($caseUserAsgn) {
         if ($caseUserAsgn == SES_ID) {
             $checkAsgn = "me";
         } else {
             $checkAsgn = "other";
         }
     }
     if (!$caseUserAsgn && $caseUserDtls == SES_ID) {
         $checkAsgn = "me";
     } elseif (!$caseUserAsgn) {
         $checkAsgn = "me";
     }
     # get last resolved
     $last_resolved = $last_resolved_ttl = '';
     if ($caseTypeRep != 10) {
         #  Checks for easycase type update
         $lastResDT = $this->Easycase->getLastResolved($ProjId, $curCaseNo);
         if ($lastResDT) {
             $resDT = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, $lastResDT['Easycase']['dt_created'], "datetime");
             $last_resolved = $dt->dateFormatOutputdateTime_day($resDT, $curDateTz);
             $last_resolved_ttl = $dt->facebook_datetimestyle($resDT);
         }
     }
     $last_closed = $last_closed_ttl = '';
     if ($caseTypeRep != 10) {
         # Checks for easycase type update
         $lastClsDT = $this->Easycase->getLastClosed($ProjId, $curCaseNo);
         if ($lastClsDT) {
             $clsDT = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, $lastClsDT['Easycase']['dt_created'], "datetime");
             $last_closed = $dt->dateFormatOutputdateTime_day($clsDT, $curDateTz);
             $last_closed_ttl = $dt->facebook_datetimestyle($clsDT);
         }
     }
     # For due date selection
     $friday = date('Y-m-d', strtotime($curDateTz . "next Friday"));
     $monday = date('Y-m-d', strtotime($curDateTz . "next Monday"));
     $tomorrow = date('Y-m-d', strtotime($curDateTz . "+1 day"));
     $caseDetail = array();
     $caseDetail['caseTitle'] = $this->Format->showlink(htmlentities($this->Format->convert_ascii($caseTitleRep), ENT_QUOTES));
     $caseDetail['estimated_hours'] = $estimated_hours;
     $caseDetail['hours'] = $hours;
     $caseDetail['completedtask'] = $completedtask;
     $caseDetail['sqlcasedata'] = $sqlcasedata;
     $caseDetail['CSrepcount'] = $sqlcasedata1['CSrepcount'];
     $caseDetail['projUniqId'] = $projUniqId;
     $caseDetail['projName'] = $ProjName;
     $caseDetail['allMems'] = $allMems;
     $caseDetail['total'] = $countall['0']['0']['total'];
     $caseDetail['taskUsrs'] = $allUserArr;
     $caseDetail['crtdt'] = $created_on;
     $caseDetail['crtdtTtl'] = $created_on_ttl;
     $caseDetail['lupdtTtl'] = $last_updated_ttl;
     $caseDetail['lupdtm'] = $last_upddtm;
     $caseDetail['mistn'] = ucfirst($milestone);
     $caseDetail['protyCls'] = $protyCls;
     $caseDetail['protyTtl'] = $protyTtl;
     $caseDetail['pstNm'] = $post_name;
     $caseDetail['pstPic'] = $post_photo;
     $caseDetail['shtNm'] = $short_name;
     $caseDetail['csby'] = $case_by;
     $caseDetail['csAtId'] = $caseAutoId;
     $caseDetail['asgnUid'] = $assignUid;
     $caseDetail['asgnTo'] = $assignTo;
     $caseDetail['asgnPic'] = $asgnPic;
     $caseDetail['asgnEmail'] = $asgnEmail;
     $caseDetail['csDuDtFmtT'] = $csDuDtFmtT;
     $caseDetail['csDuDtFmt'] = $csDuDtFmt;
     $caseDetail['taskTyp'] = $prjtype_name['Type'];
     $caseDetail['csLgndRep'] = $caseLegendRep;
     $caseDetail['dispSec'] = $displaySection;
     $caseDetail['dispCrtd'] = $displayCreated;
     $caseDetail['pstFileExst'] = $pstFileExst;
     $caseDetail['csUsrDtls'] = $caseUserDtls;
     $caseDetail['dtls'] = $details;
     $caseDetail['csFiles'] = $caseFiles;
     $caseDetail['filesArr'] = $filesArr;
     $caseDetail['cntdta'] = $countdata;
     $caseDetail['csMsgRep'] = $caseMsgRep;
     $caseDetail['csProjIdRep'] = $ProjId;
     $caseDetail['crtdBy'] = $crtdBy;
     $caseDetail['frmtCrtdDt'] = $frmtCrtdDt;
     $caseDetail['thrdStOrd'] = $thread_sortorder;
     $caseDetail['ascStyle'] = $ascStyle;
     $caseDetail['descStyle'] = $descStyle;
     $caseDetail['csUniqId'] = $caseUniqId;
     $caseDetail['usrPhoto'] = $userPhoto;
     $caseDetail['usrName'] = $user_name;
     $caseDetail['usrFileExst'] = $usrFileExst;
     # hidden fields value
     $caseDetail['csNoRep'] = $curCaseNo;
     $caseDetail['csTypRep'] = $caseTypeRep;
     $caseDetail['csPriRep'] = $casePriRep;
     $caseDetail['usrArr'] = $usrArr;
     $caseDetail['checkAsgn'] = $checkAsgn;
     $caseDetail['csUsrAsgn'] = $caseUserAsgn;
     $caseDetail['lstUpdBy'] = $lstUpdBy;
     $caseDetail['lstRes'] = $last_resolved;
     $caseDetail['lstRes_ttl'] = $last_resolved_ttl;
     $caseDetail['lstCls'] = $last_closed;
     $caseDetail['lstCls_ttl'] = $last_closed_ttl;
     $caseDetail['all_files'] = $allCaseFiles;
     $caseDetail['is_active'] = $is_active;
     # For due date selection
     $caseDetail['mdyCurCrtd'] = date('m/d/Y', strtotime($curDateTz));
     $caseDetail['mdyFriday'] = date('m/d/Y', strtotime($friday));
     $caseDetail['mdyMonday'] = date('m/d/Y', strtotime($monday));
     $caseDetail['mdyTomorrow'] = date('m/d/Y', strtotime($tomorrow));
     # for setting assign to
     $last = $caseDetail['sqlcasedata'][0];
     $record = end($allUserArr);
     if (SES_ID == $caseDetail['csUsrDtls'] && empty($caseDetail['sqlcasedata'])) {
         $caseDetail['Assign_to_user'] = $getPostCase['0']['Easycase']['assign_to'];
     } else {
         $caseDetail['Assign_to_user'] = isset($last['Easycase']['user_id']) ? $last['Easycase']['user_id'] : $record['User']['id'];
     }
     if (intval($oauth_return)) {
         return $caseDetail;
     } else {
         $this->set('caseDetail', json_encode($caseDetail));
     }
 }
Esempio n. 25
0
function twig_markdown_filter(Twig_Environment $env, $value)
{
    $markdownParser = new \Michelf\MarkdownExtra();
    return $markdownParser->transform(htmlspecialchars($value, ENT_NOQUOTES));
}
Esempio n. 26
0
 protected function org2html($section_subject, $section_content, $type_handle)
 {
     $fragments = explode(':', $type_handle);
     $type = $fragments[0];
     if ($type == 'code' || $type == 'post-answer') {
         $code_lang = $fragments[1];
         $format = 'plain';
     } else {
         if ($type == 'feature') {
             $feature_icon = $fragments[1];
             $format = 'markdown';
         } else {
             $format = $fragments[1];
         }
     }
     switch ($format) {
         case 'media_wiki':
             $wiki = new WikiParser();
             $section_content_formatted = $wiki->parse($section_content);
             break;
         case 'markdown':
             //$section_content = strip_tags ($section_content, self::RESERVED_TAGS);
             $section_content_formatted = \Michelf\Markdown::defaultTransform($section_content);
             $config = array('safe' => 1);
             $section_content_formatted = htmLawed($section_content_formatted, $config);
             break;
         case 'markdown_extra':
         case 'markdown_safe':
             //$section_content = strip_tags ($section_content, self::RESERVED_TAGS);
             $parser = new \Michelf\MarkdownExtra();
             $parser->code_class_prefix = 'brush:';
             $parser->code_attr_on_pre = true;
             $parser->code_no_code_tag = true;
             $section_content_formatted = $parser->transform($section_content);
             $config = array('safe' => 1);
             $section_content_formatted = htmLawed($section_content_formatted, $config);
             break;
         default:
             $section_content_formatted = htmlspecialchars($section_content, ENT_NOQUOTES | ENT_HTML5);
             break;
     }
     switch ($type) {
         case 'feature':
             $section_subject_formatted = htmlspecialchars($section_subject, ENT_NOQUOTES | ENT_HTML5);
             $section_content_html = "<div class=\"feature\">\n";
             $section_content_html .= "\t<div class=\"feature-icon\">\n";
             $section_content_html .= "\t\t<span class=\"glyphicon glyphicon-" . $feature_icon . "\"></span>\n";
             $section_content_html .= "\t</div>\n";
             $section_content_html .= "\t<h2>" . $section_subject_formatted . "</h2>\n";
             $section_content_html .= "\t{$section_content_formatted}\n";
             $section_content_html .= "</div>\n";
             break;
         case 'post':
         case 'plain':
         case 'post-question':
         case 'post-note':
         case 'post-reference':
             $section_content_html = "<div>\n" . $section_content_formatted . "\n</div>\n";
             break;
         case 'quotation':
             $section_content_html = "<blockquote>\n" . $section_content_formatted . "\n</blockquote>\n";
             break;
         case 'quotation-reverse':
             $section_content_html = "<blockquote class=\"blockquote-reverse\">\n" . $section_content_formatted . "\n</blockquote>\n";
             break;
         case 'address':
             $section_content_html = "<address>\n" . $section_content_formatted . "\n</address>\n";
             break;
         case 'code':
         case 'post-answer':
             $section_content_html = "<pre class=\"brush:{$code_lang}\">\n";
             $section_content_html .= $section_content_formatted;
             $section_content_html .= "\n</pre>\n";
             break;
         case 'member':
             $style = $fragments[3];
             $section_content_html = "<div class=\"panel panel-{$style}\">\n" . $section_content_formatted . "\n</div>\n";
             break;
         case 'pre':
         default:
             $section_content_html = "<pre>\n" . $section_content_formatted . "\n</pre>\n";
             break;
     }
     return $section_content_html;
 }
 public function detail($id, $milestone = null, $status = null, $status_id = null)
 {
     $this->load->helper('api');
     $this->load->model('campaign_model', 'campaign');
     $markdown_extra = new Michelf\MarkdownExtra();
     $milestones = $this->campaign->milestones_model();
     $selected_milestone = $this->input->get_post('milestone', TRUE) ? $this->input->get_post('milestone', TRUE) : $milestone;
     $selected_category = $this->input->get_post('highlight', TRUE) ? $this->input->get_post('highlight', TRUE) : null;
     $milestone = $this->campaign->milestone_filter($selected_milestone, $milestones);
     $view_data = array();
     // pass milestones data model
     $view_data['milestone'] = $milestone;
     // pass tracker data model
     $view_data['tracker_model'] = $this->campaign->tracker_model();
     $this->db->select('*');
     $this->db->where('id', $id);
     $query = $this->db->get('offices');
     if ($query->num_rows() > 0) {
         $view_data['office'] = $query->row();
         // Get note data
         $notes = $this->campaign->get_notes($view_data['office']->id, $milestone->selected_milestone);
         $view_data['note_model'] = $this->campaign->note_model();
         if ($notes->num_rows() > 0) {
             $note_list = array();
             foreach ($notes->result() as $note) {
                 $note_field = 'note_' . $note->field_name;
                 $note_list[$note_field] = json_decode($note->note);
                 if (!empty($note_list[$note_field]->current->note)) {
                     $note_html = $note_list[$note_field]->current->note;
                     $note_html = $markdown_extra->transform($note_html);
                     $note_html = linkToAnchor($note_html);
                     $note_list[$note_field]->current->note_html = $note_html;
                 } else {
                     $note_list[$note_field]->current->note_html = null;
                 }
             }
             $view_data['notes'] = $note_list;
         }
         // Get crawler data
         $view_data['office_campaign'] = $this->campaign->datagov_office($view_data['office']->id, $milestone->selected_milestone, null, $status_id);
         // Get the IDs of daily crawls before and after this date
         $crawls_before = $this->campaign->datagov_office_crawls($view_data['office']->id, $milestone->selected_milestone, $view_data['office_campaign']->status_id, '<', '5');
         $crawls_after = $this->campaign->datagov_office_crawls($view_data['office']->id, $milestone->selected_milestone, $view_data['office_campaign']->status_id, '>', '5');
         $view_data['nearby_crawls'] = array_merge(array_reverse($crawls_before), $crawls_after);
         // If we have a blank slate, populate the data model
         if (empty($view_data['office_campaign'])) {
             $view_data['office_campaign'] = $this->campaign->datagov_model();
         }
         // Make sure tracker data uses full tracker model
         if (isset($view_data['office_campaign']->tracker_fields)) {
             $tracker_fields = $view_data['office_campaign']->tracker_fields ? json_decode($view_data['office_campaign']->tracker_fields) : new stdClass();
             foreach ($view_data['tracker_model'] as $field_name => $value) {
                 $tracker_fields->{$field_name} = isset($tracker_fields->{$field_name}) ? $tracker_fields->{$field_name} : null;
             }
             $view_data['office_campaign']->tracker_fields = json_encode($tracker_fields);
         }
         if (!empty($view_data['office_campaign']->datajson_status)) {
             $view_data['office_campaign']->expected_datajson_url = !empty($view_data['office_campaign']->datajson_status['url']) ? $view_data['office_campaign']->datajson_status['url'] : '';
             $view_data['office_campaign']->expected_datajson_status = (object) json_decode($view_data['office_campaign']->datajson_status);
         }
         if ($this->config->item('show_all_offices')) {
             // Get sub offices
             $this->db->select('*');
             $this->db->from('offices');
             $this->db->join('datagov_campaign', 'datagov_campaign.office_id = offices.id', 'left');
             $this->db->where('offices.parent_office_id', $view_data['office']->id);
             $this->db->order_by("offices.name", "asc");
             $query = $this->db->get();
             if ($query->num_rows() > 0) {
                 $view_data['child_offices'] = $query->result();
             }
         }
     }
     // selected tab
     $view_data['selected_category'] = $selected_category;
     // pass tracker section breakdown model
     $view_data['section_breakdown'] = $this->campaign->tracker_sections_model();
     // pass config variable
     $view_data['config'] = array('max_remote_size' => $this->config->item('max_remote_size'), 'archive_dir' => $this->config->item('archive_dir'));
     //var_dump($view_data['office_campaign']); exit;
     $this->load->view('office_detail', $view_data);
 }
Esempio n. 28
0
 protected function Markdown($source)
 {
     $parser = new Michelf\MarkdownExtra();
     $html = $parser->transform($source);
     return $html;
 }
 function parseExtra()
 {
     return Michelf\MarkdownExtra::defaultTransform($this->content);
 }
 public function detail($id, $milestone = null, $status = null, $status_id = null)
 {
     $this->load->helper('api');
     $this->load->model('campaign_model', 'campaign');
     $markdown_extra = new Michelf\MarkdownExtra();
     $milestones = $this->campaign->milestones_model();
     if ($this->session->userdata('permissions') !== 'admin') {
         $selected_milestone = $this->get_default_milestone();
     } else {
         $selected_milestone = $this->input->get_post('milestone', TRUE) ? $this->input->get_post('milestone', TRUE) : $milestone;
     }
     $selected_category = $this->input->get_post('highlight', TRUE) ? $this->input->get_post('highlight', TRUE) : null;
     $milestone = $this->campaign->milestone_filter($selected_milestone, $milestones);
     $selected_milestone_index = array_search($selected_milestone, array_keys($milestones)) + 1;
     $view_data = array();
     // pass milestones data model
     $view_data['milestone'] = $milestone;
     // pass tracker data model
     $view_data['tracker_model'] = $this->campaign->tracker_model($selected_milestone);
     // indicate "tracker fields" that are placeholders for tables, not actual fields
     $view_data['tracker_field_tables'] = array('pa_bureau_it_leadership_table', 'pa_cio_governance_board_table', '');
     $this->db->select('*');
     $this->db->where('id', $id);
     $query = $this->db->get('offices');
     if ($query->num_rows() > 0) {
         $view_data['office'] = $query->row();
         // Get note data
         $notes = $this->campaign->get_notes($view_data['office']->id, $milestone->selected_milestone);
         $view_data['note_model'] = $this->campaign->note_model();
         if ($notes->num_rows() > 0) {
             $note_list = array();
             foreach ($notes->result() as $note) {
                 $note_field = 'note_' . $note->field_name;
                 $note_list[$note_field] = json_decode($note->note);
                 if (!empty($note_list[$note_field]->current->note)) {
                     $note_html = $note_list[$note_field]->current->note;
                     $note_html = $markdown_extra->transform($note_html);
                     $note_html = linkToAnchor($note_html);
                     $note_list[$note_field]->current->note_html = $note_html;
                 } else {
                     $note_list[$note_field]->current->note_html = null;
                 }
             }
             $view_data['notes'] = $note_list;
         }
         // Get crawler data
         $view_data['office_campaign'] = $this->campaign->ciogov_office($view_data['office']->id, $milestone->selected_milestone, null, $status_id);
         // Get the IDs of daily crawls before and after this date
         $crawls_before = $this->campaign->ciogov_office_crawls($view_data['office']->id, $milestone->selected_milestone, $view_data['office_campaign']->status_id, '<', '5');
         $crawls_after = $this->campaign->ciogov_office_crawls($view_data['office']->id, $milestone->selected_milestone, $view_data['office_campaign']->status_id, '>', '5');
         $view_data['nearby_crawls'] = array_merge(array_reverse($crawls_before), $crawls_after);
         // If we have a blank slate, populate the data model
         if (empty($view_data['office_campaign'])) {
             $view_data['office_campaign'] = $this->campaign->ciogov_model();
         }
         // Make sure tracker data uses full tracker model
         if (isset($view_data['office_campaign']->tracker_fields)) {
             $tracker_fields = $view_data['office_campaign']->tracker_fields ? json_decode($view_data['office_campaign']->tracker_fields) : new stdClass();
             $clone_tracker_model = clone $view_data['tracker_model'];
             foreach ($view_data['tracker_model'] as $field_name => $value) {
                 //disable tracker field in data+model if not in correct milestone
                 if (isset($value->active) && intval($selected_milestone_index) < intval($value->active)) {
                     unset($tracker_fields->{$field_name});
                     unset($clone_tracker_model->{$field_name});
                 } else {
                     $tracker_fields->{$field_name} = isset($tracker_fields->{$field_name}) ? $tracker_fields->{$field_name} : null;
                 }
             }
             $view_data['tracker_model'] = $clone_tracker_model;
             //updates model if any tracker fields were disabled
             $view_data['office_campaign']->tracker_fields = json_encode($tracker_fields);
         }
         //$view_data['bureau_governance_detail'] = $this->getBureauGovernanceDetail();
         $view_data = $this->getRecommendationDetail($view_data, $milestone->selected_milestone);
         if ($this->config->item('show_all_offices')) {
             // Get sub offices
             $this->db->select('*');
             $this->db->from('offices');
             $this->db->join('ciogov_campaign', 'ciogov_campaign.office_id = offices.id', 'left');
             $this->db->where('offices.parent_office_id', $view_data['office']->id);
             $this->db->order_by("offices.name", "asc");
             $query = $this->db->get();
             if ($query->num_rows() > 0) {
                 $view_data['child_offices'] = $query->result();
             }
         }
     }
     // selected tab
     $view_data['selected_category'] = $selected_category;
     // pass tracker section breakdown model
     $view_data['section_breakdown'] = $this->campaign->tracker_sections_model($selected_milestone);
     // pass config variable
     $view_data['config'] = array('max_remote_size' => $this->config->item('max_remote_size'), 'archive_dir' => $this->config->item('archive_dir'));
     //var_dump($view_data) exit;
     $this->load->view('office_detail', $view_data);
 }