Beispiel #1
0
 public function foldValue($value)
 {
     $value = \Webforge\Common\String::fixEOL($value);
     $value = wordwrap($value, 74, "\n", TRUE);
     $value = str_replace("\n", "\n ", $value);
     return $value;
 }
Beispiel #2
0
 /**
  * @return array mit den Werten als relative Pfade getrennt mit / (unsortiert)
  */
 public function listFiles()
 {
     $out = $this->exec('vb');
     $out = S::fixEOL($out);
     $files = explode("\n", $out);
     $files = array_filter($files);
     $files = array_map(function ($file) {
         return str_replace(DIRECTORY_SEPARATOR, '/', $file);
     }, $files);
     return $files;
 }
Beispiel #3
0
 /**
  * @return markupText
  */
 public static function parseList($string)
 {
     $string = S::fixEOL($string);
     /* 
      * 1.subpattern: erkenne das aufzählungszeichen -, o oder * erlaubt
      * 2.subpattern: der Text (kann über mehrere Zeilen gehen) der nach dem Aufzählungszeichen kommt
      * methode: ist in der nächsten zeile nicht das subpattern, eine leere zeile
      */
     $pattern = '/\\040*([-*o•])\\s*((?(?!(\\n\\040*\\1|\\n\\n))(?:\\n|.)|.)*)/g';
     $matches = array();
     Preg::match($string, $pattern, $matches);
     $listContent = NULL;
     foreach ($matches as $key => $match) {
         if ($key == count($matches) - 1) {
             $liContentTextfmt = rtrim($match[2], "\n");
             // letzte Lineend entfernen da dies der umbruch vor [/liste] ist
         } else {
             $liContentTextfmt = $match[2];
         }
         $listContent .= '  [li]' . $liContentTextfmt . '[/li]' . "\n";
     }
     return '[ul]' . "\n" . $listContent . "[/ul]";
 }
Beispiel #4
0
 public function extract($code, $startLine, $endLine)
 {
     $source = S::fixEOL($code);
     $source = explode("\n", $source);
     if (!array_key_exists($startLine - 1, $source) || !array_key_exists($endLine - 1, $source)) {
         throw new \Psc\Exception('In source: ' . $file . ' gibt es keinen Code von ' . $startLine . ' bis ' . $endLine);
     }
     return implode("\n", array_slice($source, $startLine - 1, $endLine - $startLine + 1));
 }