/**
 * contents
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Contents
 * @author Henry Ruhs
 */
function contents()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    $aliasValidator = new Redaxscript\Validator\Alias();
    /* query articles */
    $articles = Redaxscript\Db::forTablePrefix('articles')->where('status', 1);
    $articles->whereIn('language', array(Redaxscript\Registry::get('language'), ''));
    /* handle sibling */
    if (LAST_ID) {
        $sibling = Redaxscript\Db::forTablePrefix(LAST_TABLE)->where('id', LAST_ID)->findOne()->sibling;
        /* query sibling collection */
        $sibling_array = Redaxscript\Db::forTablePrefix(LAST_TABLE)->whereIn('sibling', array(LAST_ID, $sibling > 0 ? $sibling : null))->where('language', Redaxscript\Registry::get('language'))->select('id')->findArrayFlat();
        /* process sibling array */
        foreach ($sibling_array as $value) {
            $id_array[] = $value;
        }
    }
    /* handle article */
    if (ARTICLE) {
        $id_array[] = $sibling;
        $id_array[] = ARTICLE;
        $articles->whereIn('id', $id_array);
    } else {
        if (CATEGORY) {
            if (!$id_array) {
                if ($sibling > 0) {
                    $id_array[] = $sibling;
                } else {
                    $id_array[] = CATEGORY;
                }
            }
            $articles->whereIn('category', $id_array)->orderGlobal('rank');
            /* handle sub parameter */
            $result = $articles->findArray();
            if ($result) {
                $num_rows = count($result);
                $sub_maximum = ceil($num_rows / s('limit'));
                $sub_active = LAST_SUB_PARAMETER;
                /* sub parameter */
                if (LAST_SUB_PARAMETER > $sub_maximum || LAST_SUB_PARAMETER == '') {
                    $sub_active = 1;
                } else {
                    $offset_string = ($sub_active - 1) * s('limit') . ', ';
                }
            }
            $articles->limit($offset_string . s('limit'));
        } else {
            $articles->limit(0);
        }
    }
    /* query result */
    $result = $articles->findArray();
    $num_rows_active = count($result);
    /* handle error */
    if (CATEGORY && $num_rows == '') {
        $error = l('article_no');
    } else {
        if ($result == '' || $num_rows_active == '' || CONTENT_ERROR) {
            $error = l('content_not_found');
        } else {
            if ($result) {
                $accessValidator = new Redaxscript\Validator\Access();
                foreach ($result as $r) {
                    $access = $r['access'];
                    /* access granted */
                    if ($accessValidator->validate($access, MY_GROUPS) === Redaxscript\Validator\ValidatorInterface::PASSED) {
                        if ($r) {
                            foreach ($r as $key => $value) {
                                ${$key} = stripslashes($value);
                            }
                        }
                        if (LAST_TABLE == 'categories' || FULL_ROUTE == '' || $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::PASSED) {
                            $route = build_route('articles', $id);
                        }
                        /* parser object */
                        $parser = new Redaxscript\Parser(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                        $parser->init($text, array('className' => array('readmore' => 'link_read_more', 'codequote' => 'js_code_quote box_code'), 'route' => $route));
                        /* collect headline output */
                        $output .= Redaxscript\Hook::trigger('article_start', $r);
                        if ($headline == 1) {
                            $output .= '<h2 class="title_content" id="article-' . $alias . '">';
                            if (LAST_TABLE == 'categories' || FULL_ROUTE == '' || $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::PASSED) {
                                $output .= anchor_element('internal', '', '', $title, $route);
                            } else {
                                $output .= $title;
                            }
                            $output .= '</h2>';
                        }
                        /* collect box output */
                        $output .= '<div class="box_content">' . $parser->getOutput();
                        $output .= '</div>' . Redaxscript\Hook::trigger('article_end', $r);
                        /* prepend admin dock */
                        if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') {
                            $output .= admin_dock('articles', $id);
                        }
                        /* infoline */
                        if ($infoline == 1) {
                            $output .= infoline('articles', $id, $author, $date);
                        }
                    } else {
                        $counter++;
                    }
                }
                /* handle access */
                if (LAST_TABLE == 'categories') {
                    if ($num_rows_active == $counter) {
                        $error = l('access_no');
                    }
                } else {
                    if (LAST_TABLE == 'articles' && $counter == 1) {
                        $error = l('access_no');
                    }
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        notification(l('something_wrong'), $error);
    } else {
        $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
        echo $output;
        /* call comments as needed */
        if (ARTICLE) {
            /* comments replace */
            if ($comments == 1 && (COMMENTS_REPLACE == 1 || Redaxscript\Registry::get('commentsReplace'))) {
                Redaxscript\Hook::trigger('comments_replace');
            } else {
                if ($comments > 0) {
                    $route = build_route('articles', ARTICLE);
                    comments(ARTICLE, $route);
                    /* comment form */
                    if ($comments == 1 || COMMENTS_NEW == 1 && $comments == 3) {
                        comment_form(ARTICLE, $language);
                    }
                }
            }
        }
    }
    /* call pagination as needed */
    if ($sub_maximum > 1 && s('pagination') == 1) {
        $route = build_route('categories', CATEGORY);
        pagination($sub_active, $sub_maximum, $route);
    }
}
Example #2
0
/**
 * contents
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Contents
 * @author Henry Ruhs
 */
function contents()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    $aliasValidator = new Redaxscript\Validator\Alias();
    /* query contents */
    $query = 'SELECT id, title, author, text, language, date, headline, infoline, comments, access FROM ' . PREFIX . 'articles WHERE status = 1';
    if (ARTICLE) {
        $query .= ' && id = ' . ARTICLE;
    } else {
        if (CATEGORY) {
            $query .= ' && (language = \'' . LANGUAGE . '\' || language = \'\') && category = ' . CATEGORY . ' ORDER BY rank ' . s('order');
            $result = mysql_query($query);
            if ($result) {
                $num_rows = mysql_num_rows($result);
                $sub_maximum = ceil($num_rows / s('limit'));
                $sub_active = LAST_SUB_PARAMETER;
                /* if sub parameter */
                if (LAST_SUB_PARAMETER > $sub_maximum || LAST_SUB_PARAMETER == '') {
                    $sub_active = 1;
                } else {
                    $offset_string = ($sub_active - 1) * s('limit') . ', ';
                }
            }
            $query .= ' LIMIT ' . $offset_string . s('limit');
        } else {
            $query .= ' LIMIT 0';
        }
    }
    $result = mysql_query($query);
    $num_rows_active = mysql_num_rows($result);
    /* handle error */
    if (DB_CONNECTED == 0) {
        $error = l('database_failed');
    } else {
        if (CATEGORY && $num_rows == '') {
            $error = l('article_no');
        } else {
            if ($result == '' || $num_rows_active == '' || CONTENT_ERROR) {
                $error = l('content_not_found');
            } 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);
                                }
                            }
                            if (LAST_TABLE == 'categories' || FULL_ROUTE == '' || $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\Validator::PASSED) {
                                $route = build_route('articles', $id);
                            }
                            /* parser object */
                            $parser = new Redaxscript\Parser(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), $text, $route, array('className' => array('break' => 'link_read_more', 'code' => 'box_code')));
                            /* collect headline output */
                            $output .= Redaxscript\Hook::trigger('article_start', $id);
                            if ($headline == 1) {
                                $output .= '<h2 class="title_content">';
                                if (LAST_TABLE == 'categories' || FULL_ROUTE == '' || $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\Validator::PASSED) {
                                    $output .= anchor_element('internal', '', '', $title, $route);
                                } else {
                                    $output .= $title;
                                }
                                $output .= '</h2>';
                            }
                            /* collect box output */
                            $output .= '<div class="box_content">' . $parser->getOutput();
                            $output .= '</div>' . Redaxscript\Hook::trigger('article_end', $id);
                            /* prepend admin dock */
                            if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') {
                                $output .= admin_dock('articles', $id);
                            }
                            /* infoline */
                            if ($infoline == 1) {
                                $output .= infoline('articles', $id, $author, $date);
                            }
                        } else {
                            $counter++;
                        }
                    }
                    /* handle access */
                    if (LAST_TABLE == 'categories') {
                        if ($num_rows_active == $counter) {
                            $error = l('access_no');
                        }
                    } else {
                        if (LAST_TABLE == 'articles' && $counter == 1) {
                            $error = l('access_no');
                        }
                    }
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        notification(l('something_wrong'), $error);
    } else {
        $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
        echo $output;
        /* call comments as needed */
        if (ARTICLE) {
            /* comments replace */
            if ($comments == 1 && COMMENTS_REPLACE == 1) {
                Redaxscript\Hook::trigger('comments_replace');
            } else {
                if ($comments > 0) {
                    $route = build_route('articles', ARTICLE);
                    comments(ARTICLE, $route);
                    /* comment form */
                    if ($comments == 1 || COMMENTS_NEW == 1 && $comments == 3) {
                        comment_form(ARTICLE, $language, $access);
                    }
                }
            }
        }
    }
    /* call pagination as needed */
    if ($sub_maximum > 1 && s('pagination') == 1) {
        $route = build_route('categories', CATEGORY);
        pagination($sub_active, $sub_maximum, $route);
    }
}
/**
 * comments
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Comments
 * @author Henry Ruhs
 *
 * @param integer $article
 * @param string $route
 */
function comments($article = '', $route = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* query comments */
    $comments = Redaxscript\Db::forTablePrefix('comments')->where(array('status' => 1, 'article' => $article))->whereIn('language', array(Redaxscript\Registry::get('language'), ''))->orderGlobal('rank');
    /* query result */
    $result = $comments->findArray();
    if ($result) {
        $num_rows = count($result);
        $sub_maximum = ceil($num_rows / s('limit'));
        $sub_active = LAST_SUB_PARAMETER;
        /* sub parameter */
        if (LAST_SUB_PARAMETER > $sub_maximum || LAST_SUB_PARAMETER == '') {
            $sub_active = 1;
        } else {
            $offset_string = ($sub_active - 1) * s('limit') . ', ';
        }
    }
    $comments->limit($offset_string . s('limit'));
    /* query result */
    $result = $comments->findArray();
    $num_rows_active = count($result);
    /* handle error */
    if ($result == '' || $num_rows == '') {
        $error = l('comment_no');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            $output .= '<div class="box_line"></div>';
            foreach ($result as $r) {
                $access = $r['access'];
                /* access granted */
                if ($accessValidator->validate($access, MY_GROUPS) === Redaxscript\Validator\ValidatorInterface::PASSED) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                    /* collect headline output */
                    $output .= Redaxscript\Hook::trigger('comment_start', $r) . '<h3 id="comment-' . $id . '" class="title_comment">';
                    if ($url) {
                        $output .= anchor_element('external', '', '', $author, $url, '', 'rel="nofollow"');
                    } else {
                        $output .= $author;
                    }
                    $output .= '</h3>';
                    /* collect box output */
                    $output .= infoline('comments', $id, $author, $date);
                    $output .= '<div class="box_comment">' . $text . '</div>' . Redaxscript\Hook::trigger('comment_end', $r);
                    /* admin dock */
                    if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') {
                        $output .= admin_dock('comments', $id);
                    }
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows_active == $counter) {
                $error = l('access_no');
            }
        }
    }
    /* handle error */
    if ($error) {
        $output = '<div class="box_comment_error">' . $error . l('point') . '</div>';
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
    /* call pagination as needed */
    if ($sub_maximum > 1 && s('pagination') == 1) {
        pagination($sub_active, $sub_maximum, $route);
    }
}
Example #4
0
/**
 * comments
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Comments
 * @author Henry Ruhs
 *
 * @param integer $article
 * @param string $route
 */
function comments($article = '', $route = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* query comments */
    $query = 'SELECT id, author, url, text, date, article, access FROM ' . PREFIX . 'comments WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && article = ' . $article . ' && status = 1 ORDER BY rank ' . s('order');
    $result = mysql_query($query);
    if ($result) {
        $num_rows = mysql_num_rows($result);
        $sub_maximum = ceil($num_rows / s('limit'));
        $sub_active = LAST_SUB_PARAMETER;
        /* if sub parameter */
        if (LAST_SUB_PARAMETER > $sub_maximum || LAST_SUB_PARAMETER == '') {
            $sub_active = 1;
        } else {
            $offset_string = ($sub_active - 1) * s('limit') . ', ';
        }
    }
    $query .= ' LIMIT ' . $offset_string . s('limit');
    $result = mysql_query($query);
    $num_rows_active = mysql_num_rows($result);
    /* handle error */
    if ($result == '' || $num_rows == '') {
        $error = l('comment_no');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            $output .= '<div class="box_line"></div>';
            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);
                        }
                    }
                    /* collect headline output */
                    $output .= Redaxscript\Hook::trigger('comment_start', $id) . '<h3 id="comment-' . $id . '" class="title_comment">';
                    if ($url) {
                        $output .= anchor_element('external', '', '', $author, $url, '', 'rel="nofollow"');
                    } else {
                        $output .= $author;
                    }
                    $output .= '</h3>';
                    /* collect box output */
                    $output .= infoline('comments', $id, $author, $date);
                    $output .= '<div class="box_comment">' . $text . '</div>' . Redaxscript\Hook::trigger('comment_end', $id);
                    /* admin dock */
                    if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') {
                        $output .= admin_dock('comments', $id);
                    }
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows_active == $counter) {
                $error = l('access_no');
            }
        }
    }
    /* handle error */
    if ($error) {
        $output = '<div class="box_comment_error">' . $error . l('point') . '</div>';
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
    /* call pagination as needed */
    if ($sub_maximum > 1 && s('pagination') == 1) {
        pagination($sub_active, $sub_maximum, $route);
    }
}