File: /home/centralexf/www/modules/mod_janewsticker/elements/category.php
<?php
/*
# ------------------------------------------------------------------------
# JA News Ticker module for Joomla 1.5
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license - PHP files are GNU/GPL V2. CSS / JS are Copyrighted Commercial,
# bound by Proprietary License of JoomlArt. For details on licensing,
# Please Read Terms of Use at http://www.joomlart.com/terms_of_use.html.
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com
# Redistribution, Modification or Re-licensing of this file in part of full,
# is bound by the License applied.
# ------------------------------------------------------------------------
*/
/**
* JA News Sticker module allows display of article's title from sections or categories. \
* You can configure the setttings in the right pane. Mutiple options for animations are also added, choose any one.
* If you are using this module on Teline III template, * then the default module position is "headlines".
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
/**
* JElementCategory class.
*/
class JElementCategory extends JElement
{
/*
* Category name
*
* @access protected
* @var string
*/
var $_name = 'Category';
/*
* Control name.
*
* @access protected
* @var string
*/
var $_controlName = '';
/**
* fetch Element
*/
function fetchElement($name, $value, &$node, $control_name){
$this->_controlName = $name;
$db = &JFactory::getDBO();
$query = 'SELECT * FROM #__sections WHERE published=1';
$db->setQuery( $query );
$sections = $db->loadObjectList();
$categories=array();
foreach ($sections as $section) {
$optgroup = JHTML::_('select.optgroup',$section->title,'id','title');
$query = 'SELECT id,title FROM #__categories WHERE published=1 AND section='.$section->id;
$db->setQuery( $query );
$results = $db->loadObjectList();
array_push($categories,$optgroup);
foreach ($results as $result) {
array_push($categories,$result);
}
}
$optgroup = JHTML::_('select.optgroup',JText::_("Uncategorized"),'id','title');
array_push($categories,$optgroup);
$uncategorised=array();
$uncategorised['id'] = '0';
$uncategorised['title'] = JText::_("Uncategorized");
array_push($categories,$uncategorised);
$out = JHTML::_('select.genericlist', $categories, ''.$control_name.'['.$name.'][]', 'class="inputbox" style="width:95%;" multiple="multiple" size="10"', 'id', 'title', $value );
$out .= $this->renderJSControl();
return $out;
}
/**
* render javasript to control enable or disable options following system.
*
* return string.
*/
function renderJSControl(){
$string = '<script type="text/javascript" language="javascript">
window.addEvent("domready", function () {
var usingModes = ["rss","categories","categories_selected"];
var controlID = "params'.$this->_controlName.'";
var prexParam = "paramsusing_mode";
usingModes.each( function (val) {
var element = prexParam+val;
if( $(element) != null ){
$(element).addEvent("click", function(){
control( this.value, controlID );
});
if( $(element).checked ){
control( $(element).value , controlID );
}
}
} );
function control( value, controlID ){
switch( value ){
case "categories":
$(controlID).disabled = true;
$(controlID).getElements("option").each( function(option){
option.selected = true;
} );
$("paramsrss_link").disabled = true;
break;
case "categories_selected":
$(controlID).disabled = false;
$("paramsrss_link").disabled = true;
break;
default:
$(controlID).getElements("option").each( function(option){
option.selected = false;
} );
$(controlID).disabled=true;
$("paramsrss_link").disabled = false;
break;
}
}
} );';
$string .= '</script>';
return $string;
}
}
?>