From: vincent@cubedesigners.com Date: Tue, 22 Sep 2020 17:59:30 +0000 (+0000) Subject: wait #3905 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=fea9b2521e54a9c3bb45b446c1e43ea14daf2822;p=cubeextranet.git wait #3905 @2 --- diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index 74fac27c4..4b594a7ab 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -188,9 +188,11 @@ class wsBookParametres extends wsParametres $this->fields['centerBook'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Centrer la publication sur les couvertures'), 'grade' => 2); $this->fields['correctCenter'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Corriger les lignes blanches entre les pages'), 'grade' => 2); $this->fields['maxResolution'] = array('type' => 'combo', 'default' => 300, 'editable' => true, 'datas' => array('300dpi' => 300, '150dpi' => 150), 'grade' => 2, 'label' => __('Résolution maximale des pages')); + $this->fields['imageFormat'] = array('type' => 'combo', 'default' => 'jpg', 'editable' => true, 'datas' => array(/*__('Le plus léger') => 'best', */ + 'JPEG' => 'jpg', 'PNG' => 'png'), 'grade' => 2, 'label' => __('Format des images')); $this->fields['dynamicBackgroundColor'] = ['type' => 'textarea', 'default' => '', 'editable' => true, 'label' => 'Couleur de fond dynamique', 'grade' => 3]; $this->forms['3d_mode'] = array('label' => __('Options de visualisation'), - 'fieldsnames' => array('visualisationMode', 'antialiasReading', 'correctCenter', 'pagesBaseAngle', 'centerBook', '|', 'extraXSpace', 'extraYSpace', '|', 'viewMode', '|', 'dynamicBackgroundColor', '|', 'maxResolution')); + 'fieldsnames' => array('visualisationMode', 'antialiasReading', 'correctCenter', 'pagesBaseAngle', 'centerBook', '|', 'extraXSpace', 'extraYSpace', '|', 'viewMode', '|', 'dynamicBackgroundColor', '|', 'imageFormat', 'maxResolution')); $this->fields['preload'] = array('type' => 'integer', 'default' => 16, 'editable' => true, 'label' => __('Nombre de pages à précharger'), 'grade' => 3); diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 1db28b0b5..d3cd66ec9 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -110,7 +110,7 @@ class wsDocument extends cubeMetier public function copyOriginalFromOlderVersion() { if (!file_exists($this->in)) { - // copy('https://ws.fluidbook.com/docs/' . $this->document_id . '/original.pdf', $this->in); + // copy('https://ws.fluidbook.com/docs/' . $this->document_id . '/original.pdf', $this->in); } } @@ -556,16 +556,17 @@ class wsDocument extends cubeMetier protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null, $texts = true) { - if (is_null($in)) { - $in = $this->getCroppedPDF(); - } - $tmp = cubeFiles::tempnam(); + $pttopx = 1; + + $s = $this->generalInfos['page'][$page]['size']; + $w = floor(($s[0] * $pttopx) * ($resolution / 72)); + $h = floor(($s[1] * $pttopx) * ($resolution / 72)); $antialiasing = $antialiasing ? 'yes' : 'no'; $freetype = $texts ? 'yes' : 'no'; // Exporte les fichiers - $pdftoppm = new cubeCommandLine('pdftoppm', null, true); + $pdftoppm = new CubeIT_CommandLine('pdftoppm', null, true); $pdftoppm->setPath(CONVERTER_PATH); $pdftoppm->setArg('f', 1); @@ -576,14 +577,17 @@ class wsDocument extends cubeMetier $pdftoppm->setArg('-aa ' . $antialiasing); $pdftoppm->setArg('-aaVector ' . $antialiasing); $pdftoppm->setArg('r', $resolution); + $pdftoppm->setArg('W', $w); + $pdftoppm->setArg('H', $h); $pdftoppm->setArg(null, $this->getSplittedPDFPage($page)); $pdftoppm->setArg(null, $tmp); $pdftoppm->execute(); - $this->addToLog($pdftoppm, true, $page); + $pdftoppm->debug(); $tmp .= '.ppm'; $jpegfile = $this->out . $prefix . $page . '.jpg'; + $pngfile = $this->out . $prefix . $page . '.png'; if (file_exists($tmp)) { // $pnmtojpeg = new cubeCommandLine('pnmtojpeg', $jpegfile, false); @@ -593,13 +597,18 @@ class wsDocument extends cubeMetier // $this->addToLog($pnmtojpeg, false, $page); - $cjpeg = new cubeCommandLine('cjpeg', null, true); + $cjpeg = new cubeCommandLine('/opt/mozjpeg/bin/cjpeg', null, true); $cjpeg->setArg('-quality ' . ($quality + 6)); $cjpeg->setArg('-outfile ' . $jpegfile); $cjpeg->setArg(null, $tmp); $cjpeg->execute(); $this->addToLog($cjpeg, false, $page); + $pnmtopng = new CubeIT_CommandLine('pnmtopng', $pngfile, false); + $pnmtopng->setArg('-background white'); + $pnmtopng->setArg(null, $tmp); + $pnmtopng->execute(); + unlink($tmp); } } @@ -1132,11 +1141,11 @@ class wsDocument extends cubeMetier // return $d0; } - public static function makeHTML5FilesIfNotExists($document_id, $document_page) + public static function makeHTML5FilesIfNotExists($document_id, $document_page, $format = 'jpg') { global $core; - $path = self::getDir($document_id) . '/html/h150-' . $document_page . '.jpg'; + $path = self::getDir($document_id) . '/html/h150-' . $document_page . '.' . $format; if (!file_exists($path)) { $dao = new wsDAODocument($core->con); $doc = $dao->selectById($document_id); @@ -1144,11 +1153,11 @@ class wsDocument extends cubeMetier } } - public static function makeMobileFirstFilesIfNotExists($document_id, $document_page) + public static function makeMobileFirstFilesIfNotExists($document_id, $document_page, $format = 'jpg') { global $core; - $path = self::getDir($document_id) . '/mf/h150-' . $document_page . '.jpg'; + $path = self::getDir($document_id) . '/mf/h150-' . $document_page . '.' . $format; if (!file_exists($path)) { $dao = new wsDAODocument($core->con); $doc = $dao->selectById($document_id); diff --git a/inc/ws/Util/class.ws.pdf.convert.php b/inc/ws/Util/class.ws.pdf.convert.php index aa7ed7c4b..7ee4fcbb3 100644 --- a/inc/ws/Util/class.ws.pdf.convert.php +++ b/inc/ws/Util/class.ws.pdf.convert.php @@ -6,133 +6,152 @@ * Date: 17/11/2016 * Time: 14:24 */ -class wsPDFConvert { - - public static function makeMiniShot($in, $out, $page) { - self::makeShotFixedWidth($in, $out, $page, 'p', 500, 65, 4, 'PNM'); - } - - public static function makeShotFixedWidth($in, $out, $page, $prefix = '', $w = 100, $quality = 90, $antialiasing = 4, $method = 'PNM') { - // Make thumbs of $w width - self::makeShot($in, $out, $page, $prefix, null, $quality, $antialiasing, $method, $w, -1); - } - - public static function makeShotFixedHeight($in, $out, $page, $prefix = '', $h = '', $quality = 90, $antialiasing = 4, $method = 'PNM') { - // Make thumbs of $h height - self::makeShot($in, $out, $page, $prefix, null, $quality, $antialiasing, $method, -1, $h); - } - - public static function makeShot($in, $out, $page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $method = 'PNM', $width = null, $height = null) { - $error = false; - if ($method == 'GS') { - self::makeShotGS($in, $out, $page, $prefix, $resolution, $quality, $antialiasing, $width, $height); - } elseif ($method == 'PNM') { - self::makeShotPNM($in, $out, $page, $prefix, $resolution, $quality, $antialiasing, true, $width, $height); - } - // Test the result by checking all files - if (!file_exists($out)) { - $error = true; - } - // If error, we try to make thumbs with other method - if ($error) { - if ($method == 'GS') { - self::makeShotPNM($in, $out, $page, $prefix, $resolution, $quality, $antialiasing, true, $width, $height); - } elseif ($method == 'PNM') { - self::makeShotGS($in, $out, $page, $prefix, $resolution, $quality, $antialiasing, $width, $height); - } - } - } - - protected static function makeShotGS($in, $out, $page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $width = null, $height = null) { - - // Fabrication des thumbanails avec ghostscript - $gs = new cubeCommandLine('gs', null, true); - $gs->setPath(CONVERTER_PATH); - $gs->setEnv('GS_FONTPATH', FONT_PATH); - $gs->setArg('-dBATCH'); - $gs->setArg('-dNOPAUSE'); - $gs->setArg('-dNOPROMPT'); - // Antialias - $gs->setArg('-dDOINTERPOLATE'); - $gs->setArg('-dTextAlphaBits=' . $antialiasing); - $gs->setArg('-dGraphicsAlphaBits=' . $antialiasing); - // Device - $gs->setArg('-sDEVICE=jpeg'); - // Dispotion & colors - // $gs->setArg('-dUseCIEColor'); - $gs->setArg('-dAutoRotatePages=/None'); - $gs->setArg('-dUseCropBox'); - // Resolution & Quality - $gs->setArg('-r' . round($resolution)); - $gs->setArg('-dJPEGQ=' . $quality); - // Performances - $gs->setArg('-dNumRenderingThreads=4'); - // Page range - $gs->setArg('-dFirstPage=' . $page); - $gs->setArg('-dLastPage=' . $page); - // Files - $gs->setArg('-sOutputFile=' . $out); - - $gs->setArg(null, $in); - $gs->execute(); - } - - protected static function makeShotPNM($in, $out, $page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $texts = true, $width = null, $height = null) { - $tmp = cubeFiles::tempnam(); - - $antialiasing = $antialiasing ? 'yes' : 'no'; - $freetype = $texts ? 'yes' : 'no'; - // Exporte les fichiers - $pdftoppm = new cubeCommandLine('pdftoppm', null, true); - $pdftoppm->setPath(CONVERTER_PATH); - - $pdftoppm->setArg('f', $page); - $pdftoppm->setArg('l', $page); - $pdftoppm->setArg('-cropbox'); - $pdftoppm->setArg('-freetype ' . $freetype); - $pdftoppm->setArg('-singlefile'); - $pdftoppm->setArg('-aa ' . $antialiasing); - $pdftoppm->setArg('-aaVector ' . $antialiasing); - if (null !== $resolution) { - $pdftoppm->setArg('r', $resolution); - } - if (null !== $width) { - $pdftoppm->setArg('-scale-to-x ' . $width); - } - if (null !== $height) { - $pdftoppm->setArg('-scale-to-y ' . $height); - } - $pdftoppm->setArg(null, $in); - $pdftoppm->setArg(null, $tmp); - $pdftoppm->execute(); - $tmp .= '.ppm'; - - - if (file_exists($tmp)) { - $cjpeg = new cubeCommandLine('cjpeg', null, true); - $cjpeg->setArg('-quality ' . ($quality + 6)); - $cjpeg->setArg('-outfile ' . $out); - $cjpeg->setArg(null, $tmp); - $cjpeg->execute(); - unlink($tmp); - } - } - public static function getThumbFromPDF($pdf, $page) { - if (!file_exists($pdf)) { - return false; - } - $dir = WS_CACHE . '/thumbs/' . sha1($pdf) . '/'; - if (!file_exists($dir)) { - mkdir($dir, 0777, true); - } - $jpeg = $dir . '/p' . $page . '.jpg'; - $mtime = filemtime($jpeg); - - if (!file_exists($jpeg) || $mtime < filemtime(__FILE__) || $mtime < filemtime($pdf)) { - wsPDFConvert::makeMiniShot($pdf, $jpeg, $page); - } - - return $jpeg; - } +class wsPDFConvert +{ + + public static function makeMiniShot($in, $out, $page, $format = 'jpg') + { + self::makeShotFixedWidth($in, $out, $page, 'p', 500, 65, 4, 'PNM', $format); + } + + public static function makeShotFixedWidth($in, $out, $page, $prefix = '', $w = 100, $quality = 90, $antialiasing = 4, $method = 'PNM', $format = 'jpg') + { + // Make thumbs of $w width + self::makeShot($in, $out, $page, $prefix, null, $quality, $antialiasing, $method, $w, -1, $format); + } + + public static function makeShotFixedHeight($in, $out, $page, $prefix = '', $h = '', $quality = 90, $antialiasing = 4, $method = 'PNM', $format = 'jpg') + { + // Make thumbs of $h height + self::makeShot($in, $out, $page, $prefix, null, $quality, $antialiasing, $method, -1, $h, $format); + } + + public static function makeShot($in, $out, $page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $method = 'PNM', $width = null, $height = null, $format = 'jpg') + { + $error = false; + if ($method == 'GS') { + self::makeShotGS($in, $out, $page, $prefix, $resolution, $quality, $antialiasing, $width, $height, $format); + } elseif ($method == 'PNM') { + self::makeShotPNM($in, $out, $page, $prefix, $resolution, $quality, $antialiasing, true, $width, $height, $format); + } + // Test the result by checking all files + if (!file_exists($out)) { + $error = true; + } + // If error, we try to make thumbs with other method + if ($error) { + if ($method == 'GS') { + self::makeShotPNM($in, $out, $page, $prefix, $resolution, $quality, $antialiasing, true, $width, $height, $format); + } elseif ($method == 'PNM') { + self::makeShotGS($in, $out, $page, $prefix, $resolution, $quality, $antialiasing, $width, $height, $format); + } + } + } + + protected static function makeShotGS($in, $out, $page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $width = null, $height = null, $format = 'jpg') + { + + // Fabrication des thumbanails avec ghostscript + $gs = new cubeCommandLine('gs', null, true); + $gs->setPath(CONVERTER_PATH); + $gs->setEnv('GS_FONTPATH', FONT_PATH); + $gs->setArg('-dBATCH'); + $gs->setArg('-dNOPAUSE'); + $gs->setArg('-dNOPROMPT'); + // Antialias + $gs->setArg('-dDOINTERPOLATE'); + $gs->setArg('-dTextAlphaBits=' . $antialiasing); + $gs->setArg('-dGraphicsAlphaBits=' . $antialiasing); + // Device + $device = $format === 'jpg' ? 'jpeg' : 'png16m'; + $gs->setArg('-sDEVICE=' . $device); + // Dispotion & colors + // $gs->setArg('-dUseCIEColor'); + $gs->setArg('-dAutoRotatePages=/None'); + $gs->setArg('-dUseCropBox'); + // Resolution & Quality + $gs->setArg('-r' . round($resolution)); + if ($format === 'jpg') { + $gs->setArg('-dJPEGQ=' . $quality); + } + // Performances + $gs->setArg('-dNumRenderingThreads=4'); + // Page range + $gs->setArg('-dFirstPage=' . $page); + $gs->setArg('-dLastPage=' . $page); + // Files + $gs->setArg('-sOutputFile=' . $out); + + $gs->setArg(null, $in); + $gs->execute(); + } + + protected static function makeShotPNM($in, $out, $page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $texts = true, $width = null, $height = null, $format = 'jpg') + { + $tmp = cubeFiles::tempnam(); + + $antialiasing = $antialiasing ? 'yes' : 'no'; + $freetype = $texts ? 'yes' : 'no'; + // Exporte les fichiers + $pdftoppm = new cubeCommandLine('pdftoppm', null, true); + $pdftoppm->setPath(CONVERTER_PATH); + + $pdftoppm->setArg('f', $page); + $pdftoppm->setArg('l', $page); + $pdftoppm->setArg('-cropbox'); + $pdftoppm->setArg('-freetype ' . $freetype); + $pdftoppm->setArg('-singlefile'); + $pdftoppm->setArg('-aa ' . $antialiasing); + $pdftoppm->setArg('-aaVector ' . $antialiasing); + if (null !== $resolution) { + $pdftoppm->setArg('r', $resolution); + } + if (null !== $width) { + $pdftoppm->setArg('-scale-to-x ' . $width); + } + if (null !== $height) { + $pdftoppm->setArg('-scale-to-y ' . $height); + } + $pdftoppm->setArg(null, $in); + $pdftoppm->setArg(null, $tmp); + $pdftoppm->execute(); + $tmp .= '.ppm'; + + + if (file_exists($tmp)) { + if ($format === 'jpg') { + $cjpeg = new cubeCommandLine('/opt/mozjpeg/bin/cjpeg', null, true); + $cjpeg->setArg('-quality ' . ($quality + 6)); + $cjpeg->setArg('-outfile ' . $out); + $cjpeg->setArg(null, $tmp); + $cjpeg->execute(); + } else if ($format === 'png') { + $pnmtopng = new CubeIT_CommandLine('pnmtopng', $out, false); + $pnmtopng->setArg('-background white'); + $pnmtopng->setArg(null, $tmp); + $pnmtopng->execute(); + } + unlink($tmp); + } + } + + public static function getThumbFromPDF($pdf, $page, $format = 'jpg') + { + if (!file_exists($pdf)) { + return false; + } + $dir = WS_CACHE . '/thumbs/' . sha1($pdf) . '/'; + if (!file_exists($dir)) { + mkdir($dir, 0777, true); + } + $image = $dir . '/p' . $page . '.' . $format; + $mtime = filemtime($image); + + if (!file_exists($image) || $mtime < filemtime(__FILE__) || $mtime < filemtime($pdf)) { + wsPDFConvert::makeMiniShot($pdf, $image, $page, $format); + } + + return $image; + } } \ No newline at end of file diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index b0ecd4cc9..5ccc6c73e 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -234,6 +234,7 @@ class wsHTML5Compiler $this->multiApp = $this->home = $home; $this->version = $version; + if ($version == 'stable') { $this->assets = WS_COMPILE_ASSETS . '/player/branches/master'; } else if ($version == 'dev') { @@ -289,8 +290,10 @@ class wsHTML5Compiler $this->width = round($size[0], 8); $this->height = round($size[1], 8); - wsDocument::makeHTML5FilesIfNotExists($this->pages[1]['document_id'], $this->pages[1]['document_page']); - $firstJpeg = wsDocument::getDir($this->pages[1]['document_id']) . 'html/h150-' . $this->pages[1]['document_page'] . '.jpg'; + $this->imageFormat = $this->book->parametres->imageFormat; + + wsDocument::makeHTML5FilesIfNotExists($this->pages[1]['document_id'], $this->pages[1]['document_page'], $this->imageFormat); + $firstJpeg = wsDocument::getDir($this->pages[1]['document_id']) . 'html/h150-' . $this->pages[1]['document_page'] . '.' . $this->imageFormat; $imagesize = CubeIT_Image::getimagesize($firstJpeg); $this->pdf2htmlRatio = round(($imagesize[0] * 0.48) / $this->width, 12); @@ -308,7 +311,6 @@ class wsHTML5Compiler $this->scale = 1; - $this->numerotation = explode(',', $this->book->numerotation); if ($this->isMobileFirst()) { @@ -1857,7 +1859,7 @@ class wsHTML5Compiler $thisimagesvg = !$thisrasterize && $this->svg; $thisbackgroundPrefix = $thisrasterize ? ['t'] : $this->backgroundsPrefix; - wsDocument::$makeFunction($infos['document_id'], $infos['document_page']); + wsDocument::$makeFunction($infos['document_id'], $infos['document_page'], $this->imageFormat); foreach ($this->getResolutions() as $r) { foreach ($thisbackgroundPrefix as $backgroundsPrefix) { @@ -1865,13 +1867,13 @@ class wsHTML5Compiler if ($backgroundsPrefix === 'p') { $srcPrefix = 'h'; } - $source = $docdir . $imdir . '/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg'; + $source = $docdir . $imdir . '/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.' . $this->imageFormat; if ($r == 150 && file_exists($source)) { $firstDoc = $daoDoc->selectById($infos['document_id']); $d = $firstDoc->generalInfos['page'][$infos['document_page']]['size']; $this->config->pagesDimensions[$page] = array($this->cssWidth, $d[1] * ($this->cssWidth / $d[0])); } - $ok = $this->vdir->copy($source, 'data/background/' . $r . '/' . $backgroundsPrefix . $page . '.jpg'); + $ok = $this->vdir->copy($source, 'data/background/' . $r . '/' . $backgroundsPrefix . $page . '.' . $this->imageFormat); if (!$ok && $r = 300) { $this->maxRes = 150; } @@ -1905,14 +1907,18 @@ class wsHTML5Compiler $thumb = false; if ($this->book->parametres->pdfThumbnails) { - $thumb = wsPDFConvert::getThumbFromPDF(WS_BOOKS . '/working/' . $this->book->book_id . '/' . $this->book->parametres->pdfThumbnails, $page); + $thumb = wsPDFConvert::getThumbFromPDF(WS_BOOKS . '/working/' . $this->book->book_id . '/' . $this->book->parametres->pdfThumbnails, $page, $this->imageFormat); } if (!$thumb) { - $thumb = $docdir . 'p' . $infos['document_page'] . '.jpg'; + + $thumb = $docdir . 'p' . $infos['document_page'] . '.' . $this->imageFormat; + if (!file_exists($thumb)) { + $doc = $daoDoc->selectById($infos['document_id']); + $doc->makeMiniShot($infos['document_page']); + } } - $thumbs[$page] = $thumb; - $this->vdir->copy($thumb, 'data/thumbnails/p' . $page . '.jpg'); + $this->vdir->copy($thumb, 'data/thumbnails/p' . $page . '.' . $this->imageFormat); if ($page == 1) { $this->_makeCover($docdir . 'html/t36-' . $infos['document_page'] . '.jpg'); @@ -1923,49 +1929,9 @@ class wsHTML5Compiler } } - - //$this->makeThumbSprites($thumbs); $this->log('Made thumbnails'); } -// public function makeThumbSprites(array $thumbs) -// { -// $cols = 10; -// $rows = 10; -// $perSprite = $cols * $rows; -// $k = 0; -// $res = ''; -// $pages = count($thumbs); -// -// $hash = ''; -// for ($i = 1; $i <= $pages; $i += $perSprite) { -// $num = min(1 + $pages - $i, $perSprite); -// $srows = ceil($num / $cols); -// $files = array(); -// $mtime = 0; -// for ($j = 0; $j < $perSprite; $j++) { -// $p = $i + $j; -// if ($p > $pages) { -// break; -// } -// $files[] = $thumbs[$p]; -// $hash .= $thumbs[$p] . '--' . filemtime($thumbs[$p]); -// } -// -// $cache = WS_CACHE . '/thumbsprites/' . hash('sha256', $hash) . '.jpg'; -// $dest = 'data/thumbnails/s' . $k . '.jpg'; -// if (!file_exists($cache)) { -// $ratio = $this->width / $this->height; -// $thumbh = round(100 / $ratio); -// $cmd = 'montage ' . implode(' ', $files) . ' -geometry 100x' . $thumbh . '!+0+0 -background transparent -tile ' . $cols . 'x' . $srows . ' ' . $cache; -// $res .= `$cmd`; -// } -// $this->vdir->copy($cache, $dest); -// $k++; -// } -// return $res; -// } - protected function _makeCover($orig) { $size = CubeIT_Image::getimagesize($orig); @@ -2610,13 +2576,13 @@ class wsHTML5Compiler $lead = ''; $image = ''; - $first=true; + $first = true; foreach ($a->children() as $child) { - if($first){ - $first=false; - if($child->getName()!=='category'){ - $inner.='

 

'; + if ($first) { + $first = false; + if ($child->getName() !== 'category') { + $inner .= '

 

'; } } $inner .= $this->_articleToHTML($child, $title, $lead, $image);