/**
 * ****************************************************************************
 * marquee - MODULE FOR XOOPS
 * Copyright (c) Hervé Thouzard (http://www.herve-thouzard.com)
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       Hervé Thouzard (http://www.herve-thouzard.com)
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         marquee
 * @author 			Hervé Thouzard (http://www.herve-thouzard.com)
 *
 * Version : $Id:
 * ****************************************************************************
 */
function b_marquee_show($options)
{
    global $xoopsTpl;
    include_once XOOPS_ROOT_PATH . '/modules/marquee/include/functions.php';
    $marquee_handler =& xoops_getmodulehandler('marquee', 'marquee');
    $block = array();
    $marqueeId = intval($options[0]);
    if ($marqueeId > 0) {
        $marquee = null;
        $marquee = $marquee_handler->get($marqueeId);
        if (is_object($marquee)) {
            $uniqid = md5(uniqid(rand(), true));
            if (marquee_getmoduleoption('methodtouse') == 'DHTML') {
                $link = '<script type="text/javascript" src="' . XOOPS_URL . '/modules/marquee/js/xbMarquee.js"></script>';
                $link .= "\n<script type=\"text/javascript\">\n";
                $link .= 'var marquee' . $uniqid . ";\n";
                $link .= "var html{$uniqid} = '';\n";
                $link .= "function init_{$uniqid}()\n";
                $link .= "{\n";
                $link .= "\tmarquee{$uniqid}.start();\n";
                $link .= "}\n";
                $link .= "</script>\n";
                $xoopsTpl->assign("xoops_module_header", $link);
            }
            $block['marqueecode'] = $marquee->constructmarquee($uniqid);
        }
    }
    return $block;
}
Example #2
0
function b_marquee_news($limit, $dateformat, $itemssize)
{
    include_once XOOPS_ROOT_PATH . '/modules/marquee/include/functions.php';
    include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
    $block = $stories = array();
    $story = new NewsStory();
    $restricted = marquee_getmoduleoption('restrictindex', 'news');
    $stories = $story->getAllPublished($limit, 0, $restricted, 0, 1, true, 'published');
    if (count($stories) > 0) {
        foreach ($stories as $onestory) {
            if ($itemssize > 0) {
                $title = xoops_substr($onestory->title(), 0, $itemssize + 3);
            } else {
                $title = $onestory->title();
            }
            $block[] = array('date' => formatTimestamp($onestory->published(), $dateformat), 'category' => $onestory->topic_title(), 'author' => $onestory->uid(), 'title' => $title, 'link' => "<a href='" . XOOPS_URL . '/modules/news/article.php?storyid=' . $onestory->storyid() . "'>" . $title . '</a>');
        }
    }
    return $block;
}
Example #3
0
function AddEditMarqueeForm($marqueeid, $Action, $FormTitle, $contentvalue, $bgcolorvalue, $widthvalue, $heightvalue, $scrollamountvalue, $hspacevalue, $vspacevalue, $scrolldelayvalue, $directionvalue, $behaviourvalue, $alignvalue, $loopvalue, $stopvalue, $LabelSubmitButton, $sourcevalue = 'fixed')
{
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    global $xoopsModule, $xoopsModuleConfig;
    $sform = new XoopsThemeForm($FormTitle, 'marqueeform', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/marquee.php');
    $source = new XoopsFormSelect(_AM_MARQUEE_SOURCE, 'source', $sourcevalue);
    $source->addOption('fixed', _AM_MARQUEE_SOURCE_FIXED);
    $fileslst = myglob(XOOPS_ROOT_PATH . '/modules/marquee/plugins/', 'php');
    foreach ($fileslst as $onefile) {
        $onefile = basename($onefile, '.php');
        $source->addOption($onefile, $onefile);
    }
    $sform->addElement($source);
    $editor = marquee_utils::getWysiwygForm(_AM_MARQUEE_CONTENT, 'content', $contentvalue, 15, 60, 'content_text_hidden');
    if ($editor) {
        $sform->addElement($editor, false);
    }
    if (marquee_getmoduleoption('methodtouse') != 'DHTML') {
        $sform->addElement(new XoopsFormText(_AM_MARQUEE_BGCOLOR, 'bgcolor', 7, 7, $bgcolorvalue), false);
    }
    $sform->addElement(new XoopsFormText(_AM_MARQUEE_WIDTH, 'width', 4, 4, $widthvalue), false);
    $sform->addElement(new XoopsFormText(_AM_MARQUEE_HEIGHT, 'height', 4, 4, $heightvalue), false);
    $sform->addElement(new XoopsFormText(_AM_MARQUEE_SCRAMOUNT, 'scrollamount', 4, 4, $scrollamountvalue), false);
    if (marquee_getmoduleoption('methodtouse') != 'DHTML') {
        $sform->addElement(new XoopsFormText(_AM_MARQUEE_HSPACE, 'hspace', 4, 4, $hspacevalue), false);
        $sform->addElement(new XoopsFormText(_AM_MARQUEE_VSPACE, 'vspace', 4, 4, $vspacevalue), false);
    }
    $sform->addElement(new XoopsFormText(_AM_MARQUEE_SCRDELAY, 'scrolldelay', 6, 6, $scrolldelayvalue), false);
    $direction = new XoopsFormSelect(_AM_MARQUEE_DIRECTION, 'direction', $directionvalue);
    $direction->addOption('0', _AM_MARQUEE_DIRECTION1);
    $direction->addOption('1', _AM_MARQUEE_DIRECTION2);
    $direction->addOption('2', _AM_MARQUEE_DIRECTION3);
    $direction->addOption('3', _AM_MARQUEE_DIRECTION4);
    $sform->addElement($direction, true);
    $behaviour = new XoopsFormSelect(_AM_MARQUEE_BEHAVIOUR, 'behaviour', $behaviourvalue);
    $behaviour->addOption('0', _AM_MARQUEE_BEHAVIOUR1);
    if (marquee_getmoduleoption('methodtouse') != 'DHTML') {
        $behaviour->addOption('1', _AM_MARQUEE_BEHAVIOUR2);
    }
    $behaviour->addOption('2', _AM_MARQUEE_BEHAVIOUR3);
    $sform->addElement($behaviour, true);
    if (marquee_getmoduleoption('methodtouse') != 'DHTML') {
        $align = new XoopsFormSelect(_AM_MARQUEE_ALIGN, 'align', $alignvalue);
        $align->addOption('0', _AM_MARQUEE_ALIGN1);
        $align->addOption('1', _AM_MARQUEE_ALIGN2);
        $align->addOption('2', _AM_MARQUEE_ALIGN3);
        $sform->addElement($align, true);
    }
    $loop = new XoopsFormSelect(_AM_MARQUEE_LOOP, 'loop', $loopvalue);
    $loop->addOption('0', _AM_MARQUEE_INFINITELOOP);
    for ($i = 1; $i <= 100; $i++) {
        $loop->addOption($i, $i);
    }
    if (marquee_getmoduleoption('methodtouse') != 'DHTML') {
        $sform->addElement($loop, true);
        $sform->addElement(new XoopsFormRadioYN(_AM_MARQUEE_STOP, 'stoponmouseover', $stopvalue, _YES, _NO));
    }
    $sform->addElement(new XoopsFormHidden('op', $Action), false);
    if (!empty($marqueeid)) {
        $sform->addElement(new XoopsFormHidden('marqueeid', $marqueeid), false);
    }
    $button_tray = new XoopsFormElementTray('', '');
    $submit_btn = new XoopsFormButton('', 'submit', $LabelSubmitButton, 'submit');
    $button_tray->addElement($submit_btn);
    $cancel_btn = new XoopsFormButton('', 'reset', _AM_MARQUEE_RESETBUTTON, 'reset');
    $button_tray->addElement($cancel_btn);
    $sform->addElement($button_tray);
    $sform->display();
}
Example #4
0
 function constructmarquee($uniqid = '')
 {
     include_once XOOPS_ROOT_PATH . '/modules/marquee/include/functions.php';
     $tblalign = array('top', 'bottom', 'middle');
     $tblbehaviour = array('scroll', 'slide', 'alternate');
     $tbldirection = array('right', 'left', 'up', 'down');
     $stop = $this->getVar('marquee_stoponmouseover') == 1 ? ' onmouseover="this.stop()" onmouseout="this.start()"' : '';
     $bgcolor = trim($this->getVar('marquee_bgcolor')) != '' ? " bgcolor='" . $this->getVar('marquee_bgcolor') . "'" : '';
     $height = $this->getVar('marquee_height') != 0 ? " height=" . $this->getVar('marquee_height') : '';
     $hspace = $this->getVar('marquee_hspace') != 0 ? " hspace=" . $this->getVar('marquee_hspace') : '';
     $width = trim($this->getVar('marquee_width')) != '' ? " width='" . $this->getVar('marquee_width') . "'" : '';
     $scrolldelay = $this->getVar('marquee_scrolldelay') != 0 ? " scrolldelay=" . $this->getVar('marquee_scrolldelay') : '';
     $loop = $this->getVar('marquee_loop') != 0 ? " loop=" . $this->getVar('marquee_loop') : " loop='infinite'";
     $vspace = $this->getVar('marquee_vspace') != 0 ? " vspace=" . $this->getVar('marquee_vspace') : '';
     $scrollamount = $this->getVar('marquee_scrollamount') != 0 ? " scrollamount=" . $this->getVar('marquee_scrollamount') : '';
     $br = ' - ';
     if ($this->getVar('marquee_direction') > 1) {
         $br = '<br />';
     }
     $content = '';
     if ($this->getVar('marquee_source') != 'fixed') {
         include_once XOOPS_ROOT_PATH . '/modules/marquee/plugins/' . $this->getVar('marquee_source') . '.php';
         $function_name = 'b_marquee_' . $this->getVar('marquee_source');
         // For example b_marquee_comments
         if (function_exists($function_name)) {
             $limit = marquee_getmoduleoption('itemscount');
             $dateformat = marquee_getmoduleoption('dateformat');
             $itemssize = marquee_getmoduleoption('itemssize');
             $retval = call_user_func($function_name, $limit, $dateformat, $itemssize);
             if (is_array($retval) && count($retval) > 0) {
                 foreach ($retval as $onevalue) {
                     if (isset($onevalue['category']) && xoops_trim($onevalue['category']) != '') {
                         $onevalue['category'] = ' - ' . $onevalue['category'];
                     }
                     if (isset($onevalue['link']) && xoops_trim($onevalue['link']) != '') {
                         $onevalue['link'] = ' - ' . $onevalue['link'];
                     }
                     $content .= $onevalue['date'] . $onevalue['category'] . $onevalue['link'] . $br;
                 }
             }
         }
     } else {
         $content = $this->getVar('marquee_content');
     }
     if (!marquee_isbot()) {
         // We are using the microsoft html tag
         if (strtolower(marquee_getmoduleoption('methodtouse')) != 'dhtml') {
             return "<marquee align='" . $tblalign[$this->getVar('marquee_align')] . "' behavior='" . $tblbehaviour[$this->getVar('marquee_behaviour')] . "' direction='" . $tbldirection[$this->getVar('marquee_direction')] . "' " . $stop . $scrollamount . $bgcolor . $height . $hspace . $width . $scrolldelay . $loop . $vspace . ">" . $content . "</marquee>";
         } else {
             // We are using the javascript method
             $jscontent = '';
             $jscontent .= "<script type=\"text/javascript\">\n";
             $jscontent .= "html{$uniqid} = '';\n";
             $jscontent .= "html{$uniqid} += '" . marquee_javascript_escape($content) . "' ;\n";
             $jscontent .= "marquee{$uniqid} = new xbMarquee('marquee{$uniqid}', " . $this->getVar('marquee_height') . ", " . $this->getVar('marquee_width') . ", " . $this->getVar('marquee_scrollamount') . ", " . $this->getVar('marquee_scrolldelay') . ", '" . $tbldirection[$this->getVar('marquee_direction')] . "', '" . $tblbehaviour[$this->getVar('marquee_behaviour')] . "', html{$uniqid});\n";
             $jscontent .= "init_{$uniqid}();\n";
             $jscontent .= "</script>\n";
             return $jscontent;
         }
     } else {
         return $content;
     }
 }