public function home()
 {
     //appel des composants en base
     $headings = Heading::all();
     $slides = Slide::all();
     $featurets = Featuret::all();
     //retour de la vue
     return View::make('home', array('headings' => $headings, 'slides' => $slides, 'featurets' => $featurets));
 }
 function test_simple_components()
 {
     $comp = new Blank(3);
     $this->assertIdentical($comp->getType(), BLANK);
     $comp = new Block("hoho", 3);
     $this->assertIdentical($comp->getType(), BLOCK);
     $comp = new Heading("hoho", 3);
     $this->assertIdentical($comp->getType(), HEADING);
     $comp = new Footer("hoho", 3);
     $this->assertIdentical($comp->getType(), FOOTER);
 }
예제 #3
0
 /**
  * Answer the contents of the current topic
  * 
  * @param string $topic
  * @return object Component
  * @access public
  * @since 12/9/05
  */
 function getTopicContents($topic)
 {
     $topicContainer = new Container(new YLayout(), BLANK, 1);
     $tocPart = $this->_tableOfContents->getTableOfContentsPart($topic);
     try {
         $document = $this->getTopicXmlDocument($topic);
     } catch (DOMException $e) {
         $topicContainer->add(new Block(_("Could not load help topic:") . "<br/><br/>" . $e->getMessage(), STANDARD_BLOCK));
         return $topicContainer;
     }
     $xpath = new DOMXPath($document);
     $bodyElements = $xpath->query("/html/body");
     if (!$bodyElements->length) {
         $topicContainer->add(new Block(_("This topic has no information yet."), STANDARD_BLOCK));
         return $topicContainer;
     }
     $body = $bodyElements->item(0);
     if ($tocPart && !is_null($document->documentElement)) {
         $this->updateSrcTags($document->documentElement, $tocPart->urlPath . "/");
     }
     // put custom style sheets in the page's head
     $headElements = $xpath->query("/html/head");
     $head = $headElements->item(0);
     $newHeadText = '';
     foreach ($head->childNodes as $child) {
         $newHeadText .= $document->saveXML($child) . "\n\t\t";
     }
     $harmoni = Harmoni::instance();
     $outputHandler = $harmoni->getOutputHandler();
     $outputHandler->setHead($outputHandler->getHead() . $newHeadText);
     /*********************************************************
      * Page TOC
      *********************************************************/
     $currentLevel = 1;
     $toc = new TOC_Printer();
     foreach ($body->childNodes as $element) {
         unset($level);
         switch ($element->nodeName) {
             case 'h1':
                 $level = 1;
             case 'h2':
                 if (!isset($level)) {
                     $level = 2;
                 }
             case 'h3':
                 if (!isset($level)) {
                     $level = 3;
                 }
             case 'h4':
                 if (!isset($level)) {
                     $level = 4;
                 }
                 $heading = $element->textContent;
                 $anchor = strtolower(preg_replace('/[^a-zA-Z0-9_]/', '', $element->textContent));
                 if ($level > $currentLevel) {
                     while ($level > $currentLevel) {
                         $toc = $toc->addLevel();
                         $currentLevel++;
                     }
                 } else {
                     if ($level < $currentLevel) {
                         while ($level < $currentLevel) {
                             $toc = $toc->removeLevel();
                             $currentLevel--;
                         }
                     }
                 }
                 $toc->addHtml("<a href='#{$anchor}'>{$heading}</a>");
         }
     }
     $toc = $toc->getRoot();
     if ($toc->numChildren() > 1 || $toc->hasMoreLevels()) {
         $topicContainer->add(new Block($toc->getHtml(), STANDARD_BLOCK));
     }
     /*********************************************************
      * Content of the page
      *********************************************************/
     ob_start();
     foreach ($body->childNodes as $element) {
         switch ($element->nodeName) {
             case 'h1':
                 $heading = new Heading($element->textContent, 1);
             case 'h2':
                 if (!isset($heading)) {
                     $heading = new Heading($element->textContent, 2);
                 }
             case 'h3':
                 if (!isset($heading)) {
                     $heading = new Heading($element->textContent, 3);
                 }
             case 'h4':
                 if (!isset($heading)) {
                     $heading = new Heading($element->textContent, 4);
                 }
                 $heading->setPreHTML("<a name=\"" . strtolower(preg_replace('/[^a-zA-Z0-9_]/', '', $element->textContent)) . "\"></a>");
                 // Finish off our previous block if it had contents.
                 $previousBlockText = ob_get_clean();
                 if (strlen(trim($previousBlockText))) {
                     $topicContainer->add(new Block($this->linkify($previousBlockText), STANDARD_BLOCK));
                 }
                 // create our heading element
                 $topicContainer->add($heading);
                 unset($heading);
                 // Start a new buffer for the next block contents.
                 ob_start();
                 break;
             default:
                 print $document->saveXML($element) . "\n";
         }
     }
     $topicContainer->add(new Block($this->linkify(ob_get_clean()), STANDARD_BLOCK));
     return $topicContainer;
 }