/** * @param $id * @param $name * @param $description * @param $message * @param $redirectTo */ public function autofillDescriptions($id, $name, $description, &$message, &$redirectTo) { $autocompleteStrategy = CedTagsHelper::param('wikipediaAutocompleteStrategy', '0'); //Only supported source is Wikipedia $wikipedia = new CedTagWikipedia(); //Update single tag if (isset($name) && strlen($name) > 0) { $tag = new stdClass(); $tag->id = $id[0]; $tag->name = $name; $tag->description = $description; $updateTerm = strlen($tag->description) == 0 && $autocompleteStrategy == 0 || $autocompleteStrategy == 1; $this->updateDescriptionForTag($wikipedia, $updateTerm, $tag); $redirectTo = "index.php?option=com_cedtag&controller=term&task=edit&cid[]=" . $id[0]; } else { //Update all tags $tags = $this->getAllTags(); foreach ($tags as $tag) { $updateTerm = strlen($tag->description) == 0 && $autocompleteStrategy == 0 || $autocompleteStrategy == 1; $this->updateDescriptionForTag($wikipedia, $updateTerm, $tag); } $redirectTo = "index.php?controller=term&option=com_cedtag"; } $message = JText::_('Using ') . $wikipedia->getWikipediaServer() . "."; $message .= JText::_(' Did Search for ') . $wikipedia->getRequested() . ' term(s).'; $message .= JText::_(' Did found ') . $wikipedia->getFound() . JText::_(' term(s) description(s) '); if (sizeof($wikipedia->getNotFound()) > 0) { $message .= JText::_('Did not found ') . sizeof($wikipedia->getNotFound()) . JText::_(' term(s) description(s) '); foreach ($wikipedia->getNotFound() as $term) { // $message .= "<a href='/index.php?option=com_cedtag&controller=term&task=edit&cid[]=".$term->tid.">$term->name</a> - "; $message .= $term->name; } } }
/** * * @param $cid * @return array */ public function getModelTags($cid) { $terms = $this->getTagsForArticle($cid); $showRelatedArticles = CedTagsHelper::param('RelatedArticlesByTags', 0); $tags = array(); if (isset($terms) && !empty($terms)) { $singleTermsSuppress = CedTagsHelper::param('SuppresseSingleTerms', 1); $termIds = array(); foreach ($terms as $term) { $frequency = $this->getTagFrequency($term); if ($showRelatedArticles || $singleTermsSuppress) { if (@intval($frequency) <= 1) { if ($singleTermsSuppress) { continue; } } else { $termIds[] = $term->id; } } $date = $term->created; $tag = new stdClass(); $tag->title = JText::sprintf('COM_CEDTAG_ITEMS_TITLE', (string) $frequency, (string) $term->name, (string) $date, (string) $term->hits); $tag->id = $term->id; $tag->link = JRoute::_('index.php?option=com_cedtag&task=tag&tag=' . CedTagsHelper::urlTagname($term->name)); $tag->tag = CedTagsHelper::ucwords($term->name); $tags[] = $tag; } } //Limit size of tags displayed array_splice($tags, intval(CedTagsHelper::param('MaxTagsNumber', 10))); return $tags; }
/** * @param $id * @param $tags * @return string */ public function getRelatedAsHtml($id, $catid, $access, $tags) { $count = CedTagsHelper::param('RelatedArticlesCountByTags', 10); $relatedArticlesTitle = CedTagsHelper::param('RelatedArticlesTitleByTags', "Related Articles"); //$max=max(intval($relatedArticlesCount),array_count_values($termIds)); //find the unique article ids $contentIds = $this->getUniqueArticleId($tags, $id); $html = ""; if (is_array($contentIds) && sizeof($contentIds) > 0) { $rows = $this->getModel($contentIds, $count); if (empty($rows)) { return ''; } $user = JFactory::getUser(); $aid = JVERSION < 1.6 ? $user->get('aid', 0) : max($user->getAuthorisedViewLevels()); $html = '<div class="relateditemsbytags">' . $relatedArticlesTitle . '</div> <div> <ul class="relateditems">'; foreach ($rows as $row) { if ($row->access <= $aid) { $link = JVERSION < 1.6 ? JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid)) : JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug)); } else { $link = JRoute::_('index.php?option=com_user&view=login'); } $html .= '<li> <a href="' . $link . '">' . htmlspecialchars($row->title) . '</a></li>'; } $html .= '</ul></div>'; } return $html; }
/** * @Override * @param $fileContent * @return mixed * */ public function transform($fileContent) { $useGoogleFonts = CedTagsHelper::param('useGoogleFonts', '1'); if ($useGoogleFonts) { $googleFonts = explode("|", CedTagsHelper::param('googleFonts', "font-family: 'Open Sans', sans-serif;|Open+Sans")); $fileContent = preg_replace("/(font-family:.*;)/i", $googleFonts[0], $fileContent); } return $fileContent; }
public function addCss() { $document = JFactory::getDocument(); $document->addStyleSheet($this->getStyleSheet()); $useGoogleFonts = CedTagsHelper::param('useGoogleFonts', '1'); if ($useGoogleFonts) { $googleFonts = explode("|", CedTagsHelper::param('googleFonts', "font-family: 'Open Sans', sans-serif;|Open+Sans")); $document->addStyleSheet('http://fonts.googleapis.com/css?family=' . $googleFonts[1]); } }
private function addJs($initialTags = "[]", $articleId, $area = "", $controller = "", $tabindex = 1) { $this->addStaticJavascript(); $initialTags = implode("','", $initialTags); $articleIdParam = '&cid=' . $articleId; //instead of using a different alias for the jQuery object (when using noConflict), //I always write my jQuery code by wrapping it all in a closure. This can be done in the document.ready function: $script = "jQuery(function(\$) {\r\n \$('#tags" . $articleId . "').tagit({tagSource:'" . JURI::root() . $area . "index.php?option=com_cedtag" . $controller . "&" . JSession::getFormToken() . "=1&format=raw&task=ajaxSuggest',\r\n select:true,\r\n initialTags:['" . $initialTags . "'],\r\n sortable:true,\r\n maxTags:20,\r\n tabindex:" . $tabindex . ",\r\n triggerKeys:['enter', 'comma', 'tab'],\r\n allowSpaces:" . (CedTagsHelper::param('spacesAllowedWithoutQuotes', 0) ? 'true' : 'false') . ",\r\n highlightOnExistColor:'#0F0',\r\n tagsChanged:function (tagValue, action, element) {\r\n var xmlHttp = new XMLHttpRequest();\r\n if (action == 'moved') {\r\n\r\n }\r\n if (action == 'popped') {\r\n url = '" . JURI::root() . $area . "index.php?option=com_cedtag" . $controller . "&" . JSession::getFormToken() . "=1&format=raw&task=ajaxDelete&tags=' + tagValue + '" . $articleIdParam . "';\r\n xmlHttp.open( 'GET', url, false );\r\n xmlHttp.send( null );\r\n }\r\n if (action == 'added') {\r\n url = '" . JURI::root() . $area . "index.php?option=com_cedtag" . $controller . "&" . JSession::getFormToken() . "=1&format=raw&task=ajaxAdd&tags=' + tagValue + '" . $articleIdParam . "';\r\n xmlHttp.open( 'GET', url, false );\r\n xmlHttp.send( null );\r\n }\r\n }\r\n }\r\n );\r\n });"; $document = JFactory::getDocument(); $document->addScriptDeclaration($script); }
function termCheck($term) { $ignoreNumericTags = CedTagsHelper::param('IgnoeNumericTags', 0); if ($ignoreNumericTags) { if (is_numeric($term)) { echo 'ignore:' . $term; return false; } } $minTagLength = CedTagsHelper::param('MinTagLength', 1); $len = JString::strlen($term); if ($len < $minTagLength) { return false; } return true; }
echo $item->class; ?> " title="<?php echo $item->title; ?> "> <?php echo $item->name; ?> </a> <?php } ?> <?php if (intval(CedTagsHelper::param('removeCopyright', 0)) == 0) { ?> <div style="text-align: center;"> <a href="http://www.waltercedric.com" style="font: normal normal normal 10px/normal arial; color: rgb(187, 187, 187); border-bottom-style: none; border-bottom-width: initial; border-bottom-color: initial; text-decoration: none; " onmouseover="this.style.textDecoration='underline'" onmouseout="this.style.textDecoration='none'" target="_blank"><b>cedTag</b></a> </div> <?php } ?> </div><?php }
private function getModel($paramPrefixName) { $app = JFactory::getApplication(); $params = $app->getParams(); $document = JFactory::getDocument(); $cedTagsHelper = new CedTagsHelper(); $description = CedTagsHelper::param($paramPrefixName . 'MetaDescription'); $document->setDescription($cedTagsHelper->truncate($description)); $keywords = CedTagsHelper::param($paramPrefixName . 'MetaKeywords'); $document->setMetadata($paramPrefixName . 'Keywords', $keywords); $title = CedTagsHelper::param($paramPrefixName . 'Title'); $document->setTitle($title); $count = intval($params->get($paramPrefixName . 'Count', 25)); $sorting = $params->get('wordleTagOrder', 'sizeasort'); $reverse = intval($params->get($paramPrefixName . 'Reverse', 1)); $rows = $cedTagsHelper->getPopularTagModel($count, $sorting, $reverse); return $rows; }
private function _buildOrderBy() { $order = CedTagsHelper::param('Order'); switch ($order) { case 'date': $orderBy = 'a.created'; break; case 'rdate': $orderBy = 'a.created DESC'; break; case 'alpha': $orderBy = 'a.title'; break; case 'ralpha': $orderBy = 'a.title DESC'; break; case 'hits': $orderBy = 'a.hits DESC'; break; case 'rhits': $orderBy = 'a.hits'; break; case 'order': $orderBy = 'a.ordering'; break; case 'author': $orderBy = 'a.created_by_alias, u.name'; break; case 'rauthor': $orderBy = 'a.created_by_alias DESC, u.name DESC'; break; case 'front': $orderBy = 'f.ordering'; break; default: $orderBy = 'a.ordering'; break; } return $orderBy; }
/** * Constructor * * For php4 compatability we must not use the __constructor as a constructor for plugins * because func_get_args ( void ) returns a copy of all passed arguments NOT references. * This causes problems with cross-referencing necessary for the observer design pattern. * * @param object $subject The object to observe * @param array $config An array that holds the plugin configuration * @since 1.0 */ public function plgSystemCedTagSef(&$subject, $config) { parent::__construct($subject, $config); $this->sefTagBase = CedTagsHelper::param('sefUrlBase', 'tag'); }
private function getSqlFor($param, $field, &$sql) { $isField = CedTagsHelper::param($param, '1'); $sql .= $isField ? "{$field} as {$field}," : ""; return $sql; }
function __construct() { parent::__construct(); $this->wikipediaServer = CedTagsHelper::param('wikipediaServer', 'http://en.wikipedia.org'); }
public function isValidName($name) { $name = CedTagsHelper::preHandle($name); if (empty($name)) { return false; } $useStopWords = CedTagsHelper::param("useStopWords", '1'); if ($useStopWords && in_array($name, CedTagsHelper::getExcludedWordList())) { return false; } return $name; }
/** * @param null $tpl * @return mixed */ private function defaultTpl($tpl = null) { $params = JComponentHelper::getParams('com_cedtag'); //Layout $defaultLayout = $params->get('layout', 'blog'); $layout = JFactory::getApplication()->input->get('layout', $defaultLayout, 'STRING'); $this->setLayout($layout); $tag = JFactory::getApplication()->input->get('tag', null, 'string'); // create custom pathway $app = JFactory::getApplication(); $pathway = $app->getPathway(); $pathway->addItem(JText::_('COM_CEDTAG_PATHWAY_TITLE'), JURI::root() . 'index.php?option=com_cedtag&view=alltags'); $pathway->addItem($tag, ''); $cedTagsHelper = new CedTagsHelper(); $tag = $cedTagsHelper->unUrlTagname($tag); JFactory::getApplication()->input->set('tag', $tag); $this->assign('tag', $tag); //Term do not exist $isTermExist = $this->get('TermExist'); if (!$isTermExist) { $tagNotFoundUseWarningPage = CedTagsHelper::param('tagNotFoundUseWarningPage', true); if ($tagNotFoundUseWarningPage) { $this->assign('message', 'REQUEST_TAG_NOT_EXIST_WARNING'); $this->setLayout('requested_tag_do_not_exist'); return parent::display($tpl); } JError::raiseError(404, JText::_("Could not find tag \"{$tag}\"")); } //No Articles found with that Term $hasTermArticles = $this->get('TermArticles'); if (!$hasTermArticles) { $this->assign('message', 'NO_ARTICLES_WITH_TAG'); $this->setLayout('no_articles_with_tag'); return parent::display($tpl); } $items = $this->get('Data'); $this->assignRef('results', $items); //switch off edit capabilities to reuse blog_item.php $comContentParams = clone JComponentHelper::getParams('com_content'); //TODO not correct for sure for blog with editor $comContentParams->set('access-edit', false); $comContentParams->set('access-view', true); foreach ($items as $item) { $item->params = $comContentParams; //TODO switch this off for now $item->alternative_readmore = null; } $this->prepareData($items); $this->assign('total', $this->get('Total')); $this->assign('tagDescription', $this->get('TagDescription')); $this->assign('showDescription', $params->get('description', '1')); $this->assign('showMeta', $params->get('contentMeta', '1')); $this->assignRef('ads', $params->get('ads', '')); $this->assignRef('pagination', $this->get('Pagination')); $this->assign('show_pagination', $comContentParams->def('show_pagination', 1)); $this->assign('show_pagination_results', $comContentParams->def('show_pagination_results', 1)); $this->assign('ads_top_use', $params->get('ads_top_use', '0')); $this->assign('ads_top_content', $params->get('ads_top_content', '0')); $this->assign('ads_bottom_use', $params->get('ads_bottom_use', '0')); $this->assign('ads_bottom_content', $params->get('ads_bottom_content', '0')); $config = JFactory::getConfig(); $this->assign('title', $this->get('Title') . ' | ' . $config->getValue('sitename')); parent::display($tpl); }