File manager - Edit - /home/jardides/www/Jardi-design/plugins/pagebuilderck/blog/blog.php
Back
<?php /** * @copyright Copyright (C) 2015 Cédric KEIFLIN alias ced1870 * https://www.template-creator.com * https://www.joomlack.fr * @license GNU/GPL * */ defined('_JEXEC') or die('Restricted access'); use Joomla\CMS\Date\Date; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; jimport('joomla.event.plugin'); use \Pagebuilderck\CKFof; class plgPagebuilderckBlog extends JPlugin { private $context = 'PLG_PAGEBUILDERCK_BLOG'; private $type = 'blog'; private $layout_params; private $image_params; private $iconhtml; function __construct(&$subject, $params) { $lang = JFactory::getLanguage(); $lang->load('plg_pagebuilderck_blog', JPATH_ADMINISTRATOR, $lang->getTag(), false); $this->loadLanguage(); parent::__construct($subject, $params); } public function callAssets() { $doc = JFactory::getDocument(); PagebuilderckFrontHelper::addStylesheet(JUri::root(true) . '/plugins/pagebuilderck/blog/assets/blog.css?ver=2.11.1'); } /* * Construct the Menu Item to drag into the interface * * Return Object with item data */ public function onPagebuilderckAddItemToMenu() { $this->callAssets(); PagebuilderckFrontHelper::addStyleDeclaration($this->getCss()); // load the language files of the plugin $this->loadLanguage(); // create the menu item $menuitem = new stdClass(); $menuitem->type = $this->type; $menuitem->group = 'text'; $menuitem->title = JText::_($this->context . '_MENUITEM_TITLE'); $menuitem->description = JText::_($this->context . '_MENUITEM_DESC'); $menuitem->image = JUri::root(true) . '/plugins/pagebuilderck/blog/assets/images/blogs.png'; return $menuitem; } private function getCss() { $css = '@media only screen and (max-width:640px){ div.blogck { display: block; } div.blogck .blogck-item { width: initial !important; } }'; return $css; } /* * Display the html code for the item to be used into the interface * * Return String the html code */ public function onPagebuilderckLoadItemContentBlog() { // ckstyle and inner classes are needed to get the styles from the interface $input = JFactory::getApplication()->input; $id = $input->get('ckid', '', 'string'); ?> <div id="<?php echo $id; ?>" class="cktype" data-type="<?php echo $this->type ?>"> <div class="tab_linkstyles ckprops" linkbackgroundpositionend="100" linkbackgrounddirection="topbottom" linkbackgroundimageattachment="scroll" linkbackgroundimagerepeat="no-repeat" linkbackgroundimagesize="auto" linkcolor="#525252" linkmargins="5" linkpaddingtop="5" linkpaddingright="10" linkpaddingbottom="5" linkpaddingleft="10" linkbordertopstyle="solid" linkborderrightstyle="solid" linkborderbottomstyle="solid" linkborderleftstyle="solid" linkborderscolor="#dddddd" linkborderssize="1" linkbordersstyle="solid" linkshadowinset="0" fieldslist="linkbackgroundpositionend,linkbackgrounddirection,linkbackgroundimageattachment,linkbackgroundimagerepeat,linkbackgroundimagesize,linkcolor,linkalignementleft,linkalignementcenter,linkalignementright,linkalignementjustify,linkmargins,linkpaddingtop,linkpaddingright,linkpaddingbottom,linkpaddingleft,linkbordertopstyle,linkborderrightstyle,linkborderbottomstyle,linkborderleftstyle,linkborderscolor,linkborderssize,linkbordersstyle,linkshadowinset"></div><div class="tab_imagestyles ckprops" imagebackgroundpositionend="100" imagebackgrounddirection="topbottom" imagebackgroundimageattachment="scroll" imagebackgroundimagerepeat="no-repeat" imagebackgroundimagesize="auto" imagebordertopstyle="solid" imageborderrightstyle="solid" imageborderbottomstyle="solid" imageborderleftstyle="solid" imagebordersstyle="solid" imageshadowinset="0" fieldslist="imagebackgroundpositionend,imagebackgrounddirection,imagebackgroundimageattachment,imagebackgroundimagerepeat,imagebackgroundimagesize,imagealignementleft,imagealignementcenter,imagealignementright,imagealignementjustify,imagebordertopstyle,imageborderrightstyle,imageborderbottomstyle,imageborderleftstyle,imagebordersstyle,imageshadowinset"></div><div class="tab_textstyles ckprops" textbackgroundpositionend="100" textbackgrounddirection="topbottom" textbackgroundimageattachment="scroll" textbackgroundimagerepeat="no-repeat" textbackgroundimagesize="auto" textpaddings="10" textbordertopstyle="solid" textborderrightstyle="solid" textborderbottomstyle="solid" textborderleftstyle="solid" textbordersstyle="solid" textshadowinset="0" fieldslist="textbackgroundpositionend,textbackgrounddirection,textbackgroundimageattachment,textbackgroundimagerepeat,textbackgroundimagesize,textalignementleft,textalignementcenter,textalignementright,textalignementjustify,textpaddings,textbordertopstyle,textborderrightstyle,textborderbottomstyle,textborderleftstyle,textbordersstyle,textshadowinset"></div><div class="tab_titlestyles ckprops" titlebackgroundpositionend="100" titlebackgrounddirection="topbottom" titlebackgroundimageattachment="scroll" titlebackgroundimagerepeat="no-repeat" titlebackgroundimagesize="auto" titlefontsize="20" titlepaddingtop="10" titlepaddingleft="10" titlebordertopstyle="solid" titleborderrightstyle="solid" titleborderbottomstyle="solid" titleborderleftstyle="solid" titlebordersstyle="solid" titleshadowinset="0" fieldslist="titlebackgroundpositionend,titlebackgrounddirection,titlebackgroundimageattachment,titlebackgroundimagerepeat,titlebackgroundimagesize,titlefontsize,titlealignementleft,titlealignementcenter,titlealignementright,titlealignementjustify,titlepaddingtop,titlepaddingleft,titlebordertopstyle,titleborderrightstyle,titleborderbottomstyle,titleborderleftstyle,titlebordersstyle,titleshadowinset"></div><div class="tab_itemstyles ckprops" itembackgroundpositionend="100" itembackgrounddirection="topbottom" itembackgroundimageattachment="scroll" itembackgroundimagerepeat="no-repeat" itembackgroundimagesize="auto" itembordertopstyle="solid" itemborderrightstyle="solid" itemborderbottomstyle="solid" itemborderleftstyle="solid" itemborderscolor="#dddddd" itemborderssize="1" itembordersstyle="solid" itemshadowinset="0" fieldslist="itembackgroundpositionend,itembackgrounddirection,itembackgroundimageattachment,itembackgroundimagerepeat,itembackgroundimagesize,itemalignementleft,itemalignementcenter,itemalignementright,itemalignementjustify,itembordertopstyle,itemborderrightstyle,itemborderbottomstyle,itemborderleftstyle,itemborderscolor,itemborderssize,itembordersstyle,itemshadowinset"></div><div class="tab_blocstyles ckprops" blocbackgroundpositionend="100" blocbackgrounddirection="topbottom" blocbackgroundimageattachment="scroll" blocbackgroundimagerepeat="no-repeat" blocbackgroundimagesize="auto" blocbordertopstyle="solid" blocborderrightstyle="solid" blocborderbottomstyle="solid" blocborderleftstyle="solid" blocbordersstyle="solid" blocshadowinset="0" fieldslist="blocbackgroundpositionend,blocbackgrounddirection,blocbackgroundimageattachment,blocbackgroundimagerepeat,blocbackgroundimagesize,blocalignementleft,blocalignementcenter,blocalignementright,blocalignementjustify,blocbordertopstyle,blocborderrightstyle,blocborderbottomstyle,blocborderleftstyle,blocbordersstyle,blocshadowinset"></div><div class="tab_layout ckprops" fieldslist=""></div><div class="tab_article ckprops" articleimgsource="text" imgsource="introimage" show_front="show" article_ordering="a.ordering" article_ordering_direction="DESC" fieldslist="articleimgsource,imgsource,show_front,category_filtering_type_1,category_filtering_type_0,show_child_category_articles_1,show_child_category_articles_0,article_ordering,article_ordering_direction"></div> <div class="tab_datestyles ckprops" datebackgroundcolorstart="#3784a6" datebackgroundpositionend="100" datebackgrounddirection="topbottom" datebackgroundimageattachment="scroll" datebackgroundimagerepeat="no-repeat" datebackgroundimagesize="auto" datecolor="#ffffff" datefontsize="11" datealignementcenter="checked" datemargintop="10" datemarginright="20%" datemarginbottom="5" datemarginleft="20%" datepaddings="3" dateborderradius="3" datebordertopstyle="solid" dateborderrightstyle="solid" dateborderbottomstyle="solid" dateborderleftstyle="solid" datebordersstyle="solid" dateshadowinset="0" fieldslist="datebackgroundcolorstart,datebackgroundpositionend,datebackgrounddirection,datebackgroundimageattachment,datebackgroundimagerepeat,datebackgroundimagesize,datecolor,datefontsize,datealignementleft,datealignementcenter,datealignementright,datealignementjustify,datemargintop,datemarginright,datemarginbottom,datemarginleft,datepaddings,dateborderradius,datebordertopstyle,dateborderrightstyle,dateborderbottomstyle,dateborderleftstyle,datebordersstyle,dateshadowinset"></div> <div class="ckstyle"> <style> #<?php echo $id; ?> .blogck .blogck-item { border: #dddddd 1px solid; } #<?php echo $id; ?> .blogck .blogck-title { padding-top: 10px; padding-left: 10px; font-size: 20px; } #<?php echo $id; ?> .blogck .blogck-text { padding: 10px; } #<?php echo $id; ?> .blogck .blogck-image { } #<?php echo $id; ?> .blogck .blogck-link { border: #dddddd 1px solid; color: #525252; margin: 5px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; } #<?php echo $id; ?> .textck { padding: 10px; } #<?php echo $id; ?> .titleck { padding-top: 10px; padding-left: 10px; font-size: 20px; } #<?php echo $id; ?> .blogck-date { background: #3784a6; -moz-border-radius: 3px; -o-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; -moz-border-radius: 3px 3px 3px 3px; -o-border-radius: 3px 3px 3px 3px; -webkit-border-radius: 3px 3px 3px 3px; border-radius: 3px 3px 3px 3px; color: #ffffff; margin-top: 10px; margin-right: 20%; margin-bottom: 5px; margin-left: 20%; padding: 3px; text-align: center; font-size: 11px; } </style> </div> <div class="blogck inner block-link-bottom"> <div class="blogck-item" style="width: calc(1/3*100% - (1 - 1/3)*10px);"> <div class="blogck-image"> <img src="<?php echo JUri::root(true); ?>/plugins/pagebuilderck/blog/assets/images/image1.jpg" width="100%" height="auto" /> </div> <div class="blogck-title">Lorem Ipsum</div> <div class="blogck-date">2123-02-16</div> <div class="blogck-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed molestie scelerisque ultrices. Nullam venenatis, felis ut accumsan vestibulum, diam leo congue nisl, eget luctus sapien libero eget urna. Duis ac pellentesque nisi.</div> <a href="#" class="blogck-link">Read more</a> </div> <div class="blogck-item" style="width: calc(1/3*100% - (1 - 1/3)*10px);"> <div class="blogck-image"> <img src="<?php echo JUri::root(true); ?>/plugins/pagebuilderck/blog/assets/images/image2.jpg" width="100%" height="auto" /> </div> <div class="blogck-title">Lorem Ipsum</div> <div class="blogck-date">2123-02-16</div> <div class="blogck-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed molestie scelerisque ultrices. Nullam venenatis, felis ut accumsan vestibulum, diam leo congue nisl, eget luctus sapien libero eget urna. Duis ac pellentesque nisi.</div> <a href="#" class="blogck-link">Read more</a> </div> <div class="blogck-item" style="width: calc(1/3*100% - (1 - 1/3)*10px);"> <div class="blogck-image"> <img src="<?php echo JUri::root(true); ?>/plugins/pagebuilderck/blog/assets/images/image3.jpg" width="100%" height="auto" /> </div> <div class="blogck-title">Lorem Ipsum</div> <div class="blogck-date">2123-02-16</div> <div class="blogck-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed molestie scelerisque ultrices. Nullam venenatis, felis ut accumsan vestibulum, diam leo congue nisl, eget luctus sapien libero eget urna. Duis ac pellentesque nisi.</div> <a href="#" class="blogck-link">Read more</a> </div> <div class="blogck-item" style="width: calc(1/3*100% - (1 - 1/3)*10px);display:none;"> <div class="blogck-image"> <img src="<?php echo JUri::root(true); ?>/plugins/pagebuilderck/blog/assets/images/image1.jpg" width="100%" height="auto" /> </div> <div class="blogck-title">Lorem Ipsum</div> <div class="blogck-date">2123-02-16</div> <div class="blogck-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed molestie scelerisque ultrices. Nullam venenatis, felis ut accumsan vestibulum, diam leo congue nisl, eget luctus sapien libero eget urna. Duis ac pellentesque nisi.</div> <a href="#" class="blogck-link">Read more</a> </div> </div> </div> <?php } /* * Display the html code for the item to be used into the interface * * Return String the html code */ public function onPagebuilderckLoadItemOptionsBlog() { // load the language files of the plugin $this->loadLanguage(); // load the interface for the options $tpl = JPATH_SITE . '/plugins/pagebuilderck/blog/layouts/edit_blog.php'; return $tpl; } /* * Display the html code for the item to be used into the frontend page * @param string the item object from simple_html_dom * * Return String the html code */ public function onPagebuilderckRenderItemBlog($item) { $this->callAssets(); // load the helper to help us to use the parameters include_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/pagebuilderckfront.php'; include_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/loaders/article.php'; $app = JFactory::getApplication(); $input = CKFof::getInput(); $attrs = $item->find('.tab_article'); // this is the tab id in the interface which contains the map options $params = PagebuilderckFrontHelper::createParamsFromElement($attrs); $layout_attrs = $item->find('.tab_layout'); // this is the tab id in the interface which contains the map options $this->layout_params = PagebuilderckFrontHelper::createParamsFromElement($layout_attrs); $this->image_params = PagebuilderckFrontHelper::createParamsFromElement($item->find('.tab_imagestyles')); $this->iconhtml = ''; $icon = $item->find('.blogck-link .pbckicon'); if (! empty($icon) && isset($icon[0])) { // $this->iconhtml = '<i class="' . $icon[0]->attr['class'] . '" style="' . (isset($icon[0]->attr['style']) ? $icon[0]->attr['style'] : '') . '"></i>'; $this->iconhtml = $icon[0]->outertext; } // ckstyle and inner classes are needed to get the styles from the interface $ckstyle = $item->find('.ckstyle'); $styles = count($ckstyle) ? $ckstyle[0]->innertext : ''; // get the items list $items = PagebuilderckLoaderArticles::getItems($params); $maxarticles = $this->layout_params->get('maxarticles', ''); $pagination = $this->layout_params->get('pagination_1', '') == 'checked' ? '1': '0'; $totalitems = count($items); if ($pagination === '1') { $page = $input->get('blogckpage', 1, 'int'); $start = ($page - 1) * (int) $maxarticles; } else { $start = 0; } if ($maxarticles) $items = array_slice($items, $start, $maxarticles); $nbitems = count($items); $nbcols = $this->layout_params->get('nbcols', '3'); $gutter = $this->layout_params->get('gutter', '10'); $adjustlast = $this->layout_params->get('adjustlast_0', '') !== 'checked' ? '1': '0'; if ($adjustlast == '1') { $nbcols = ($nbitems < $nbcols && $nbitems > 0) ? $nbitems : $nbcols; $styles .= '#'.$item->attr['id'].' .blogck-item { width: calc(1/' . (int)$nbcols . '*100% - (1 - 1/' . (int)$nbcols . ')*' . (int)$gutter . 'px); margin-bottom: ' . (int)$gutter . 'px; } '; // add css to adapt the last items if ((int)$nbcols >= '2') $styles .= '#'.$item->attr['id'].' .blogck-item.ckn1 { width: calc(1/1*100% - (1 - 1/1)*' . (int)$gutter . 'px); margin-bottom: ' . (int)$gutter . 'px; } '; if ((int)$nbcols >= '3') $styles .= '#'.$item->attr['id'].' .blogck-item.ckn2 { width: calc(1/2*100% - (1 - 1/2)*' . (int)$gutter . 'px); margin-bottom: ' . (int)$gutter . 'px; } '; if ((int)$nbcols >= '4') $styles .= '#'.$item->attr['id'].' .blogck-item.ckn3 { width: calc(1/3*100% - (1 - 1/3)*' . (int)$gutter . 'px); margin-bottom: ' . (int)$gutter . 'px; } '; } else { $styles .= '#'.$item->attr['id'].' .blogck { display: grid; justify-content: space-around; flex-wrap: wrap; grid-template-columns:' . str_repeat(' 1fr', (int)$nbcols) . '; grid-gap: ' . (int)$gutter . 'px; } '; } $styles .= '@media only screen and (max-width:' . (int)$this->layout_params->get('responsiveresolution', '640') . 'px){ #'.$item->attr['id'].' div.blogck { display: block; } #'.$item->attr['id'].' div.blogck .blogck-item { width: initial !important; } }'; // calculate how many items will be outside the number of columns value. Example 5 items in 3 cols, it stays 2 last items $nblastitems = $nbitems - ((int) ($nbitems / $nbcols) * $nbcols); $layoutorder = explode(',', $this->layout_params->get('layoutorder', 'image,title,text,link')); $layoutstate = explode(',', $this->layout_params->get('layoutstate', '1,1,1,1')); $linkbottom = $this->layout_params->get('linkbottom_0', '') == 'checked' ? '': ' block-link-bottom'; $blogckclass = $this->layout_params->get('gridlayout', '') == 'grid' ? ' blogck-grid': ''; $html = '<div class="ckstyle"> '. $styles . ' </div> <div class="blogck' . $blogckclass . ' inner' . $linkbottom . '">'; foreach ($items as $i => $item) { $itemclass = $i >= $nbitems - $nblastitems ? ' ckn' . $nblastitems : ''; $html .= '<div class="blogck-item' . $itemclass . '">'; $i = 0; $item->text = JHTML::_('content.prepare', $item->text); $textlength = $this->layout_params->get('textlength', ''); if ($textlength) $item->text = PagebuilderckHelper::substring($item->text, $textlength); foreach ($layoutorder as $type) { $funcName = ucfirst($type); if ($layoutstate[$i] != '0') $html .= $this->{'render' . $funcName}($item); $i++; } $html .='</div>'; } $html .= '</div>'; if ($pagination === '1' && $maxarticles) { $html .= $this->renderPagination($start, $maxarticles, $totalitems); } $doc = JFactory::getDocument(); $doc->addScriptDeclaration($this->getJavascript()); return $html; } private function getJavascript() { $js = 'function pbckBlogPagination(i) { var form = document.getElementById("blogckpagination"); form.blogckpage.value=i; form.submit(); } '; return $js; } private function renderImage($item) { if ($item->image) { $item->image = PagebuilderckHelper::setImageUrl($item->image); $linkstart = $this->layout_params->get('linkon_image', '') == 'checked' ? '<a href="' . $item->link . '">' : ''; $linkend = $this->layout_params->get('linkon_image', '') == 'checked' ? '</a>' : ''; $imageclass = $this->image_params->get('imagecssclass', ''); $imgtitle = $item->title; $imgtext = $item->text; if(isset($item->images['image_intro_caption']) && $item->images['image_intro_caption']) { $texttmp = explode('::', $item->images['image_intro_caption']); $imgtitle = $texttmp[0]; $imgtext = isset($texttmp[1]) ? $texttmp[1] : ''; } $imgalt = $item->title; if(isset($item->images['image_intro_alt']) && $item->images['image_intro_alt']) { $imgalt = htmlspecialchars($item->images['image_intro_alt']); } $imgalttag = $imgalt ? ' alt="' . $imgalt . '"' : ''; $imgtitletag = ($this->image_params->get('show_title_in_effect_1', '') == 'checked' ? htmlspecialchars($imgtitle) : '') . ($this->image_params->get('show_text_in_effect_1', '') == 'checked' ? '::' . htmlspecialchars($imgtext) : ''); $imgtitletag = $imgtitletag ? ' title="' . $imgtitletag . '"' : ''; $imageclass = $imageclass ? ' class="' . $imageclass . '"' : ''; $html = '<div class="blogck-image"> ' . $linkstart . ' <img src="' . $item->image . '" width="100%" height="auto"' . $imageclass . $imgtitletag . $imgalttag . ' /> ' . $linkend . ' </div>'; } else { $html = ''; } return $html; } private function renderTitle($item) { $linkstart = $this->layout_params->get('linkon_title', '') == 'checked' ? '<a href="' . $item->link . '">' : ''; $linkend = $this->layout_params->get('linkon_title', '') == 'checked' ? '</a>' : ''; $html = '<div class="blogck-title">' . $linkstart . $item->title . $linkend . '</div>'; return $html; } private function renderText($item) { $html = '<div class="blogck-text">' . $item->text . '</div>'; return $html; } private function renderLink($item) { $readmoretext = $this->layout_params->get('readmoretext', 'PLG_PAGEBUILDERCK_BLOG_READMORE'); $html = '<a href="' . $item->link . '" class="blogck-link" data-align="' . $this->layout_params->get('readmorealign', 'center') . '">' . $this->iconhtml . JText::_($readmoretext) . '</a>'; return $html; } private function renderDate($item) { $format = $this->layout_params->get('dateformat', 'DATE_FORMAT_LC4'); // $date = date(JText::_($format), strtotime($item->displayDate)); $date = HtmlHelper::date($item->displayDate, $format); $html = '<div class="blogck-date">' . $date . '</div>'; return $html; } private function renderPagination($start, $max, $total) { $nbpages = (int)( ($total - 1) / $max) + 1; if ($nbpages <= 1) return ''; $input = CKFof::getInput(); $page = $input->get('blogckpage', 1, 'int'); $html = '<form id="blogckpagination" class="blogck-pagination-form"><input id="blogckpage" name="blogckpage" type="hidden" /></form>'; $html .= '<div class="blogck-pagination tck-pagination pagination"><ul class="pagination-list">'; $i = 1; while ($i <= $nbpages) { if ($i == $page) { $html .= '<li class="active"><span class="blogck-pagination-link">' . $i . '</span></li>'; } else { $html .= '<li><a href="javascript:void(0)" onclick="pbckBlogPagination(' . $i . ')" class="blogck-pagination-link">' . $i . '</a></li>'; } $i++; } $html .= '</ul></div>'; return $html; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings