Beispiel #1
0
 function getList(&$params)
 {
     $dbo = JFactory::getDBO();
     $query = $dbo->getQuery(true);
     $query->select('count(*) as frequency');
     $query->select('name as name');
     $query->select('t.hits as hits');
     $query->select('t.created as created');
     $query->from('#__cedtag_term_content as tc');
     $query->innerJoin('#__cedtag_term as t on t.id=tc.tid');
     $query->where("t.published='1'");
     $query->group('tid');
     $query->order('hits desc');
     $dbo->setQuery($query);
     $count = intval($params->get('count', 25));
     $dbo->setQuery($query, 0, $count);
     $rows = $dbo->loadObjectList();
     if (isset($rows) && !empty($rows)) {
         $CedTagsHelper = new CedTagsHelper();
         $rows = $CedTagsHelper->mappingFrequencyToSize($rows);
         $sorting = $params->get('sorting', 'hitsasort');
         usort($rows, array('CedTagsHelper', $sorting));
         $CedTagThemes = new CedTagThemes();
         $CedTagThemes->addCss();
         if (intval($params->get('reverse', 0))) {
             $rows = array_reverse($rows);
         }
     }
     return $rows;
 }
Beispiel #2
0
 function getList(&$params)
 {
     $CedTagsHelper = new CedTagsHelper();
     $count = intval($params->get('count', 25));
     $sorting = $params->get('sorting', 'sizeasort');
     $reverse = intval($params->get('reverse', 0));
     return $CedTagsHelper->getPopularTagModel($count, $sorting, $reverse);
 }
Beispiel #3
0
 public function getList(&$params)
 {
     $termIds = $params->get("tagIds");
     $idsArray = @explode(',', $termIds);
     if (empty($idsArray)) {
         return array();
     }
     $dbo = JFactory::getDBO();
     $query = $dbo->getQuery(true);
     $query->select('count(*) as frequency');
     $query->select('id as id');
     $query->select('name as name');
     $query->select('t.hits as hits');
     $query->select('t.created as created');
     $query->select('1 as sequence');
     $query->from('#__cedtag_term as t');
     $query->where("t.id in (" . @implode(',', $idsArray) . ")");
     $dbo->setQuery($query);
     $query = $query->dump();
     $rows = $dbo->loadObjectList();
     //if there is results
     if (isset($rows) && !empty($rows)) {
         $rowsMap = array();
         $total_tags = count($rows);
         foreach ($rows as $row) {
             $rowsMap[$row->id] = $row;
         }
         $sortedRows = array();
         for ($index = 0; $index < $total_tags; $index++) {
             $id = $idsArray[$index];
             $rowsMap[$id]->sequence = $total_tags - $index;
             $sortedRows[] = $rowsMap[$id];
         }
         $rows = array_reverse($sortedRows);
         unset($sortedRows);
         unset($rowsMap);
         $CedTagsHelper = new CedTagsHelper();
         $rows = $CedTagsHelper->mappingFrequencyToSize($rows);
         $sorting = $params->get('sorting', 'tag_latestasort');
         usort($rows, array('CedTagsHelper', $sorting));
         $CedTagThemes = new CedTagThemes();
         $CedTagThemes->addCss();
         if (intval($params->get('reverse', 0))) {
             $rows = array_reverse($rows);
         }
     }
     return $rows;
 }
Beispiel #4
0
 /**
  * @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;
 }
Beispiel #5
0
 function defaultTpl($tpl = null)
 {
     JToolBarHelper::title(JText::_('CedTag') . " " . CedTagsHelper::getComponentVersion(), 'tag.png');
     //JURI::root().'media/com_cedtag/images/tag_logo48.png'
     //JToolBarHelper::help('JHELP_SITE_SYSTEM_INFORMATION');
     parent::display($tpl);
 }
Beispiel #6
0
 /**
  * Tags Search method
  *
  * The sql must return the following fields that are
  * used in a common display routine: href, title, section, created, text,
  * browsernav
  * @param string Target search string
  * @param string mathcing option, exact|any|all
  * @param string ordering option, newest|oldest|popular|alpha|category
  * @param mixed An array if restricted to areas, null if search all
  */
 function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $searchText = $text;
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys(plgSearchTagsAreas()))) {
             return array();
         }
     }
     // load plugin params info
     $plugin = JPluginHelper::getPlugin('search', 'cedtags');
     $pluginParams = new JParameter($plugin->params);
     $limit = $pluginParams->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $rows = $this->searchForText($text, $limit);
     $count = count($rows);
     for ($i = 0; $i < $count; $i++) {
         $link = 'index.php?option=com_cedtag&task=tag&tag=' . CedTagsHelper::urlTagname($rows[$i]->name);
         $rows[$i]->href = JRoute::_($link);
         $rows[$i]->section = JText::_('TAG');
     }
     $return = array();
     foreach ($rows as $key => $tag) {
         if (searchHelper::checkNoHTML($tag, $searchText, array('name', 'title', 'text'))) {
             $return[] = $tag;
         }
     }
     return $return;
 }
Beispiel #7
0
 /**
  *
  * @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;
 }
Beispiel #8
0
 /**
  * @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;
 }
Beispiel #9
0
/**
 * The second function, [componentname]ParseRoute($segments), must transform an array of segments back into an array of URL parameters. Schematically:
 * @param $segments
 * @return array
 */
function cedtagParseRoute($segments)
{
    $vars = array();
    $tag = array_shift($segments);
    $vars['tag'] = CedTagsHelper::urlTagname($tag);
    $vars['task'] = 'tag';
    $vars['view'] = 'tag';
    return $vars;
}
Beispiel #10
0
 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]);
     }
 }
Beispiel #11
0
 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);
 }
Beispiel #12
0
 function importTagsFromMetaKeys()
 {
     $dbo = JFactory::getDbo();
     $query = 'select id,metakey from #__content';
     $dbo->setQuery($query);
     $metaKeys = $dbo->loadObjectList();
     if (!empty($metaKeys)) {
         foreach ($metaKeys as $meta) {
             if (isset($meta->metakey) && empty($meta->metakey) == false) {
                 $cid = $meta->id;
                 if (!$this->isContentHasTags($cid)) {
                     $keys = explode(',', $meta->metakey);
                     $keysProcessed = array();
                     foreach ($keys as $key) {
                         $key = CedTagsHelper::preHandle($key);
                         if (empty($key) == false) {
                             if (!in_array($key, $keysProcessed)) {
                                 $keysProcessed[] = $key;
                             }
                         }
                     }
                     unset($keys);
                     $deleteTags = 'delete from #__cedtag_term_content where cid=' . $dbo->quote($cid);
                     $dbo->setQuery($deleteTags);
                     $dbo->query();
                     foreach ($keysProcessed as $key) {
                         $pass = $this->termCheck($key);
                         if ($pass) {
                             $tid = $this->storeTerm($key);
                             $this->insertContentterm($tid, $cid);
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
Beispiel #13
0
 private function ajaxDelete()
 {
     //this will check for the token in the url.
     //JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
     $id = JFactory::getApplication()->input->get('cid', 0, 'int');
     $CedTagsHelper = new CedTagsHelper();
     if ($CedTagsHelper->canUserDoTagOperations($id)) {
         $tag = JFactory::getApplication()->input->get('tags', '', 'string');
         $CedTagsHelper->getTagModel()->deleteTag($id, $tag);
     }
 }
Beispiel #14
0
        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 
}
Beispiel #15
0
 * @author waltercedric.com
 * @copyright (C) 2012 http://www.waltercedric.com 2010
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 **/
defined('_JEXEC') or die('Restricted access');
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
require_once JPATH_SITE . '/components/com_cedtag/helpers/themes.php';
// to reuse components/com_content/views/category/tmpl/blog_item.php
// when doing later $this->loadTemplate('item');
$this->addTemplatePath(JPATH_SITE . '/components/com_content/views/category/tmpl');
JHtml::addIncludePath(JPATH_SITE . '/components/com_cedtag/helpers');
//blog_item.php use icon.php
JHtml::addIncludePath(JPATH_SITE . '/components/com_content/helpers');
$document = JFactory::getDocument();
$document->addStyleSheet('media/com_cedtag/css/blog.css');
$cedTagsHelper = new CedTagsHelper();
if ($this->tagDescription) {
    $document->setDescription($cedTagsHelper->truncate($this->tagDescription));
} else {
    $document->setDescription($cedTagsHelper->truncate($this->tag));
}
$document->setTitle($this->title);
$document->setMetadata('keywords', $this->tag);
$CedTagThemes = new CedTagThemes();
$CedTagThemes->addCss();
?>

<h1><?php 
echo JText::_('COM_CEDTAG_POSTS_TAGGED') . " " . JText::_('\'') . $this->tag . JText::_('\'');
?>
</h1>
Beispiel #16
0
 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;
 }
Beispiel #17
0
" border="0"/>
        <map name="mymap">
            <?php 
    foreach ($this->cloud->get_image_map() as $map) {
        ?>
            <area shape="rect"
                  coords="<?php 
        echo $map[1]->get_map_coords();
        ?>
"
                  title="<?php 
        echo $map[0];
        ?>
"
                  href="<?php 
        echo JRoute::_('index.php?option=com_cedtag&task=tag&tag=' . CedTagsHelper::urlTagname($map[0]));
        ?>
"
                />
            <?php 
    }
    ?>
        </map>
    </div>
    <div class="copyright">
        <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: inherit; border-bottom-color: inherit; text-decoration: none; "
           onmouseover="this.style.textDecoration='underline'" onmouseout="this.style.textDecoration='none'" target="_blank"><b>cedTag</b></a>
    </div>
    <!-- CedTag Free Tagging system for Joomla by www.waltercedric.com -->
</div>
Beispiel #18
0
 /**
  * @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);
 }
Beispiel #19
0
 private function getSqlFor($param, $field, &$sql)
 {
     $isField = CedTagsHelper::param($param, '1');
     $sql .= $isField ? "{$field} as {$field}," : "";
     return $sql;
 }
Beispiel #20
0
                <span><?php 
echo JText::_('Follow Me on Google+');
?>
</span></a>
        </div>
    </div>


</div>

<div class="tagversion">
    <h1><img src="<?php 
echo JURI::root();
?>
media/com_cedtag/images/tag_logo48.png"/>CedTag <?php 
echo CedTagsHelper::getComponentVersion();
?>
</h1>


    <table border="0" align="center" cellpadding="4" cellspacing="0">
        <tbody>
        <tr>
            <td class="right">&nbsp;</td>
            <td width="200" nowrap="" class="topunderright" align="center">
                <form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="return validate_form(this)">
                    <script>
                        function validate_form(check) {
                            check.amount.value = check.amount.value.replace(/^\$/g, '');
                            if (check.amount.value < 5) {
                                alert("Please enter a $5 minimum amount to cover administration costs");
Beispiel #21
0
        </tr>
        </thead>
        <tfoot>
        <tr>
            <td colspan="9" align="center">
                <div align="center"><?php 
echo $this->termList->page->getPagesLinks();
?>
                </div>
            </td>
        </tr>
        </tfoot>
        <tbody>
        <?php 
$k = 0;
$cedTagsHelper = new CedTagsHelper();
if (count($rows)) {
    for ($i = 0, $n = count($rows); $i < $n; $i++) {
        $row =& $rows[$i];
        JFilterOutput::objectHtmlSafe($row);
        $row->description = $cedTagsHelper->truncate($row->description);
        $link = 'index.php?option=com_cedtag&controller=term&task=edit&cid[]=' . $row->id;
        $checked = JHTML::_('grid.id', $i, $row->id);
        ?>
		<tr class="<?php 
        echo "row{$k}";
        ?>
">
			<td><?php 
        echo $limitstart + $i + 1;
        ?>
Beispiel #22
0
 /**
  * @param $name
  * @param null $description
  * @param int $weight
  * @return bool|int
  */
 public function store($name, $description = null, $weight = 0)
 {
     $dbo = JFactory::getDbo();
     $cedTagsHelper = new CedTagsHelper();
     $name = $cedTagsHelper->isValidName($name);
     if (!$name) {
         return false;
     }
     $cedTagModelTag = new CedTagModelTag();
     $tagAlreadyExisting = $cedTagModelTag->getTagId($name);
     if (isset($tagAlreadyExisting) & isset($tagAlreadyExisting->id)) {
         $needUpdate = false;
         $updateQuery = 'update #__cedtag_term set ';
         if (isset($description) && !empty($description)) {
             $needUpdate = true;
             $updateQuery .= "description='" . $description . "'";
         }
         if (isset($weight)) {
             if ($needUpdate) {
                 $updateQuery .= ', weight=' . $weight;
             } else {
                 $updateQuery .= ' weight=' . $weight;
                 $needUpdate = true;
             }
         }
         if ($needUpdate) {
             $updateQuery .= ' where id=' . $tagAlreadyExisting->id;
             $dbo->setQuery($updateQuery);
             $dbo->query();
         }
         return $tagAlreadyExisting->id;
     } else {
         $insertQuery = "insert into #__cedtag_term (name";
         $valuePart = " values('" . $name . "'";
         if (isset($description) && !empty($description)) {
             $insertQuery .= ",description";
             $valuePart .= ",'" . $description . "'";
         }
         if (isset($weight)) {
             $insertQuery .= ",weight";
             $valuePart .= "," . $weight;
         }
         $date = JFactory::getDate();
         $now = JDate::getInstance()->toSql($date);
         $insertQuery .= ',created) ';
         $valuePart .= ',' . $dbo->Quote($now) . ')';
         $dbo->setQuery($insertQuery . $valuePart);
         $dbo->query();
         return $dbo->insertid();
     }
 }
Beispiel #23
0
 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;
 }
Beispiel #24
0
 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;
 }
Beispiel #25
0
 /**
  * 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');
 }
Beispiel #26
0
 /**
  * @param $name
  * @param null $description
  * @param int $weight
  * @return int existing or new one tag id
  */
 function storeTerm($name, $description = null, $weight = 0)
 {
     $cedTagsHelper = new CedTagsHelper();
     $name = $cedTagsHelper->isValidName($name);
     if (!$name) {
         return false;
     }
     $tagExists = $this->tagExists($name);
     if ($tagExists) {
         return $this->updateExistingTag($description, $weight, $this->getTagId($name));
     } else {
         return $this->insertNewTag($name, $description, $weight);
     }
 }
 /**
  * http://rhodopsin.blogspot.com/2008/05/php-tag-cloud.html
  * http://en.wikipedia.org/wiki/Pareto_distribution
  * @param $rows
  * @return array
  */
 public function mappingFrequencyToSizeWithPareto($rows)
 {
     $tags = array();
     $tagsNameToRow = array();
     foreach ($rows as $row) {
         $tags[$row->name] = $row->frequency;
         $tagsNameToRow[$row->name] = $row;
     }
     $maxSize = $rows[0]->frequency;
     $minSize = 1;
     $tags = $this->fromParetoCurve($tags, $minSize, $maxSize);
     $result = array();
     while (list($tagname, $tagsize) = each($tags)) {
         $term = new stdClass();
         $term->size = $tagsize;
         $term->link = JRoute::_('index.php?option=com_cedtag&task=tag&tag=' . CedTagsHelper::urlTagname($tagname));
         $term->name = CedTagsHelper::ucwords($tagname);
         $term->frequency = $tagsNameToRow[$tagname]->frequency;
         $term->hits = $tagsNameToRow[$tagname]->hits;
         $term->created = $tagsNameToRow[$tagname]->created;
         $term->title = JText::sprintf('COM_CEDTAG_ITEMS_TITLE', (string) $term->frequency, (string) $term->name, (string) $term->created, (string) $term->hits);
         $term->class = 'cedtag';
         $result[] = $term;
     }
     return $result;
 }
Beispiel #28
0
 function __construct()
 {
     parent::__construct();
     $this->wikipediaServer = CedTagsHelper::param('wikipediaServer', 'http://en.wikipedia.org');
 }