function WIDGET_mootickerRSS($block = 'gl_mootickerRSS', $id = 'gl_mooticker') { global $_CONF, $_TABLES, $LANG_WIDGETS; $query = "SELECT bid, rdfurl, rdflimit, UNIX_TIMESTAMP(rdfupdated) AS date FROM {$_TABLES['blocks']} WHERE type = 'portal' AND is_enabled = 0"; // Update feeds from blocks where 'is_enabled' -tag is set to 0 $blocksql['mysql'] = $query; $blocksql['mssql'] .= $query; $result = DB_query($blocksql); $nrows = DB_numRows($result); $blocks = array(); for ($i = 0; $i < $nrows; $i++) { $blocks[] = DB_fetchArray($result); } // Loop though resulting sorted array and pass associative arrays // to COM_rdfCheck foreach ($blocks as $A) { COM_rdfCheck($A['bid'], $A['rdfurl'], $A['date'], $A['rdflimit']); } $retval = ''; $result = DB_query("SELECT *, rdfupdated as date FROM {$_TABLES['blocks']} WHERE name='" . DB_escapeString($block) . "'"); $numRows = DB_numRows($result); if ($numRows < 1 || $result == NULL) { return $retval; } $B = DB_fetchArray($result); if ($B['is_enabled'] == 0) { COM_formatBlock($B, true); $retval = <<<EOT <script type="text/javascript"> var MooTicker=new Class({options:{controls:true,delay:2000,duration:800,blankimage:'{site_url}/images/speck.gif'},initialize:function(b,c){this.setOptions(c);this.element=\$(b)||null;this.element.addEvents({'mouseenter':this.stop.bind(this),'mouseleave':this.play.bind(this)});this.news=this.element.getElements('ul li');this.current=0;this.fx=[];this.news.getParent().setStyle('position','relative');var d=this;this.news.each(function(a,i){a.setStyle('position','absolute');this.fx[i]=new Fx.Style(a,'opacity',{duration:this.options.duration,onStart:function(){d.transitioning=true},onComplete:function(){d.transitioning=false}}).set(1);if(!i)return;a.setStyle('opacity',0)},this);if(this.options.controls)this.addControls();this.status='stop';window.addEvent('load',this.play.bind(this));return this},addControls:function(){var a=new Element('span',{'class':'controls'}).injectTop(this.element);this.arrowPrev=new Element('img',{'class':'control-prev','title':'{prev}','alt':'{prev}','src':this.options.blankimage}).inject(a);this.arrowNext=new Element('img',{'class':'control-next','title':'{next}','alt':'{next}','src':this.options.blankimage}).inject(a);this.arrowPrev.addEvent('click',this.previous.bind(this));this.arrowNext.addEvent('click',this.next.bind(this));return this},previous:function(){if(this.transitioning)return this;var a=(!this.current)?this.news.length-1:this.current-1;this.fx[this.current].start(0);this.fx[a].start(1);this.current=a;return this},next:function(){if(this.transitioning)return this;var a=(this.current==this.news.length-1)?0:this.current+1;this.fx[this.current].start(0);this.fx[a].start(1);this.current=a;return this},play:function(){if(this.status=='play')return this;this.status='play';this.timer=this.next.periodical(this.options.delay+this.options.duration,this);return this},stop:function(){this.status='stop';\$clear(this.timer);return this}});MooTicker.implement(new Options,new Events); </script> <script type="text/javascript"> window.addEvent('domready', function() { var x = new MooTicker('{$id}', { controls: true, delay: 2500, duration: 600 }); }); </script> <div id="{$id}"> EOT; $retval = str_replace('{site_url}', $_CONF['site_url'], $retval); $retval = str_replace('{prev}', $LANG_WIDGETS['prev'], $retval); $retval = str_replace('{next}', $LANG_WIDGETS['next'], $retval); $retval .= '<span class="tickertitle">' . $LANG_WIDGETS['latest_news'] . ':</span>'; $retval .= $B['content'] . '</div>'; } return $retval; }
/** * Formats a Geeklog block * * This shows a single block and is typically called from * COM_showBlocks OR from plugin code * * @param array $A Block Record * @param boolean $noboxes Set to true if userpref is no blocks * @return string HTML Formated block * */ function COM_formatBlock($A, $noboxes = false) { global $_CONF, $_TABLES, $LANG21; $retval = ''; $lang = COM_getLanguageId(); if (!empty($lang)) { $blocksql['mssql'] = "SELECT bid, is_enabled, name, type, title, tid, blockorder, cast(content as text) as content, "; $blocksql['mssql'] .= "rdfurl, rdfupdated, rdflimit, onleft, phpblockfn, help, owner_id, "; $blocksql['mssql'] .= "group_id, perm_owner, perm_group, perm_members, perm_anon, allow_autotags,UNIX_TIMESTAMP(rdfupdated) AS date "; $blocksql['mysql'] = "SELECT *,UNIX_TIMESTAMP(rdfupdated) AS date "; $blocksql['pgsql'] = 'SELECT *, date_part(\'epoch\', rdfupdated) AS date'; $commonsql = "FROM {$_TABLES['blocks']} WHERE name = '" . $A['name'] . '_' . $lang . "'"; $blocksql['mysql'] .= $commonsql; $blocksql['mssql'] .= $commonsql; $blocksql['pgsql'] .= $commonsql; $result = DB_query($blocksql); if (DB_numRows($result) == 1) { // overwrite with data for language-specific block $A = DB_fetchArray($result); } } if (array_key_exists('onleft', $A)) { if ($A['onleft'] == 1) { $position = 'left'; } else { $position = 'right'; } } else { $position = ''; } if ($A['type'] == 'portal') { if (COM_rdfCheck($A['bid'], $A['rdfurl'], $A['date'], $A['rdflimit'])) { $A['content'] = DB_getItem($_TABLES['blocks'], 'content', "bid = '{$A['bid']}'"); } } if ($A['type'] == 'gldefault') { $retval .= COM_showBlock($A['name'], $A['help'], $A['title'], $position); } if ($A['type'] == 'phpblock' && !$noboxes) { if (!($A['name'] == 'whosonline_block' and DB_getItem($_TABLES['blocks'], 'is_enabled', "name='whosonline_block'") == 0)) { $function = $A['phpblockfn']; $matches = array(); if (preg_match('/^(phpblock_\\w*)\\((.*)\\)$/', $function, $matches) == 1) { $function = $matches[1]; $args = $matches[2]; } $blkheader = COM_startBlock($A['title'], $A['help'], COM_getBlockTemplate($A['name'], 'header', $position)); $blkfooter = COM_endBlock(COM_getBlockTemplate($A['name'], 'footer', $position)); if (function_exists($function)) { if (isset($args)) { $fretval = $function($A, $args); } else { $fretval = $function(); } if (!empty($fretval)) { $retval .= $blkheader; $retval .= $fretval; $retval .= $blkfooter; } } else { // show error message $retval .= $blkheader; $retval .= sprintf($LANG21[31], $function); $retval .= $blkfooter; } } } if (!empty($A['content']) && trim($A['content']) != '' && !$noboxes) { $blockcontent = stripslashes($A['content']); // Hack: If the block content starts with a '<' assume it // contains HTML and do not call nl2br() which would only add // unwanted <br> tags. if (substr($blockcontent, 0, 1) != '<') { $blockcontent = nl2br($blockcontent); } // autotags are only(!) allowed in normal blocks if ($A['allow_autotags'] == 1 && $A['type'] == 'normal') { $blockcontent = PLG_replaceTags($blockcontent); } $blockcontent = str_replace(array('<?', '?>'), '', $blockcontent); $retval .= COM_startBlock($A['title'], $A['help'], COM_getBlockTemplate($A['name'], 'header', $position)) . $blockcontent . LB . COM_endBlock(COM_getBlockTemplate($A['name'], 'footer', $position)); } return $retval; }
/** * Formats a Geeklog block * This shows a single block and is typically called from * COM_showBlocks OR from plugin code * * @param array $A Block Record * @param boolean $noBoxes Set to true if userpref is no blocks * @param boolean $noPosition Set to true if you don't want to use the left or right side footer and header of * block * @return string HTML Formatted block */ function COM_formatBlock($A, $noBoxes = false, $noPosition = false) { global $_CONF, $_TABLES, $LANG21, $_DEVICE; $retval = ''; $lang = COM_getLanguageId(); if (!empty($lang)) { $blockSql['mysql'] = "SELECT *,UNIX_TIMESTAMP(rdfupdated) AS date "; $blockSql['pgsql'] = "SELECT *, date_part('epoch', rdfupdated) AS date "; $commonSql = "FROM {$_TABLES['blocks']} WHERE name = '" . $A['name'] . '_' . $lang . "'"; $blockSql['mysql'] .= $commonSql; $blockSql['pgsql'] .= $commonSql; $result = DB_query($blockSql); if (DB_numRows($result) == 1) { // overwrite with data for language-specific block $A = DB_fetchArray($result); } } // Make sure block can be used by specific device // If no device column found then bypass compare check (could happen with dynamic blocks that do not pass device) if (!isset($A['device']) || $_DEVICE->compare($A['device'])) { if (array_key_exists('onleft', $A) && !$noPosition) { $position = $A['onleft'] == 1 ? 'left' : 'right'; } else { $position = ''; } if ($A['type'] === 'portal') { if (COM_rdfCheck($A['bid'], $A['rdfurl'], $A['date'], $A['rdflimit'])) { $A['content'] = DB_getItem($_TABLES['blocks'], 'content', "bid = '{$A['bid']}'"); } } if ($A['type'] === 'gldefault') { $retval .= COM_showBlock($A['name'], $A['help'], $A['title'], $position); } else { // The only time cache_time would not be set if for dynamic blocks (they can handle their own caching if needed) // Don't Cache default blocks either if (isset($A['cache_time']) && ($A['cache_time'] > 0 || $A['cache_time'] == -1)) { $cacheInstance = 'block__' . $A['bid'] . '__' . CACHE_security_hash() . '__' . $_CONF['theme']; $retval = CACHE_check_instance($cacheInstance); if ($retval && $A['cache_time'] == -1) { return $retval; } elseif ($retval && $A['cache_time'] > 0) { $lu = CACHE_get_instance_update($cacheInstance); $now = time(); if ($now - $lu < $A['cache_time']) { return $retval; } else { $retval = ''; } } } } if ($A['type'] === 'phpblock' && !$noBoxes) { if (!($A['name'] === 'whosonline_block' && DB_getItem($_TABLES['blocks'], 'is_enabled', "name='whosonline_block'") == 0)) { $function = $A['phpblockfn']; $matches = array(); if (preg_match('/^(phpblock_\\w*)\\((.*)\\)$/', $function, $matches) == 1) { $function = $matches[1]; $args = $matches[2]; } $blockHeader = COM_startBlock($A['title'], $A['help'], COM_getBlockTemplate($A['name'], 'header', $position)); $blockFooter = COM_endBlock(COM_getBlockTemplate($A['name'], 'footer', $position)); if (function_exists($function)) { if (isset($args)) { $fRetval = $function($A, $args); } else { $fRetval = $function(); } if (!empty($fRetval)) { $retval .= $blockHeader; $retval .= $fRetval; $retval .= $blockFooter; } } else { // show error message $retval .= $blockHeader; $retval .= sprintf($LANG21[31], $function); $retval .= $blockFooter; } } } if (!empty($A['content']) && trim($A['content']) != '' && !$noBoxes) { $blockContent = stripslashes($A['content']); // Hack: If the block content starts with a '<' assume it // contains HTML and do not call COM_nl2br() which would only add // unwanted <br> tags. if (substr(trim($blockContent), 0, 1) != '<') { $blockContent = COM_nl2br($blockContent); } // autotags are only(!) allowed in normal blocks if ($A['allow_autotags'] == 1 && $A['type'] === 'normal') { $blockContent = PLG_replaceTags($blockContent); } $blockContent = str_replace(array('<?', '?>'), '', $blockContent); $retval .= COM_startBlock($A['title'], $A['help'], COM_getBlockTemplate($A['name'], 'header', $position)) . $blockContent . LB . COM_endBlock(COM_getBlockTemplate($A['name'], 'footer', $position)); } // Cache only if enabled and not gldefault or dynamic if (isset($A['cache_time']) && ($A['cache_time'] > 0 || $A['cache_time'] == -1) && $A['type'] !== 'gldefault') { CACHE_create_instance($cacheInstance, $retval); } } return $retval; }