protected function parseSubImages($tag, $value, array $attr_template = null)
 {
     $offset = 0;
     while (($block = WebHelper::getblock($tag, $value, $offset)) !== false) {
         $offset = $block[WebHelper::BLOCK_ARRAY_VALUE_ENDPOS];
         $this->data[ImageExtObject::ARRAY_IMAGES][] = $this->getImageArray($tag, $block, $attr_template);
     }
 }
 protected function parseAndConvertTag($tag, $value, array $attr_template = null)
 {
     $offset = 0;
     while (($block = WebHelper::getblock($tag, $value, $offset)) !== false) {
         $content = "";
         $offset = $block[WebHelper::BLOCK_ARRAY_VALUE_ENDPOS];
         $start = $block[WebHelper::BLOCK_ARRAY_VALUE_STARTPOS];
         $length = $block[WebHelper::BLOCK_ARRAY_VALUE_ENDPOS] - $block[WebHelper::BLOCK_ARRAY_VALUE_STARTPOS];
         switch ($tag) {
             case ImageExtObject::TAG_IMAGEEXT_GALLERY:
             case ImageExtObject::TAG_IMAGE_GALLERY:
                 $gallery = new ImageExtGallery($this);
                 $gallery->parse($tag, $block, $attr_template);
                 $gallery->optimizeOutput();
                 if ($this->isDebug()) {
                     $content = $gallery->getDebug();
                 } else {
                     $content = $gallery->toHTML();
                 }
                 break;
             case ImageExtObject::TAG_IMAGEEXT:
             case ImageExtObject::TAG_IMAGE:
                 $image = new ImageExtImage($this);
                 $image->parse($tag, $block, $attr_template);
                 $image->parseFileAttributes();
                 $image->optimizeOutput();
                 if ($this->isDebug()) {
                     $content = $image->getDebug();
                 } else {
                     $image->generate();
                     $content = $image->toHTML();
                 }
                 break;
         }
         // Replace placholder with final content
         $value = substr_replace($value, $content, $start, $length);
         $offset = $start + strlen($content);
     }
     return $value;
 }
     * Calculate age
     */
    $offset = 0;
    $key = 'age';
    while (($block = WebHelper::getblock($key, $value, $offset)) !== false) {
        $offset = $block[WebHelper::BLOCK_ARRAY_VALUE_ENDPOS];
        $block_new = WebHelper::calcAge($block[WebHelper::BLOCK_ARRAY_VALUE_ATTRIBUTES][$key]);
        $start = $block[WebHelper::BLOCK_ARRAY_VALUE_STARTPOS];
        $length = $block[WebHelper::BLOCK_ARRAY_VALUE_ENDPOS] - $block[WebHelper::BLOCK_ARRAY_VALUE_STARTPOS];
        $value = substr_replace($value, $block_new, $start, $length);
    }
    /*
     * Figure
     */
    $offset = 0;
    $key = 'figure';
    while (($block = WebHelper::getblock($key, $value, $offset)) !== false) {
        $offset = $block[WebHelper::BLOCK_ARRAY_VALUE_ENDPOS];
        $content = $block[WebHelper::BLOCK_ARRAY_VALUE_CONTENT];
        $caption = array_key_exists('caption', $block[WebHelper::BLOCK_ARRAY_VALUE_ATTRIBUTES]) ? $block[WebHelper::BLOCK_ARRAY_VALUE_ATTRIBUTES]['caption'] : false;
        $caption = empty($caption) ? false : $caption;
        $caption_top = array_key_exists('caption_top', $block[WebHelper::BLOCK_ARRAY_VALUE_ATTRIBUTES]) ? $block[WebHelper::BLOCK_ARRAY_VALUE_ATTRIBUTES]['caption_top'] : false;
        $caption_top = $caption_top === "false" || empty($caption_top) ? false : $caption_top;
        $caption_class = array_key_exists('class', $block[WebHelper::BLOCK_ARRAY_VALUE_ATTRIBUTES]) ? $block[WebHelper::BLOCK_ARRAY_VALUE_ATTRIBUTES]['class'] : false;
        $block_new = WebHelper::blockFigure($content, $caption, $caption_top, $caption_class);
        $start = $block[WebHelper::BLOCK_ARRAY_VALUE_STARTPOS];
        $length = $block[WebHelper::BLOCK_ARRAY_VALUE_ENDPOS] - $block[WebHelper::BLOCK_ARRAY_VALUE_STARTPOS];
        $value = substr_replace($value, $block_new, $start, $length);
    }
    return $value;
};