Esempio n. 1
0
$start = $page * $media_per_page;
$current_print_page = floor($start / $media_per_page) + 1;
if ($current_print_page == 0) {
    $current_print_page = 1;
}
$total_print_pages = $total_pages;
if ($total_print_pages == 0) {
    $total_print_pages = 1;
}
$birdseed = MG_getBirdseed(0, 0, 0, $total_print_pages);
$ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($root_album->owner_id));
$album_last_update = MG_getUserDateTimeFormat($root_album->last_update);
$pagination = COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php', $page + 1, $total_pages);
$rsslink = '';
if ($_MG_CONF['rss_full_enabled']) {
    $rsslink = COM_createLink(COM_createImage(MG_getImageFile('feed.png'), '', array('class' => 'mg_rssimg')), MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss'), array('type' => 'application/rss+xml'));
}
$T = COM_newTemplate(MG_getTemplatePath_byName($root_album->skin));
$T->set_file('page', 'album_page.thtml');
$T->set_var(array('site_url' => $_MG_CONF['site_url'], 'birdseed' => $birdseed, 'album_title' => PLG_replaceTags($root_album->title), 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => $pagination, 'bottom_pagination' => $pagination, 'page_number' => sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages), 'jumpbox' => MG_buildAlbumJumpbox($root_album, $album_id, 1, -1), 'album_id' => $album_id, 'album_description' => $root_album->display_album_desc ? PLG_replaceTags($root_album->description) : '', 'album_id_display' => $root_album->owner_id || $_MG_CONF['enable_media_id'] == 1 ? $LANG_MG03['album_id_display'] . $album_id : '', 'select_adminbox' => COM_isAnonUser() ? '' : MG_buildAdminbox($root_album), 'album_last_update' => $album_last_update[0], 'album_owner' => $ownername, 'media_count' => $root_album->getMediaCount(), 'lang_menulabel' => $LANG_MG03['menulabel'], 'lang_search' => $LANG_MG01['search'], 'rsslink' => $rsslink, 'list_title' => $LANG_MG03['list_title'], 'list_desc' => $LANG_MG03['list_desc'], 'list_size' => $LANG_MG03['list_size'], 'list_user' => $LANG_MG03['list_user'], 'list_updated' => $LANG_MG03['list_updated']));
// completed setting header / footer vars, parse them
PLG_templateSetVars('mediagallery', $T);
// main processing of the album contents.
if ($total_media > 0) {
    $k = 0;
    $col = 0;
    $T->set_block('page', 'ImageColumn', 'IColumn');
    $T->set_block('page', 'ImageRow', 'IRow');
    for ($i = 0; $i < $media_per_page; $i += $columns_per_page) {
        $next_columns = $i + $columns_per_page;
        for ($j = $i; $j < $next_columns; $j++) {
Esempio n. 2
0
/**
*   List all backups, i.e. all files ending in .sql or .sql.gz
*
*   @return string  HTML for the list of files or an error when not writable
*/
function DBADMIN_list()
{
    global $_CONF, $_TABLES, $_IMAGE_TYPE, $LANG08, $LANG_ADMIN, $LANG_DB_BACKUP;
    global $token;
    USES_lib_admin();
    $retval = '';
    if (is_writable($_CONF['backup_path'])) {
        $backups = array();
        $fd = opendir($_CONF['backup_path']);
        $index = 0;
        while (false !== ($file = @readdir($fd))) {
            if ($file != '.' && $file != '..' && $file != 'CVS' && preg_match('/\\.sql(\\.gz)?$/i', $file)) {
                $index++;
                clearstatcache();
                $backups[] = $file;
            }
        }
        // AS, 2004-03-29 - Sort backup files by date, newest first.
        // Order given by 'readdir' might not be correct.
        usort($backups, 'DBADMIN_compareBackupFiles');
        $data_arr = array();
        $diskIconUrl = $_CONF['layout_url'] . '/images/admin/disk.' . $_IMAGE_TYPE;
        $attr['title'] = $LANG_DB_BACKUP['download'];
        $alt = $LANG_DB_BACKUP['download'];
        $num_backups = count($backups);
        $icon_img = COM_createImage($diskIconUrl, $alt, $attr);
        for ($i = 0; $i < $num_backups; $i++) {
            $downloadUrl = LGLIB_ADMIN_URL . '/index.php?download=x&amp;file=' . urlencode($backups[$i]);
            $downloadLink = COM_createLink($icon_img, $downloadUrl, $attr);
            $downloadLink .= '&nbsp;&nbsp;';
            $attr['style'] = 'vertical-align:top;';
            $downloadLink .= COM_createLink($backups[$i], $downloadUrl, $attr);
            $backupfile = $_CONF['backup_path'] . $backups[$i];
            $backupfilesize = COM_numberFormat(filesize($backupfile)) . ' <b>' . $LANG_DB_BACKUP['bytes'] . '</b>';
            $data_arr[$i] = array('file' => $downloadLink, 'size' => $backupfilesize, 'filename' => $backups[$i]);
        }
        $retval .= DBADMIN_menu("<p>{$LANG_DB_BACKUP['db_explanation']}</p><p>" . sprintf($LANG_DB_BACKUP['total_number'], $index) . '</p>');
        $header_arr = array(array('text' => $LANG_DB_BACKUP['backup_file'], 'field' => 'file'), array('text' => $LANG_DB_BACKUP['size'], 'field' => 'size'));
        $text_arr = array('form_url' => LGLIB_ADMIN_URL . '/index.php');
        $form_arr = array('bottom' => '', 'top' => '');
        if ($num_backups > 0) {
            $form_arr['bottom'] = '<input type="hidden" name="delete" value="x" />' . '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '" />' . LB;
        }
        $options = array('chkselect' => true, 'chkminimum' => 0, 'chkfield' => 'filename');
        $retval .= ADMIN_simpleList('', $header_arr, $text_arr, $data_arr, $options, $form_arr);
        $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    } else {
        $retval .= COM_startBlock($LANG08[06], '', COM_getBlockTemplate('_msg_block', 'header'));
        $retval .= $LANG_DB_BACKUP['no_access'];
        COM_errorLog($_CONF['backup_path'] . ' is not writable.', 1);
        $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
    }
    return $retval;
}
Esempio n. 3
0
/**
 *  Display the ads under the given category ID.  Also puts in the
 *  subscription link and breadcrumbs.
 *  @param integer $cat Category number to list
 *  @return string  HTML for category list
 */
function adListCat($cat = '')
{
    global $_TABLES, $LANG_ADVT, $_CONF, $_USER, $_CONF_ADVT, $_GROUPS;
    global $CatListcolors;
    if ($cat == '') {
        return;
    }
    if (CLASSIFIEDS_checkCatAccess($cat) < 2) {
        return CLASSIFIEDS_errorMsg($LANG_ADVT['cat_unavailable'], 'alert');
    }
    $T = new Template(CLASSIFIEDS_PI_PATH . '/templates');
    $T->set_file('header', CLASSIFIEDS_getTemplate('adlisthdrCat'));
    $T->set_var('pi_url', $_CONF['site_url'] . '/' . $_CONF_ADVT['pi_name']);
    $sql = "SELECT image, owner_id, group_id, papa_id\n                perm_owner, perm_group, perm_members, perm_anon\n            FROM {$_TABLES['ad_category']}\n            WHERE cat_id={$cat}";
    $r = DB_query($sql);
    if (!$r || DB_numRows($r) < 1) {
        return;
    }
    $row = DB_fetchArray($r);
    $img_name = $row['image'];
    if ($img_name != '') {
        $T->set_var('catimg_url', CLASSIFIEDS_thumbUrl($img_name));
    }
    // Set the breadcrumb navigation
    //$T->set_var('breadcrumbs', CLASSIFIEDS_BreadCrumbs($cat), true);
    USES_classifieds_class_category();
    $T->set_var('breadcrumbs', adCategory::BreadCrumbs($cat), true);
    // if non-anonymous, allow the user to subscribe to this category
    if (!COM_isAnonUser()) {
        $result = DB_getItem($_TABLES['ad_notice'], 'count(*)', "uid = {$_USER['uid']} AND cat_id = {$cat}");
        // Determine whether the user is subscribed to notifications for
        // this category and display a message and or link accordingly
        $subscribed = $result > 0 ? 1 : 0;
        if ($subscribed) {
            $T->set_var('subscribe_msg', '<a href="' . CLASSIFIEDS_makeURL('del_notice', $cat) . '">' . COM_createImage(CLASSIFIEDS_URL . '/images/unsubscribe.png', $LANG_ADVT['remove'], array('title' => $LANG_ADVT['you_are_subscribed'], 'class' => 'gl_mootip')));
        } else {
            $T->set_var('subscribe_msg', '<a href="' . CLASSIFIEDS_makeURL('add_notice', $cat) . '">' . COM_createImage(CLASSIFIEDS_URL . '/images/subscribe.png', $LANG_ADVT['subscribe'], array('title' => $LANG_ADVT['subscribe'], 'class' => 'gl_mootip')));
        }
        // Display a link to submit an ad to the current category
        $submit_url = '';
        if (SEC_hasRights($_CONF_ADVT['pi_name'] . '.admin')) {
            $submit_url = $_CONF['site_admin_url'] . '/plugins/' . $_CONF_ADVT['pi_name'] . '/index.php?mode=edit&cat=' . $cat;
        } elseif (CLASSIFIEDS_checkCatAccess($cat, false, $row) == 3) {
            $submit_url = $_CONF['site_url'] . '/submit.php?type=' . $_CONF_ADVT['pi_name'] . '&cat=' . $cat;
        }
        $T->set_var('submit_url', $submit_url);
    } else {
        // Not-logged-in users can't subscribe or submit.
        $T->set_var('subscribe_msg', '');
        $T->set_var('submit_msg', '');
    }
    // This is a comma-separated string of category IDs for a SQL "IN" clause.
    // Start with the current category
    $cat_for_adlist = $cat;
    // Get the sub-categories which have this category as their parent
    USES_classifieds_class_category();
    $subcats = adCategory::SubCats($cat);
    $listvals = '';
    $max = count($CatListcolors);
    $i = 0;
    foreach ($subcats as $row) {
        // for each sub-category, add it to the list for getting ads
        $cat_for_adlist .= ",{$row['cat_id']}";
        // only show the category selection for immediate children.
        if ($row['papa_id'] != $cat) {
            continue;
        }
        $T->set_block('header', 'SubCat', 'sCat');
        if ($row['fgcolor'] == '' || $row['bgcolor'] == '') {
            if ($i >= $max) {
                $i = 0;
            }
            $T->set_var('bgcolor', $CatListcolors[$i][0]);
            $T->set_var('fgcolor', $CatListcolors[$i][1]);
            $i++;
        } else {
            $T->set_var('bgcolor', $row['bgcolor']);
            $T->set_var('fgcolor', $row['fgcolor']);
        }
        $T->set_var('subcat_url', CLASSIFIEDS_makeURL('list', $row['cat_id']));
        $T->set_var('subcat_name', $row['cat_name']);
        $T->set_var('subcat_count', adCategory::TotalAds($row['cat_id']));
        $T->parse('sCat', 'SubCat', true);
    }
    // Get the count of ads under this category
    $time = time();
    $sql = "SELECT cat_id FROM {$_TABLES['ad_ads']}\n            WHERE cat_id IN ({$cat_for_adlist})\n                AND exp_date > {$time} " . COM_getPermSQL('AND', 0, 2);
    //echo $sql;
    $result = DB_query($sql);
    if (!$result) {
        return CLASSIFIEDS_errorMsg($LANG_ADVT['database_error'], 'alert');
    }
    $totalAds = DB_numRows($result);
    $where_clause = " ad.cat_id IN ({$cat_for_adlist})\n        AND ad.exp_date > {$time} ";
    $T->parse('output', 'header');
    $retval = $T->finish($T->get_var('output'));
    $retval .= adExpList('', $cat, $where_clause);
    return $retval;
}
Esempio n. 4
0
/**
* List all backups, i.e. all files ending in .sql
*
* @return   string      HTML for the list of files or an error when not writable
*
*/
function DBADMIN_list()
{
    global $_CONF, $_TABLES, $_IMAGE_TYPE, $LANG08, $LANG_ADMIN, $LANG_DB_BACKUP;
    $retval = '';
    if (is_writable($_CONF['backup_path'])) {
        $backups = array();
        $fd = opendir($_CONF['backup_path']);
        $index = 0;
        while (false !== ($file = @readdir($fd))) {
            if ($file != '.' && $file != '..' && $file != 'CVS' && preg_match('/\\.sql(\\.gz)?$/i', $file)) {
                $index++;
                clearstatcache();
                $backups[] = $file;
            }
        }
        usort($backups, 'DBADMIN_compareBackupFiles');
        $data_arr = array();
        $thisUrl = $_CONF['site_admin_url'] . '/database.php';
        $diskIconUrl = $_CONF['layout_url'] . '/images/admin/disk.' . $_IMAGE_TYPE;
        $attr['title'] = $LANG_DB_BACKUP['download'];
        $alt = $LANG_DB_BACKUP['download'];
        $num_backups = count($backups);
        for ($i = 0; $i < $num_backups; $i++) {
            $downloadUrl = $thisUrl . '?download=x&amp;file=' . urlencode($backups[$i]);
            $downloadLink = COM_createLink(COM_createImage($diskIconUrl, $alt, $attr), $downloadUrl, $attr);
            $downloadLink .= '&nbsp;&nbsp;';
            $attr['style'] = 'vertical-align:top;';
            $downloadLink .= COM_createLink($backups[$i], $downloadUrl, $attr);
            $backupfile = $_CONF['backup_path'] . $backups[$i];
            $backupfilesize = COM_numberFormat(filesize($backupfile)) . ' <b>' . $LANG_DB_BACKUP['bytes'] . '</b>';
            $data_arr[$i] = array('file' => $downloadLink, 'size' => $backupfilesize, 'filename' => $backups[$i]);
        }
        $token = SEC_createToken();
        $menu_arr = array();
        $allInnoDB = DBADMIN_innodbStatus();
        $menu_arr[] = array('url' => $_CONF['site_admin_url'] . '/database.php?backupdb=x', 'text' => $LANG_DB_BACKUP['create_backup']);
        $menu_arr[] = array('url' => $_CONF['site_admin_url'] . '/database.php?optimize=x', 'text' => $LANG_DB_BACKUP['optimize_menu']);
        if (!$allInnoDB && DBADMIN_supported_engine('InnoDB')) {
            $menu_arr[] = array('url' => $_CONF['site_admin_url'] . '/database.php?innodb=x', 'text' => $LANG_DB_BACKUP['convert_menu']);
        }
        if ($allInnoDB && DBADMIN_supported_engine('MyISAM')) {
            $menu_arr[] = array('url' => $_CONF['site_admin_url'] . '/database.php?myisam=x', 'text' => $LANG_DB_BACKUP['convert_myisam_menu']);
        }
        $menu_arr[] = array('url' => $_CONF['site_admin_url'] . '/database.php?config=x', 'text' => $LANG_DB_BACKUP['configure']);
        $menu_arr[] = array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']);
        $retval .= COM_startBlock($LANG_DB_BACKUP['database_admin'], '', COM_getBlockTemplate('_admin_block', 'header'));
        $retval .= ADMIN_createMenu($menu_arr, "<p>{$LANG_DB_BACKUP['db_explanation']}</p>" . '<p>' . sprintf($LANG_DB_BACKUP['total_number'], $index) . '</p>', $_CONF['layout_url'] . '/images/icons/database.' . $_IMAGE_TYPE);
        $header_arr = array(array('text' => $LANG_DB_BACKUP['backup_file'], 'field' => 'file'), array('text' => $LANG_DB_BACKUP['size'], 'field' => 'size'));
        $text_arr = array('form_url' => $thisUrl);
        $form_arr = array('bottom' => '', 'top' => '');
        if ($num_backups > 0) {
            $form_arr['bottom'] = '<input type="hidden" name="delete" value="x">' . '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '">' . LB;
        }
        $options = array('chkdelete' => true, 'chkminimum' => 0, 'chkfield' => 'filename');
        $retval .= ADMIN_simpleList('', $header_arr, $text_arr, $data_arr, $options, $form_arr);
        $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    } else {
        $retval .= COM_startBlock($LANG08[06], '', COM_getBlockTemplate('_msg_block', 'header'));
        $retval .= $LANG_DB_BACKUP['no_access'];
        COM_errorLog($_CONF['backup_path'] . ' is not writable.', 1);
        $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
    }
    return $retval;
}
Esempio n. 5
0
 public function testCreateWithoutUrl()
 {
     global $_CONF;
     $image = '/image.png';
     $url = $_CONF['layout_url'] . $image;
     $fixture = '<img src="' . $url . '" alt="">';
     $this->assertFalse(empty($_CONF['layout_url']));
     $this->assertEquals($fixture, COM_createImage($url));
 }
Esempio n. 6
0
/**
 * Creates a menu with an optional icon and optional text below
 * this is used in the admin screens but may be used elsewhere also.
 *
 * @param    array  $menu_arr array of text & URL of the menu entries
 * @param    string $text     instructions to be displayed
 * @param    string $icon     url of an icon that will be displayed
 * @return   string           HTML output of function
 */
function ADMIN_createMenu($menu_arr, $text, $icon = '')
{
    global $_CONF;
    $admin_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/lists');
    $admin_templates->set_file(array('top_menu' => 'topmenu.thtml'));
    $menu_fields = '';
    $attr = array('class' => 'admin-menu-item');
    for ($i = 0; $i < count($menu_arr); $i++) {
        # iterate through menu
        $menu_fields .= COM_createLink($menu_arr[$i]['text'], $menu_arr[$i]['url'], $attr);
        if ($i < count($menu_arr) - 1) {
            $menu_fields .= ' | ';
            # add separator
        }
    }
    if (!empty($icon)) {
        $attr = array('class' => 'admin-menu-icon');
        $icon = COM_createImage($icon, '', $attr);
        $admin_templates->set_var('icon', $icon);
    }
    $admin_templates->set_var('menu_fields', $menu_fields);
    $admin_templates->set_var('lang_instructions', $text);
    $admin_templates->parse('top_menu', 'top_menu');
    $retval = $admin_templates->finish($admin_templates->get_var('top_menu'));
    return $retval;
}
Esempio n. 7
0
function DLM_updatePlugin()
{
    global $_CONF, $_TABLES, $LANG_DLM, $LANG32;
    $retval = '';
    $need = false;
    if (version_compare(VERSION, '1.8.0') >= 0) {
        $n = DB_getItem($_TABLES['conf_values'], 'COUNT(name)', "group_name = 'downloads' AND type = 'tab'");
        if ($n == 0) {
            $need = true;
        }
    }
    if ($need == true) {
        $content = $LANG32[42];
        $imgurl = $_CONF['layout_url'] . '/images/update.png';
        $attr = array('style' => 'vertical-align: middle;float: none');
        $img = COM_createImage($imgurl, $content, $attr);
        $url = $_CONF['site_admin_url'] . '/plugins/downloads/update.php';
        $link = COM_createLink($img . $content, $url, array('title' => $content));
        $msg = $LANG_DLM['please_update'] . ' ' . $link;
        $retval .= COM_showMessageText($msg);
    }
    return $retval;
}
Esempio n. 8
0
 /**
  * Generates the HTML code based on the preset style
  *
  * @access public
  * @param array $rows_arr The rows to display in the list
  * @param string $title The title of the list
  * @param string $list_top HTML that will appear before the list is printed
  * @param string $list_bottom HTML that will appear after the list is printed
  * @param boolean $show_sort True to enable column sorting, false to disable
  * @param boolean $show_limit True to show page limits, false to hide
  * @param array $params_arr GET params array
  * @return string HTML output
  *
  */
 function getFormattedOutput2($rows_arr, $title, $list_top = '', $list_bottom = '', $show_sort = true, $show_limit = true, $params_arr = null)
 {
     global $_CONF, $_IMAGE_TYPE, $LANG_ADMIN, $LANG09;
     $list_templates = COM_newTemplate($_CONF['path_layout'] . 'lists/');
     $list_templates->set_file('list', $this->_style == 'inline' ? 'list_inline.thtml' : 'list_table.thtml');
     $blocks = array('field', 'row', 'limit', 'sort', 'direction', 'input_hidden');
     foreach ($blocks as $block) {
         $list_templates->set_block('list', $block);
     }
     $list_templates->set_var('lang_submit', $LANG09[73]);
     $list_templates->set_var('lang_sort', $LANG09[68]);
     $list_templates->set_var('lang_limit', $LANG09[74]);
     $list_templates->set_var('page_url', $_CONF['site_url'] . '/search.php');
     if ($this->_style == 'table') {
         $params_arr = array_merge($params_arr, array('order' => $this->_sort_arr['field'], 'direction' => $this->_sort_arr['direction']));
     }
     foreach ($params_arr as $key => $val) {
         $list_templates->set_var('hidden_name', $key);
         $list_templates->set_var('hidden_val', $val);
         $list_templates->parse('page_hidden', 'input_hidden', true);
     }
     if (count($rows_arr) == 0) {
         $list_templates->set_var('show_sort', 'display:none;');
         $list_templates->set_var('show_limit', 'display:none;');
         $list_templates->set_var('message', $LANG_ADMIN['no_results']);
         $list_templates->set_var('list_top', $list_top);
         $list_templates->set_var('list_bottom', $list_bottom);
         $list_templates->parse('output', 'list');
         // No results to show so quickly print a message and exit
         $retval = '';
         if (!empty($title)) {
             $retval .= COM_startBlock($title, '', COM_getBlockTemplate('_admin_block', 'header'));
         }
         $retval .= $list_templates->finish($list_templates->get_var('output'));
         if (!empty($title)) {
             $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
         }
         return $retval;
     }
     // Draw the page limit select box
     if ($show_limit) {
         foreach ($this->_page_limits as $key => $val) {
             $text = is_numeric($key) ? $val : $key;
             $selected = $this->_per_page == $val ? ' selected="selected"' : '';
             $list_templates->set_var('limit_val', $val);
             $list_templates->set_var('limit_text', $text);
             $list_templates->set_var('limit_selected', $selected);
             $list_templates->parse('page_limit', 'limit', true);
         }
         if (empty($text)) {
             $list_templates->set_var('show_limit', 'display:none;');
         }
     } else {
         $list_templates->set_var('show_limit', 'display:none;');
     }
     // Create how to display the sort field
     if ($this->_style == 'table') {
         $arrow = $this->_sort_arr['direction'] == 'asc' ? 'bararrowdown' : 'bararrowup';
         $sort_selected = "{$_CONF['layout_url']}/images/{$arrow}.{$_IMAGE_TYPE}";
         $sort_selected = ' &nbsp;' . COM_createImage($sort_selected, $arrow);
         $sort_text = '';
     } else {
         $sort_selected = '';
         $sort_text = '';
         if (!$show_sort) {
             $list_templates->set_var('show_sort', 'display:none;');
         }
     }
     // Draw the sorting select box/table headings
     foreach ($this->_fields as $field) {
         if ($field['display'] == true && $field['title'] != '') {
             $text = $sort_text . $field['title'];
             $href = '';
             $selected = '';
             if ($this->_style == 'inline' && $show_sort && $field['sort'] != false) {
                 if ($this->_sort_arr['field'] === $field['name']) {
                     $selected = ' selected="selected"';
                 }
                 // Write field
                 $list_templates->set_var('sort_text', $text);
                 $list_templates->set_var('sort_val', $field['name']);
                 $list_templates->set_var('sort_selected', $selected);
                 $list_templates->parse('page_sort', 'sort', true);
             } else {
                 if ($this->_style == 'table') {
                     $direction = $this->_sort_arr['direction'] == 'asc' ? 'desc' : 'asc';
                     $href = $this->_page_url . "results={$this->_per_page}&amp;" . "order={$field['name']}&amp;direction={$direction}";
                     if ($show_sort && $field['sort'] != false) {
                         $text = "<a href=\"{$href}\">{$text}</a>";
                         if ($this->_sort_arr['field'] === $field['name']) {
                             $selected = $sort_selected;
                         }
                     }
                     // Write field
                     $list_templates->set_var('sort_text', $text);
                     $list_templates->set_var('sort_href', $href);
                     $list_templates->set_var('sort_val', $field['name']);
                     $list_templates->set_var('sort_selected', $selected);
                     $list_templates->parse('page_sort', 'sort', true);
                 }
             }
         }
     }
     // Draw the sort direction select box
     if ($this->_style == 'inline' && $show_sort) {
         foreach (array('desc', 'asc') as $direction) {
             $direction_text = $direction == 'asc' ? $LANG09[71] : $LANG09[72];
             $list_templates->set_var('direction_text', $direction_text);
             $list_templates->set_var('direction_val', $direction);
             $direction_selected = '';
             if ($this->_sort_arr['direction'] == $direction) {
                 $direction_selected = ' selected="selected"';
             }
             $list_templates->set_var('direction_selected', $direction_selected);
             $list_templates->parse('page_direction', 'direction', true);
         }
     }
     $offset = ($this->_page - 1) * $this->_per_page;
     $list_templates->set_var('show_message', 'display:none;');
     // Run through all the results
     $r = 1;
     foreach ($rows_arr as $row) {
         if (is_callable($this->_function)) {
             $row = call_user_func_array($this->_function, array(false, $row));
         }
         foreach ($this->_fields as $field) {
             if ($field['display'] == true) {
                 $fieldvalue = '';
                 if ($field['name'] == LF_ROW_NUMBER) {
                     $fieldvalue = $r + $offset;
                 } else {
                     if (!empty($row[$field['name']])) {
                         $fieldvalue = $row[$field['name']];
                     }
                 }
                 if ($fieldvalue != 'LF_NULL') {
                     $fieldvalue = sprintf($field['format'], $fieldvalue, $field['title']);
                     // Write field
                     $list_templates->set_var('field_text', $fieldvalue);
                     $list_templates->parse('item_field', 'field', true);
                 } else {
                     // Write an empty field
                     $list_templates->set_var('field_text', ' ');
                     $list_templates->parse('item_field', 'field', true);
                 }
             }
         }
         // Write row
         $r++;
         $list_templates->set_var('cssid', $r % 2 + 1);
         $list_templates->parse('item_row', 'row', true);
         $list_templates->clear_var('item_field');
     }
     // Print page numbers
     $page_url = $this->_page_url . 'order=' . $this->_sort_arr['field'] . '&amp;direction=' . $this->_sort_arr['direction'] . '&amp;results=' . $this->_per_page;
     $num_pages = ceil($this->_total_found / $this->_per_page);
     if ($num_pages > 1) {
         $list_templates->set_var('google_paging', COM_printPageNavigation($page_url, $this->_page, $num_pages, 'page=', false, '', ''));
     } else {
         $list_templates->set_var('google_paging', '');
     }
     $list_top = sprintf($list_top, $offset + 1, $r + $offset - 1, $this->_total_found);
     $list_templates->set_var('list_top', $list_top);
     $list_templates->set_var('list_bottom', $list_bottom);
     $list_templates->parse('output', 'list');
     // Do the actual output
     $retval = '';
     if (!empty($title)) {
         $retval .= COM_startBlock($title, '', COM_getBlockTemplate('_admin_block', 'header'));
     }
     $retval .= $list_templates->finish($list_templates->get_var('output'));
     if (!empty($title)) {
         $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
     }
     return $retval;
 }
Esempio n. 9
0
function makeCategoryPart($cid)
{
    global $_CONF, $_DLM_CONF, $LANG_DLM, $mytree;
    $T = new Template($_DLM_CONF['path_layout']);
    $T->set_file(array('categorypart' => 'filelisting_category.thtml', 'categoryrow' => 'filelisting_category_row.thtml', 'categoryitem' => 'filelisting_category_item.thtml'));
    DLM_setDefaultTemplateVars($T);
    $arr = $mytree->getFirstChild($cid, 'corder');
    // all child ID are listed (Affected by the language mode)
    if (count($arr) == 0) {
        return '';
    }
    //  if ($_DLM_CONF['numCategoriesPerRow'] < 1) $_DLM_CONF['numCategoriesPerRow'] = 1; // probably no longer necessary
    //  if ($_DLM_CONF['numCategoriesPerRow'] > 6) $_DLM_CONF['numCategoriesPerRow'] = 6; // probably no longer necessary
    $count = 0;
    foreach ($arr as $ele) {
        // Each category
        $chtitle = DLM_htmlspecialchars($ele['title']);
        $T->set_var('cid', $ele['cid']);
        $T->set_var('chtitle', $chtitle);
        $T->set_var('totaldownload', getTotalItems($ele['cid']));
        $category_image_link = '&nbsp;';
        if ($_DLM_CONF['download_useshots']) {
            if ($ele['imgurl'] && $ele['imgurl'] != "http://") {
                $imgurl = $_DLM_CONF['snapcat_url'] . '/' . DLM_htmlspecialchars($ele['imgurl']);
            } else {
                $imgurl = $_CONF['site_url'] . '/downloads/images/download.png';
            }
            $category_image_link = COM_createImage($imgurl, $chtitle, array('width' => $_DLM_CONF['download_shotwidth']));
            $category_image_link = COM_createLink($category_image_link, $_CONF['site_url'] . '/downloads/index.php?cid=' . $ele['cid']);
        }
        $T->set_var('category_link', $category_image_link);
        $T->parse('category_row', 'categoryitem', true);
        $count++;
        if ($count == $_DLM_CONF['numCategoriesPerRow']) {
            $T->parse('category_records', 'categoryrow', true);
            $T->set_var('category_row', '');
            $count = 0;
        }
    }
    if ($count > 0) {
        $T->parse('category_records', 'categoryrow', true);
    }
    return $T->finish($T->parse('category_part', 'categorypart'));
}
Esempio n. 10
0
function ADMIN_createMenuHeader($menu_arr, $text, $title = '', $icon = '')
{
    global $_CONF;
    $admin_templates = new Template($_CONF['path_layout'] . 'admin/lists');
    $admin_templates->set_file(array('top_menu' => 'topmenu_nav.thtml'));
    $menu_fields = '';
    $attr = array('class' => 'admin-menu-item');
    $admin_templates->set_block('top_menu', 'menu_items', 'menuvar');
    $admin_templates->set_block('top_menu', 'alt_menu_items', 'alt_menuvar');
    for ($i = 0; $i < count($menu_arr); $i++) {
        # iterate through menu
        $admin_templates->set_var('menu_item_url', $menu_arr[$i]['url']);
        $admin_templates->set_var('menu_item_text', $menu_arr[$i]['text']);
        $admin_templates->parse('menuvar', 'menu_items', true);
        $admin_templates->parse('alt_menuvar', 'alt_menu_items', true);
    }
    if (!empty($icon)) {
        $attr = array('class' => 'admin-menu-icon');
        $icon = COM_createImage($icon, '', $attr);
        $admin_templates->set_var('icon', $icon);
    }
    $admin_templates->set_var('lang_title', $title);
    $admin_templates->set_var('lang_instructions', $text);
    $admin_templates->parse('top_menu', 'top_menu');
    $retval = $admin_templates->finish($admin_templates->get_var('top_menu'));
    return $retval;
}
Esempio n. 11
0
 /**
  * Generates the HTML code based on the preset style
  *
  * @access public
  * @param array $rows_arr The rows to display in the list
  * @param string $title The title of the list
  * @param string $list_top HTML that will appear before the list is printed
  * @param string $list_bottom HTML that will appear after the list is printed
  * @param boolean $show_sort True to enable column sorting, false to disable
  * @param boolean $show_limit True to show page limits, false to hide
  * @return string HTML output
  *
  */
 function getFormattedOutput($rows_arr, $title, $list_top = '', $list_bottom = '', $show_sort = true, $show_limit = true)
 {
     global $_CONF, $_IMAGE_TYPE, $LANG_ADMIN, $LANG09;
     // get all template fields.
     $list_templates = COM_newTemplate($_CONF['path_layout'] . 'lists/' . $this->_style);
     $list_templates->set_file(array('list' => 'list.thtml', 'limit' => 'page_limit.thtml', 'sort' => 'page_sort.thtml', 'row' => 'item_row.thtml', 'field' => 'item_field.thtml'));
     if (count($rows_arr) == 0) {
         $list_templates->set_var('show_sort', 'display:none;');
         $list_templates->set_var('show_limit', 'display:none;');
         $list_templates->set_var('message', $LANG_ADMIN['no_results']);
         $list_templates->set_var('list_top', $list_top);
         $list_templates->set_var('list_bottom', $list_bottom);
         $list_templates->parse('output', 'list');
         // No results to show so quickly print a message and exit
         $retval = '';
         if (!empty($title)) {
             $retval .= COM_startBlock($title, '', COM_getBlockTemplate('_admin_block', 'header'));
         }
         $retval .= $list_templates->finish($list_templates->get_var('output'));
         if (!empty($title)) {
             $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
         }
         return $retval;
     }
     // Draw the page limit select box
     if ($show_limit) {
         foreach ($this->_page_limits as $key => $val) {
             $text = is_numeric($key) ? sprintf($LANG09[67], $val) : $key;
             $href = $this->_page_url . "order={$this->_sort_arr['field']}&amp;" . "direction={$this->_sort_arr['direction']}&amp;results={$val}";
             // Prevent displaying too many limit items
             if ($this->_total_found <= $val) {
                 // If this is the last item, chances are its going to be selected
                 $selected = $this->_per_page >= $val ? ' selected="selected"' : '';
                 $list_templates->set_var('limit_href', $href);
                 $list_templates->set_var('limit_text', $text);
                 $list_templates->set_var('limit_selected', $selected);
                 $list_templates->parse('page_limit', 'limit', true);
                 break;
             }
             $selected = $this->_per_page == $val ? ' selected="selected"' : '';
             $list_templates->set_var('limit_text', $text);
             $list_templates->set_var('limit_href', $href);
             $list_templates->set_var('limit_selected', $selected);
             $list_templates->parse('page_limit', 'limit', true);
         }
         if (empty($text)) {
             $list_templates->set_var('show_limit', 'display:none;');
         }
     } else {
         $list_templates->set_var('show_limit', 'display:none;');
     }
     // Create how to display the sort field
     if ($this->_style == 'table') {
         $arrow = $this->_sort_arr['direction'] == 'asc' ? 'bararrowdown' : 'bararrowup';
         $sort_selected = "{$_CONF['layout_url']}/images/{$arrow}.{$_IMAGE_TYPE}";
         $sort_selected = ' &nbsp;' . COM_createImage($sort_selected, $arrow);
         $sort_text = '';
     } else {
         $sort_selected = '';
         $sort_text = $LANG09[68] . ' ';
         if (!$show_sort) {
             $list_templates->set_var('show_sort', 'display:none;');
         }
     }
     // Draw the sorting select box/table headings
     foreach ($this->_fields as $field) {
         if ($field['display'] == true && $field['title'] != '') {
             $text = $sort_text . $field['title'];
             $href = '';
             $selected = '';
             if ($this->_style == 'inline' && $show_sort && $field['sort'] != false) {
                 $direction = $this->_def_sort_arr['direction'];
                 // Show the sort arrow
                 if ($this->_sort_arr['field'] === $field['name']) {
                     // Add drop down item for current sort order
                     if ($this->_sort_arr['direction'] == 'asc') {
                         $list_templates->set_var('sort_text', $text . ' (' . $LANG09[71] . ')');
                     } else {
                         $list_templates->set_var('sort_text', $text . ' (' . $LANG09[72] . ')');
                     }
                     $list_templates->set_var('sort_href', '');
                     $list_templates->set_var('sort_selected', ' selected="selected"');
                     $list_templates->parse('page_sort', 'sort', true);
                     // Set up the sort order for the opposite direction
                     $direction = $this->_sort_arr['direction'] == 'asc' ? 'desc' : 'asc';
                     if ($direction == 'asc') {
                         $text .= ' (' . $LANG09[71] . ')';
                     } else {
                         $text .= ' (' . $LANG09[72] . ')';
                     }
                 }
                 $href = $this->_page_url . "results={$this->_per_page}&amp;" . "order={$field['name']}&amp;direction={$direction}";
                 // Write field
                 $list_templates->set_var('sort_text', $text);
                 $list_templates->set_var('sort_href', $href);
                 $list_templates->set_var('sort_selected', '');
                 $list_templates->parse('page_sort', 'sort', true);
             } else {
                 if ($this->_style == 'table') {
                     $direction = $this->_sort_arr['direction'] == 'asc' ? 'desc' : 'asc';
                     $href = $this->_page_url . "results={$this->_per_page}&amp;" . "order={$field['name']}&amp;direction={$direction}";
                     if ($show_sort && $field['sort'] != false) {
                         $text = "<a href=\"{$href}\">{$text}</a>";
                         if ($this->_sort_arr['field'] === $field['name']) {
                             $selected = $sort_selected;
                         }
                     }
                     // Write field
                     $list_templates->set_var('sort_text', $text);
                     $list_templates->set_var('sort_href', $href);
                     $list_templates->set_var('sort_selected', $selected);
                     $list_templates->parse('page_sort', 'sort', true);
                 }
             }
         }
     }
     $offset = ($this->_page - 1) * $this->_per_page;
     $list_templates->set_var('show_message', 'display:none;');
     // Run through all the results
     $r = 1;
     foreach ($rows_arr as $row) {
         if (is_callable($this->_function)) {
             $row = call_user_func_array($this->_function, array(false, $row));
         }
         foreach ($this->_fields as $field) {
             if ($field['display'] == true) {
                 $fieldvalue = '';
                 if ($field['name'] == LF_ROW_NUMBER) {
                     $fieldvalue = $r + $offset;
                 } else {
                     if (!empty($row[$field['name']])) {
                         $fieldvalue = $row[$field['name']];
                     }
                 }
                 if ($fieldvalue != 'LF_NULL') {
                     $fieldvalue = sprintf($field['format'], $fieldvalue, $field['title']);
                     // Write field
                     $list_templates->set_var('field_text', $fieldvalue);
                     $list_templates->parse('item_field', 'field', true);
                 } else {
                     // Write an empty field
                     $list_templates->set_var('field_text', ' ');
                     $list_templates->parse('item_field', 'field', true);
                 }
             }
         }
         // Write row
         $r++;
         $list_templates->set_var('cssid', $r % 2 + 1);
         $list_templates->parse('item_row', 'row', true);
         $list_templates->clear_var('item_field');
     }
     // Print page numbers
     $page_url = $this->_page_url . 'order=' . $this->_sort_arr['field'] . '&amp;direction=' . $this->_sort_arr['direction'] . '&amp;results=' . $this->_per_page;
     $num_pages = ceil($this->_total_found / $this->_per_page);
     if ($num_pages > 1) {
         $list_templates->set_var('google_paging', COM_printPageNavigation($page_url, $this->_page, $num_pages, 'page=', false, '', ''));
     } else {
         $list_templates->set_var('google_paging', '');
     }
     $list_top = sprintf($list_top, $offset + 1, $r + $offset - 1, $this->_total_found);
     $list_templates->set_var('list_top', $list_top);
     $list_templates->set_var('list_bottom', $list_bottom);
     $list_templates->parse('output', 'list');
     // Do the actual output
     $retval = '';
     if (!empty($title)) {
         $retval .= COM_startBlock($title, '', COM_getBlockTemplate('_admin_block', 'header'));
     }
     $retval .= $list_templates->finish($list_templates->get_var('output'));
     if (!empty($title)) {
         $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
     }
     return $retval;
 }
Esempio n. 12
0
/**
*   Returns a formatted field to the admin list when managing general locations
*   @param  string  $fieldname  Name of field
*   @param  string  $fieldvalue Value of field
*   @param  array   $A          Array of all values
*   @param  array   $icon_arr   Array of icons
*   @return string  String to display for the selected field
*
*/
function EXP_getAdminListField($fieldname, $fieldvalue, $A, $icon_arr)
{
    global $_CONF, $_CONF_EXP, $LANG24, $LANG_EX00;
    $retval = '';
    switch ($fieldname) {
        case 'edit':
            $retval = COM_createLink($icon_arr['edit'], "{$_CONF['site_admin_url']}/plugins/{$_CONF_EXP['pi_name']}/edit.php?exid={$A['exid']}");
            $retval .= '&nbsp;&nbsp;' . COM_createLink(COM_createImage($_CONF['site_url'] . '/' . $_CONF_EXP['pi_name'] . '/images/deleteitem.png', 'Delete this item', array('title' => 'Delete this item', 'class' => 'gl_mootip', 'onclick' => "return confirm('Do you really want to delete this item?');")), "{$_CONF['site_admin_url']}/plugins/{$_CONF_EXP['pi_name']}/index.php" . "?mode=delete&amp;exid={$A['exid']}");
            break;
        case 'exid':
        case 'title':
        case 'hits':
            $retval = htmlspecialchars($fieldvalue);
            break;
        case 'url':
            $retval = COM_createLink($fieldvalue, $fieldvalue);
            break;
    }
    return $retval;
}
Esempio n. 13
0
function plugin_getListField_AdCategories($fieldname, $fieldvalue, $A, $icon_arr)
{
    global $_CONF, $_CONF_ADVT, $LANG24, $LANG_ADVT, $_TABLES;
    $retval = '';
    switch ($fieldname) {
        case 'edit':
            $retval = COM_createLink($icon_arr['edit'], CLASSIFIEDS_ADMIN_URL . "/index.php?editcat=x&cat_id={$A['cat_id']}");
            break;
        case 'delete':
            $retval .= '&nbsp;&nbsp;' . COM_createLink(COM_createImage($_CONF['layout_url'] . '/images/admin/delete.png', 'Delete this item', array('title' => 'Delete this item', 'class' => 'gl_mootip')), CLASSIFIEDS_ADMIN_URL . "/index.php?deletecat=cat&amp;cat_id={$A['cat_id']}");
            break;
        case 'parent':
            $retval = DB_getItem($_TABLES['ad_category'], 'cat_name', 'cat_id=' . $A['papa_id']);
            break;
        default:
            $retval = $fieldvalue;
            break;
    }
    return $retval;
}