コード例 #1
0
function SQLmenuABCpages($letra, $args = '')
{
    global $DBCFG;
    global $CFG;
    $letra = ctype_digit($letra) ? $letra : secure_data($letra, "ADOsql");
    $defaults = array("min" => 0, "limit" => 50);
    $args = t3_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $min = 0 < (int) $min ? (int) $min : 0;
    $limit = 50 <= (int) $limit ? (int) $limit : 50;
    $where_letter = ctype_digit($letra) ? " LEFT(tema.tema,1) REGEXP '[[:digit:]]' " : " LEFT(tema.tema,1)={$letra} ";
    $where = "";
    if (!$_SESSION[$_SESSION["CFGURL"]][ssuser_id]) {
        //Control de estados
        $where = " and tema.estado_id='13' ";
        //hide hidden equivalent terms
        if (count($CFG["HIDDEN_EQ"]) > 0) {
            $hidden_labels = implode("','", $CFG["HIDDEN_EQ"]);
            $hidden_labels = '\'' . $hidden_labels . '\'';
            $leftJoin = "left join {$DBCFG['DBprefix']}values trr on trr.value_id=relaciones.rel_rel_id and trr.value_code in ({$hidden_labels}) ";
            $where .= " and trr.value_id is null ";
        }
    }
    $sql = SQL("select", "if(relaciones.id is not null,relaciones.id_menor,tema.tema_id) id_definitivo,\r\n\ttema.tema_id,\r\n\ttema.tema,\r\n\ttema.estado_id,\r\n\ttema.isMetaTerm,\r\n\trelaciones.t_relacion,\r\n\ttemasPreferidos.tema as termino_preferido\r\n\tfrom {$DBCFG['DBprefix']}tema as tema\r\n\tleft join {$DBCFG['DBprefix']}tabla_rel as relaciones on relaciones.id_mayor=tema.tema_id and relaciones.t_relacion in (4,5,6,7,8)\r\n\tleft join {$DBCFG['DBprefix']}tema as temasPreferidos on temasPreferidos.tema_id=relaciones.id_menor\r\n\tand tema.tema_id=relaciones.id_mayor\r\n\t{$leftJoin}\r\n\twhere\r\n\t{$where_letter}\r\n\t{$where}\r\n\tgroup by tema.tema_id\r\n\torder by lower(tema.tema)\r\n\tlimit {$min},{$limit}");
    return $sql;
}
コード例 #2
0
/**
* Retrieve paginated link for archive post pages.
*
* Technically, the function can be used to create paginated link list for any
* area. The 'base' argument is used to reference the url, which will be used to
* create the paginated links. The 'format' argument is then used for replacing
* the page number. It is however, most likely and by default, to be used on the
* archive post pages.
*
* The 'type' argument controls format of the returned value. The default is
* 'plain', which is just a string with the links separated by a newline
* character. The other possible values are either 'array' or 'list'. The
* 'array' value will return an array of the paginated link list to offer full
* control of display. The 'list' value will place all of the paginated links in
* an unordered HTML list.
*
* The 'total' argument is the total amount of pages and is an integer. The
* 'current' argument is the current page number and is also an integer.
*
* An example of the 'base' argument is "http://example.com/all_posts.php%_%"
* and the '%_%' is required. The '%_%' will be replaced by the contents of in
* the 'format' argument. An example for the 'format' argument is "?page=%#%"
* and the '%#%' is also required. The '%#%' will be replaced with the page
* number.
*
* You can include the previous and next links in the list by setting the
* 'prev_next' argument to true, which it is by default. You can set the
* previous text, by using the 'prev_text' argument. You can set the next text
* by setting the 'next_text' argument.
*
* If the 'show_all' argument is set to true, then it will show all of the pages
* instead of a short list of the pages near the current page. By default, the
* 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
* arguments. The 'end_size' argument is how many numbers on either the start
* and the end list edges, by default is 1. The 'mid_size' argument is how many
* numbers to either side of current page, but not including current page.
*
* It is possible to add query vars to the link by using the 'add_args' argument
* and see {@link add_query_arg()} for more information.
*
* @since 2.1.0
*
* @param string|array $args Optional. Override defaults.
* @return array|string String of page links or array of page links.
* http://codex.wordpress.org/Function_Reference/paginate_links
*/
function paginate_links($args = '')
{
    $defaults = array('base' => '%_%', 'format' => '?letra=%#%', 'total' => 1, 'current' => 0, 'show_all' => false, 'prev_next' => true, 'prev_text' => '&laquo; ' . ucfirst(LABEL_Prev), 'next_text' => ucfirst(LABEL_Next) . ' &raquo;', 'end_size' => 1, 'mid_size' => 2, 'type' => 'plain', 'add_args' => false, 'add_fragment' => '');
    $args = t3_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    // Who knows what else people pass in $args
    $total = (int) $total;
    if ($total < 1) {
        return;
    }
    $current = (int) $current;
    $end_size = 0 < (int) $end_size ? (int) $end_size : 1;
    // Out of bounds?  Make it the default.
    $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
    $r = '';
    $page_links = array();
    $n = 0;
    $dots = false;
    if ($prev_next && $current && 1 < $current) {
        $link = str_replace('%_%', 2 == $current ? '' : $format, $base);
        $link = str_replace('%#%', $current - 1, $link);
        $link .= $add_fragment;
        $page_links[] = '<a class="previous-off" href="' . $link . '" title="' . $prev_text . '">' . $prev_text . '</a>';
    }
    for ($n = 1; $n <= $total + 1; $n++) {
        $n_display = $n;
        if ($n == $current) {
            $page_links[] = "<span class='page-numbers active'>{$n_display}</span>";
            $dots = true;
        } else {
            if ($show_all || ($n <= $end_size || $current && $n >= $current - $mid_size && $n <= $current + $mid_size || $n > $total - $end_size)) {
                $link = str_replace('%_%', 1 == $n ? '' : $format, $base);
                $link = str_replace('%#%', $n, $link);
                $link .= $add_fragment;
                $page_links[] = '<a class="page-numbers" href="' . $link . '" title="' . LABEL_PageNum . ' ' . $n_display . '">' . $n_display . '</a>';
                $dots = true;
            } elseif ($dots && !$show_all) {
                $page_links[] = '<span class="page-numbers dots">&hellip;</span>';
                $dots = false;
            }
        }
    }
    if ($prev_next && $current && ($current <= $total || -1 == $total)) {
        $link = str_replace('%_%', $format, $base);
        $link = str_replace('%#%', $current + 1, $link);
        $link .= $add_fragment;
        $page_links[] = '<a class="next-off" href="' . $link . '" title="' . $next_text . '">' . $next_text . '</a>';
    }
    switch ($type) {
        case 'array':
            return $page_links;
            break;
        case 'list':
            $r .= "<ul class='pagination pagination-sm'>\n\t<li>";
            $r .= join("</li>\n\t<li>", $page_links);
            $r .= "</li>\n</ul>\n";
            break;
        default:
            $r = join("\n", $page_links);
            break;
    }
    return $r;
}