Current Path :
/
home
/
develito
/
www
/
modules
/
mod_jtnet_yazarlar
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/develito/www/modules/mod_jtnet_yazarlar/helper.php
<?php /** * @package Jtnet Yazarlar Modülü Joomla! 3 * @version $Id: 1.0 * @author muratyil * @Copyright (C) 2013- muratyil * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html **/ // no direct access defined('_JEXEC') or die; error_reporting(E_ALL & ~E_STRICT &~E_WARNING); require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php'); jimport('joomla.application.component.model'); JModellegacy::addIncludePath(JPATH_SITE.'/components/com_content/models', 'ContentModel'); abstract class modGlobalNewsHelper { public function getGN_Img( &$params, $link, $img, $pfx ) { $align = $params->get( $pfx.'_img_align', 'left' ); $margin = $params->get( $pfx.'_img_margin', '3px' ); $width = (int)$params->get( $pfx.'_img_width', '' ); $height = (int)$params->get( $pfx.'_img_height', '' ); $border = $params->get( $pfx.'_img_border', '0' ); if ( $align == 'left' ) : $style = 'float:left;'; if ( $pfx == 'cat' ) { $style .= 'margin-right:' . $margin . ';'; } else { $style .= 'margin:' . $margin . ';'; } endif; if ( $align == 'right' ) : $style = 'float:right;'; if ( $pfx == 'cat' ) { $style .= 'margin-left:' . $margin . ';'; } else { $style .= 'margin:' . $margin . ';'; } endif; $style .= 'border:' . $border . ';'; $attribs = array ('style' => $style); if ( $height ) $attribs = array('height' => $height, $attribs); if ( $width ) $attribs = array('width' => $width, $attribs ); $image = JHTML::_('image', $img, JText::_('IMAGE'), $attribs ); if ( $link ) $image = JHTML::_('link', $link, $image); if ( $align = 'center') $image = '<center>' . $image . '</center>'; return $image; } public function getGN_Cats(&$params) { $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $catid = $params->get('catid', ''); $curcat = $params->get('curcat', 0); $current = $params->get('current', 1); $show_cat = $params->get('show_cat', 1); $cat_title = $params->get('cat_title', 1); $cat_img = $params->get( 'cat_img_align', 0); $access = !JComponentHelper::getParams('com_content')->get('show_noauth'); $group_id = $condition = ''; switch ($params->get( 'cat_order', 1)) { case '0': $ordering = 'rand()'; break; case '1': $ordering = 'c.id ASC'; break; case '2': $ordering = 'c.title ASC'; break; case '3': default: $ordering = 'c.ordering ASC'; break; } if ( $curcat == 1 || $current != 1 ) : if ( JRequest::getCmd('option') == 'com_content' ) { $view = JRequest::getCmd('view'); $temp = JRequest::getString('id'); $temp = explode(':', $temp); $id = $temp[0]; } endif; $catids = $params->get('catid'); JArrayHelper::toInteger($catids); $catids = implode(',', $catids); if (!empty($catids)) { $condition .= ' AND c.id IN ('.$catids.')'; } $query = 'SELECT c.*, ' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as slug' . ' FROM #__categories AS c' . ' WHERE c.published = 1 AND c.extension = "com_content"' . ($access ? ' AND c.access IN ('.$groups.')' : ''). ($condition!='' ? $condition : ''). ' ORDER BY '. $ordering; $db->setQuery($query); $rows = $db->loadObjectList(); $i = 0; $cats = array(); foreach ( $rows as $row ) { $cats[$i]->link = JRoute::_(ContentHelperRoute::getCategoryRoute( $row->slug )); //$cats[$i]->cond = ' AND a.catid = '.$row->id; $cats[$i]->cond = $row->id; $cats[$i]->title = ''; $cats[$i]->image = ''; if ( $cat_img ) { $catParams = new JRegistry; $catParams->loadString($row->params); if ( $image = $catParams->get('image')) { $cats[$i]->image .= modGlobalNewsHelper::getGN_Img( $params, $cats[$i]->link, $image, 'cat' ); } } if ( $group_id == $row->id && $curcat == 1 ) { $cats[$i]->link = ''; } if ( $cat_title != 0 ) { $tags = array(array('',''),array('',''),array('<strong>','</strong>'),array('<u>','</u>'),array('<strong><u>','</u></strong>'),array('<h1>','</h1>'),array('<h2>','</h2>'),array('<h3>','</h3>'),array('<h4>','</h4>'),array('<h5>','</h5>'),array('<h6>','</h6>')); if ( $show_cat == 2 ) { $cats[$i]->title .= $tags[$cat_title][0] . $row->title . $tags[$cat_title][1]; } else { $cats[$i]->title .= ( $cat_title > 4 ? $tags[$cat_title][0] : '' ) . ( $cats[$i]->link ? '<a href="' . $cats[$i]->link. '">' : '' ) . ( $cat_title < 5 ? $tags[$cat_title][0] : '' ) . $row->title . ( $cat_title < 5 ? $tags[$cat_title][1] : '' ) . ( $cats[$i]->link ? '</a>' : '' ) . ( $cat_title > 4 ? $tags[$cat_title][1] : '' ); } } $i++; } return $cats; } public function getGN_List(&$params,$catid) { $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $userId = (int) $user->get('id'); $groups = implode(',', $user->getAuthorisedViewLevels()); $count = trim( $params->get('count', 5) ); $current = trim( $params->get('current', 1) ); $layout = $params->get('layout', 'list'); $html = $params->get('html'); $show_front = $params->get('show_front', 1); $aid = $user->get('aid', 0); $limittitle = $params->get('limittitle', ''); $nullDate = $db->getNullDate(); jimport('joomla.utilities.date'); $date = new JDate(); $now = $date->toSQL(); $article_id = 0; if ($current != 1 && JRequest::getCmd('option') === 'com_content' && JRequest::getCmd('view') === 'article') { $article_id = JRequest::getInt('id'); } $articles = JModellegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true)); $app = JFactory::getApplication(); $appParams = $app->getParams(); $articles->setState('params', $appParams); $articles->setState('list.start', 0); $articles->setState('list.limit', (int) $params->get('count', 5)); $articles->setState('filter.published', 1); $access = !JComponentHelper::getParams('com_content')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $articles->setState('filter.access', $access); if ($params->get('show_child_category_articles', 0) && (int) $params->get('levels', 0) > 0) { $categories = JModellegacy::getInstance('Categories', 'ContentModel', array('ignore_request' => true)); $categories->setState('params', $appParams); $levels = $params->get('levels', 1) ? $params->get('levels', 1) : 9999; $categories->setState('filter.get_children', $levels); $categories->setState('filter.published', 1); $categories->setState('filter.access', $access); $additional_catids = array(); $categories->setState('filter.parentId', $catid); $recursive = true; $items = $categories->getItems($recursive); if ($items) { foreach($items as $category) { $condition = (($category->level - $categories->getParent()->level) <= $levels); if ($condition) { $additional_catids[] = $category->id; } } } $catid = array_unique(array_merge(array($catid), $additional_catids)); } $articles->setState('filter.category_id', $catid); $articles->setState('list.ordering', $params->get('article_ordering', 'a.ordering')); $articles->setState('list.direction', $params->get('article_ordering_direction', 'ASC')); $articles->setState('filter.featured', $params->get('show_front', 'show')); $articles->setState('filter.author_id', $params->get('created_by', "")); $articles->setState('filter.author_id.include', 1); if ( $article_id && $current == 0 ) { $articles->setState('filter.article_id', $article_id); $articles->setState('filter.article_id.include', false); // Exclude } $rows = $articles->getItems(); $i = 0; $lists = array(); foreach ( $rows as $row ) { if ( $article_id == $row->id && $current == 2 ) { $link = ''; } else { $row->slug = $row->id.':'.$row->alias; $row->catslug = $row->catid ? $row->catid .':'.$row->category_alias : $row->catid; $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug)); } if ( $limittitle && strlen( $row->title ) > $limittitle ) { $row->title = substr( $row->title, 0, $limittitle ). '...'; } if ( $link ) { $lists[$i]->title = '<a href="'.$link.'">'.htmlspecialchars( $row->title ).'</a>'; } else { $lists[$i]->title = htmlspecialchars( $row->title ); } if ( $layout != 'list' ) : $gn_image = ''; $gn_title = ''; $gn_created = ''; $gn_author = ''; $gn_text = ''; $gn_readmore = ''; $gn_comments = ''; if ( preg_match("/GN_title/", $html) ) { $gn_title = $lists[$i]->title; $gn_title = preg_replace('/\$/','$-',$gn_title); } if ( preg_match("/GN_date/", $html) ) { $gn_created = JHTML::_('date', ($params->get( 'date' ) == 'created' ? $row->created : $row->modified ), $params->get('date_format', '' ) ); } if ( preg_match("/GN_author/", $html) ) { $author = $params->get( 'author' ); if ( $author != 'alias' ) { $query = "SELECT " . $author . " FROM #__users WHERE id = " . $row->created_by; $db->setQuery($query); $gn_author = $db->loadResult(); } else { $gn_author = $row->created_by_alias; } } if ( preg_match("/GN_text/", $html) ) { $limit = trim( $params->get('limittext', '150') ); $gn_text = $row->introtext; if ( $params->get('striptext', '1')) $gn_text = trim( strip_tags( $gn_text, $params->get('allowedtags', '') ) ); $pattern = array("/[\n\t\r]+/",'/{(\w+)[^}]*}.*{\/\1}|{(\w+)[^}]*}/Us', '/\$/'); $replace = array(' ', '', '$-'); $gn_text = preg_replace( $pattern, $replace, $gn_text ); if ( $limit && strlen( $gn_text ) > $limit ) { $gn_text = substr( $gn_text, 0, $limit ); $space = strrpos( $gn_text, ' ' ); $gn_text = substr( $gn_text, 0, $space ). '...'; } } $code = array("/GN_image/", "/GN_title/", "/GN_date/", "/GN_author/", "/GN_text/", "/GN_readmore/", "/GN_comments/","/GN_break/","/GN_space/"); $rplc = array( $gn_image, $gn_title, $gn_created, $gn_author, $gn_text, $gn_readmore, $gn_comments, "<br />", " "); $lists[$i]->content = preg_replace($code, $rplc, $html); $lists[$i]->content = preg_replace('/\$-/','$',$lists[$i]->content); endif; $i++; } return $lists; } public function addGN_CSS(&$params, $layout, $globalnews_id, $total) { $doc =& JFactory::getDocument(); $layout = $params->get( 'layout', 'list' ); $padding = (int)$params->get('padding', '5px'); $border = $params->get('border', '1px solid #EFEFEF'); $color = $params->get('color', '#FFFFFF'); $show_cat = $params->get('show_cat', '1'); $css = ''; if ( $globalnews_id == 1 ) : $css .= ".gn_clear { clear:both; height:0; line-height:0; }\n"; endif; $header = '.gn_header_' . $globalnews_id . ' {' .' background-color:' . $params->get('header_color', '#EFEFEF') . ';' .' border:' . $border . ';' .' border-bottom:none;' .' padding:' . (int)$params->get('header_padding', '5px') . 'px;' .' }'; $marquee = ' border:' . $border . ';' . ( $show_cat != 0 ? ' border-top:none;' : '' ) .' padding:' . $padding . 'px;' .' height:' . $params->get('height', '100px') . ';' .' background-color:' . $color . ';' .' overflow:hidden;'; switch ( $layout ) { case 'list' : $css .= $header . "\n" .".gn_list_" . $globalnews_id . " {" . $marquee ." }"; break; case 'static' : $css .= $header . "\n" .".gn_static_" . $globalnews_id . " {" . $marquee ." }"; break; case 'slider' : $css .= $header . "\n" .".gn_slider_" . $globalnews_id . " {" . $marquee ." border-bottom:none;" ." }" . "\n" .".gn_slider_" . $globalnews_id . " .gn_opacitylayer {" ." height:100%;" ." filter:progid:DXImageTransform.Microsoft.alpha(opacity=100);" ." -moz-opacity:1;" ." opacity:1;" ." }" . "\n" .".gn_pagination_" . $globalnews_id . " {" ." border:" . $border . ";" ." border-top:none;" ." padding:2px " . $padding . "px;" ." text-align:right;" ." background-color:" . $color . ";" ." }" . "\n" .".gn_pagination_" . $globalnews_id . " a:link {" ." font-weight:bold;" ." padding:0 2px;" ." }" . "\n" .".gn_pagination_" . $globalnews_id . " a:hover, .gn_pagination_" . $globalnews_id . " a.selected {" ." color:#000;" ." }"; break; case 'browser' : $containerIds = array(); for ($m=0;$m<$total;$m++) { $containerIds[$m] = '#gn_container_' . $globalnews_id . '_' . ($m+1); } $css .= $header . "\n" . implode(',' , $containerIds) . " {" . $marquee ." position: relative;" ." }"; break; case 'scroller' : $scrollerIds = array(); for ($m=0;$m<$total;$m++) { $scrollerIds[$m] = '#gn_scroller_' . $globalnews_id . '_' . ($m+1); } $css .= $header . "\n" . implode(',' , $scrollerIds) . " {" . $marquee ." }"; break; } return $doc->addStyleDeclaration($css); } }