Exemplo n.º 1
0
 public function generateElementHTML($material)
 {
     $materialData = $this->getMaterialDataText($material['material']);
     $backgroundURL = $this->imagePath . $material['material'] . ".png";
     if (!file_exists($backgroundURL)) {
         $backgroundURL = $this->imagePath . $material['material'] . ".jpg";
         if (!file_exists($backgroundURL)) {
             $backgroundURL = null;
         }
     }
     $style = "";
     if ($backgroundURL != null) {
         $style = "style=\"background: url('" . $backgroundURL . "') top center no-repeat\"";
     }
     $out = "<div class='material_element' " . $style . ">";
     $out .= "<a id='" . $material['material'] . "'></a>";
     $out .= "<div class='material_element_title'>";
     $out .= "<div class='material_element_title_text'>";
     $out .= $materialData['title'];
     $out .= "</div>";
     $out .= "</div>";
     //            $out .= "<h2>";
     //                $out .= "<a id='".$material['material']."'></a>";
     //                $out .= $materialData['title'];
     //            $out .= "</h2>";
     $out .= "<div class='text'>";
     if ($material['showShortMaterialsText'] != '0') {
         $out .= "<div class='promoText'>";
         $materialText = strip_tags($materialData['text']);
         $maxLength = 300;
         if ($maxLength < strlen($materialText)) {
             $length = stripos($materialText, " ", $maxLength);
             $materialText = substr($materialText, 0, $length);
         }
         $out .= $materialText;
         $out .= "</div>";
     }
     $out .= '<div class="infoPanel">';
     $out .= $this->getDate($material);
     $urlHelper = new UrlHelper();
     $params[0] = $material['material'];
     $url = $urlHelper->chengeParams($params);
     $out .= '<center><div class="buttonIn"><a href="' . $url . '">подробнее</a></div></center>';
     $out .= "</div>";
     $out .= "</div>";
     $out .= "</div>";
     return $out;
 }