/** * If current file exists, then output it as background url * * @param strin $path * @return background url */ public static function outputBackgroundUrlIfExists($path) { $cleanPath = strpos($path, '?') ? substr($path, 0, strpos($path, '?')) : $path; if (file_exists(Site_View_Helper_File::_getPublicPath() . $cleanPath)) { echo 'style="background-image: url(' . $path . ');"'; } }
/** * Get artile data by ID * * @param int $articleID * @return Article */ public function getArticleData($articleID) { $articleID = (int) $articleID; $article = $this->getResource('Article')->getArticleByID($articleID); if ($articleID == 0 || $article == null) { return [status => 0, message => 'Article not found!']; } $imagePath = '/img/articles/' . $article->ArticleID . '.jpg'; if (file_exists(Site_View_Helper_File::_getPublicPath() . $imagePath)) { $imagePath .= '?gid=' . md5($article->ImageUpdateTime); } else { $imagePath = ''; } return [status => 1, title => $article->ArticleTitle, text => $article->ArticleText, picture => $imagePath]; }
/** * Get testimonial data by ID * * @param int $testimonialID * @return Testimonial */ public function getTestimonialData($testimonialID) { $testimonialID = (int) $testimonialID; $testimonial = $this->getResource('Testimonial')->getTestimonialByID($testimonialID); if ($testimonialID == 0 || $testimonial == null) { return [status => 0, message => 'Testimonial not found!']; } $imagePath = '/img/testimonials/' . $testimonial->TestimonialID . '.jpg'; if (file_exists(Site_View_Helper_File::_getPublicPath() . $imagePath)) { $imagePath .= '?gid=' . md5($testimonial->ImageUpdateTime); } else { $imagePath = ''; } return [status => 1, leftBy => $testimonial->LeftBy, text => $testimonial->TestimonialText, picture => $imagePath]; }