示例#1
0
 /**
  * @param bool $smaller
  * @return null|string
  */
 function renderDescriptionPanel($smaller = false)
 {
     $description = $this->renderDescription();
     if (!$description) {
         return null;
     }
     $output = getPanelStart($smaller, 'textPanelSpacing');
     $output .= $description;
     $output .= getPanelEnd();
     return $output;
 }
示例#2
0
 public function showExamplesAsHTML()
 {
     $output = "";
     if (isset($this->exampleEntries[$this->category][$this->example]) == false) {
         return "";
     }
     $examples = $this->exampleEntries[$this->category][$this->example];
     $count = 1;
     foreach ($examples as $example) {
         $example = unserialize($example);
         $output .= "<div class='row'>\n                <div class='col-md-12 contentPanel'>";
         $header = false;
         if (count($examples) > 1) {
             $header = "Example {$count}";
         }
         $description = $example->getDescription();
         if (strlen(trim($description))) {
             if ($header) {
                 $header .= ' - ' . $description;
             } else {
                 $header = $description;
             }
         }
         $uri = sprintf("https://github.com/Danack/Imagick-demos/tree/master/src/ImagickDemo/%s/functions.php", $example->category);
         if ($example->startLine && $example->endLine) {
             $uri .= sprintf("#L%d-L%d", $example->startLine, $example->endLine);
         } else {
             if ($example->startLine) {
                 $uri .= sprintf("#L%d", $example->startLine);
             }
         }
         $string = $example->getLines();
         $offset = 0;
         $lines = explode("\n", $string);
         foreach ($lines as $line) {
             if (!strlen(trim($line))) {
                 continue;
             }
             $matched = preg_match('#[^\\s]#', $line, $matches, PREG_OFFSET_CAPTURE);
             if ($matched) {
                 $offset = $matches[0][1];
                 break;
             }
         }
         $output .= "<div class='shContainer'>";
         $output .= "<pre class='brush: php;' data-github='{$uri}'>";
         if ($header) {
             for ($x = 0; $x < $offset; $x++) {
                 $output .= ' ';
             }
             $output .= '//' . $header . "\n\n";
         }
         $output .= $example->getLines();
         $output .= "</pre></div>";
         $count++;
         $output .= getPanelEnd();
     }
     return $output;
 }