Exemplo n.º 1
0
/**
 * Translate a category that came from an url back to it's
 * proper name, if necessary. Returns false if the category
 * isn't present.
 *
 * @param string $cat
 * @return mixed
 */
function category_from_para($cat)
{
    // Get all categories..
    $all_cats = cfg_cats();
    if (isset($all_cats[$cat])) {
        // If $cat is present 'as is'
        return $cat;
    } else {
        if (is_numeric($cat)) {
            // If it's numeric, we need to translate it back..
            $keys = array_keys($all_cats);
            return $keys[$cat];
        } else {
            // Make an educated guess.
            // If it's there, but it had an underscore instead of a space
            foreach ($all_cats as $loop_cat) {
                if (str_replace("_", " ", $cat) == str_replace("_", " ", $loop_cat['name'])) {
                    return $loop_cat['name'];
                }
            }
            // Hmm, we don't know this category
            return false;
        }
    }
}
Exemplo n.º 2
0
/**
 * Display the screen with entries.
 *
 * @param string $message
 */
function entries_screen($message = "")
{
    global $config_array, $Pivot_Vars, $Cfg, $absmax;
    PageHeader(lang('userbar', 'entries'), 1);
    PageAnkeiler(lang('userbar', 'entries') . ' » ' . lang('userbar', 'entries_title'));
    // display a message, if there is one..
    if ($message != "") {
        echo "<p><b>{$message}</b></p>";
    }
    // if there is an 'action' to do
    if (isset($Pivot_Vars['doaction']) && $Pivot_Vars['action'] != "") {
        if ($Pivot_Vars['action'] == "delete" && $Pivot_Vars['confirmed'] != 1) {
            $vars = array("action", $Pivot_Vars['action'], "check", serialize($Pivot_Vars['check']), "doaction", "1");
            if (count($Pivot_Vars['check']) == 1) {
                ConfirmPage("hmm ho hum", $vars, lang('entries', 'delete_one_confirm'));
            } else {
                ConfirmPage("hmm ho hum", $vars, lang('entries', 'delete_multiple_confirm'));
            }
        }
        entries_action($Pivot_Vars['action'], $Pivot_Vars['check']);
    }
    $db = new db();
    if (!isset($Cfg['overview_entriesperpage'])) {
        $Cfg['overview_entriesperpage'] = 20;
    }
    $absmax = $db->get_entries_count();
    $show = isset($Pivot_Vars['show']) ? $Pivot_Vars['show'] : $Cfg['overview_entriesperpage'];
    $offset = isset($Pivot_Vars['offset']) ? $Pivot_Vars['offset'] : 0;
    if (isset($Pivot_Vars['first'])) {
        $offset = $absmax - $show;
    }
    $myurl = sprintf("index.php?session=%s&amp;menu=entries", $Pivot_Vars['session']);
    //Sort entries change
    //set initial values for sort values
    $entry_sort = "";
    //goes in query string
    $sort = "date";
    //goes in the getlist method call
    if (isset($Pivot_Vars['sort'])) {
        $entry_sort = "&amp;sort=" . $Pivot_Vars['sort'];
        $sort = $Pivot_Vars['sort'];
        if (isset($Pivot_Vars['reverse'])) {
            $sort_order = TRUE;
            $entry_sort .= "&amp;reverse";
        } else {
            $sort_order = FALSE;
            $myurl .= "&amp;reverse";
        }
    }
    if (isset($Pivot_Vars['filtercat'])) {
        $overview_arr = $db->getlist(-$show, $offset, "", array($Pivot_Vars['filtercat']), $sort_order, $sort);
        $filter = "&amp;filtercat=" . $Pivot_Vars['filtercat'];
        $filtertitle = str_replace('%name%', $Pivot_Vars['filtercat'], lang('entries', 'filteron'));
    } else {
        if (isset($Pivot_Vars['filteruser'])) {
            $overview_arr = $db->getlist(-$show, $offset, $Pivot_Vars['filteruser'], "", $sort_order, $sort);
            $filter = "&amp;filteruser="******"modules/module_search.php";
                $overview_arr = search_entries($Pivot_Vars['search']);
                $filtertitle = str_replace('%name%', '&hellip;', lang('entries', 'filteron'));
                $offset = 0;
                $absmax = $show = 1;
            } else {
                $overview_arr = $db->getlist(-$show, $offset, "", "", $sort_order, $sort);
                $filter = "";
                $filtertitle = str_replace('%name%', '&hellip;', lang('entries', 'filteron'));
            }
        }
    }
    if ($offset < $absmax - $show) {
        $prev = $offset + $show;
        $prevlink = sprintf('<a href="%s&amp;offset=%s&amp;show=%s%s%s">&laquo; ' . lang('entries', 'first') . '</a>&nbsp;&nbsp;', $myurl, $absmax - $show, $show, $filter, $entry_sort);
        $prevlink .= sprintf('<a href="%s&amp;offset=%s&amp;show=%s%s%s">&lsaquo; ' . lang('entries', 'previous') . ' %s</a>', $myurl, $prev, $show, $filter, $entry_sort, $show);
    } else {
        $prevlink = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    }
    if ($offset > 0) {
        $next = max(0, $offset - $show);
        $nextlink = sprintf('<a href="%s&amp;offset=%s&amp;show=%s%s%s">&rsaquo; ' . lang('entries', 'next') . ' %s</a>&nbsp;&nbsp;', $myurl, $next, $show, $filter, $entry_sort, $show);
        $nextlink .= sprintf('<a href="%s&amp;show=%s%s%s">&raquo; ' . lang('entries', 'last') . '</a>', $myurl, $show, $filter, $entry_sort);
    } else {
        $nextlink = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    }
    // make the html for the paginator..
    $numofpages = (int) ceil($absmax / abs($show));
    if ($numofpages > 1) {
        for ($i = 0; $i < $numofpages; $i++) {
            $init = $i * abs($show);
            $pages_arr[] = sprintf("<option value=\"%s%s&amp;show=%s%s&amp;offset=%s\">%s</option>", $myurl, $entry_sort, abs($show), $filter, $init, $i + 1);
        }
        $title = str_replace('%num%', ceil($offset / abs($show)) + 1, lang('entries', 'jumptopage'));
        $pages = "<select name='selectedPage' onchange='changePage(this.form.selectedPage)' \tclass='input'>";
        $pages .= sprintf("<option value='' selected='selected'>%s</option>", $title);
        $pages .= implode("\n", $pages_arr);
        $pages .= "</select>";
    }
    // make the HTML for the filter box
    if (isset($Pivot_Vars['filtercat']) || isset($Pivot_Vars['filteruser'])) {
        $pages_arr = array(sprintf("<option value=\"%s%s&amp;show=%s\">%s</option>", $myurl, $entry_sort, abs($show), lang('entries', 'filteroff')));
    } else {
        $pages_arr = array();
    }
    $cats = cfg_cats();
    $pages_arr[] = "<option value=''>" . lang('entries', 'category') . "</option>";
    foreach ($cats as $cat) {
        $pages_arr[] = sprintf("<option value=\"%s%s&amp;show=%s&amp;filtercat=%s\"> - %s</option>", $myurl, $entry_sort, abs($show), $cat['name'], $cat['name']);
    }
    $users = explode("|", $Cfg['users']);
    $pages_arr[] = "<option value=''>" . lang('entries', 'author') . "</option>";
    foreach ($users as $user) {
        $pages_arr[] = sprintf("<option value=\"%s%s&amp;show=%s&amp;filteruser=%s\"> - %s</option>", $myurl, $entry_sort, abs($show), $user, $user);
    }
    $pages .= "<select name='selectedFilter' onchange='changePage(this.form.selectedFilter)' class='input'>";
    $pages .= sprintf("<option value='' selected='selected'>%s</option>", $filtertitle);
    $pages .= implode("\n", $pages_arr);
    $pages .= "</select>";
    $searchval = isset($Pivot_Vars['search']) ? $Pivot_Vars['search'] : 'search';
    $pages .= "<input type='text' name='search' value='" . $searchval . "' class='input' style='padding: 2px; height: 19px; width: 90px;' onfocus='this.select();' />";
    // Some JS for the paginator and filter menus
    echo "<scr" . "ipt language='JavaScript' type='text/JavaScript'>\nfun" . "ction changePage(newLoc)\n{\nnextPage = newLoc.options[newLoc.selectedIndex].value;\nif (nextPage != '') { document.location.href = nextPage; } }</scr" . "ipt>";
    printf("<form name='form1' method='post' action='%s&amp;doaction=1'>\n<table cellspacing='0' class='tabular_border' border='0'>\n", $myurl);
    echo "<tr class='tabular_nav'><td colspan='8'>\n";
    echo '<table cellspacing="0" cellpadding="0" class="tabular_border" style="border:0px;" border="0" width="100%"><tr>';
    printf('<td>%s&nbsp;</td>', $prevlink);
    printf('<td align="center">%s</td>', $pages);
    printf('<td align="right" class="tabular_nav">&nbsp;%s</td></tr></table>', $nextlink);
    echo "\n</td></tr><tr class='tabular_header'><td>&nbsp;</td>";
    echo '<td><a href="' . $myurl . '&amp;sort=status">' . lang('entries', 'status') . '</a></td>';
    echo '<td><a href="' . $myurl . '&amp;sort=title">' . lang('entries', 'title') . '</a></td>';
    echo '<td><a href="' . $myurl . '&amp;sort=category">' . lang('entries', 'category') . '</a></td>';
    echo '<td><a href="' . $myurl . '&amp;sort=user">' . lang('entries', 'author') . '</a></td>';
    echo '<td><a href="' . $myurl . '&amp;sort=date">' . lang('entries', 'date') . '</a></td>';
    echo '<td><a href="' . $myurl . '&amp;sort=commcount">' . lang('entries', 'comm') . '</a></td>';
    echo '<td><a href="' . $myurl . '&amp;sort=trackcount">' . lang('entries', 'track') . '</a></td>';
    echo '</tr>';
    //End Sort Entry Changes
    foreach ($overview_arr as $overview_line) {
        print_row($overview_line);
    }
    echo '<tr class="tabular_header"><td colspan="8"><img src="pics/arrow_ltr.gif" width="29" height="14" border="0" alt="" />';
    echo '<a href="#" onclick=\'setCheckboxes("form1", true); return false;\'>' . lang('forms', 'c_all') . '</a> / ';
    echo '<a href="#" onclick=\'setCheckboxes("form1", false); return false;\'>' . lang('forms', 'c_none') . '</a>';
    echo '&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;' . lang('forms', 'with_checked_entries');
    echo '<select name="action" class="input">
	<option value="" selected="selected">' . lang('forms', 'choose') . '</option>
	<option value="publish">' . lang('forms', 'publish') . '</option>
	<option value="hold" >' . lang('forms', 'hold') . '</option>
	<option value="delete">' . lang('forms', 'delete') . '</option>
	<option value="generate">' . lang('forms', 'generate') . '</option>
			</select>';
    echo '&nbsp;&nbsp;<input type="submit" value="' . lang('go') . '" class="button" /></td></tr>';
    echo '</table></form>';
    PageFooter();
}
Exemplo n.º 3
0
/**
* The screen to edit a weblog, screen 2
*/
function main_blogs_edit2()
{
    global $Cfg, $Pivot_Vars, $blog_settings, $Weblogs, $Current_subweblog;
    PageHeader(lang('weblog_config', 'create_2'));
    PageAnkeiler(lang('userbar', 'admin') . ' &raquo; ' . lang('weblog_config', 'create_2'));
    $temp_weblog = array('name' => stripslashes($Pivot_Vars['name']), 'payoff' => stripslashes($Pivot_Vars['payoff']), 'siteurl' => stripslashes($Pivot_Vars['siteurl']), 'front_filename' => $Pivot_Vars['front_filename'], 'front_path' => fixPathSlash($Pivot_Vars['front_path']), 'ssi_prefix' => $Pivot_Vars['ssi_prefix'], 'language' => $Pivot_Vars['language'], 'live_entries' => $Pivot_Vars['live_entries'], 'entry_filename' => $Pivot_Vars['entry_filename'], 'entry_path' => fixPathSlash($Pivot_Vars['entry_path']), 'read_more' => stripslashes($Pivot_Vars['read_more']), 'archive_filename' => $Pivot_Vars['archive_filename'], 'archive_path' => fixPathSlash($Pivot_Vars['archive_path']), 'archive_unit' => $Pivot_Vars['archive_unit'], 'archive_amount' => $Pivot_Vars['archive_amount'], 'archive_link' => stripslashes($Pivot_Vars['archive_link']), 'archive_linkfile' => stripslashes($Pivot_Vars['archive_linkfile']), 'archive_order' => stripslashes($Pivot_Vars['archive_order']), 'front_template' => $Pivot_Vars['front_template'], 'archive_template' => $Pivot_Vars['archive_template'], 'entry_template' => $Pivot_Vars['entry_template'], 'extra_template' => $Pivot_Vars['extra_template']);
    if (isset($Pivot_Vars['orig_name']) && strlen($Pivot_Vars['orig_name']) > 1) {
        $blog_settings = $Weblogs[$Pivot_Vars['orig_name']];
        $orig_name = $Pivot_Vars['orig_name'];
        MidHeading(sprintf(lang('weblog_config', 'edit_weblog') . ' \'%s\'', $Weblogs[$Pivot_Vars['orig_name']]['name']));
    } else {
        $blog_settings = get_tempweblog();
        $orig_name = "";
        MidHeading(lang('weblog_config', 'create_new'));
    }
    StartForm('blog_edit3', 1);
    StartTable();
    EndForm(lang('go'), 2, lang('weblog_config', 'subw_heading'));
    // initialize the settings array..
    $settings = array();
    $settings[] = array('orig_name', 'originalname', '', 7, $orig_name);
    $settings[] = array('temp_weblog', 'tempweblog', '', 7, urlencode(serialize($temp_weblog)));
    $templates = gettemplates('_sub');
    $categories = cfg_cats();
    $template_html = load_template($temp_weblog['front_template']);
    // to cater for users that upgraded their old templates, we
    // assume [[weblog]] to be [[weblog:standard]]
    $template_html = str_replace("[[weblog]]", "[[weblog:standard]]", $template_html);
    preg_match_all("/\\[\\[(sub)?weblog:([^:]*)(:.*)?\\]\\]/mUi", $template_html, $match);
    $subweblogs = $match[2];
    foreach ($subweblogs as $key) {
        $key = trim($key);
        // if the subweblog is in the template, but not in the config files, assume some defaults
        if (!isset($blog_settings['sub_weblog'][$key])) {
            $blog_settings['sub_weblog'][$key]['template'] = "_sub_entry_standard.html";
            $blog_settings['sub_weblog'][$key]['num_entries'] = 10;
            $blog_settings['sub_weblog'][$key]['comments'] = 1;
            $blog_settings['sub_weblog'][$key]['categories'] = array();
        }
        $subweblog = $blog_settings['sub_weblog'][$key];
        $settings[] = array('heading', $key, '', 8, '', 2);
        $settings[] = array('sub_weblog[' . $key . '][template]', lang('weblog_config', 'shortentry_template'), lang('weblog_config', 'shortentry_template_desc'), 3, $templates, '', $key);
        $settings[] = array('sub_weblog[' . $key . '][num_entries]', lang('weblog_config', 'num_entries'), lang('weblog_config', 'num_entries_desc'), 0, $subweblog['num_entries']);
        $settings[] = array('sub_weblog[' . $key . '][offset]', lang('weblog_config', 'offset'), lang('weblog_config', 'offset_desc'), 0, $subweblog['offset']);
        // JM - 2004/10/15 - lang abstraction inserted
        $settings[] = array('', lang('weblog_config', 'publish_cats'), '', 6);
        $style_nosearch = 'style="background-color:#eee;"';
        // NOTE - include style if a no-index category...
        $cats_nosearch = cfg_cat_nosearchindex();
        foreach ($categories as $category) {
            $label = sprintf('&nbsp;&nbsp;&nbsp;' . $category['name']);
            $name = urlencode($category['name']);
            if (in_array($category['name'], $subweblog['categories'])) {
                $settings[] = array('sub_weblog[' . $key . '][categories][' . $name . ']', $label, '', 2, 1, '', '');
            } else {
                $settings[] = array('sub_weblog[' . $key . '][categories][' . $name . ']', $label, '', 2, 0, '', '');
            }
        }
        $numentries = $blog_settings['sub_weblog'][$key]['num_entries'];
    }
    DisplaySettings($settings, 'blog_settings');
    EndForm(lang('go'), 1);
    PageFooter();
}
Exemplo n.º 4
0
function snippet_category_link($filter = "", $filename = "")
{
    global $Cfg, $db, $Weblogs, $Current_weblog, $Current_subweblog, $Paths;
    if ($filename == "") {
        if ($Cfg['mod_rewrite'] == 0) {
            $filename = $Paths['pivot_url'] . "archive.php?c=";
        } else {
            $filename = $Paths['log_url'] . "category/";
        }
    }
    $output = $db->entry["category"];
    if ($filter != "" && isset($Weblogs[$Current_weblog]['sub_weblog'][$Current_subweblog])) {
        $output = array_intersect($Weblogs[$Current_weblog]['sub_weblog'][$Current_subweblog]['categories'], $output);
    }
    $allcats = cfg_cats();
    foreach ($output as $key => $item) {
        // skip cat if it doesn't exist anymore
        if (!isset($allcats[$item])) {
            unset($output[$key]);
        } else {
            $url = $filename . para_category($item);
            // check if a weblog parameter is needed for the current category/weblog combo
            if (para_weblog_needed($Current_weblog, $item)) {
                if ($Cfg['mod_rewrite'] == 0) {
                    $url .= "&amp;w=" . para_weblog($Current_weblog, $item);
                } else {
                    $url .= "/?w=" . para_weblog($Current_weblog, $item);
                }
            }
            $output[$key] = sprintf("<a href=\"{$url}\">%s</a>", encode_text($item));
        }
    }
    if (is_array($output)) {
        return implode(", ", $output);
    } else {
        return "";
    }
}
Exemplo n.º 5
0
/**
 * Returns the number of categories
 *
 * @return int
 */
function get_categories_num()
{
    return count(cfg_cats());
}