/**
     */
    public function testGetBlocks()
    {
        $strTemplate = <<<EOT
<!-- BEGIN one -->
 <!-- BEGIN three -->
  <!-- BEGIN four -->
   <!-- BEGIN six -->
    some text
   <!-- END six -->
  <!-- END four -->
 <!-- END three -->
 <!-- BEGIN five -->
 <!-- END five -->
<!-- END one -->
<!-- BEGIN two -->
<!-- END two -->
EOT;
        $arBlocks = HTML_Template_PHPLIB_Generator::getBlocks(HTML_Template_PHPLIB_Helper::splitLines($strTemplate));
        $this->assertEquals(2, count($arBlocks));
        $this->assertArrayHasKey('one', $arBlocks);
        $this->assertArrayHasKey('two', $arBlocks);
        $this->assertEquals(2, count($arBlocks['one']['sub']));
        $this->assertArrayHasKey('three', $arBlocks['one']['sub']);
        $this->assertArrayHasKey('five', $arBlocks['one']['sub']);
        $this->assertArrayHasKey('four', $arBlocks['one']['sub']['three']['sub']);
    }
    /**
     */
    public function testSplitLines()
    {
        $strContent = <<<EOT
1
22
333
44
5
EOT;
        $this->assertEquals(array('1', '22', '333', '44', '5'), HTML_Template_PHPLIB_Helper::splitLines($strContent));
    }
Beispiel #3
0
 /**
  * Returns an array with all lines of the text.
  * Extracts it from the file or the text
  *
  * @param string $strFile    File name
  * @param string $strContent Template code
  *
  * @return array Array with text lines, without trailing newlines,
  *                false when both are null
  */
 public static function getLines($strFile = null, $strContent = null)
 {
     if ($strContent !== null) {
         $arLines = HTML_Template_PHPLIB_Helper::splitLines($strContent);
     } else {
         if ($strFile !== null) {
             $arLines = file($strFile, FILE_IGNORE_NEW_LINES);
         } else {
             //all null?
             return false;
         }
     }
     return $arLines;
 }