/** * feed list * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Modules * @author Henry Ruhs */ function feed_list() { $articles_total = query_total('articles', 'access', 0); $comments_total = query_total('comments', 'access', 0); /* collect output */ if ($articles_total > 0) { $output = '<li>' . anchor_element('internal', '', '', l('feed_articles', 'feed_generator'), 'feed/articles', '', 'rel="nofollow"') . '</li>'; } if ($comments_total > 0) { $output .= '<li>' . anchor_element('internal', '', '', l('feed_comments', 'feed_generator'), 'feed/comments', '', 'rel="nofollow"') . '</li>'; } if ($articles_total > 0 || $comments_total > 0) { $output = '<ul class="list_feed">' . $output . '</ul>'; } echo $output; }
/** * admin routing * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_routing() { /* call last update */ if (FIRST_PARAMETER == 'admin' && ADMIN_PARAMETER == '' || ADMIN_PARAMETER == 'view' && TABLE_PARAMETER == 'users' || UPDATE == '') { admin_last_update(); } /* validate routing */ switch (true) { case ADMIN_PARAMETER && in_array(ADMIN_PARAMETER, array('new', 'view', 'edit', 'up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable', 'install', 'uninstall', 'delete', 'process', 'update')) == '': case ADMIN_PARAMETER == 'process' && $_POST['new'] == '' && $_POST['edit'] == '': case ADMIN_PARAMETER == 'update' && $_POST['update'] == '': case ADMIN_PARAMETER && in_array(TABLE_PARAMETER, array('categories', 'articles', 'extras', 'comments', 'groups', 'users', 'modules', 'settings')) == '': case ALIAS_PARAMETER == '' && (ADMIN_PARAMETER == 'install' || ADMIN_PARAMETER == 'uninstall'): case ID_PARAMETER == '' && in_array(ADMIN_PARAMETER, array('edit', 'up', 'down', 'publish', 'unpublish', 'enable', 'disable')) && TABLE_PARAMETER != 'settings': case is_numeric(ID_PARAMETER) && retrieve('id', TABLE_PARAMETER, 'id', ID_PARAMETER) == '': notification(l('something_wrong'), '', l('back'), 'admin'); return; } /* define access variables */ if (ADMIN_PARAMETER && TABLE_PARAMETER) { if (TABLE_PARAMETER == 'modules') { $install = MODULES_INSTALL; $uninstall = MODULES_UNINSTALL; } else { if (TABLE_PARAMETER != 'settings') { $new = TABLE_NEW; if (TABLE_PARAMETER == 'comments') { $articles_total = query_total('articles'); $articles_comments_disable = query_total('articles', 'comments', 0); if ($articles_total == $articles_comments_disable) { $new = 0; } } $delete = TABLE_DELETE; } } $edit = TABLE_EDIT; } if ($edit == 1 || $delete == 1) { $accessValidator = new Redaxscript\Validator\Access(); $access = retrieve('access', TABLE_PARAMETER, 'id', ID_PARAMETER); $check_access = $accessValidator->validate($access, MY_GROUPS); } /* validate access */ switch (true) { case ADMIN_PARAMETER == 'new' && $new == 0: case ADMIN_PARAMETER == 'view' && in_array(TABLE_PARAMETER, array('categories', 'articles', 'extras', 'comments', 'groups', 'users')) && $new == 0 && $edit == 0 && $delete == 0: case ADMIN_PARAMETER == 'view' && TABLE_PARAMETER == 'settings': case ADMIN_PARAMETER == 'view' && TABLE_PARAMETER == 'modules' && $edit == 0 && $install == 0 && $uninstall == 0: case ADMIN_PARAMETER == 'edit' && $edit == 0 && USERS_EXCEPTION == 0: case in_array(ADMIN_PARAMETER, array('up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable')) && $edit == 0: case ADMIN_PARAMETER == 'install' && $install == 0: case ADMIN_PARAMETER == 'uninstall' && $uninstall == 0: case ADMIN_PARAMETER == 'delete' && $delete == 0 && USERS_EXCEPTION == 0: case ADMIN_PARAMETER == 'process' && $_POST['new'] && $new == 0: case ADMIN_PARAMETER == 'process' && $_POST['edit'] && $edit == 0 && USERS_EXCEPTION == 0: case ADMIN_PARAMETER == 'update' && $edit == 0: case ID_PARAMETER == 1 && (ADMIN_PARAMETER == 'disable' || ADMIN_PARAMETER == 'delete') && (TABLE_PARAMETER == 'groups' || TABLE_PARAMETER == 'users'): case is_numeric(ID_PARAMETER) && TABLE_PARAMETER && $check_access == 0 && USERS_EXCEPTION == 0: notification(l('error_occurred'), l('access_no'), l('back'), 'admin'); return; } /* check token */ if (in_array(ADMIN_PARAMETER, array('up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable', 'install', 'uninstall', 'delete')) && TOKEN_PARAMETER == '') { notification(l('error_occurred'), l('access_no'), l('back'), 'admin'); return; } /* admin routing */ if (FIRST_PARAMETER == 'admin' && ADMIN_PARAMETER == '') { admin_notification(); contents(); } switch (ADMIN_PARAMETER) { case 'new': if (in_array(TABLE_PARAMETER, array('categories', 'articles', 'extras', 'comments'))) { admin_contents_form(); } if (in_array(TABLE_PARAMETER, array('groups', 'users'))) { call_user_func('admin_' . TABLE_PARAMETER . '_form'); } return; case 'view': if (in_array(TABLE_PARAMETER, array('categories', 'articles', 'extras', 'comments'))) { admin_contents_list(); } if (in_array(TABLE_PARAMETER, array('groups', 'users', 'modules'))) { call_user_func('admin_' . TABLE_PARAMETER . '_list'); } return; case 'edit': if (in_array(TABLE_PARAMETER, array('categories', 'articles', 'extras', 'comments'))) { admin_contents_form(); } if (in_array(TABLE_PARAMETER, array('groups', 'users', 'modules', 'settings'))) { call_user_func('admin_' . TABLE_PARAMETER . '_form'); } return; case 'up': case 'down': admin_move(); return; case 'sort': admin_sort(); return; case 'publish': case 'enable': admin_status(1); return; case 'unpublish': case 'disable': admin_status(0); return; case 'install': case 'uninstall': admin_install(); return; case 'delete': case 'process': case 'update': call_user_func('admin_' . ADMIN_PARAMETER); return; } }
/** * head * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Head * @author Henry Ruhs */ function head() { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); if (LAST_TABLE) { /* query contents */ $query = 'SELECT title, description, keywords, access FROM ' . PREFIX . LAST_TABLE . ' WHERE alias = \'' . LAST_PARAMETER . '\' && status = 1'; $result = mysql_query($query); 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); } } } } } } /* prepare title */ if (TITLE) { $title = TITLE; } else { if ($title == '') { $title = s('title'); } } /* prepare description */ if (DESCRIPTION) { $description = DESCRIPTION; } else { if ($description == '') { $description = s('description'); } } /* prepare keywords */ if (KEYWORDS) { $keywords = KEYWORDS; } else { if ($keywords == '') { $keywords = s('keywords'); } } /* prepare robots */ if (ROBOTS) { $robots = ROBOTS; } else { if (CONTENT_ERROR || LAST_PARAMETER && $check_access == 0) { $robots = 'none'; } else { $robots = s('robots'); } } /* collect meta output */ $output .= '<base href="' . ROOT . '/" />' . PHP_EOL; $output .= '<meta charset="' . s('charset') . '" />' . PHP_EOL; /* collect title output */ if ($title || $description) { if ($title && $description) { $divider = s('divider'); } $output .= '<title>' . truncate($title . $divider . $description, 80) . '</title>' . PHP_EOL; } /* collect refresh route */ if (REFRESH_ROUTE) { $output .= '<meta http-equiv="refresh" content="2; url=' . REFRESH_ROUTE . '" />' . PHP_EOL; } /* collect author */ if (s('author')) { $output .= '<meta name="author" content="' . s('author') . '" />' . PHP_EOL; } /* collect metadata */ $output .= '<meta name="generator" content="' . l('redaxscript') . ' ' . l('redaxscript_version') . '" />' . PHP_EOL; if ($description) { $output .= '<meta name="description" content="' . $description . '" />' . PHP_EOL; } if ($keywords) { $output .= '<meta name="keywords" content="' . $keywords . '" />' . PHP_EOL; } $output .= '<meta name="robots" content="' . $robots . '" />' . PHP_EOL; /* build canonical url */ $canonical_url = ROOT . '/' . REWRITE_ROUTE; /* if article in category */ if (FIRST_TABLE == 'categories' && LAST_TABLE == 'articles') { if (SECOND_TABLE == 'categories') { $category = retrieve('id', SECOND_TABLE, 'alias', SECOND_PARAMETER); } else { $category = retrieve('id', FIRST_TABLE, 'alias', FIRST_PARAMETER); } /* total articles of category */ $articles_total = query_total('articles', 'category', $category); if ($articles_total == 1) { $canonical_route = FIRST_PARAMETER; if (SECOND_TABLE == 'categories') { $canonical_route .= '/' . SECOND_PARAMETER; } } } /* extend canonical url */ if ($canonical_route) { $canonical_url .= $canonical_route; } else { $canonical_url .= FULL_ROUTE; } $output .= '<link href="' . $canonical_url . '" rel="canonical" />' . PHP_EOL; $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); echo $output; }
/** * infoline * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Contents * @author Henry Ruhs * * @param string $table * @param integer $id * @param string $author * @param string $date * * @return string */ function infoline($table = '', $id = '', $author = '', $date = '') { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); $time = date(s('time'), strtotime($date)); $date = date(s('date'), strtotime($date)); if ($table == 'articles') { $comments_total = query_total('comments', 'article', $id); } /* collect output */ $output .= '<div class="box_infoline box_infoline_' . $table . '">'; /* collect author output */ if ($table == 'articles') { $output .= '<span class="infoline_posted_by">' . l('posted_by') . ' ' . $author . '</span>'; $output .= '<span class="infoline_on"> ' . l('on') . ' </span>'; } /* collect date and time output */ $output .= '<span class="infoline_date">' . $date . '</span>'; $output .= '<span class="infoline_at"> ' . l('at') . ' </span>'; $output .= '<span class="infoline_time">' . $time . '</span>'; /* collect comment output */ if ($comments_total) { $output .= '<span class="divider">' . s('divider') . '</span><span class="infoline_total">' . $comments_total . ' '; if ($comments_total == 1) { $output .= l('comment'); } else { $output .= l('comments'); } $output .= '</span>'; } $output .= '</div>'; $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); return $output; }
/** * admin contents list * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_contents_list() { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); /* define access variables */ $table_new = TABLE_NEW; if (TABLE_PARAMETER == 'comments') { $articles_total = query_total('articles'); $articles_comments_disable = query_total('articles', 'comments', 0); if ($articles_total == $articles_comments_disable) { $table_new = 0; } } /* switch table */ switch (TABLE_PARAMETER) { case 'categories': $wording_single = 'category'; $wording_parent = 'category_parent'; break; case 'articles': $wording_single = 'article'; $wording_parent = 'category'; break; case 'extras': $wording_single = 'extra'; break; case 'comments': $wording_single = 'comment'; $wording_parent = 'article'; break; } /* query contents */ $query = 'SELECT * FROM ' . PREFIX . TABLE_PARAMETER . ' ORDER BY rank ASC'; $result = mysql_query($query); $num_rows = mysql_num_rows($result); /* collect listing output */ $output .= '<h2 class="title_content">' . l(TABLE_PARAMETER) . '</h2>'; $output .= '<div class="wrapper_button_admin">'; if ($table_new == 1) { $output .= anchor_element('internal', '', 'button_admin button_plus_admin', l($wording_single . '_new'), 'admin/new/' . TABLE_PARAMETER); } if (TABLE_EDIT == 1 && $num_rows) { $output .= anchor_element('internal', '', 'button_admin button_sort_admin', l('sort'), 'admin/sort/' . TABLE_PARAMETER . '/' . TOKEN); } $output .= '</div><div class="wrapper_table_admin"><table class="table table_admin">'; /* collect thead */ $output .= '<thead><tr><th class="s3o6 column_first">' . l('title') . '</th><th class="'; if (TABLE_PARAMETER != 'extras') { $output .= 's1o6'; } else { $output .= 's3o6'; } $output .= ' column_second">'; if (TABLE_PARAMETER == 'comments') { $output .= l('identifier'); } else { $output .= l('alias'); } $output .= '</th>'; if (TABLE_PARAMETER != 'extras') { $output .= '<th class="column_third">' . l($wording_parent) . '</th>'; } $output .= '<th class="column_move column_last">' . l('rank') . '</th></tr></thead>'; /* collect tfoot */ $output .= '<tfoot><tr><td class="column_first">' . l('title') . '</td><td class="column_second">'; if (TABLE_PARAMETER == 'comments') { $output .= l('identifier'); } else { $output .= l('alias'); } $output .= '</td>'; if (TABLE_PARAMETER != 'extras') { $output .= '<td class="column_third">' . l($wording_parent) . '</td>'; } $output .= '<td class="column_move column_last">' . l('rank') . '</td></tr></tfoot>'; 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); } } /* prepare name */ if (TABLE_PARAMETER == 'comments') { $name = truncate($author . l('colon') . ' ' . strip_tags($text), 80, '...'); } else { $name = $title; } /* build class string */ if ($status == 1) { $class_status = ''; } else { $class_status = 'row_disabled'; } /* build route */ if (TABLE_PARAMETER != 'extras' && $status == 1) { if (TABLE_PARAMETER == 'categories' && $parent == 0 || TABLE_PARAMETER == 'articles' && $category == 0) { $route = $alias; } else { $route = build_route(TABLE_PARAMETER, $id); } } else { $route = ''; } /* collect tbody output */ if (TABLE_PARAMETER == 'categories') { if ($before != $parent) { $output .= '<tbody><tr class="row_group"><td colspan="4">'; if ($parent) { $output .= retrieve('title', 'categories', 'id', $parent); } else { $output .= l('none'); } $output .= '</td></tr>'; } $before = $parent; } if (TABLE_PARAMETER == 'articles') { if ($before != $category) { $output .= '<tbody><tr class="row_group"><td colspan="4">'; if ($category) { $output .= retrieve('title', 'categories', 'id', $category); } else { $output .= l('uncategorized'); } $output .= '</td></tr>'; } $before = $category; } if (TABLE_PARAMETER == 'comments') { if ($before != $article) { $output .= '<tbody><tr class="row_group"><td colspan="4">'; if ($article) { $output .= retrieve('title', 'articles', 'id', $article); } else { $output .= l('none'); } $output .= '</td></tr>'; } $before = $article; } /* collect table row */ $output .= '<tr'; if ($alias) { $output .= ' id="' . $alias . '"'; } if ($class_status) { $output .= ' class="' . $class_status . '"'; } $output .= '><td class="column_first">'; if ($language) { $output .= '<span class="icon_flag language_' . $language . '" title="' . l($language) . '">' . $language . '</span>'; } if ($status == 1) { $output .= anchor_element('internal', '', 'link_view', $name, $route); } else { $output .= $name; } /* collect control output */ $output .= admin_control('contents', TABLE_PARAMETER, $id, $alias, $status, TABLE_NEW, TABLE_EDIT, TABLE_DELETE); /* collect alias and id output */ $output .= '</td><td class="column_second">'; if (TABLE_PARAMETER == 'comments') { $output .= $id; } else { $output .= $alias; } $output .= '</td>'; /* collect parent output */ if (TABLE_PARAMETER != 'extras') { $output .= '<td class="column_third">'; if (TABLE_PARAMETER == 'categories') { if ($parent) { $output .= anchor_element('internal', '', 'link_parent', retrieve('title', 'categories', 'id', $parent), 'admin/edit/categories/' . $parent); } else { $output .= l('none'); } } if (TABLE_PARAMETER == 'articles') { if ($category) { $output .= anchor_element('internal', '', 'link_parent', retrieve('title', 'categories', 'id', $category), 'admin/edit/categories/' . $category); } else { $output .= l('uncategorized'); } } if (TABLE_PARAMETER == 'comments') { if ($article) { $output .= anchor_element('internal', '', 'link_parent', retrieve('title', 'articles', 'id', $article), 'admin/edit/articles/' . $article); } else { $output .= l('none'); } } $output .= '</td>'; } $output .= '<td class="column_move column_last">'; /* collect control output */ if (TABLE_EDIT == 1) { $rank_desc = query_plumb('rank', TABLE_PARAMETER, 'max'); if ($rank > 1) { $output .= anchor_element('internal', '', 'move_up', l('up'), 'admin/up/' . TABLE_PARAMETER . '/' . $id . '/' . TOKEN); } else { $output .= '<span class="move_up">' . l('up') . '</span>'; } if ($rank < $rank_desc) { $output .= anchor_element('internal', '', 'move_down', l('down'), 'admin/down/' . TABLE_PARAMETER . '/' . $id . '/' . TOKEN); } else { $output .= '<span class="move_down">' . l('down') . '</span>'; } $output .= '</td>'; } $output .= '</tr>'; /* collect tbody output */ if (TABLE_PARAMETER == 'categories') { if ($before != $parent) { $output .= '</tbody>'; } } if (TABLE_PARAMETER == 'articles') { if ($before != $category) { $output .= '</tbody>'; } } if (TABLE_PARAMETER == 'comments') { if ($before != $article) { $output .= '</tbody>'; } } } else { $counter++; } } /* handle access */ if ($num_rows == $counter) { $error = l('access_no') . l('point'); } } } /* handle error */ if ($error) { $output .= '<tbody><tr><td colspan="4">' . $error . '</td></tr></tbody>'; } $output .= '</table></div>'; $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); echo $output; }