/**
  * getArticle hook
  *
  * insert custom template when
  * getArticle hook is called
  *
  */
 public function insertCustomTemplate($tpl, $data, $article)
 {
     global $objPage;
     $layoutID = $objPage->layout;
     $objLayout = \LayoutModel::findByID($layoutID);
     if ($objLayout->activateCArticles) {
         $template = new \FrontendTemplate('mod_customarticle');
         $count = count($tpl->elements);
         $containertype = 'container';
         $article_color = \Contao\StringUtil::deserialize($tpl->article_color);
         $article_width = \Contao\StringUtil::deserialize($tpl->article_width);
         $article_minheight = \Contao\StringUtil::deserialize($tpl->article_minheight);
         $article_image = $tpl->article_image;
         $article_image_position = $tpl->article_image_position;
         $article_image_repeat = $tpl->article_image_repeat;
         $article_image_cover = $tpl->article_image_cover;
         $article_image_fixed = $tpl->article_image_fixed;
         $inner_article_width = \Contao\StringUtil::deserialize($tpl->inner_article_width);
         $inner_article_space = $tpl->inner_article_space;
         $inner_article_overflow = $tpl->inner_article_overflow;
         $inner_article_color = \Contao\StringUtil::deserialize($tpl->inner_article_color);
         $inner_article_float = $tpl->inner_article_float;
         $inner_article_minheight = \Contao\StringUtil::deserialize($tpl->inner_article_minheight);
         if ($tpl->article_visible != '') {
             $tmpclasses = $article->cssID;
             $article_visible = @unserialize($tpl->article_visible);
             if ($article_visible === 'b:0;' || $article_visible !== false) {
                 foreach (\Contao\StringUtil::deserialize($tpl->article_hidden) as $key => $value) {
                     $tmpclasses[1] .= ' ' . $value;
                 }
             } else {
                 $tmpclasses[1] .= ' ' . $tpl->article_visible;
             }
             $article->cssID = $tmpclasses;
         }
         if ($tpl->article_hidden != '') {
             $tmpclasses = $article->cssID;
             $article_hidden = @unserialize($tpl->article_hidden);
             if ($article_hidden === 'b:0;' || $article_hidden !== false) {
                 foreach (\Contao\StringUtil::deserialize($tpl->article_hidden) as $key => $value) {
                     $tmpclasses[1] .= ' ' . $value;
                 }
             } else {
                 $tmpclasses[1] .= ' ' . $tpl->article_hidden;
             }
             $article->cssID = $tmpclasses;
         }
         $customstyle = ".mod_article.customarticle_{$tpl->id} { ";
         if (isset($article_width['value']) && $article_width['value'] != '') {
             if ($article_width['value'] == 100 && $article_width['unit'] == "%") {
                 $containertype = 'container-fluid';
             } else {
                 $containertype = 'container';
             }
             $customstyle .= "width:" . $article_width['value'] . $article_width['unit'] . " !important;";
             $customstyle .= "max-width:" . $article_width['value'] . $article_width['unit'] . " !important;";
         }
         if (isset($article_minheight['value']) && $article_minheight['value'] != '') {
             $customstyle .= "min-height:" . $article_minheight['value'] . $article_minheight['unit'] . " !important;";
         }
         if (isset($article_color[0]) && $article_color[0] != '') {
             $customstyle .= "background-color:" . $this->cHex2rgba($article_color[0], $article_color[1]) . " !important;";
         }
         if (isset($article_image) && $article_image != '') {
             $customstyle .= "background-image:url('" . $article_image . "') !important;";
         }
         if (isset($article_image_repeat) && $article_image_repeat != '') {
             $customstyle .= "background-repeat:" . $article_image_repeat . " !important;";
         }
         if (isset($article_image_position) && $article_image_position != '') {
             $customstyle .= "background-position:" . $article_image_position . " !important;";
         }
         if ($article_image_cover) {
             $customstyle .= "\n\t\t\t\t\t\t-webkit-background-size: cover;\n\t\t\t\t\t\t-moz-background-size: cover;\n\t\t\t\t\t\t-o-background-size: cover;\n\t\t\t\t\t\tbackground-size: cover;\n\t\t\t\t\t\tfilter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src={$img}-uri, sizingMethod='scale');\n\t\t\t\t\t\t-ms-filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src={$img}-uri, sizingMethod='scale') !important;";
             if ($article_image_fixed) {
                 $customstyle .= "background-attachment: fixed";
             } else {
                 $customstyle .= "background-attachment: initial";
             }
         }
         $customstyle .= "\t}";
         $customstyle .= ".mod_article.customarticle_{$tpl->id} .outer { ";
         if (isset($inner_article_color[0]) && $inner_article_color[0] != '') {
             $customstyle .= "background-color:" . $this->cHex2rgba($inner_article_color[0], $inner_article_color[1]) . " !important;";
         }
         if (isset($inner_article_width['value']) && $inner_article_width['value'] != '') {
             $customstyle .= "width:" . $inner_article_width['value'] . $inner_article_width['unit'] . " !important;";
             $customstyle .= "max-width:" . $inner_article_width['value'] . $inner_article_width['unit'] . " !important;";
         }
         if (isset($inner_article_height['value']) && $inner_article_height['value'] != '') {
             $customstyle .= "min-height:" . $inner_article_height['value'] . $inner_article_height['unit'] . " !important;";
         }
         $customstyle .= "\t}";
         $customstyle .= ".mod_article.customarticle_{$tpl->id} .inner { ";
         if (isset($inner_article_space) && $inner_article_space != '') {
             if ($inner_article_space == 'top_spaceing') {
                 $customstyle .= "padding-bottom:0 !important;";
             }
             if ($inner_article_space == 'bottom_spaceing') {
                 $customstyle .= "padding-top:0 !important;";
             }
             if ($inner_article_space == 'no_spaceing') {
                 $customstyle .= "padding-bottom:0 !important;";
                 $customstyle .= "padding-top:0 !important;";
             }
         }
         if (isset($inner_article_overflow) && $inner_article_overflow != '') {
             if ($inner_article_overflow == 'overflow_hidden') {
                 $customstyle .= "overflow:hidden !important;";
             }
             if ($inner_article_overflow == 'overflow_visible') {
                 $customstyle .= "overflow:visible !important;";
             }
         }
         $customstyle .= "\t}";
         $tpl->customstyle = $customstyle;
         $tpl->gridcount = $count;
         $tpl->containertype = $containertype;
         $template->setData($tpl->getData());
         $article->Template = $template;
     }
 }
 /**
  * [insertCustomGrid description]
  * @param  Database_Result $objElement
  * @param  [string]          $strBuffer
  * @return [string]
  */
 public function insertCustomGrid($objElement, $strBuffer)
 {
     global $objPage;
     $layoutID = $objPage->layout;
     $objLayout = \LayoutModel::findByID($layoutID);
     if ($objLayout->activateCArticles) {
         $strClass = $this->findContentElement($objElement->type);
         $newObjElement = new $strClass($objElement);
         $classes = ' col';
         $arrClasses = ['grid_xs' => 'col-xs-', 'grid_sm' => 'col-sm-', 'grid_md' => 'col-md-', 'grid_lg' => 'col-lg-', 'offset_xs' => 'col-xs-offset-', 'offset_sm' => 'col-sm-offset-', 'offset_md' => 'col-md-offset-', 'offset_lg' => 'col-lg-offset-', 'pull_xs' => 'col-xs-pull-', 'pull_sm' => 'col-sm-pull-', 'pull_md' => 'col-md-pull-', 'pull_lg' => 'col-lg-pull-', 'push_xs' => 'col-xs-push-', 'push_sm' => 'col-sm-push-', 'push_md' => 'col-md-push-', 'push_lg' => 'col-lg-push-'];
         foreach ($arrClasses as $key => $classPart) {
             if ($objElement->{$key} != '' && $objElement->{$key} != -1) {
                 $classes .= ' ' . $classPart . $objElement->{$key};
             }
         }
         if ($objElement->grid_visible != '') {
             $grid_visible = @unserialize($objElement->grid_visible);
             if ($grid_visible === 'b:0;' || $grid_visible !== false) {
                 foreach (\Contao\StringUtil::deserialize($objElement->grid_visible) as $key => $value) {
                     $classes .= ' ' . $value;
                 }
             } else {
                 $classes .= ' ' . $objElement->grid_visible;
             }
         }
         if ($objElement->grid_hidden != '') {
             $grid_hidden = @unserialize($objElement->grid_hidden);
             if ($grid_hidden === 'b:0;' || $grid_hidden !== false) {
                 foreach (\Contao\StringUtil::deserialize($objElement->grid_hidden) as $key => $value) {
                     $classes .= ' ' . $value;
                 }
             } else {
                 $classes .= ' ' . $objElement->grid_hidden;
             }
         }
         if ($objElement->col_no_padding || $objElement->col_no_padding != '') {
             if ($objElement->col_no_padding == 'padding_no_top_bottom') {
                 $classes .= ' col-no-padding-top-bottom';
             }
             if ($objElement->col_no_padding == 'padding_no_left_right') {
                 $classes .= ' col-no-padding-left-right';
             }
             if ($objElement->col_no_padding == 'padding_no_all') {
                 $classes .= ' col-no-padding';
             }
         }
         if ($objElement->col_centered) {
             $classes .= ' col-centered';
         }
         if ($objElement->col_newline) {
             $classes .= ' col-newline';
         }
         if ($classes != '') {
             $arrCss = \Contao\StringUtil::deserialize($objElement->cssID);
             $arrCss[1] .= $classes;
             $newObjElement->cssID = $arrCss;
         }
         $strBuffer = $newObjElement->generate();
     }
     return $strBuffer;
 }