示例#1
0
function SOC_getShareIcons($title = '', $summary = '', $itemUrl = '', $image = '', $type = '')
{
    global $_CONF, $_TABLES, $LANG_SOCIAL;
    $replacementArray = array('%%t', '%%s', '%%u', '%%i');
    $retval = '';
    $T = new Template($_CONF['path_layout'] . 'social');
    $T->set_file('social_icons', 'socialshare.thtml');
    $sql = "SELECT * FROM {$_TABLES['social_share']} WHERE enabled=1";
    $result = DB_query($sql);
    $numRows = DB_numRows($result);
    if ($numRows <= 0) {
        return $retval;
    }
    $T->set_block('social_icons', 'social_buttons', 'sb');
    $output = outputHandler::getInstance();
    $output->addLinkScript($_CONF['site_url'] . '/javascript/socialshare.js');
    for ($x = 0; $x < $numRows; $x++) {
        $row = DB_fetchArray($result);
        $id = $row['id'];
        $name = $row['name'];
        $display_name = $row['display_name'];
        $icon = $row['icon'];
        $url = $row['url'];
        // now parse the URL and replace with stuff
        foreach ($replacementArray as $item) {
            switch ($item) {
                case '%%t':
                    $replacementItem = $title;
                    break;
                case '%%s':
                    $replacementItem = $summary;
                    break;
                case '%%u':
                    $replacementItem = $itemUrl;
                    break;
                case '%%i':
                    $replacementItem = $image;
                    break;
                default:
                    $replacementItem = '';
                    break;
            }
            $url = str_replace($item, $replacementItem, $url);
        }
        // now build the actual button
        $T->set_var('service_name', $name);
        $T->set_var('service_id', $id);
        $T->set_var('service_display_name', $display_name);
        $T->set_var('icon', $icon);
        $T->parse('sb', 'social_buttons', true);
    }
    $T->set_var('lang_share_it', $LANG_SOCIAL['share_it_label']);
    $retval = $T->finish($T->parse('output', 'social_icons'));
    return $retval;
}
示例#2
0
function MB_displayTree($menu_id)
{
    global $_CONF, $LANG_MB01, $LANG_MB_ADMIN, $LANG_ADMIN;
    $retval = '';
    $menu = menu::getInstance($menu_id);
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/menu.php?mode=new&amp;menuid=' . (int) $menu_id, 'text' => $LANG_MB01['create_element']), array('url' => $_CONF['site_admin_url'] . '/menu.php', 'text' => $LANG_MB01['menu_list']));
    $retval .= COM_startBlock($LANG_MB01['menu_builder'] . ' :: ' . $menu->name, '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= ADMIN_createMenu($menu_arr, $LANG_MB_ADMIN[3], $_CONF['layout_url'] . '/images/icons/menubuilder.png');
    $data_arr = array();
    $text_arr = array();
    $options = array();
    $header_arr = array(array('text' => $LANG_MB01['menu_element'], 'field' => 'label'), array('text' => $LANG_MB01['info'], 'field' => 'info', 'align' => 'center'), array('text' => $LANG_MB01['enabled'], 'field' => 'enabled', 'align' => 'center'), array('text' => $LANG_MB01['edit'], 'field' => 'edit', 'align' => 'center'), array('text' => $LANG_MB01['delete'], 'field' => 'delete', 'align' => 'center'), array('text' => $LANG_MB01['order'], 'field' => 'order', 'align' => 'center'));
    $text_arr = array('has_menu' => false, 'title' => '', 'help_url' => '', 'no_data' => $LANG_MB01['no_elements'], 'form_url' => "{$_CONF['site_admin_url']}/menu.php");
    $form_arr['bottom'] = '<input type="hidden" id="menu" name="menu" value="' . $menu_id . '"/>' . LB . '<input type="hidden" name="mode" value="activate"/>' . LB . '<script type="text/javascript">' . LB . '    document.getElementById(\'menubuilder\').style.display=\'\'' . LB . '</script>';
    $data_arr = $menu->editTree();
    $retval .= ADMIN_simpleList("_mb_getListField_menu", $header_arr, $text_arr, $data_arr, $options, $form_arr);
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    $outputHandle = outputHandler::getInstance();
    $outputHandle->addLinkScript($_CONF['site_url'] . '/javascript/admin.js', HEADER_PRIO_NORMAL, 'text/javascript');
    return $retval;
}
示例#3
0
function MG_index()
{
    global $_USER, $_MG_CONF, $_CONF, $_TABLES, $MG_albums, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $themeStyle;
    $display = '';
    $media_size = false;
    $page = 0;
    if (isset($_GET['page'])) {
        $page = COM_applyFilter($_GET['page'], true);
    }
    if ($page != 0) {
        $page = $page - 1;
    }
    $themeStyle = MG_getThemeCSS(0);
    if (!isset($_MG_CONF['album_display_columns']) || $_MG_CONF['album_display_columns'] < 1) {
        $_MG_CONF['album_display_columns'] = 1;
    }
    switch ($_MG_CONF['album_display_columns']) {
        case 1:
            $albumListTemplate = 'gallery_page_body_1.thtml';
            $albumColumnWidth = "100%";
            break;
        case 2:
            $albumListTemplate = 'gallery_page_body_2.thtml';
            $albumColumnWidth = "50%";
            break;
        default:
            $albumListTemplate = 'gallery_page_body_3.thtml';
            $albumColumnWidth = @intval(100 / $_MG_CONF['album_display_columns']) . '%';
            if ($albumColumnWidth == 0) {
                $albumColumnWidth = "25%";
            }
            break;
    }
    $T = new Template(MG_getTemplatePath(0));
    $T->set_file(array('page' => 'gallery_page.thtml', 'body' => $albumListTemplate, 'noitems' => 'gallery_page_noitems.thtml'));
    $T->set_var(array('lang_menulabel' => $_MG_CONF['menulabel'], 'lang_search' => $LANG_MG01['search'], 'site_url' => $_MG_CONF['site_url']));
    if ($_MG_CONF['rss_full_enabled']) {
        $feedUrl = MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss');
        $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">';
        $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" alt="" style="border:none;"/></a>';
        $T->set_var('rsslink', $rsslink);
        $T->set_var('rsslink_url', $feedUrl);
    } else {
        $T->set_var('rsslink', '');
    }
    $nFrame = new mgFrame();
    $nFrame->constructor($_MG_CONF['indexskin']);
    $MG_albums[0]->albumFrameTemplate = $nFrame->getTemplate();
    $MG_albums[0]->afrWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR'];
    $MG_albums[0]->afrHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB'];
    // Let's build our admin menu options
    $showAdminBox = 0;
    $admin_box_item = '';
    $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0;">' . LB;
    $admin_box .= '<div>';
    $admin_box .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB;
    $admin_box_item .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>' . LB;
    if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) {
        $admin_box_item .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>' . LB;
        $showAdminBox = 1;
    }
    if ($MG_albums[0]->owner_id) {
        $admin_box_item .= '<option value="albumsort">' . $LANG_MG01['sort_albums'] . '</option>' . LB;
        $admin_box_item .= '<option value="globalattr">' . $LANG_MG01['globalattr'] . '</option>' . LB;
        $admin_box_item .= '<option value="globalperm">' . $LANG_MG01['globalperm'] . '</option>' . LB;
        $queue_count = DB_count($_TABLES['mg_media_album_queue']);
        $admin_box_item .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>' . LB;
        $admin_box_item .= '<option value="wmmanage">' . $LANG_MG01['wm_management'] . '</option>' . LB;
        $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    } elseif ($MG_albums[0]->access == 3) {
        $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) {
        $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    }
    $admin_box .= $admin_box_item;
    $admin_box .= '</select>' . LB;
    $admin_box .= '<input type="hidden" name="album_id" value="0"/>' . LB;
    $admin_box .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '"/>' . LB;
    $admin_box .= '</div>';
    $admin_box .= '</form>';
    // build ul
    $admin_menu = '';
    $showAdminMenu = 0;
    $admin_url = $_MG_CONF['site_url'] . '/admin.php?album_id=0';
    if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) {
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=upload">' . $LANG_MG01['add_media'] . '</a></li>';
        $showAdminMenu = 1;
    }
    if ($MG_albums[0]->owner_id) {
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=albumsort">' . $LANG_MG01['sort_albums'] . '</a></li>';
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=globalattr">' . $LANG_MG01['globalattr'] . '</a></li>' . LB;
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=globalperm">' . $LANG_MG01['globalperm'] . '</a></li>' . LB;
        $queue_count = DB_count($_TABLES['mg_media_album_queue']);
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</a></li>' . LB;
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=wmmanage">' . $LANG_MG01['wm_management'] . '</a></li>' . LB;
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB;
        $showAdminMenu = 1;
    } elseif ($MG_albums[0]->access == 3) {
        $admin_Menu .= '<li><a href="' . $abmin_url . '&amp;mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB;
        $showAdminMenu = 1;
    } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) {
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB;
        $showAdminMenu = 1;
    }
    // end of ul
    if ($showAdminBox == 0) {
        $admin_box = '';
        $admin_box_item = '';
    }
    if ($showAdminMenu == 1) {
        $T->set_var('admin_menu', $admin_menu);
    }
    $T->set_var('select_adminbox', $admin_box);
    $T->set_var('select_box_items', $admin_box_item);
    $album_count = 0;
    $width = intval(100 / $_MG_CONF['album_display_columns']);
    $rowcounter = 0;
    $albumCount = 0;
    $indexCounter = 0;
    if (COM_isAnonUser()) {
        $lastlogin = time();
    } else {
        if (!COM_isAnonUser()) {
            $lastlogin = $_USER['lastlogin'];
        } else {
            $lastlogin = time();
        }
    }
    $children = $MG_albums[0]->getChildren();
    $nrows = count($children);
    $checkCounter = 0;
    $aCount = 0;
    $achild = array();
    for ($i = 0; $i < $nrows; $i++) {
        $access = $MG_albums[$children[$i]]->access;
        if ($access == 0 || $MG_albums[$children[$i]]->hidden == 1 && $access != 3) {
            // no op
        } else {
            $achild[] = $MG_albums[$children[$i]]->id;
            $aCount++;
        }
    }
    if ($_MG_CONF['album_display_rows'] < 1) {
        $_MG_CONF['album_display_rows'] = 9;
    }
    $items_per_page = $_MG_CONF['album_display_columns'] * $_MG_CONF['album_display_rows'];
    $begin = $items_per_page * $page;
    $end = $items_per_page;
    $nrows = count($achild);
    $indexCounter = $begin;
    $noParse = 0;
    $needFinalParse = 0;
    if ($nrows > 0) {
        $k = 0;
        $T->set_block('body', 'AlbumColumn', 'AColumn');
        $T->set_block('body', 'AlbumRow', 'ARow');
        for ($i = $begin; $i < $begin + $items_per_page; $i += $_MG_CONF['album_display_columns']) {
            for ($j = $i; $j < $i + $_MG_CONF['album_display_columns']; $j++) {
                $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                if ($j >= $nrows) {
                    $k = $i + $_MG_CONF['album_display_columns'] - $j;
                    $m = $k % $_MG_CONF['album_display_columns'];
                    for ($z = $m; $z > 0; $z--) {
                        $needFinalParse = 1;
                    }
                    if ($needFinalParse == 1) {
                        $T->parse('ARow', 'AlbumRow', true);
                        $T->set_var('AColumn', '');
                    }
                    $noParse = 1;
                    break;
                }
                $access = $MG_albums[$achild[$indexCounter]]->access;
                if ($access == 0 || $MG_albums[$achild[$indexCounter]]->hidden == 1 && $access != 3) {
                    $j--;
                    $indexCounter++;
                    continue;
                }
                $albumCount++;
                if ($MG_albums[$achild[$indexCounter]]->media_count > 0) {
                    if ($MG_albums[$achild[$indexCounter]]->cover_filename != '' && $MG_albums[$achild[$indexCounter]]->cover_filename != '0') {
                        $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update);
                        if (substr($MG_albums[$achild[$indexCounter]]->cover_filename, 0, 3) == 'tn_') {
                            $offset = 3;
                        } else {
                            $offset = 0;
                        }
                        foreach ($_MG_CONF['validExtensions'] as $ext) {
                            if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext)) {
                                $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext;
                                $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext);
                                break;
                            }
                        }
                        $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count;
                        if (!COM_isAnonUser()) {
                            if ($MG_albums[$achild[$indexCounter]]->last_update > $lastlogin) {
                                $album_last_update[0] = '<font color="red">' . $album_last_update[0] . '</font>';
                            }
                        }
                        $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt']));
                    } else {
                        $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count;
                        $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update);
                        $filename = $MG_albums[$achild[$indexCounter]]->findCover();
                        if ($filename == '') {
                            $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                            $media_size = array(200, 200);
                        } else {
                            if (substr($filename, 0, 3) == 'tn_') {
                                $offset = 3;
                            } else {
                                $offset = 0;
                            }
                            foreach ($_MG_CONF['validExtensions'] as $ext) {
                                if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext)) {
                                    $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[$offset] . '/' . $filename . $ext;
                                    $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext);
                                    break;
                                }
                            }
                        }
                        $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt']));
                    }
                } else {
                    // nothing in the album yet...
                    // here we need to search the sub-albums if any and see if we can find a picture....
                    $album_media_count = 0;
                    $album_last_update[0] = "";
                    $filename = $MG_albums[$achild[$indexCounter]]->findCover();
                    if ($filename == '') {
                        $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                        $media_size = array(200, 200);
                    } else {
                        foreach ($_MG_CONF['validExtensions'] as $ext) {
                            if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext)) {
                                $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[0] . '/' . $filename . $ext;
                                $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext);
                                break;
                            }
                        }
                    }
                    $T->set_var('updated_prompt', '');
                }
                $T->clear_var(array('lang_views', 'views'));
                if ($MG_albums[$achild[$indexCounter]]->enable_album_views) {
                    $T->set_var(array('lang_views' => $LANG_MG03['views'], 'views' => $MG_albums[$achild[$indexCounter]]->views));
                }
                if ($MG_albums[$achild[$indexCounter]]->tn_attached == 1) {
                    $media_size = false;
                    foreach ($_MG_CONF['validExtensions'] as $ext) {
                        if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext)) {
                            $album_last_image = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext;
                            $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext);
                            break;
                        }
                    }
                }
                // a little fail safe here to make sure we don't show empty boxes...
                if ($media_size === false || $media_size[0] == 0 || $media_size[1] == 0) {
                    $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                    $media_size = array(200, 200);
                }
                // set the image size here...
                switch ($_MG_CONF['gallery_tn_size']) {
                    case '0':
                        //small
                        $tn_height = 100;
                        $tn_width = 100;
                        break;
                    case '1':
                        //medium
                        $tn_height = 150;
                        $tn_width = 150;
                        break;
                    case '2':
                        $tn_height = 200;
                        $tn_width = 200;
                        break;
                    case '3':
                        $tn_height = $_MG_CONF['gallery_tn_height'];
                        $tn_width = $_MG_CONF['gallery_tn_width'];
                        break;
                    default:
                        $tn_height = 200;
                        $tn_width = 200;
                        break;
                }
                if ($media_size[0] > $media_size[1]) {
                    $ratio = $media_size[0] / $tn_height;
                    $newwidth = $tn_height;
                    $newheight = @round($media_size[1] / $ratio);
                } else {
                    $ratio = $media_size[1] / $tn_height;
                    $newheight = $tn_height;
                    $newwidth = @round($media_size[0] / $ratio);
                }
                // pull the sub-album info here
                $subAlbumDisplay = '';
                if (isset($_MG_CONF['subalbum_select']) && $_MG_CONF['subalbum_select'] == 1) {
                    $subAlbumDisplay = '<form name="subalbums' . $MG_albums[$achild[$indexCounter]]->id . '" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0">';
                    $subAlbumDisplay .= '<select name="aid" onchange="forms[\'subalbums' . $MG_albums[$achild[$indexCounter]]->id . '\'].submit()">';
                    $subAlbumDisplay .= '<optgroup label="' . $LANG_MG01['select_subalbum'] . '">' . LB;
                }
                $saRows = 0;
                $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist'));
                if (!empty($MG_albums[$achild[$indexCounter]]->children)) {
                    $SAchildren = $MG_albums[$achild[$indexCounter]]->getChildren();
                    foreach ($SAchildren as $SAchild) {
                        if ($MG_albums[$SAchild]->access > 0) {
                            if ($MG_albums[$SAchild]->hidden) {
                                if ($MG_albums[$SAchild]->access == 3) {
                                    $mediaCount = $MG_albums[$SAchild]->getMediaCount();
                                    if ($_MG_CONF['subalbum_select'] == 1) {
                                        if (strlen($MG_albums[$SAchild]->title) > 50) {
                                            $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...';
                                        } else {
                                            $aTitle = $MG_albums[$SAchild]->title;
                                        }
                                        $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>';
                                    } else {
                                        $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&amp;page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>';
                                    }
                                    $saRows++;
                                }
                            } else {
                                $mediaCount = $MG_albums[$SAchild]->getMediaCount();
                                if ($_MG_CONF['subalbum_select'] == 1) {
                                    if (strlen($MG_albums[$SAchild]->title) > 50) {
                                        $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...';
                                    } else {
                                        $aTitle = $MG_albums[$SAchild]->title;
                                    }
                                    $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>';
                                } else {
                                    $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&amp;page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>';
                                }
                                $saRows++;
                            }
                        }
                    }
                    if ($_MG_CONF['subalbum_select'] == 1) {
                        $subAlbumDisplay .= '</optgroup></select>';
                        $subAlbumDisplay .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '" />';
                        $subAlbumDisplay .= '<input type="hidden" name="page" value="1"/>';
                        $subAlbumDisplay .= '</form>';
                    }
                    if ($_MG_CONF['album_display_columns'] > 1 && $_MG_CONF['subalbum_select'] != 1) {
                        $T->set_var(array('subalbumlist' => '<span style="font-weight:bold;">' . $LANG_MG01['subalbums'] . '</span> (' . $saRows . ')'));
                    } else {
                        $T->set_var(array('lang_subalbums' => $LANG_MG01['subalbums'], 'subalbumcount' => '(' . $saRows . ')', 'subalbumlist' => $subAlbumDisplay));
                    }
                }
                if ($saRows == 0) {
                    $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist'));
                }
                $T->clear_var(array('saulstart', 'saulend'));
                if ($saRows > 0 && $_MG_CONF['subalbum_select'] != 1) {
                    $T->set_var(array('saulstart' => '<ul>', 'saulend' => '</ul>'));
                }
                // now pull the total image count for all sub albums...
                $total_images_subalbums = $MG_albums[$achild[$indexCounter]]->getMediaCount();
                $owner_id = $MG_albums[$achild[$indexCounter]]->owner_id;
                if ($owner_id == '' || !isset($MG_albums[$achild[$indexCounter]]->owner_id)) {
                    $owner_id = 0;
                }
                $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($owner_id));
                $F = new Template($_MG_CONF['template_path']);
                $F->set_var('media_frame', $MG_albums[0]->albumFrameTemplate);
                $F->set_var(array('border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&amp;page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&amp;page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight));
                $F->parse('media', 'media_frame');
                $media_item_thumbnail = $F->finish($F->get_var('media'));
                $T->set_var(array('media_item_thumbnail' => $media_item_thumbnail, 'class' => $rowcounter % 2, 'table_column_width' => 'width="' . $width . '%"', 'album_id' => $MG_albums[$achild[$indexCounter]]->id, 'album_title' => PLG_replaceTags($MG_albums[$achild[$indexCounter]]->title, 'mediagallery', 'album_title'), 'album_desc' => $MG_albums[$achild[$indexCounter]]->description == '' ? '' : PLG_replaceTags($MG_albums[$achild[$indexCounter]]->description, 'mediagallery', 'album_description'), 'album_media_count' => $album_media_count, 'subalbum_media_count' => $total_images_subalbums, 'album_owner' => $ownername, 'album_last_update' => $album_last_update[0], 'column_width' => $albumColumnWidth, 'column_width2' => $tn_height + 35 . 'px', 'lang_album' => $LANG_MG00['album'], 'border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&amp;page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&amp;page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight));
                $T->parse('AColumn', 'AlbumColumn', true);
                $indexCounter++;
            }
            if ($noParse == 1) {
                break;
            } else {
                $T->parse('ARow', 'AlbumRow', true);
                $T->set_var('AColumn', '');
            }
        }
    }
    $T->set_var(array('bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php', $page + 1, ceil($aCount / $items_per_page)), 'table_columns' => $_MG_CONF['album_display_columns']));
    if ($albumCount == 0) {
        $T->set_var(array('noitems' => $LANG_MG03['no_album_objects']));
        $T->parse('gallery_noitems', 'noitems');
    } else {
        $T->parse('gallery_body', 'body');
    }
    $T->parse('output', 'page');
    $nCSS = $nFrame->getCSS();
    if ($nCSS != '') {
        $outputHandle = outputHandler::getInstance();
        $outputHandle->addStyle($nCSS);
    }
    $display .= MG_siteHeader($LANG_MG00['plugin']);
    $display .= $T->finish($T->get_var('output'));
    $display .= MG_siteFooter();
    echo $display;
    exit;
}
示例#4
0
function MG_indexAll()
{
    global $_USER, $_MG_CONF, $_CONF, $_TABLES, $MG_albums, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $themeStyle, $ImageSkin, $sortOrder, $displayColumns, $displayRows, $tnSize, $level, $album_jumpbox;
    $album_id = 0;
    if (isset($_GET['aid'])) {
        $album_id = (int) COM_applyFilter($_GET['aid'], true);
    }
    $page = 0;
    if (isset($_GET['page'])) {
        $page = (int) COM_applyFilter($_GET['page'], true);
    }
    if ($page != 0) {
        $page = $page - 1;
    }
    $lbSlideShow = '';
    $errorMessage = '';
    $columns_per_page = $displayColumns;
    $rows_per_page = $displayRows;
    $media_per_page = $columns_per_page * $rows_per_page;
    // image frame setup
    $nFrame = new mgFrame();
    $nFrame->constructor($ImageSkin);
    $imageFrameTemplate = $nFrame->getTemplate();
    $frWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR'];
    $frHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB'];
    $fCSS = $nFrame->getCSS();
    // Let's build our admin menu options
    $showAdminBox = 0;
    $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0;">' . LB;
    $admin_box .= '<div>';
    $admin_box .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB;
    $admin_box .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>' . LB;
    if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && (isset($_USER['uid']) && $_USER['uid'] > 1)) {
        $admin_box .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>' . LB;
        $showAdminBox = 1;
    }
    if ($MG_albums[0]->owner_id) {
        $admin_box .= '<option value="albumsort">' . $LANG_MG01['sort_albums'] . '</option>' . LB;
        $admin_box .= '<option value="globalattr">' . $LANG_MG01['globalattr'] . '</option>' . LB;
        $admin_box .= '<option value="globalperm">' . $LANG_MG01['globalperm'] . '</option>' . LB;
        $queue_count = DB_count($_TABLES['mg_media_album_queue']);
        $admin_box .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>' . LB;
        $admin_box .= '<option value="wmmanage">' . $LANG_MG01['wm_management'] . '</option>' . LB;
        $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    } elseif ($MG_albums[0]->access == 3) {
        $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    } elseif ($_MG_CONF['member_albums'] == 1 && (isset($_USER['uid']) && $_USER['uid'] > 1) && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) {
        $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    }
    $admin_box .= '</select>' . LB;
    $admin_box .= '<input type="hidden" name="album_id" value="0"/>' . LB;
    $admin_box .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '"/>' . LB;
    $admin_box .= '</div>';
    $admin_box .= '</form>';
    if ($showAdminBox == 0) {
        $admin_box = '';
    }
    // construct the album jumpbox...
    $level = 0;
    $album_jumpbox = '<form name="jumpbox" id="jumpbox" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0"><div>';
    $album_jumpbox .= $LANG_MG03['jump_to'] . ':&nbsp;<select name="aid" onchange="forms[\'jumpbox\'].submit()">';
    $MG_albums[0]->buildJumpBox(0);
    $album_jumpbox .= '</select>';
    $album_jumpbox .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '"/>';
    $album_jumpbox .= '<input type="hidden" name="page" value="1"/>';
    $album_jumpbox .= '</div></form>';
    // initialize our variables
    $total_media = 0;
    $arrayCounter = 0;
    $total_object_count = 0;
    $mediaObject = array();
    $begin = $media_per_page * $page;
    $end = $media_per_page;
    $MG_media = array();
    // loop thru all the albums and build a list of valid albums that the user can see
    $first = 0;
    $albumList = getAlbumList($album_id, $first);
    $orderBy = ' ORDER BY m.media_upload_time ' . $sortOrder;
    if ($albumList != '') {
        $sql = "SELECT COUNT(*) AS total FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id IN (" . $albumList . ") " . $orderBy;
        $result = DB_query($sql);
        $row = DB_fetchArray($result);
        $cCount = $row['total'];
    } else {
        $cCount = 0;
    }
    if ($albumList != '') {
        $sql = "SELECT * FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id IN (" . $albumList . ") " . $orderBy;
        $sql .= ' LIMIT ' . $begin . ',' . $end;
        $result = DB_query($sql);
        $nRows = DB_numRows($result);
    } else {
        $nRows = 0;
    }
    $mediaRows = 0;
    $lbss_count = 0;
    $posCount = 0;
    if ($nRows > 0) {
        while ($row = DB_fetchArray($result)) {
            $media = new MediaItem();
            $media->constructor($row, $row['album_id']);
            $MG_media[$arrayCounter] = $media;
            $MG_albums[$row['album_id']]->imageFrameTemplate = $imageFrameTemplate;
            $arrayCounter++;
            $mediaRows++;
        }
    }
    $total_media = $total_media + $mediaRows;
    $total_items_in_album = $cCount;
    $total_pages = ceil($total_items_in_album / $media_per_page);
    if ($page >= $total_pages) {
        $page = $total_pages - 1;
    }
    $start = $page * $media_per_page;
    $current_print_page = floor($start / $media_per_page) + 1;
    $total_print_pages = ceil($total_items_in_album / $media_per_page);
    if ($current_print_page == 0) {
        $current_print_page = 1;
    }
    if ($total_print_pages == 0) {
        $total_print_pages = 1;
    }
    // now build the admin select...
    $admin_box = '';
    $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0">';
    $admin_box .= '<div><input type="hidden" name="album_id" value="' . $album_id . '"/>';
    $admin_box .= '<select name="mode" onchange="forms[\'adminbox\'].submit()">';
    $admin_box .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>';
    $admin_box .= '<option value="search">' . $LANG_MG01['search'] . '</option>';
    $uploadMenu = 0;
    $adminMenu = 0;
    if ($MG_albums[0]->owner_id) {
        $uploadMenu = 1;
        $adminMenu = 1;
    } else {
        if ($MG_albums[$album_id]->access == 3) {
            $uploadMenu = 1;
            $adminMenu = 1;
            if ($_MG_CONF['member_albums']) {
                if ($_MG_USERPREFS['active'] != 1) {
                    $uploadMenu = 0;
                    $adminMenu = 0;
                } else {
                    $uploadMenu = 1;
                    $adminMenu = 1;
                }
            }
        } else {
            if ($MG_albums[$album_id]->member_uploads == 1 && isset($_USER['uid']) && $_USER['uid'] >= 2) {
                $uploadMenu = 1;
                $adminMenu = 0;
            }
        }
    }
    if ($uploadMenu == 1) {
        $admin_box .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>';
    }
    if ($adminMenu == 1) {
        $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>';
    } elseif ($_MG_CONF['member_albums'] == 1 && !empty($_USER['username']) && $_MG_CONF['member_create_new'] == 1 && $_MG_USERPREFS['active'] == 1 && $album_id == $_MG_CONF['member_album_root']) {
        $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>';
        $adminMenu = 1;
    }
    // now check for moderation capabilities....
    if ($MG_albums[$album_id]->member_uploads == 1 && $MG_albums[$album_id]->moderate == 1) {
        // check to see if we are in the album_mod_group
        if (SEC_inGroup($MG_albums[$album_id]->mod_group_id) || $MG_albums[0]->owner_id) {
            $queue_count = DB_count($_TABLES['mg_media_album_queue'], 'album_id', $album_id);
            $admin_box .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>';
            $adminMenu = 1;
        }
    }
    $admin_box .= '</select>';
    $admin_box .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '" style="padding:0px;margin:0px;"/>';
    $admin_box .= '</div></form>';
    if ($uploadMenu == 0 && $adminMenu == 0) {
        $admin_box = '';
    }
    if ($MG_albums[$album_id]->enable_sort == 1) {
        $sort_box = '<form name="sortbox" id="sortbox" action="' . $_MG_CONF['site_url'] . '/album.php" method="get" style="margin:0;padding:0"><div>';
        $sort_box .= '<input type="hidden" name="aid" value="' . $album_id . '"/>';
        $sort_box .= '<input type="hidden" name="page" value="' . $page . '"/>';
        $sort_box .= $LANG_MG03['sort_by'] . '&nbsp;<select name="sort" onchange="forms[\'sortbox\'].submit()">';
        $sort_box .= '<option value="0" ' . ($sortOrder == 0 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_default'] . '</option>';
        $sort_box .= '<option value="1" ' . ($sortOrder == 1 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_default_asc'] . '</option>';
        $sort_box .= '<option value="2" ' . ($sortOrder == 2 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_upload'] . '</option>';
        $sort_box .= '<option value="3" ' . ($sortOrder == 3 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_upload_asc'] . '</option>';
        $sort_box .= '<option value="4" ' . ($sortOrder == 4 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_capture'] . '</option>';
        $sort_box .= '<option value="5" ' . ($sortOrder == 5 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_capture_asc'] . '</option>';
        $sort_box .= '<option value="6" ' . ($sortOrder == 6 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_rating'] . '</option>';
        $sort_box .= '<option value="7" ' . ($sortOrder == 7 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_rating_asc'] . '</option>';
        $sort_box .= '<option value="8" ' . ($sortOrder == 8 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_views'] . '</option>';
        $sort_box .= '<option value="9" ' . ($sortOrder == 9 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_views_asc'] . '</option>';
        $sort_box .= '<option value="10" ' . ($sortOrder == 10 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha'] . '</option>';
        $sort_box .= '<option value="11" ' . ($sortOrder == 11 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha_asc'] . '</option>';
        $sort_box .= '</select>';
        $sort_box .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '"/>';
        $sort_box .= '</div></form>';
    } else {
        $sort_box = '';
    }
    $owner_id = $MG_albums[$album_id]->owner_id;
    if ($owner_id == '' || !isset($MG_albums[$album_id]->owner_id)) {
        $owner_id = 0;
    }
    $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . (int) $owner_id);
    $album_last_update = MG_getUserDateTimeFormat($MG_albums[$album_id]->last_update);
    $T = new Template($_MG_CONF['template_path']);
    $T->set_file(array('page' => 'index-all.thtml'));
    //@TODO fix language tag
    $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'album_title' => "All Photos - Sorted by Post Date", 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php?aid=' . $album_id, $page + 1, ceil($total_items_in_album / $media_per_page)), 'bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php?aid=' . $album_id, $page + 1, ceil($total_items_in_album / $media_per_page)), 'page_number' => sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages), 'jumpbox' => $album_jumpbox, 'album_id' => $album_id, 'lbslideshow' => $lbSlideShow, 'album_description' => $MG_albums[$album_id]->display_album_desc ? PLG_replaceTags($MG_albums[$album_id]->description) : '', 'album_id_display' => $MG_albums[0]->owner_id || $_MG_CONF['enable_media_id'] == 1 ? $LANG_MG03['album_id_display'] . $album_id : '', 'select_adminbox' => $admin_box, 'select_sortbox' => $sort_box, 'album_last_update' => $album_last_update[0], 'album_owner' => $ownername, 'media_count' => $MG_albums[$album_id]->getMediaCount(), 'lang_search' => $LANG_MG01['search'], 'table_columns' => $displayColumns));
    $T->set_var('select_adminbox', $admin_box);
    if ($_MG_CONF['rss_full_enabled']) {
        $feedUrl = MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss');
        $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">';
        $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" alt="" style="border:none;"/></a>';
        $T->set_var('rsslink', $rsslink);
    } else {
        $T->set_var('rsslink', '');
    }
    // completed setting header / footer vars, parse them
    PLG_templateSetVars('mediagallery', $T);
    if ($total_media == 0) {
        $T->set_var(array('lang_no_image' => $LANG_MG03['no_media_objects']));
    }
    //
    // main processing of the album contents.
    //
    $noParse = 0;
    $needFinalParse = 0;
    if ($total_media > 0) {
        $k = 0;
        $T->set_block('page', 'ImageColumn', 'IColumn');
        $T->set_block('page', 'ImageRow', 'IRow');
        for ($i = 0; $i < $media_per_page; $i += $columns_per_page) {
            for ($j = $i; $j < $i + $columns_per_page; $j++) {
                if ($j >= $total_media) {
                    $k = $i + $columns_per_page - $j;
                    $m = $k % $columns_per_page;
                    for ($z = $m; $z > 0; $z--) {
                        $T->set_var(array('CELL_DISPLAY_IMAGE' => ''));
                        $T->parse('IColumn', 'ImageColumn', true);
                        $needFinalParse = 1;
                    }
                    if ($needFinalParse == 1) {
                        $T->parse('IRow', 'ImageRow', true);
                        $T->set_var('IColumn', '');
                    }
                    $noParse = 1;
                    break;
                }
                $previous_image = $i - 1;
                if ($previous_image < 0) {
                    $previous_image = -1;
                }
                $next_image = $i + 1;
                if ($next_image >= $total_media - 1) {
                    $next_image = -1;
                }
                $z = $j + $start;
                $celldisplay = $MG_media[$j]->displayThumb($z, 0, $imageFrameTemplate);
                if ($MG_media[$j]->type == 1) {
                    $PhotoURL = $_MG_CONF['mediaobjects_url'] . '/disp/' . $MG_media[$j]->filename[0] . '/' . $MG_media[$j]->filename . '.jpg';
                    $T->set_var(array('URL' => $PhotoURL));
                }
                $T->set_var(array('CELL_DISPLAY_IMAGE' => $celldisplay));
                $T->parse('IColumn', 'ImageColumn', true);
            }
            if ($noParse == 1) {
                break;
            }
            $T->parse('IRow', 'ImageRow', true);
            $T->set_var('IColumn', '');
        }
    }
    $T->parse('output', 'page');
    $fCSS = $nFrame->getCSS();
    if ($fCSS != '') {
        $outputHandle = outputHandler::getInstance();
        $outputHandle->addStyle($fCSS);
    }
    $display = MG_siteHeader(strip_tags($MG_albums[$album_id]->title));
    $display .= $T->finish($T->get_var('output'));
    $display .= MG_siteFooter();
    echo $display;
}
示例#5
0
function PAGE_list()
{
    global $_CONF, $_TABLES, $_IMAGE_TYPE, $LANG_ADMIN, $LANG_ACCESS, $LANG_STATIC;
    USES_lib_admin();
    $retval = '';
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/plugins/staticpages/index.php?edit=x', 'text' => $LANG_ADMIN['create_new']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $retval .= COM_startBlock($LANG_STATIC['staticpagelist'], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= ADMIN_createMenu($menu_arr, $LANG_STATIC['instructions'], plugin_geticon_staticpages());
    $header_arr = array(array('text' => $LANG_ADMIN['edit'], 'field' => 'edit', 'sort' => false, 'align' => 'center'), array('text' => $LANG_ADMIN['copy'], 'field' => 'copy', 'sort' => false, 'align' => 'center'), array('text' => $LANG_STATIC['id'], 'field' => 'sp_id', 'sort' => true), array('text' => $LANG_ADMIN['title'], 'field' => 'sp_title', 'sort' => true), array('text' => $LANG_STATIC['head_centerblock'], 'field' => 'sp_centerblock', 'sort' => true, 'align' => 'center'), array('text' => $LANG_STATIC['writtenby'], 'field' => 'sp_uid', 'sort' => true), array('text' => $LANG_ACCESS['access'], 'field' => 'access', 'sort' => false, 'align' => 'center'), array('text' => $LANG_STATIC['date'], 'field' => 'unixdate', 'sort' => true, 'align' => 'center'), array('text' => $LANG_ADMIN['delete'], 'field' => 'delete', 'sort' => false, 'align' => 'center'), array('text' => $LANG_ADMIN['enabled'], 'field' => 'sp_status', 'sort' => true, 'align' => 'center'));
    $defsort_arr = array('field' => 'sp_title', 'direction' => 'asc');
    $text_arr = array('has_extras' => true, 'form_url' => $_CONF['site_admin_url'] . '/plugins/staticpages/index.php');
    // sql query which drives the list
    $sql = "SELECT *,UNIX_TIMESTAMP(sp_date) AS unixdate " . "FROM {$_TABLES['staticpage']} WHERE 1=1 ";
    $query_arr = array('table' => 'staticpage', 'sql' => $sql, 'query_fields' => array('sp_title', 'sp_id'), 'default_filter' => COM_getPermSQL('AND'));
    // create the security token, and embed it in the list form
    // also set the hidden var which signifies that this list allows for pages
    // to be enabled/disabled via checkbox
    $token = SEC_createToken();
    $form_arr = array('top' => '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '"/>', 'bottom' => '<input type="hidden" name="staticpageenabler" value="true"/>');
    $retval .= ADMIN_list('static_pages', 'PAGE_getListField', $header_arr, $text_arr, $query_arr, $defsort_arr, '', $token, '', $form_arr);
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    $outputHandle = outputHandler::getInstance();
    $outputHandle->addLinkScript($_CONF['site_url'] . '/javascript/admin.js', HEADER_PRIO_NORMAL, 'text/javascript');
    return $retval;
}
示例#6
0
 function parse($p1, $p2 = '', $fulltag)
 {
     global $_CONF, $_MG_CONF, $_TABLES, $_USER, $LANG_MG03, $_PLUGINS, $MG_albums, $_DB_dbms, $mg_installed_version;
     $retval = '';
     $skip = 0;
     $itemsToDisplay = 15;
     if (!in_array('mediagallery', $_PLUGINS)) {
         return $retval;
     }
     // defaults:
     $itemsToDisplay = $p1;
     $uniqueID = md5($p1);
     if ($mg_installed_version != $_MG_CONF['pi_version']) {
         return $retval;
     }
     $truncate = 1;
     $caption = 0;
     $px = explode(' ', trim($p2));
     if (is_array($px)) {
         foreach ($px as $part) {
             if (substr($part, 0, 9) == 'truncate:') {
                 $a = explode(':', $part);
                 $truncate = (int) $a[1];
                 $skip++;
             } elseif (substr($part, 0, 8) == 'caption:') {
                 $a = explode(':', $part);
                 $caption = (int) $a[1];
                 $skip++;
             } else {
                 break;
             }
         }
     }
     if ($truncate == 1) {
         $truncate_word = 'true';
     } else {
         $truncate_word = 'false';
     }
     $outputHandle = outputHandler::getInstance();
     $outputHandle->addLinkScript($_CONF['site_url'] . '/mediagallery/js/jquery.flex-images.js');
     $outputHandle->addLinkStyle($_CONF['site_url'] . '/mediagallery/js/jquery.flex-images.css');
     $hash = CACHE_security_hash();
     $instance_id = 'whatsnew_newimages_' . $uniqueID . '_' . $hash . '_' . $_USER['theme'];
     if (($cache = CACHE_check_instance($instance_id, 0)) !== FALSE) {
         return $cache;
     }
     $imageArray = array();
     require_once $_CONF['path'] . 'plugins/mediagallery/include/init.php';
     MG_initAlbums();
     $sql = "SELECT ma.album_id,m.media_user_id,m.media_id,m.media_filename,m.media_title,\n                u.fullname FROM {$_TABLES['mg_albums']} as a\n                LEFT JOIN {$_TABLES['mg_media_albums']} as ma\n                on a.album_id=ma.album_id LEFT JOIN {$_TABLES['mg_media']} as m\n                on ma.media_id=m.media_id\n                LEFT JOIN {$_TABLES['users']} as u ON m.media_user_id=u.uid\n                WHERE\n                m.media_type=0 AND a.enable_random=1 AND a.hidden=0 " . COM_getPermSQL('and') . " ORDER BY m.media_upload_time DESC LIMIT " . (int) $itemsToDisplay;
     $result = DB_query($sql, 1);
     $nRows = DB_numRows($result);
     for ($x = 0; $x < $nRows; $x++) {
         $row = DB_fetchArray($result);
         $url_media = $_MG_CONF['site_url'] . '/media.php?s=' . $row['media_id'];
         $url_album = $_MG_CONF['site_url'] . '/album.php?aid=' . $row['album_id'] . '&amp;s=' . $row['media_id'] . '#' . $row['media_id'];
         $msize = false;
         foreach ($_MG_CONF['validExtensions'] as $ext) {
             if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) {
                 $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext;
                 $msize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext);
                 $media_url = $_MG_CONF['site_url'] . '/mediaobjects/' . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext;
                 break;
             }
         }
         if ($msize == false) {
             continue;
         }
         $imageArray[] = array('url' => $media_url, 'height' => $msize[1], 'width' => $msize[0], 'link' => $url_media, 'caption' => $row['media_title']);
     }
     $retval .= '<div class="flex-images uk-panel uk-panel-box">';
     foreach ($imageArray as $image) {
         $retval .= '<div class="item" data-w="' . $image['width'] . '" data-h="' . $image['height'] . '">';
         if ($caption) {
             $retval .= '<div class="over uk-hidden-small">' . $image['caption'] . '</div>';
         }
         $retval .= '<a href="' . $image['url'] . '"  data-uk-lightbox>';
         $retval .= '<img class="uk-thumbnail" src="' . $image['url'] . '">';
         $retval .= '</a>';
         $retval .= '</div>';
     }
     $retval .= '</div>';
     $retval .= '<script>$(\'.flex-images\').flexImages({rowHeight: 200, truncate:' . $truncate_word . '});</script>';
     CACHE_create_instance($instance_id, $retval, 0);
     return $retval;
 }
示例#7
0
}
$nrows = DB_numRows($result);
for ($i = 0; $i < $nrows; $i++) {
    $A = DB_fetchArray($result);
    if ($A['onleft'] == 1) {
        $_BLOCK_TEMPLATE[$A['name']] = 'blockheader-left.thtml,blockfooter-left.thtml';
    } else {
        $_BLOCK_TEMPLATE[$A['name']] = 'blockheader-right.thtml,blockfooter-right.thtml';
    }
}
$_BLOCK_TEMPLATE['_msg_block'] = 'blockheader-message.thtml,blockfooter-message.thtml';
$_BLOCK_TEMPLATE['_persistent_msg_block'] = 'blockheader-message.thtml,blockfooter-persistent-message.thtml';
$_BLOCK_TEMPLATE['whats_related_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';
$_BLOCK_TEMPLATE['story_options_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';
// Define the blocks that are a list of links styled as an unordered list - using class="blocklist"
$_BLOCK_TEMPLATE['admin_block'] = 'blockheader-list.thtml,blockfooter-list.thtml';
$_BLOCK_TEMPLATE['section_block'] = 'blockheader-list.thtml,blockfooter-list.thtml';
$_BLOCK_TEMPLATE['user_block'] = 'blockheader-list.thtml,blockfooter-list.thtml';
$_BLOCK_TEMPLATE['forum_menu'] = 'blockheader-left.thtml,blockfooter-left.thtml';
// define the JS we need for this theme..
$outputHandle = outputHandler::getInstance();
// must load the jquery ui library we want to use.
$outputHandle->addLinkStyle($_CONF['layout_url'] . '/css/ui-lightness/jquery-ui.min.css');
// check to see if we have a custom.css file to load
if (file_exists($_CONF['path_layout'] . 'custom.css')) {
    $outputHandle->addLinkStyle($_CONF['layout_url'] . '/custom.css');
}
function theme_getToolTipStyle()
{
    return 'tooltip';
}
示例#8
0
function WIDGET_tabslide($dataArray)
{
    global $_CONF, $_TABLES;
    $retval = '';
    $templateFile = 'tab-slider.thtml';
    $id = rand(1, 1000);
    // define the JS we need for this theme..
    $outputHandle = outputHandler::getInstance();
    // core js
    $outputHandle->addLinkScript($_CONF['site_url'] . '/javascript/addons/slider-tabs/jquery.sliderTabs.min.js');
    $outputHandle->addLinkStyle($_CONF['site_url'] . '/javascript/addons/slider-tabs/styles/jquery.sliderTabs.min.css');
    $page_ids = $dataArray['panels'];
    if (!is_array($page_ids[0])) {
        //we are in Static Pages Mode
        $sql = "SELECT sp_id, sp_content, sp_php, sp_title FROM {$_TABLES['staticpage']} WHERE sp_id in (" . implode(', ', array_map(create_function('$a', 'return "\'" . htmlspecialchars($a) . "\'";'), $page_ids)) . ')' . COM_getPermSQL('AND');
        $res = DB_query($sql);
        $pages = array();
        for ($i = 0; $A = DB_fetchArray($res); ++$i) {
            $content = SP_render_content($A['sp_content'], $A['sp_php']);
            $title = htmlspecialchars($A['sp_title']);
            $order = array_search($A['sp_id'], $page_ids);
            // find proper order
            $pages[$order] = array('sp_id' => $A['sp_id'], 'content' => $content, 'title' => $title, 'index' => $order + 1);
        }
    } else {
        //we have been passed pre-formatted pages
        $pages = array();
        for ($i = 0; $i < sizeof($page_ids); ++$i) {
            $content = $page_ids[$i]['content'];
            $title = htmlspecialchars($page_ids[$i]['title']);
            $order = $i;
            $pages[$order] = array('sp_id' => $title, 'content' => $content, 'title' => $title, 'index' => $order + 1);
        }
    }
    if (count($pages) == 0) {
        return '';
    }
    ksort($pages);
    $T = new Template($_CONF['path_layout'] . '/widgets');
    if (isset($dataArray['template'])) {
        $templateFile = $dataArray['template'];
    }
    $T->set_file('widget', $templateFile);
    $T->set_var('rand', $id);
    $T->set_block('widget', 'tabs', 't');
    foreach ($pages as $page) {
        extract($page);
        $T->set_var('sp_id', $sp_id);
        $T->set_var('title', stripslashes($title));
        $T->parse('t', 'tabs', true);
    }
    $T->set_block('widget', 'slide_content', 's');
    foreach ($pages as $page) {
        extract($page);
        $T->set_var('sp_id', $sp_id);
        $T->set_var('content', $content);
        $T->parse('s', 'slide_content', true);
    }
    $T->set_block('widget', 'optionvalues', 'o');
    foreach ($dataArray['options'] as $option => $value) {
        if (is_numeric($value)) {
            $T->set_var('optionline', $option . ": " . $value . ",");
        } else {
            $T->set_var('optionline', $option . ": " . "'" . $value . "',");
        }
        $T->parse('o', 'optionvalues', true);
    }
    $T->parse('output', 'widget');
    $retval = $T->finish($T->get_var('output'));
    return $retval;
}
示例#9
0
function forum_pagination($base_url, $curpage, $num_pages, $page_str = 'page=', $do_rewrite = false, $msg = '', $open_ended = '', $suffix = '')
{
    global $_CONF, $LANG05;
    $retval = '';
    $output = outputHandler::getInstance();
    if ($num_pages < 2) {
        return $retval;
    }
    $T = new Template($_CONF['path'] . 'plugins/forum/templates');
    $T->set_file('pagination', 'pagination.thtml');
    if (!$do_rewrite) {
        $hasargs = strstr($base_url, '?');
        if ($hasargs) {
            $sep = '&amp;';
        } else {
            $sep = '?';
        }
    } else {
        $sep = '/';
        $page_str = '';
    }
    if ($curpage > 1) {
        $T->set_var('first', true);
        $T->set_var('first_link', $base_url . $sep . $page_str . '1' . $suffix);
        $pg = $sep . $page_str . ($curpage - 1);
        $T->set_var('prev', true);
        $T->set_var('prev_link', $base_url . $pg . $suffix);
        $output->addLink('prev', urldecode($base_url . $pg . $suffix));
    } else {
        $T->unset_var('first');
        $T->unset_var('first_link');
        $T->unset_var('prev');
        $T->unset_var('prev_link');
    }
    $T->set_block('pagination', 'datarow', 'datavar');
    if ($curpage == 1) {
        $T->set_var('page_str', '1');
        $T->set_var('page_link', '#');
        $T->set_var('disabled', true);
        $T->set_var('active', true);
        $T->parse('datavar', 'datarow', true);
        $T->unset_var('active');
        $T->unset_var('disabled');
    } else {
        $T->set_var('page_str', '1');
        $pg = $sep . $page_str . 1;
        $T->set_var('page_link', $base_url . $pg . $suffix);
        $T->parse('datavar', 'datarow', true);
    }
    if ($num_pages > 5) {
        $start_cnt = min(max(1, $curpage - 4), $num_pages - 5);
        $end_cnt = max(min($num_pages, $curpage + 2), 6);
        if ($start_cnt > 1) {
            $T->set_var('page_str', '...');
            $T->set_var('page_link', '#');
            $T->set_var('disabled', true);
            $T->parse('datavar', 'datarow', true);
        }
        for ($i = $start_cnt + 1; $i < $end_cnt; $i++) {
            if ($i == $curpage) {
                $T->set_var('page_str', $i);
                $T->set_var('page_link', '#');
                $T->set_var('disabled', true);
                $T->set_var('active', true);
            } else {
                $T->set_var('page_str', $i);
                $pg = $sep . $page_str . $i;
                $T->set_var('page_link', $base_url . $pg . $suffix);
            }
            $T->parse('datavar', 'datarow', true);
            $T->unset_var('active');
            $T->unset_var('disabled');
        }
        if ($end_cnt < $num_pages) {
            $T->set_var('page_str', '...');
            $T->set_var('page_link', '#');
            $T->set_var('disabled', true);
            $T->parse('datavar', 'datarow', true);
        }
        if ($curpage == $num_pages) {
            $T->set_var('page_str', $num_pages);
            $T->set_var('page_link', '#');
            $T->set_var('active', true);
        } else {
            $T->set_var('page_str', $num_pages);
            $pg = $sep . $page_str . $num_pages;
            $T->set_var('page_link', $base_url . $pg . $suffix);
        }
        $T->parse('datavar', 'datarow', true);
    } else {
        for ($pgcount = $curpage - 10; $pgcount <= $curpage + 9 and $pgcount <= $num_pages; $pgcount++) {
            if ($pgcount <= 0) {
                $pgcount = 2;
            }
            if ($pgcount == $curpage) {
                $T->set_var('active', true);
                $T->set_var('page_str', $curpage);
            } else {
                $T->unset_var('active');
                $T->set_var('page_str', $pgcount);
                $pg = $sep . $page_str . $pgcount;
                $T->set_var('page_link', $base_url . $pg . $suffix);
            }
            $T->parse('datavar', 'datarow', true);
        }
    }
    if (!empty($open_ended)) {
        $T->set_var('open_ended', true);
    } else {
        if ($curpage == $num_pages) {
            $T->unset_var('open_ended');
            $T->unset_var('next');
            $T->unset_var('last');
            $T->unset_var('next_link');
            $T->unset_var('last_link');
        } else {
            $T->set_var('next', true);
            $T->set_var('next_link', $base_url . $sep . $page_str . ($curpage + 1) . $suffix);
            $T->set_var('last', true);
            $T->set_var('last_link', $base_url . $sep . $page_str . $num_pages . $suffix);
            $output->addLink('next', urldecode($base_url . $sep . $page_str . ($curpage + 1) . $suffix));
        }
    }
    if (!empty($msg)) {
        $T->set_var('msg', $msg);
    }
    $retval = $T->finish($T->parse('output', 'pagination'));
    return $retval;
}
示例#10
0
/**
* Display admin list of social follow me services
*
* Builds admin list of all available social follow me services
*
* @return   string              HTML to display
*
*/
function SI_FollowMelist()
{
    global $_CONF, $_TABLES, $LANG_ADMIN, $LANG_SOCIAL;
    USES_lib_admin();
    $outputHandle = outputHandler::getInstance();
    $outputHandle->addLinkScript($_CONF['site_url'] . '/javascript/admin.js', HEADER_PRIO_NORMAL, 'text/javascript');
    $retval = '';
    // if an social admin is using this page, offer navigation to the admin page(s)
    if (SEC_hasRights('social.admin')) {
        $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/social.php', 'text' => $LANG_SOCIAL['social_share']), array('url' => $_CONF['site_admin_url'] . '/social.php?list=s', 'text' => $LANG_SOCIAL['site_memberships']), array('url' => $_CONF['site_admin_url'] . '/index.php', 'text' => $LANG_ADMIN['admin_home']));
    } else {
        $menu_arr = array();
    }
    // display the header and instructions
    $retval .= COM_startBlock($LANG_SOCIAL['social_follow'], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= ADMIN_createMenu($menu_arr, $LANG_SOCIAL['follow_instructions'], $_CONF['layout_url'] . '/images/icons/share.png');
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    // default sort array and direction
    $defsort_arr = array('field' => 'display_name', 'direction' => 'asc');
    // render the list of share options
    $header_arr = array(array('text' => $LANG_SOCIAL['name'], 'field' => 'display_name', 'sort' => true), array('text' => $LANG_SOCIAL['enabled'], 'field' => 'enabled', 'sort' => true, 'align' => 'center'));
    $text_arr = array('form_url' => $_CONF['site_admin_url'] . '/social.php');
    $query_arr = array('table' => 'social_follow_services', 'sql' => "SELECT * FROM {$_TABLES['social_follow_services']} WHERE 1 = 1", 'query_fields' => array('ssid', 'service_name'), 'default_filter' => COM_getPermSql('AND'));
    $token = SEC_createToken();
    // sisenabler is a hidden field which if set, indicates that one of the
    // social share has been enabled or disabled - the value is the onleft var
    $form_arr = array('top' => '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '"/>', 'bottom' => '<input type="hidden" name="sfmenabler" value="1">');
    $retval .= ADMIN_list('social_follow_services', 'SI_getListField_FM', $header_arr, $text_arr, $query_arr, $defsort_arr, '', $token, '', $form_arr);
    return $retval;
}
示例#11
0
function _js_out()
{
    global $_CONF, $_SYSTEM, $_USER, $_PLUGINS, $themeAPI;
    $js = '';
    $file_content = '';
    $files = array();
    global $_CONF, $_SYSTEM, $_USER, $_PLUGINS;
    $outputHandle = outputHandler::getInstance();
    if (!isset($_CONF['js_cache_filename'])) {
        $_CONF['js_cache_filename'] = 'js.cache';
    }
    list($cacheFile, $cacheURL) = COM_getJSCacheLocation();
    // standard JS used by glFusion
    if (!isset($_SYSTEM['disable_jquery']) || $_SYSTEM['disable_jquery'] == false) {
        $files[] = $_CONF['path_html'] . 'javascript/jquery/jquery.min.js';
        $files[] = $_CONF['path_html'] . 'javascript/jquery/jquery-ui.min.js';
        $files[] = $_CONF['path_html'] . 'javascript/addons/jqrating.min.js';
        if (!isset($_SYSTEM['disable_jquery_tooltip']) || $_SYSTEM['disable_jquery_tooltip'] == false) {
            $files[] = $_CONF['path_html'] . 'javascript/addons/tooltipster/jquery.tooltipster.min.js';
            $files[] = $_CONF['path_html'] . 'javascript/addons/tooltipster/tooltip.min.js';
        }
        if (!isset($_SYSTEM['disable_jquery_menu']) || $_SYSTEM['disable_jquery_menu'] == false) {
            $files[] = $_CONF['path_html'] . 'javascript/addons/superfish/superfish.min.js';
            $files[] = $_CONF['path_html'] . 'javascript/addons/superfish/hoverIntent.min.js';
        }
        if (!isset($_SYSTEM['disable_jquery_slimbox']) || $_SYSTEM['disable_jquery_slimbox'] == false) {
            $files[] = $_CONF['path_html'] . 'javascript/addons/slimbox/slimbox2.min.js';
        }
        if (!isset($_SYSTEM['disable_jquery_validate']) || $_SYSTEM['disable_jquery_validate'] == false) {
            $files[] = $_CONF['path_html'] . 'javascript/addons/jquery-validate/jquery.validate.min.js';
            $files[] = $_CONF['path_html'] . 'javascript/addons/jquery-validate/additional-methods.min.js';
        }
        if (!isset($_SYSTEM['disable_jquery_slideshow']) || $_SYSTEM['disable_jquery_slideshow'] == false) {
            $files[] = $_CONF['path_html'] . 'javascript/addons/tcycle/jquery.tcycle.min.js';
        }
    }
    $files[] = $_CONF['path_html'] . 'javascript/common.min.js';
    // need to parse the outputhandler to see if there are any js scripts to load
    $headerscripts = $outputHandle->getScriptFiles();
    foreach ($headerscripts as $s) {
        $files[] = $s;
    }
    /*
     * Check to see if the theme has any JavaScript to include...
     */
    $function = 'theme_themeJS';
    if (function_exists($function)) {
        $jTheme = $function();
        if (is_array($jTheme)) {
            foreach ($jTheme as $item => $file) {
                $files[] = $file;
            }
        }
    }
    /*
     * Check to see if there are any custom javascript files to include
     */
    if (function_exists('CUSTOM_js')) {
        $jTheme = CUSTOM_js();
        if (is_array($jTheme)) {
            foreach ($jTheme as $item => $file) {
                $files[] = $file;
            }
        }
    }
    /*
     * Let the plugins add their JavaScript needs here...
     */
    if (is_array($_PLUGINS)) {
        foreach ($_PLUGINS as $pi_name) {
            if (function_exists('plugin_getheaderjs_' . $pi_name)) {
                $function = 'plugin_getheaderjs_' . $pi_name;
                $pHeader = array();
                $pHeader = $function();
                if (is_array($pHeader)) {
                    foreach ($pHeader as $item => $file) {
                        $files[] = $file;
                    }
                }
            }
        }
    }
    /*
     * Let the plugins add any global JS variables
     */
    if (is_array($_PLUGINS)) {
        foreach ($_PLUGINS as $pi_name) {
            if (function_exists('plugin_getglobaljs_' . $pi_name)) {
                $function = 'plugin_getglobaljs_' . $pi_name;
                $globalJS = array();
                $globalJS = $function();
                if (is_array($globalJS)) {
                    foreach ($globalJS as $name => $value) {
                        $pluginJSvars[$name] = $value;
                    }
                }
            }
        }
    }
    if (js_cacheok($cacheFile, $files)) {
        return $cacheURL;
    }
    // add some global variables
    $urlparts = parse_url($_CONF['site_url']);
    if (isset($urlparts['path'])) {
        $fileroot = $urlparts['path'];
    } else {
        $fileroot = '';
    }
    $js .= "var glfusionSiteUrl = '" . $_CONF['site_url'] . "';" . LB;
    $js .= "var glfusionFileRoot = '" . $fileroot . "';" . LB;
    $js .= "var glfusionLayoutUrl = '" . $_CONF['layout_url'] . "';" . LB;
    $js .= "var site_admin_url = '" . $_CONF['site_admin_url'] . "';" . LB;
    if (isset($_SYSTEM['use_direct_style_js']) && $_SYSTEM['use_direct_style_js']) {
        $js .= "var glfusionStyleCSS      = '" . $_CONF['site_url'] . '/' . $_CONF['css_cache_filename'] . $_USER['theme'] . '.css?t=' . $_USER['theme'] . "';" . LB;
    } else {
        $js .= "var glfusionStyleCSS      = '" . $_CONF['site_url'] . "/css.php?t=" . $_USER['theme'] . "';" . LB;
    }
    // send any global plugin JS vars
    if (isset($pluginJSvars) && is_array($pluginJSvars)) {
        foreach ($pluginJSvars as $name => $value) {
            $js .= "var " . $name . " = '" . $value . "';";
        }
    }
    if (is_array($files)) {
        foreach ($files as $file) {
            $file_content = @file_get_contents($file);
            if ($file_content === false) {
                COM_errorLog("ERROR: Unable to retrieve JS file: " . $file);
            } else {
                $js .= $file_content;
            }
            $js .= LB;
        }
    }
    $js .= LB;
    // https://bugzilla.mozilla.org/show_bug.cgi?id=316033
    $rc = writeFile_lck($cacheFile, '', $js, 'glfusion_js.lck');
    if ($rc === false) {
        writeFile_lck($cacheFile, '', $js, 'glfusion_js.lck');
    }
    return $cacheURL;
}
示例#12
0
/**
 * display the block administration list
 *
 */
function BLOCK_list()
{
    global $_CONF, $_TABLES, $LANG_ADMIN, $LANG21, $_IMAGE_TYPE, $blockInterface;
    USES_lib_admin();
    $retval = '';
    // writing the menu on top
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/block.php?edit=x', 'text' => $LANG_ADMIN['create_new']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $retval .= COM_startBlock($LANG21[19], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= ADMIN_createMenu($menu_arr, $LANG21[25], $_CONF['layout_url'] . '/images/icons/block.' . $_IMAGE_TYPE);
    BLOCK_reorder();
    // writing the list
    $header_arr = array(array('text' => $LANG_ADMIN['edit'], 'field' => 'edit', 'sort' => false, 'align' => 'center', 'width' => '5%'), array('text' => $LANG21[65], 'field' => 'blockorder', 'sort' => true, 'align' => 'center', 'width' => '8%'), array('text' => $LANG21[46], 'field' => 'move', 'sort' => false, 'align' => 'center', 'width' => '8%'), array('text' => $LANG_ADMIN['name'], 'field' => 'name', 'sort' => true, 'width' => '18%', 'align' => 'center'), array('text' => $LANG_ADMIN['title'], 'field' => 'title', 'sort' => true, 'width' => '18%', 'align' => 'center'), array('text' => $LANG_ADMIN['topic'], 'field' => 'tid', 'sort' => true, 'align' => 'center', 'width' => '18%'), array('text' => $LANG_ADMIN['type'], 'field' => 'type', 'sort' => true, 'align' => 'center', 'width' => '9%'), array('text' => $LANG_ADMIN['delete'], 'field' => 'delete', 'sort' => false, 'align' => 'center', 'width' => '7%'), array('text' => $LANG_ADMIN['enabled'], 'field' => 'is_enabled', 'sort' => true, 'align' => 'center', 'width' => '9%'));
    $defsort_arr = array('field' => 'blockorder', 'direction' => 'asc');
    if (isset($blockInterface['left']['title'])) {
        $label = $blockInterface['left']['title'];
    } else {
        $label = $LANG21[40];
    }
    $text_arr = array('title' => $label, 'form_url' => $_CONF['site_admin_url'] . '/block.php');
    $query_arr = array('table' => 'blocks', 'sql' => "SELECT * FROM {$_TABLES['blocks']} WHERE onleft = 1", 'query_fields' => array('title', 'content'), 'default_filter' => COM_getPermSql('AND'));
    // embed a CSRF token as a hidden var at the top of each of the lists
    // this is used to validate block enable/disable
    $token = SEC_createToken();
    // blockenabler is a hidden field which if set, indicates that one of the
    // blocks has been enabled or disabled - the value is the onleft var
    $form_arr = array('top' => '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '"/>', 'bottom' => '<input type="hidden" name="blockenabler" value="1">');
    $retval .= ADMIN_list('blocks', 'BLOCK_getListField', $header_arr, $text_arr, $query_arr, $defsort_arr, '', $token, '', $form_arr);
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    $query_arr = array('table' => 'blocks', 'sql' => "SELECT * FROM {$_TABLES['blocks']} WHERE onleft = 0", 'query_fields' => array('title', 'content'), 'default_filter' => COM_getPermSql('AND'));
    if (isset($blockInterface['right']['title'])) {
        $label = $blockInterface['right']['title'];
    } else {
        $label = $LANG21[41];
    }
    $text_arr = array('title' => $label, 'form_url' => $_CONF['site_admin_url'] . '/block.php');
    // blockenabler is a hidden field which if set, indicates that one of the
    // blocks has been enabled or disabled - the value is the onleft var
    $form_arr = array('top' => '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '"/>', 'bottom' => '<input type="hidden" name="blockenabler" value="0"/>');
    $retval .= ADMIN_list('blocks', 'BLOCK_getListField', $header_arr, $text_arr, $query_arr, $defsort_arr, '', $token, '', $form_arr);
    $outputHandle = outputHandler::getInstance();
    $outputHandle->addLinkScript($_CONF['site_url'] . '/javascript/admin.js', HEADER_PRIO_NORMAL, 'text/javascript');
    return $retval;
}
示例#13
0
function MG_displayMediaImage($mediaObject, $full, $sortOrder, $comments, $sortID = 0, $spage = 0)
{
    global $MG_albums, $_TABLES, $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_MG04, $LANG_ACCESS, $LANG01, $album_jumpbox, $glversion, $_USER, $_MG_USERPREFS;
    global $_DB_dbms, $LANG04, $ratedIds;
    $retval = '';
    $media_link_start = '';
    $media_link_end = '';
    $srcID = $mediaObject;
    $outputHandle = outputHandler::getInstance();
    $aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . DB_escapeString($mediaObject) . '"');
    if (isset($MG_albums[$aid]->pid)) {
        $pid = $MG_albums[$aid]->pid;
    } else {
        $pid = 0;
    }
    if (@method_exists($MG_albums[$aid], 'getOffset')) {
        $aOffset = $MG_albums[$aid]->getOffset();
    } else {
        $aOffset = -1;
    }
    if ($aOffset == -1 || $MG_albums[$aid]->access == 0) {
        $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true);
        return array($LANG_MG00['access_denied_msg'], $retval);
    }
    $mid = $mediaObject;
    $orderBy = MG_getSortOrder($aid, $sortOrder);
    $sql = "SELECT * FROM {$_TABLES['mg_media_albums']} as ma LEFT JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id=" . $aid . $orderBy;
    $result = DB_query($sql);
    $nRows = DB_numRows($result);
    $total_media = $nRows;
    $media = array();
    while ($row = DB_fetchArray($result)) {
        $media[] = $row;
        $ids[] = $row['media_id'];
    }
    $key = array_search($mid, $ids);
    if ($key === false) {
        $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true);
        return array($LANG_MG00['access_denited_msg'], $retval);
    }
    $mediaObject = $key;
    if ($MG_albums[$aid]->full == 2 || $_MG_CONF['discard_original'] == 1 || $MG_albums[$aid]->full == 1 && COM_isAnonUser()) {
        $full = 0;
    }
    if ($full) {
        $disp = 'orig';
    } else {
        $disp = 'disp';
    }
    if ($MG_albums[$aid]->enable_comments == 0) {
        $comments = 0;
    }
    if ($sortID > 0) {
        $MG_albums[$aid]->enable_slideshow = 0;
    }
    $themeCSS = '';
    $nFrame = new mgFrame();
    $nFrame->constructor($MG_albums[$aid]->display_skin);
    $MG_albums[$aid]->displayFrameTemplate = $nFrame->getTemplate();
    $MG_albums[$aid]->dfrWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR'];
    $MG_albums[$aid]->dfrHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB'];
    $themeCSS = $nFrame->getCSS();
    if ($themeCSS != '') {
        $outputHandle->addStyle($themeCSS);
        $themeCSS = '';
    }
    $T = new Template(MG_getTemplatePath($aid));
    switch ($media[$mediaObject]['media_type']) {
        case '0':
            // image
            $T->set_file('page', 'view_image.thtml');
            $ogType = 'article';
            break;
        case '1':
            // video
        // video
        case '5':
            // embedded video
            $meta_file_name = $_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . '.' . $media[$mediaObject]['media_mime_ext'];
            COM_errorLog("DEBUG: Video File: " . $meta_file_name);
            $meta = IMG_getMediaMetaData($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . '.' . $media[$mediaObject]['media_mime_ext']);
            COM_errorLog("DEBUG: Video Meta Type: " . $meta['mime_type']);
            if ($meta['mime_type'] == 'video/quicktime') {
                if ($meta['fileformat'] == 'mp4') {
                    $media[$mediaObject]['mime_type'] = 'video/mp4';
                }
            }
            $T->set_file('page', 'view_video.thtml');
            $ogType = 'video.movie';
            break;
        case '2':
            // audio
            $T->set_file('page', 'view_audio.thtml');
            $ogType = 'music.song';
            break;
        default:
            $T->set_file('page', 'view_image.thtml');
            $ogType = 'article';
            break;
    }
    $ptitle = isset($media[$mediaObject]['media_title']) && $media[$mediaObject]['media_title'] != ' ' ? PLG_replaceTags($media[$mediaObject]['media_title'], 'mediagallery', 'media_title') : '';
    $permalink = COM_buildUrl($_MG_CONF['site_url'] . '/media.php?s=' . $srcID);
    $outputHandle->addLink("canonical", $permalink);
    $outputHandle->addMeta('property', 'og:title', $ptitle);
    $outputHandle->addMeta('property', 'og:type', $ogType);
    $outputHandle->addMeta('property', 'og:url', $permalink);
    $T->set_var('permalink', $permalink);
    $T->set_file(array('shutterfly' => 'digibug.thtml'));
    $T->set_var('header', $LANG_MG00['plugin']);
    $T->set_var('site_url', $_MG_CONF['site_url']);
    $T->set_var('plugin', 'mediagallery');
    // construct the album jumpbox...
    $level = 0;
    $album_jumpbox = '<form name="jumpbox" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0"><div>';
    $album_jumpbox .= $LANG_MG03['jump_to'] . ':&nbsp;<select name="aid" onchange="forms[\'jumpbox\'].submit()">';
    $MG_albums[0]->buildJumpBox($aid);
    $album_jumpbox .= '</select>';
    $album_jumpbox .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '"/>';
    $album_jumpbox .= '<input type="hidden" name="page" value="1"/>';
    $album_jumpbox .= '</div></form>';
    // Update the views count... But only for non-admins
    if (!$MG_albums[0]->owner_id) {
        $media_views = $media[$mediaObject]['media_views'] + 1;
        DB_query("UPDATE " . $_TABLES['mg_media'] . " SET media_views=" . $media_views . " WHERE media_id='" . DB_escapeString($media[$mediaObject]['media_id']) . "'");
    }
    $columns_per_page = $MG_albums[$aid]->display_columns == 0 ? $_MG_CONF['ad_display_columns'] : $MG_albums[$aid]->display_columns;
    $rows_per_page = $MG_albums[$aid]->display_rows == 0 ? $_MG_CONF['ad_display_rows'] : $MG_albums[$aid]->display_rows;
    if (isset($_MG_USERPREFS['display_rows']) && $_MG_USERPREFS['display_rows'] > 0) {
        $rows_per_page = $_MG_USERPREFS['display_rows'];
    }
    if (isset($_MG_USERPREFS['display_columns']) && $_MG_USERPREFS['display_columns'] > 0) {
        $columns_per_page = $_MG_USERPREFS['display_columns'];
    }
    $media_per_page = $columns_per_page * $rows_per_page;
    if ($MG_albums[$aid]->albums_first) {
        $childCount = $MG_albums[$aid]->getChildCount();
        $page = intval(($mediaObject + $childCount) / $media_per_page) + 1;
    } else {
        $page = intval($mediaObject / $media_per_page) + 1;
    }
    /*
     * check to see if the original image exists, if not fall back to full image
     */
    $media_size_orig = @getimagesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . '.' . $media[$mediaObject]['media_mime_ext']);
    if ($media_size_orig == false) {
        $full = 0;
        $disp = 'disp';
    }
    $aPage = intval($aOffset / ($_MG_CONF['album_display_columns'] * $_MG_CONF['album_display_rows'])) + 1;
    if ($sortID > 0) {
        $birdseed = '<a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a> ' . ($_MG_CONF['gallery_only'] == 1 ? '' : $_MG_CONF['seperator'] . ' <a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a> ') . $_MG_CONF['seperator'] . '<a href="' . $_MG_CONF['site_url'] . '/search.php?id=' . $sortID . '&amp;page=' . $spage . '">' . $LANG_MG03['search_results'] . '</a>';
        $MG_albums[$aid]->getPath(1, $sortOrder, $page) . '</a>';
        $birdseed_ul = '<li><a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a></li>' . '<li><a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a></li>' . '<li><a href="' . $_MG_CONF['site_url'] . '/search.php?id=' . $sortID . '&amp;page=' . $spage . '">' . $LANG_MG03['search_results'] . '</a></li>' . $MG_albums[$aid]->getPath_ul(1, $sortOrder, $page) . '</a>';
        $album_link = '<a href="' . $_MG_CONF['site_url'] . '/search.php?id=' . $sortID . '&amp;page=' . $spage . '">';
    } else {
        $birdseed = '<a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a> ' . ($_MG_CONF['gallery_only'] == 1 ? '' : $_MG_CONF['seperator'] . ' <a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a> ') . $MG_albums[$aid]->getPath(1, $sortOrder, $page) . '</a>';
        $birdseed_ul = '<li><a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a></li>' . '<li><a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a></li>' . $MG_albums[$aid]->getPath_ul(1, $sortOrder, $page) . '</a>';
        $album_link = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $aid . '&amp;page=' . $page . '&amp;sort=' . $sortOrder . '">';
    }
    mg_usage('media_view', $MG_albums[$aid]->title, $media[$mediaObject]['media_title'], $media[$mediaObject]['media_id']);
    // hack for tga files...
    if ($media[$mediaObject]['mime_type'] == 'image/x-targa' || $media[$mediaObject]['mime_type'] == 'image/tga') {
        $full = 0;
        $disp = 'disp';
    }
    switch ($media[$mediaObject]['mime_type']) {
        case 'video/x-ms-asf':
        case 'video/x-ms-asf-plugin':
        case 'video/avi':
        case 'video/msvideo':
        case 'video/x-msvideo':
        case 'video/avs-video':
        case 'video/x-ms-wmv':
        case 'video/x-ms-wvx':
        case 'video/x-ms-wm':
        case 'application/x-troff-msvideo':
        case 'application/x-ms-wmz':
        case 'application/x-ms-wmd':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayASF($aid, $media[$mediaObject], $full);
            break;
        case 'audio/x-ms-wma':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMP3($aid, $media[$mediaObject], $full);
            break;
        case 'video/mp4':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMP4($aid, $media[$mediaObject], $full);
            break;
        case 'video/mpeg':
        case 'video/x-mpeg':
        case 'video/x-mpeq2a':
            if ($_MG_CONF['use_wmp_mpeg'] == 1) {
                list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayASF($aid, $media[$mediaObject], $full);
                break;
            }
        case 'video/x-motion-jpeg':
        case 'video/quicktime':
        case 'video/x-qtc':
        case 'video/x-m4v':
            if ($media[$mediaObject]['media_mime_ext'] == 'mp4' && isset($_MG_CONF['play_mp4_flv']) && $_MG_CONF['play_mp4_flv'] == true) {
                list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayFLV($aid, $media[$mediaObject], $full);
            } else {
                list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMOV($aid, $media[$mediaObject], $full);
            }
            break;
        case 'embed':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayEmbed($aid, $media[$mediaObject], $full, $mediaObject);
            break;
        case 'application/x-shockwave-flash':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displaySWF($aid, $media[$mediaObject], $full);
            break;
        case 'video/x-flv':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayFLV($aid, $media[$mediaObject], $full);
            break;
        case 'audio/mpeg':
        case 'audio/x-mpeg':
        case 'audio/mpeg3':
        case 'audio/x-mpeg-3':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMP3($aid, $media[$mediaObject], $full);
            break;
        case 'application/ogg':
        case 'application/x-ogg':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayOGG($aid, $media[$mediaObject], $full);
            break;
        case 'image/x-targa':
        case 'image/tga':
        case 'image/tiff':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayTGA($aid, $media[$mediaObject], $full, $mediaObject);
            break;
        case 'image/photoshop':
        case 'image/x-photoshop':
        case 'image/psd':
        case 'application/photoshop':
        case 'application/psd':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayPSD($aid, $media[$mediaObject], $full, $mediaObject);
            break;
        case 'image/gif':
        case 'image/jpeg':
        case 'image/jpg':
        case 'image/png':
        case 'image/bmp':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url, $media_link_start, $media_link_end) = MG_displayJPG($aid, $media[$mediaObject], $full, $media[$mediaObject]['media_id'], $sortOrder, $sortID, $spage);
            break;
        default:
            switch ($media[$mediaObject]['media_mime_ext']) {
                case 'jpg':
                case 'gif':
                case 'png':
                case 'bmp':
                    list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url, $media_link_start, $media_link_end) = MG_displayJPG($aid, $media[$mediaObject], $full, $media[$mediaObject]['media_id'], $sortOrder, $sortID, $spage);
                    break;
                case 'asf':
                    list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayASF($aid, $media[$mediaObject], $full);
                    break;
                default:
                    list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayGeneric($aid, $media[$mediaObject], $full, $media[$mediaObject]['media_id'], $sortOrder);
                    break;
            }
    }
    $mid = $media[$mediaObject]['media_id'];
    $media_date = MG_getUserDateTimeFormat($media[$mediaObject]['media_time']);
    $upload_date = MG_getUserDateTimeFormat($media[$mediaObject]['media_upload_time']);
    // build the rating bar if rating is enabled.
    if ($MG_albums[$aid]->enable_rating > 0) {
        $uid = COM_isAnonUser() ? 1 : $_USER['uid'];
        $static = false;
        $voted = 0;
        // check to see if we are the owner, if so, no rating for us...
        if (isset($_USER['uid']) && $_USER['uid'] == $media[$mediaObject]['media_user_id']) {
            $static = true;
            $voted = 0;
        } else {
            if (in_array($media[$mediaObject]['media_id'], $ratedIds)) {
                $static = true;
                $voted = 1;
            } else {
                $static = 0;
                $voted = 0;
            }
        }
        if ($MG_albums[$aid]->enable_rating == 1 && COM_isAnonUser()) {
            $static = true;
            $voted = 0;
        }
        $rating_box = RATING_ratingBar('mediagallery', $media[$mediaObject]['media_id'], $media[$mediaObject]['media_votes'], $media[$mediaObject]['media_rating'], $voted, 5, $static, '');
    } else {
        $rating_box = '';
    }
    $T->set_var('rating_box', $rating_box);
    if ($MG_albums[$aid]->allow_download) {
        $T->set_var(array('download' => '<a href="' . $_MG_CONF['site_url'] . '/download.php?mid=' . $media[$mediaObject]['media_id'] . '">' . $LANG_MG01['download'] . '</a>'));
    }
    if ($media[$mediaObject]['media_type'] == 0 && $MG_albums[$aid]->enable_shutterfly) {
        $media_size_orig = false;
        $media_size_tn = false;
        if ($_MG_CONF['discard_original'] == 1) {
            foreach ($_MG_CONF['validExtensions'] as $ext) {
                if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext)) {
                    $sf_picture = $_MG_CONF['mediaobjects_url'] . '/disp/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext;
                    $media_size_orig = @getimagesize($_MG_CONF['path_mediaobjects'] . 'disp/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext);
                    break;
                }
            }
        } else {
            foreach ($_MG_CONF['validExtensions'] as $ext) {
                if (file_exists($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext)) {
                    $sf_picture = $_MG_CONF['mediaobjects_url'] . '/orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext;
                    $media_size_orig = @getimagesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext);
                    break;
                }
            }
        }
        foreach ($_MG_CONF['validExtensions'] as $ext) {
            if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext)) {
                $tnImage = $_MG_CONF['mediaobjects_url'] . '/tn/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext;
                $media_size_tn = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext);
                break;
            }
        }
        $outputHandle->addMeta('property', 'og:image', $tnImage);
        if ($media_size_orig != false && $media_size_tn != false) {
            $T->set_var(array('sf_height' => $media_size_orig[1], 'sf_width' => $media_size_orig[0], 'sf_tn_height' => $media_size_tn[1], 'sf_tn_width' => $media_size_tn[0], 'sf_thumbnail' => $tnImage, 'sf_picture' => $sf_picture, 'sf_title' => $media[$mediaObject]['media_title'], 'lang_print_digibug' => $LANG_MG03['print_digibug'], 'lang_print_shutterfly' => $LANG_MG03['print_shutterfly']));
            $T->parse('shutterfly_submit', 'shutterfly');
        }
    }
    if ($MG_albums[$aid]->access == 3 || $_MG_CONF['allow_user_edit'] == true && isset($_USER['uid']) && $media[$mediaObject]['media_user_id'] == $_USER['uid']) {
        $edit_item = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&amp;s=1&amp;album_id=' . $aid . '&amp;mid=' . $mid . '">' . $LANG_MG01['edit'] . '</a>';
    } else {
        $edit_item = '';
    }
    $media_desc = PLG_replaceTags(nl2br($media[$mediaObject]['media_desc']), 'mediagallery', 'media_description');
    if (strlen($media_desc) > 0) {
        USES_lib_html2text();
        $metaDesc = $media_desc;
        $metaDesc = strip_tags($metaDesc);
        $html2txt = new html2text($metaDesc, false);
        $metaDesc = trim($html2txt->get_text());
        $shortComment = '';
        $metaArray = explode(' ', $metaDesc);
        $wordCount = count($metaArray);
        $lengthCount = 0;
        $tailString = '';
        foreach ($metaArray as $word) {
            $lengthCount = $lengthCount + strlen($word);
            $shortComment .= $word . ' ';
            if ($lengthCount >= 100) {
                $tailString = '...';
                break;
            }
        }
        $metaDesc = trim($shortComment) . $tailString;
        $outputHandle->addMeta('name', 'description', htmlspecialchars($metaDesc, ENT_QUOTES, COM_getEncodingt()));
        $media_desc .= '<br/><br/>';
    }
    // start of the lightbox slideshow code
    if ($MG_albums[$aid]->enable_slideshow == 2) {
        $lbSlideShow = '<noscript><div class="pluginAlert">' . $LANG04[150] . '</div></noscript>' . LB;
        $lbSlideShow .= '<script type="text/javascript">' . LB;
        $lbSlideShow .= 'function openGallery1() {' . LB;
        $lbSlideShow .= '    return loadXMLDoc("' . $_MG_CONF['site_url'] . '/lightbox.php?aid=' . $aid . '");';
        $lbSlideShow .= '}' . LB;
        $lbSlideShow .= '</script>' . LB;
        $T->set_var('lbslideshow', $lbSlideShow);
    } else {
        $T->set_var('lbslideshow', '');
    }
    // end of the lightbox slideshow code
    switch ($MG_albums[$aid]->enable_slideshow) {
        case 0:
            $url_slideshow = '';
            break;
        case 1:
            $url_slideshow = '<a href="' . $_MG_CONF['site_url'] . '/slideshow.php?aid=' . $aid . '&amp;sort=' . $sortOrder . '"><b>' . $LANG_MG03['slide_show'] . '</b></a>';
            break;
        case 2:
            $lbss_count = DB_count($_TABLES['mg_media'], 'media_type', 0);
            $sql = "SELECT COUNT(m.media_id) as lbss_count FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE m.media_type = 0 AND ma.album_id=" . $aid;
            $res = DB_query($sql);
            list($lbss_count) = DB_fetchArray($res);
            if ($lbss_count != 0) {
                $url_slideshow = '<span id="mgslideshow" class="jsenabled_show" style="display:none"><a href="#" onclick="return openGallery1()"><b>' . $LANG_MG03['slide_show'] . '</b></a></span>';
            } else {
                $MG_albums[$aid]->enable_slideshow = 0;
            }
            break;
        case 3:
            $url_slideshow = '<a href="' . $_MG_CONF['site_url'] . '/fslideshow.php?aid=' . $aid . '&amp;src=disp"><b>' . $LANG_MG03['slide_show'] . '</b></a>';
            break;
        case 4:
            $url_slideshow = '<a href="' . $_MG_CONF['site_url'] . '/fslideshow.php?aid=' . $aid . '&amp;src=orig"><b>' . $LANG_MG03['slide_show'] . '</b></a>';
            break;
    }
    $prevLink = '';
    $nextLink = '';
    list($prevLink, $nextLink) = $sortID > 0 ? array('', '') : MG_getNextandPrev($_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '1' : '0') . "&amp;sort=" . $sortOrder, $nRows, 1, $mediaObject, $media, TRUE);
    $T->set_var(array('birdseed' => $birdseed, 'birdseed_ul' => $birdseed_ul, 'slide_show' => isset($url_slideshow) ? $url_slideshow : '', 'image_detail' => $u_image, 'border_height' => $raw_image_height + 30, 'border_width' => $raw_image_width + 30, 'media_title' => isset($media[$mediaObject]['media_title']) && $media[$mediaObject]['media_title'] != ' ' ? PLG_replaceTags($media[$mediaObject]['media_title'], 'mediagallery', 'media_title') : '', 'album_title' => $sortID > 0 ? $LANG_MG03['search_results'] : $MG_albums[$aid]->title, 'media_desc' => isset($media[$mediaObject]['media_desc']) && $media[$mediaObject]['media_desc'] != ' ' ? $media_desc : '', 'artist' => isset($media[$mediaObject]['artist']) ? $media[$mediaObject]['artist'] : '', 'media_time' => $media_date[0], 'upload_time' => $upload_date[0], 'media_views' => $MG_albums[$aid]->enable_views ? $media[$mediaObject]['media_views'] : '', 'media_comments' => $MG_albums[$aid]->enable_comments ? $media[$mediaObject]['media_comments'] . '<br />' : '', 'pagination' => $sortID > 0 ? '' : generate_pic_pagination($_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '1' : '0') . "&amp;sort=" . $sortOrder, $nRows, 1, $mediaObject, $media, TRUE), 'media_number' => sprintf("%s %d %s %d", $LANG_MG03['image'], $mediaObject + 1, $LANG_MG03['of'], $total_media), 'jumpbox' => $album_jumpbox, 'edit_item' => $edit_item, 'site_url' => $_MG_CONF['site_url'], 'lang_prev' => $LANG_MG03['previous'], 'lang_next' => $LANG_MG03['next'], 'next_link' => $nextLink, 'prev_link' => $prevLink, 'image_height' => $raw_image_height, 'image_width' => $raw_image_width, 'left_side' => intval($raw_image_width / 2) - 1, 'right_side' => intval($raw_image_width / 2), 'raw_image' => $raw_image, 'media_link_start' => $media_link_start, 'media_link_end' => $media_link_end, 'raw_link_url' => $raw_link_url, 'album_link' => $MG_albums[$aid]->getPath(1, $sortOrder, $page), 'item_number' => $mediaObject + 1, 'total_items' => $total_media, 'lang_of' => $LANG_MG03['of'], 'album_link' => $album_link));
    $getid3link = '';
    $getid3linkend = '';
    $T->set_var(array('getid3' => $getid3link, 'getid3end' => $getid3linkend));
    if ($getid3link != '') {
        $T->set_var('media_properties', $LANG_MG03['media_properties']);
    } else {
        $T->set_var('media_properties', '');
    }
    if ($MG_albums[$aid]->enable_keywords == 1 && !empty($media[$mediaObject]['media_keywords'])) {
        $kwText = '';
        $keyWords = array();
        $keyWords = explode(' ', $media[$mediaObject]['media_keywords']);
        $numKeyWords = count($keyWords);
        for ($i = 0; $i < $numKeyWords; $i++) {
            $keyWords[$i] = str_replace('"', ' ', $keyWords[$i]);
            $searchKeyword = $keyWords[$i];
            $keyWords[$i] = str_replace('_', ' ', $keyWords[$i]);
            $kwText .= '<a href="' . $_MG_CONF['site_url'] . '/search.php?mode=search&amp;swhere=1&amp;keywords=' . $searchKeyword . '&amp;keyType=any">' . $keyWords[$i] . '</a> ';
        }
        $T->set_var(array('media_keywords' => $kwText, 'lang_keywords' => $LANG_MG01['keywords']));
    } else {
        $T->set_var(array('media_keywords' => '', 'lang_keywords' => ''));
    }
    if ($media[$mediaObject]['media_user_id'] == '' || !isset($media[$mediaObject]['media_user_id'])) {
        $media[$mediaObject]['media_user_id'] = 0;
    }
    if ($_CONF['show_fullname']) {
        $displayname = 'fullname';
    } else {
        $displayname = 'username';
    }
    $owner_name = DB_getItem($_TABLES['users'], $displayname, "uid = {$media[$mediaObject]['media_user_id']}");
    if (empty($owner_name) || $owner_name == '') {
        $owner_name = DB_getItem($_TABLES['users'], 'username', "uid = {$media[$mediaObject]['media_user_id']}");
        if (empty($owner_name) || $owner_name == '') {
            $owner_name = 'unknown';
        }
    }
    if ($owner_name != 'unknown') {
        $owner_link = '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $media[$mediaObject]['media_user_id'] . '">' . $owner_name . '</a>';
    } else {
        $owner_link = $owner_name;
    }
    $T->set_var('owner_username', $owner_link);
    if (($MG_albums[$aid]->exif_display == 2 || $MG_albums[$aid]->exif_display == 3) && $media[$mediaObject]['media_type'] == 0) {
        require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php';
        $haveEXIF = MG_haveEXIF($media[$mediaObject]['media_id']);
        if ($haveEXIF) {
            $T->set_var(array('property' => $_MG_CONF['site_url'] . '/property.php?mid=' . $media[$mediaObject]['media_id'], 'lang_property' => $LANG_MG04['exif_header']));
        }
    }
    if ($MG_albums[0]->owner_id || $_MG_CONF['enable_media_id'] == 1) {
        $T->set_var(array('media_id' => $media[$mediaObject]['media_id']));
    }
    // Language specific vars
    $T->set_var(array('lang_comments' => $MG_albums[$aid]->enable_comments ? $LANG_MG03['comments'] : '', 'lang_views' => $MG_albums[$aid]->enable_views ? $LANG_MG03['views'] : '', 'lang_title' => $LANG_MG01['title'], 'print_shutterfly' => $LANG_MG03['print_shutterfly'], 'lang_uploaded_by' => $LANG_MG01['uploaded_by'], 'album_id' => $aid, 'lang_search' => $LANG_MG01['search']));
    if (($MG_albums[$aid]->exif_display == 1 || $MG_albums[$aid]->exif_display == 3) && $media[$mediaObject]['media_type'] == 0) {
        require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php';
        $haveEXIF = MG_haveEXIF($media[$mediaObject]['media_id']);
        if ($haveEXIF) {
            $exifData = MG_readEXIF($media[$mediaObject]['media_id'], 2);
            $T->set_var(array('exif_info' => $exifData));
        }
    }
    if ($sortID == 0) {
        if ($MG_albums[$aid]->enable_postcard == 1 && !COM_isAnonUser() || $MG_albums[$aid]->enable_postcard == 2) {
            if ($media[$mediaObject]['media_type'] == 0) {
                $postcard_link = '<a href="' . $_MG_CONF['site_url'] . '/postcard.php?mode=edit&amp;mid=' . $media[$mediaObject]['media_id'] . '"><img src="' . MG_getImageFile('icon_envelopeSmall.gif') . '" alt="' . $LANG_MG03['send_postcard'] . '" style="border:none;"/></a>';
                $T->set_var('postcard_link', $postcard_link);
            }
        }
    }
    PLG_templateSetVars('mediagallery', $T);
    $T->parse('output', 'page');
    $retval .= $T->finish($T->get_var('output'));
    if ($comments) {
        // glFusion Comment support
        $mid = $media[$mediaObject]['media_id'];
        if ($MG_albums[$aid]->enable_comments == 1) {
            USES_lib_comment();
            if ($MG_albums[$aid]->access == 3 || $MG_albums[0]->owner_id) {
                $delete_option = true;
            } else {
                $delete_option = false;
            }
            if (DB_count($_TABLES['comments'], 'sid', $mid) > 0 || $_MG_CONF['commentbar']) {
                $cid = $mid;
                $page = isset($_GET['page']) ? COM_applyFilter($_GET['page'], true) : 0;
                if (isset($_POST['order'])) {
                    $comorder = $_POST['order'] == 'ASC' ? 'ASC' : 'DESC';
                } elseif (isset($_GET['order'])) {
                    $comorder = $_GET['order'] == 'ASC' ? 'ASC' : 'DESC';
                } else {
                    $comorder = '';
                }
                if (isset($_POST['mode'])) {
                    $commode = COM_applyFilter($_POST['mode']);
                } elseif (isset($_GET['mode'])) {
                    $commode = COM_applyFilter($_GET['mode']);
                } else {
                    $commode = '';
                }
                $valid_cmt_modes = array('flat', 'nested', 'nocomment', 'nobar');
                if (!in_array($commode, $valid_cmt_modes)) {
                    $commode = 'nested';
                }
                $commentbar = CMT_userComments($cid, $media[$mediaObject]['media_title'], 'mediagallery', $comorder, $commode, 0, $page, false, $delete_option, 0, $media[$mediaObject]['media_user_id']);
                $retval .= $commentbar;
            } else {
                $retval .= ' <center><a href="' . $_CONF['site_url'] . '/comment.php?sid=' . $mid . '&amp;title=' . $title . '&amp;pid=0&amp;type=mediagallery' . '">' . $LANG01[60] . '</a></center>';
            }
        }
    }
    return array(strip_tags($media[$mediaObject]['media_title']), $retval, '', $aid);
}
示例#14
0
/**
* Prepare a link item for rendering
*
* @param    array   $A          link details
* @param    ref     $template   reference of the links template
*
*/
function prepare_link_item($A, &$template)
{
    global $_LI_CONF, $_CONF, $_USER, $LANG_ADMIN, $LANG_LINKS, $_IMAGE_TYPE, $LANG_LOCALE;
    $url = COM_buildUrl($_CONF['site_url'] . '/links/portal.php?what=link&amp;item=' . $A['lid']);
    $template->set_var('link_url', $url);
    $template->set_var('link_actual_url', $A['url']);
    $template->set_var('link_name', $A['title']);
    $template->set_var('link_hits', COM_numberFormat($A['hits']));
    $linkDesc = PLG_replaceTags(nl2br($A['description']), 'links', 'description');
    $template->set_var('link_description', $linkDesc);
    //                        PLG_replaceTags(nl2br($A['description']),'links','description'));
    $content = $A['title'];
    if ($_LI_CONF['target_blank'] == 1) {
        $attr = array('title' => $A['url'], 'class' => 'ext-link', 'target' => '_blank');
    } else {
        $attr = array('title' => $A['url'], 'class' => 'ext-link');
    }
    $html = COM_createLink($content, $url, $attr);
    $template->set_var('link_html', $html);
    if (!COM_isAnonUser() && !SEC_hasRights('links.edit')) {
        $reporturl = $_CONF['site_url'] . '/links/index.php?mode=report&amp;lid=' . $A['lid'];
        $template->set_var('link_broken', COM_createLink($LANG_LINKS[117], $reporturl, array('class' => 'pluginSmallText', 'rel' => 'nofollow')));
    } else {
        $template->set_var('link_broken', '');
    }
    if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('links.edit')) {
        $editurl = $_CONF['site_admin_url'] . '/plugins/links/index.php?edit=x&amp;lid=' . $A['lid'];
        $template->set_var('edit_url', $editurl);
        $template->set_var('link_edit', COM_createLink($LANG_ADMIN['edit'], $editurl));
        $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}\" " . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"/>";
        $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl));
    } else {
        $template->set_var('link_edit', '');
        $template->set_var('edit_icon', '');
    }
    if ($_LI_CONF['linksperpage'] == 1) {
        $outputHandle = outputHandler::getInstance();
        $outputHandle->addMeta('property', 'og:site_name', urlencode($_CONF['site_name']));
        $outputHandle->addMeta('property', 'og:locale', isset($LANG_LOCALE) ? $LANG_LOCALE : 'en_US');
        $outputHandle->addMeta('property', 'og:title', $A['title']);
        $outputHandle->addMeta('property', 'og:type', 'website');
        $outputHandle->addMeta('property', 'og:url', $A['url']);
        if (preg_match('/<img[^>]+src=([\'"])?((?(1).+?|[^\\s>]+))(?(1)\\1)/si', $linkDesc, $arrResult)) {
            $outputHandle->addMeta('property', 'og:image', $arrResult[2]);
        }
    }
}
示例#15
0
function WIDGET_tabslide($dataArray)
{
    global $_CONF, $_TABLES;
    $retval = '';
    $id = rand(1, 1000);
    // define the JS we need for this theme..
    $outputHandle = outputHandler::getInstance();
    // core js
    $outputHandle->addLinkScript($_CONF['site_url'] . '/javascript/addons/slider-tabs/jquery.sliderTabs.min.js');
    $outputHandle->addLinkStyle($_CONF['site_url'] . '/javascript/addons/slider-tabs/styles/jquery.sliderTabs.min.css');
    $page_ids = $dataArray['panels'];
    if (!is_array($page_ids[0])) {
        //we are in Static Pages Mode
        $sql = "SELECT sp_id, sp_content, sp_php, sp_title FROM {$_TABLES['staticpage']} WHERE sp_id in (" . implode(', ', array_map(create_function('$a', 'return "\'" . htmlspecialchars($a) . "\'";'), $page_ids)) . ')' . COM_getPermSQL('AND');
        $res = DB_query($sql);
        $pages = array();
        for ($i = 0; $A = DB_fetchArray($res); ++$i) {
            $content = SP_render_content($A['sp_content'], $A['sp_php']);
            $title = htmlspecialchars($A['sp_title']);
            $order = array_search($A['sp_id'], $page_ids);
            // find proper order
            $pages[$order] = array('sp_id' => $A['sp_id'], 'content' => $content, 'title' => $title, 'index' => $order + 1);
        }
    } else {
        //we have been passed pre-formatted pages
        $pages = array();
        for ($i = 0; $i < sizeof($page_ids); ++$i) {
            $content = $page_ids[$i]['content'];
            $title = htmlspecialchars($page_ids[$i]['title']);
            $order = $i;
            $pages[$order] = array('sp_id' => $title, 'content' => $content, 'title' => $title, 'index' => $order + 1);
        }
    }
    if (count($pages) == 0) {
        return '';
    }
    ksort($pages);
    $retval .= '<div id="slidertabs_' . $id . '" class="tab-slider">';
    $retval .= '<ul>';
    foreach ($pages as $page) {
        extract($page);
        $retval .= '<li><a href="#' . $sp_id . '">' . stripslashes($title) . '</a></li>';
    }
    $retval .= '</ul>';
    foreach ($pages as $page) {
        extract($page);
        $retval .= '<div id="' . $sp_id . '">';
        $retval .= $content;
        $retval .= '</div>';
    }
    $retval .= '</div><div style="clear:both;"></div>';
    $retval .= '<script type="text/javascript">$(document).ready(function(){';
    $retval .= '$("div#slidertabs_' . $id . '").sliderTabs({';
    foreach ($dataArray['options'] as $option => $value) {
        if (is_numeric($value)) {
            $retval .= $option . ": " . $value . ",";
        } else {
            $retval .= $option . ": " . "'" . $value . "',";
        }
    }
    $retval .= '}); ';
    $retval .= ' });</script>';
    return $retval;
}