Пример #1
0
function mediashare_user_albumlist($args)
{
    $order = mediashareGetStringUrl('order', $args, 'createdDate');
    $orderDir = mediashareGetStringUrl('orderdir', $args, 'desc');
    $template = isset($args['tpl']) ? $args['tpl'] : 'list';
    if (!($albums = pnModAPIFunc('mediashare', 'user', 'getAlbumList', compact('order', 'orderDir')))) {
        return false;
    }
    // Build the output
    $render =& pnRender::getInstance('mediashare', false);
    $render->assign('albums', $albums);
    $template = DataUtil::formatForOS($template);
    if (!$render->template_exists("mediashare_user_album{$template}.html")) {
        $template = 'list';
    }
    return $render->fetch("mediashare_user_album{$template}.html");
}
Пример #2
0
/**
 * Add / edit media items
 */
function mediashare_edit_addmedia($args)
{
    $albumId = mediashareGetIntUrl('aid', $args, 1);
    $sourceName = mediashareGetStringUrl('source', $args);
    // Check access
    if (!mediashareAccessAlbum($albumId, mediashareAccessRequirementAddMedia, '')) {
        return LogUtil::registerPermissionError();
    }
    $dom = ZLanguage::getModuleDomain('mediashare');
    // Get parent album info (ignore unknown parent => this means we add to a top most album)
    if (!($album = pnModAPIFunc('mediashare', 'user', 'getAlbum', array('albumId' => $albumId)))) {
        return false;
    }
    // Get media sources
    if (($sources = pnModAPIFunc('mediashare', 'sources', 'getSources', array('active' => 1))) === false) {
        return false;
    }
    if (count($sources) == 0) {
        return LogUtil::registerError(__('No media sources found. You need to go to the admin panel and perform a scan for media sources.', $dom));
    }
    if ($sourceName == '') {
        $sourceName = $sources[0]['name'];
    }
    // Find current source
    $source = null;
    foreach ($sources as $s) {
        if ($s['name'] == $sourceName) {
            $source = $s;
        }
    }
    $selectedSourceFile = DataUtil::formatForStore("source_{$sourceName}");
    if (!pnModLoad('mediashare', $selectedSourceFile)) {
        return LogUtil::registerError("Failed to load Mediashare {$selectedSourceFile} file");
    }
    $sourceHtml = pnModFunc('mediashare', $selectedSourceFile, 'view');
    if ($sourceHtml === false || $sourceHtml === true) {
        return $sourceHtml;
    }
    // Build the output
    $render =& pnRender::getInstance('mediashare', false);
    $render->assign('album', $album);
    $render->assign('sources', $sources);
    $render->assign('selectedSource', $source);
    $render->assign('selectedSourceName', $sourceName);
    $render->assign('selectedSourceFile', $selectedSourceFile);
    $render->assign('sourceHtml', $sourceHtml);
    return $render->fetch('mediashare_edit_addmedia.html');
}