コード例 #1
0
/**
 * navigation list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Navigation
 * @author Henry Ruhs
 *
 * @param string $table
 * @param array $options
 */
function navigation_list($table = '', $options = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    }
    /* fallback */
    if ($option_order == '') {
        $option_order = s('order');
    }
    if ($option_limit == '') {
        $option_limit = s('limit');
    }
    /* switch table */
    switch ($table) {
        case 'categories':
            $wording_single = 'category';
            $query_parent = 'parent';
            break;
        case 'articles':
            $wording_single = 'article';
            $query_parent = 'category';
            break;
        case 'comments':
            $wording_single = 'comment';
            $query_parent = 'article';
            break;
    }
    /* query contents */
    $contents = Redaxscript\Db::forTablePrefix($table)->where('status', 1)->whereIn('language', array(Redaxscript\Registry::get('language'), ''));
    /* setup parent */
    if ($query_parent) {
        if ($option_parent) {
            $contents->where($query_parent, $option_parent);
        } else {
            if ($table == 'categories') {
                $contents->where($query_parent, 0);
            }
        }
    }
    /* setup query filter */
    if ($table == 'categories' || $table == 'articles') {
        /* setup filter alias option */
        if ($option_filter_alias) {
            $contents->whereIn('alias', $option_filter_alias);
        }
        /* setup filter rank option */
        if ($option_filter_rank) {
            $contents->whereIn('rank', $option_filter_rank);
        }
    }
    /* setup rank and limit */
    if ($option_order === 'asc') {
        $contents->orderByAsc('rank');
    } else {
        $contents->orderByDesc('rank');
    }
    $contents->limit($option_limit);
    /* query result */
    $result = $contents->findArray();
    $num_rows = count($result);
    if ($result == '' || $num_rows == '') {
        $error = l($wording_single . '_no') . l('point');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            foreach ($result as $r) {
                $access = $r['access'];
                /* if access granted */
                if ($accessValidator->validate($access, MY_GROUPS) === Redaxscript\Validator\ValidatorInterface::PASSED) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                    /* build class string */
                    if (LAST_PARAMETER == $alias && $table != 'comments') {
                        $class_string = ' class="item_active"';
                    } else {
                        $class_string = '';
                    }
                    /* prepare metadata */
                    if ($table == 'comments') {
                        $description = $title = truncate($author . l('colon') . ' ' . strip_tags($text), 80, '...');
                    }
                    if ($description == '') {
                        $description = $title;
                    }
                    /* build route */
                    if ($table == 'categories' && $parent == 0 || $table == 'articles' && $category == 0) {
                        $route = $alias;
                    } else {
                        $route = build_route($table, $id);
                    }
                    /* collect item output */
                    $output .= '<li' . $class_string . '>' . anchor_element('internal', '', '', $title, $route, $description);
                    /* collect children list output */
                    if ($table == 'categories' && $option_children == 1) {
                        ob_start();
                        navigation_list($table, array('parent' => $id, 'class' => 'list_children'));
                        $output .= ob_get_clean();
                    }
                    $output .= '</li>';
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows == $counter) {
                $error = l('access_no') . l('point');
            }
        }
    }
    /* build id string */
    if ($option_id) {
        $id_string = ' id="' . $option_id . '"';
    }
    /* build class string */
    if ($option_class) {
        $class_string = ' class="' . $option_class . '"';
    } else {
        $class_string = ' class="list_' . $table . '"';
    }
    /* handle error */
    if ($error && $option_parent == '') {
        $output = '<ul' . $id_string . $class_string . '><li>' . $error . '</li></ul>';
    } else {
        if ($output) {
            $output = '<ul' . $id_string . $class_string . '>' . $output . '</ul>';
        }
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
コード例 #2
0
ファイル: navigation.php プロジェクト: redaxmedia/redaxscript
/**
 * navigation list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Navigation
 * @author Henry Ruhs
 *
 * @param string $table
 * @param array $options
 */
function navigation_list($table, $options)
{
    $output = Redaxscript\Hook::trigger('navigationStart');
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    }
    /* fallback */
    if (!$option_order) {
        $option_order = Redaxscript\Db::getSetting('order');
    }
    if (!$option_limit) {
        $option_limit = Redaxscript\Db::getSetting('limit');
    }
    /* switch table */
    switch ($table) {
        case 'categories':
            $wording_single = 'category';
            $query_parent = 'parent';
            break;
        case 'articles':
            $wording_single = 'article';
            $query_parent = 'category';
            break;
        case 'comments':
            $wording_single = 'comment';
            $query_parent = 'article';
            break;
    }
    /* query contents */
    $contents = Redaxscript\Db::forTablePrefix($table)->where('status', 1)->whereLanguageIs(Redaxscript\Registry::get('language'));
    /* setup parent */
    if ($query_parent) {
        if ($option_parent) {
            $contents->where($query_parent, $option_parent);
        } else {
            if ($table == 'categories') {
                $contents->whereNull($query_parent);
            }
        }
    }
    /* setup query filter */
    if ($table == 'categories' || $table == 'articles') {
        /* setup filter alias option */
        if ($option_filter_alias) {
            $contents->whereIn('alias', $option_filter_alias);
        }
        /* setup filter rank option */
        if ($option_filter_rank) {
            $contents->whereIn('rank', $option_filter_rank);
        }
    }
    /* setup rank and limit */
    if ($option_order === 'asc') {
        $contents->orderByAsc('rank');
    } else {
        $contents->orderByDesc('rank');
    }
    $contents->limit($option_limit);
    /* query result */
    $result = $contents->findArray();
    $num_rows = count($result);
    if (!$result || !$num_rows) {
        $error = Redaxscript\Language::get($wording_single . '_no') . Redaxscript\Language::get('point');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            foreach ($result as $r) {
                $access = $r['access'];
                /* access granted */
                if ($accessValidator->validate($access, Redaxscript\Registry::get('myGroups')) === Redaxscript\Validator\ValidatorInterface::PASSED) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                    /* build class string */
                    if (Redaxscript\Registry::get('lastParameter') == $alias && $table != 'comments') {
                        $class_string = ' class="rs-item-active"';
                    } else {
                        $class_string = null;
                    }
                    /* prepare metadata */
                    if ($table == 'comments') {
                        $description = $title = $author . Redaxscript\Language::get('colon') . ' ' . strip_tags($text);
                    }
                    if (!$description) {
                        $description = $title;
                    }
                    /* build route */
                    if ($table == 'categories' && $parent == 0 || $table == 'articles' && $category == 0) {
                        $route = $alias;
                    } else {
                        $route = build_route($table, $id);
                    }
                    /* collect item output */
                    $output .= '<li' . $class_string . '><a href="' . Redaxscript\Registry::get('parameterRoute') . $route . '">' . $title . '</a>';
                    /* collect children list output */
                    if ($table == 'categories' && $option_children == 1) {
                        ob_start();
                        navigation_list($table, ['parent' => $id, 'class' => 'rs-list-children']);
                        $output .= ob_get_clean();
                    }
                    $output .= '</li>';
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows == $counter) {
                $error = Redaxscript\Language::get('access_no') . Redaxscript\Language::get('point');
            }
        }
    }
    /* build id string */
    if ($option_id) {
        $id_string = ' id="' . $option_id . '"';
    }
    /* build class string */
    if ($option_class) {
        $class_string = ' class="' . $option_class . '"';
    } else {
        $class_string = ' class="rs-list-' . $table . '"';
    }
    /* handle error */
    if ($error && !$option_parent) {
        $output = '<ul' . $id_string . $class_string . '><li><span>' . $error . '</span></li></ul>';
    } else {
        if ($output) {
            $output = '<ul' . $id_string . $class_string . '>' . $output . '</ul>';
        }
    }
    $output .= Redaxscript\Hook::trigger('navigationEnd');
    echo $output;
}
コード例 #3
0
ファイル: navigation.php プロジェクト: ITw3/redaxscript
/**
 * navigation list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Navigation
 * @author Henry Ruhs
 *
 * @param string $table
 * @param array $options
 */
function navigation_list($table = '', $options = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    }
    /* fallback */
    if ($option_order == '') {
        $option_order = s('order');
    }
    if ($option_limit == '') {
        $option_limit = s('limit');
    }
    /* switch table */
    switch ($table) {
        case 'categories':
            $wording_single = 'category';
            $query_parent = 'parent';
            break;
        case 'articles':
            $wording_single = 'article';
            $query_parent = 'category';
            break;
        case 'comments':
            $wording_single = 'comment';
            $query_parent = 'article';
            break;
    }
    /* query contents */
    $query = 'SELECT * FROM ' . PREFIX . $table . ' WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && status = 1';
    /* setup parent */
    if ($query_parent) {
        if ($option_parent) {
            $query .= ' && ' . $query_parent . ' = ' . $option_parent;
        } else {
            if ($table == 'categories') {
                $query .= ' && ' . $query_parent . ' = 0';
            }
        }
    }
    /* setup query filter */
    if ($table == 'categories' || $table == 'articles') {
        /* setup filter alias option */
        if ($option_filter_alias) {
            $query .= ' && alias IN (' . $option_filter_alias . ')';
        }
        /* setup filter rank option */
        if ($option_filter_rank) {
            $query .= ' && rank IN (' . $option_filter_rank . ')';
        }
    }
    /* setup rank and limit */
    $query .= ' ORDER BY rank ' . $option_order . ' LIMIT ' . $option_limit;
    /* query result */
    $result = mysql_query($query);
    $num_rows = mysql_num_rows($result);
    if ($result == '' || $num_rows == '') {
        $error = l($wording_single . '_no') . l('point');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            while ($r = mysql_fetch_assoc($result)) {
                $access = $r['access'];
                $check_access = $accessValidator->validate($access, MY_GROUPS);
                /* if access granted */
                if ($check_access == 1) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                    /* build class string */
                    if (LAST_PARAMETER == $alias && $table != 'comments') {
                        $class_string = ' class="item_active"';
                    } else {
                        $class_string = '';
                    }
                    /* prepare metadata */
                    if ($table == 'comments') {
                        $description = $title = truncate($author . l('colon') . ' ' . strip_tags($text), 80, '...');
                    }
                    if ($description == '') {
                        $description = $title;
                    }
                    /* build route */
                    if ($table == 'categories' && $parent == 0 || $table == 'articles' && $category == 0) {
                        $route = $alias;
                    } else {
                        $route = build_route($table, $id);
                    }
                    /* collect item output */
                    $output .= '<li' . $class_string . '>' . anchor_element('internal', '', '', $title, $route, $description);
                    /* collect children list output */
                    if ($table == 'categories' && $option_children == 1) {
                        ob_start();
                        navigation_list($table, array('parent' => $id, 'class' => 'list_children'));
                        $output .= ob_get_clean();
                    }
                    $output .= '</li>';
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows == $counter) {
                $error = l('access_no') . l('point');
            }
        }
    }
    /* build id string */
    if ($option_id) {
        $id_string = ' id="' . $option_id . '"';
    }
    /* build class string */
    if ($option_class) {
        $class_string = ' class="' . $option_class . '"';
    } else {
        $class_string = ' class="list_' . $table . '"';
    }
    /* handle error */
    if ($error && $option_parent == '') {
        $output = '<ul' . $id_string . $class_string . '><li>' . $error . '</li></ul>';
    } else {
        if ($output) {
            $output = '<ul' . $id_string . $class_string . '>' . $output . '</ul>';
        }
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
コード例 #4
0
ファイル: index.php プロジェクト: ITw3/redaxscript
/**
 * sitemap
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @return string
 */
function sitemap()
{
    /* query categories */
    $categories_query = 'SELECT id, title, alias, description, access FROM ' . PREFIX . 'categories WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && status = 1 && parent = 0 ORDER BY rank ASC';
    $categories_result = mysql_query($categories_query);
    $categories_num_rows = mysql_num_rows($categories_result);
    /* collect output */
    $output = form_element('fieldset', '', 'set_sitemap', '', '', '<span class="title_content_sub title_sitemap_sub">' . l('categories') . '</span>') . '<ul class="list_default list_sitemap">';
    if ($categories_result == '' || $categories_num_rows == '') {
        $categories_error = l('category_no') . l('point');
    } else {
        if ($categories_result) {
            $accessValidator = new Redaxscript\Validator\Access();
            while ($r = mysql_fetch_assoc($categories_result)) {
                $access = $r['access'];
                $check_access = $accessValidator->validate($access, MY_GROUPS);
                /* if access granted */
                if ($check_access == 1) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                    if ($description == '') {
                        $description = $title;
                    }
                    /* collect item output */
                    $output .= '<li>' . anchor_element('internal', '', '', $title, $alias, $description);
                    /* collect children list output */
                    ob_start();
                    navigation_list('categories', array('parent' => $id, 'class' => 'list_children'));
                    navigation_list('articles', array('parent' => $id, 'class' => 'list_children'));
                    $output .= ob_get_clean();
                    $output .= '</li>';
                } else {
                    $categories_counter++;
                }
            }
            /* handle access */
            if ($categories_num_rows == $categories_counter) {
                $categories_error = l('access_no') . l('point');
            }
        }
    }
    /* handle error */
    if ($categories_error) {
        $output .= '<li>' . $categories_error . '</li>';
    }
    $output .= '</ul></fieldset>';
    /* query articles */
    $articles_query = 'SELECT id, title, alias, description, access FROM ' . PREFIX . 'articles WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && status = 1 && category = 0 ORDER BY rank ASC';
    $articles_result = mysql_query($articles_query);
    $articles_num_rows = mysql_num_rows($articles_result);
    /* collect output */
    $output .= form_element('fieldset', '', 'set_sitemap', '', '', '<span class="title_content_sub title_sitemap_sub">' . l('uncategorized') . '</span>') . '<ul class="list_default list_sitemap">';
    if ($articles_result == '' || $articles_num_rows == '') {
        $articles_error = l('article_no') . l('point');
    } else {
        if ($articles_result) {
            while ($r = mysql_fetch_assoc($articles_result)) {
                $access = $r['access'];
                $check_access = $accessValidator->validate($access, MY_GROUPS);
                /* if access granted */
                if ($check_access == 1) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                    if ($description == '') {
                        $description = $title;
                    }
                    /* collect item output */
                    $output .= '<li>' . anchor_element('internal', '', '', $title, $alias, $description) . '</li>';
                } else {
                    $articles_counter++;
                }
            }
            /* handle access */
            if ($articles_num_rows == $articles_counter) {
                $articles_error = l('access_no') . l('point');
            }
        }
    }
    /* handle error */
    if ($articles_error) {
        $output .= '<li>' . $articles_error . '</li>';
    }
    $output .= '</ul></fieldset>';
    return $output;
}