mambax7/marquee

View on GitHub
plugins/smartmedia.php

Summary

Maintainability
A
1 hr
Test Coverage
<?php declare(strict_types=1);
/**
 * ****************************************************************************
 * marquee - MODULE FOR XOOPS
 * Copyright (c) Hervé Thouzard (https://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 (https://www.herve-thouzard.com)
 * @license           GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
 * @author            Hervé Thouzard (https://www.herve-thouzard.com)
 *
 * Version :
 * ****************************************************************************
 *
 * @param $limit
 * @param $dateFormat
 * @param $itemsSize
 *
 * @return array
 */

// Script to list recent clips from the smartmedia module (tested with smartmedia 0.85)
function b_marquee_smartmedia($limit, $dateFormat, $itemsSize)
{
    $block = [];
    if (!defined('SMARTMEDIA_DIRNAME')) {
        define('SMARTMEDIA_DIRNAME', 'smartmedia');
    }
    require_once XOOPS_ROOT_PATH . '/modules/' . SMARTMEDIA_DIRNAME . '/include/common.php';
    $title_length = 99999;
    if ($itemsSize > 0) {
        $title_length = $itemsSize;
    }
    $maxClips              = $limit;
    $smartmediaClipHandler = smartmedia_gethandler('clip');
    $clipsArray            = &$smartmediaClipHandler->getClipsFromAdmin(0, $maxClips, 'clips.created_date', 'DESC', 'all');
    if ($clipsArray) {
        foreach ($clipsArray as $clipArray) {
            $clip    = [];
            $block[] = [
                'date'     => '',
                'category' => '',
                'author'   => '',
                'title'    => $clipArray['title'],
                'link'     => '<a href="' . SMARTMEDIA_URL . 'clip.php?categoryid=' . $clipArray['categoryid'] . '&folderid=' . $clipArray['folderid'] . '&clipid=' . $clipArray['clipid'] . '">' . $clipArray['title'] . '</a>',
            ];
            unset($clip);
        }
    }

    return $block;
}