本文整理汇总了PHP中build_route函数的典型用法代码示例。如果您正苦于以下问题:PHP build_route函数的具体用法?PHP build_route怎么用?PHP build_route使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了build_route函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* process the class
*
* @since 3.0.0
*
* @return string
*/
public function process()
{
$specialFilter = new Filter\Special();
$emailFilter = new Filter\Email();
$urlFilter = new Filter\Url();
$htmlFilter = new Filter\Html();
/* process post */
$postArray = ['author' => $specialFilter->sanitize($this->_request->getPost('author')), 'email' => $emailFilter->sanitize($this->_request->getPost('email')), 'url' => $urlFilter->sanitize($this->_request->getPost('url')), 'text' => $htmlFilter->sanitize($this->_request->getPost('text')), 'article' => $specialFilter->sanitize($this->_request->getPost('article')), 'task' => $this->_request->getPost('task'), 'solution' => $this->_request->getPost('solution')];
$route = build_route('articles', $postArray['article']);
/* handle error */
$messageArray = $this->_validate($postArray);
if ($messageArray) {
return $this->_error(['route' => $route, 'message' => $messageArray]);
}
/* handle success */
$createArray = ['author' => $postArray['author'], 'email' => $postArray['email'], 'url' => $postArray['url'], 'text' => $postArray['text'], 'language' => Db::forTablePrefix('articles')->whereIdIs($postArray['article'])->findOne()->language, 'article' => $postArray['article'], 'status' => Db::getSetting('verification') ? 0 : 1];
$mailArray = ['email' => $postArray['email'], 'url' => $postArray['url'], 'route' => $route, 'author' => $postArray['author'], 'text' => $postArray['text'], 'article' => Db::forTablePrefix('articles')->whereIdIs($postArray['article'])->findOne()->title];
/* create */
if (!$this->_create($createArray)) {
return $this->_error(['route' => $route, 'message' => $this->_language->get('something_wrong')]);
}
/* mail */
if (!$this->_mail($mailArray)) {
return $this->_warning(['route' => $route, 'message' => $this->_language->get('email_failed')]);
}
return $this->_success(['route' => $route, 'timeout' => Db::getSetting('notification') ? 2 : 0, 'message' => Db::getSetting('moderation') ? $this->_language->get('comment_moderation') : $this->_language->get('comment_sent')]);
}
示例2: _writeXML
/**
* @param object $categories
* @param object $articles
*
* @return string
*/
protected static function _writeXML($categories = null, $articles = null)
{
$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->setIndentString(' ');
$writer->startDocument('1.0', Db::getSetting('charset'));
$writer->startElement('urlset');
$writer->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
$writer->startElement('url');
$writer->writeElement('loc', Registry::get('root'));
$writer->endElement();
/* process categories */
foreach ($categories as $value) {
$writer->startElement('url');
$writer->writeElement('loc', Registry::get('root') . Registry::get('parameterRoute') . build_route('categories', $value->id));
$writer->writeElement('lastmod', date('c', strtotime($value->date)));
$writer->endElement();
}
/* process articles */
foreach ($articles as $value) {
$writer->startElement('url');
$writer->writeElement('loc', Registry::get('root') . Registry::get('parameterRoute') . build_route('articles', $value->id));
$writer->writeElement('lastmod', date('c', strtotime($value->date)));
$writer->endElement();
}
$writer->endElement();
$writer->endDocument();
return $writer->outputMemory(true);
}
示例3: render
/**
* render
*
* @since 2.2.0
*
* @return string
*/
public static function render()
{
$output = null;
$outputItem = null;
/* html elements */
$titleElement = new Html\Element();
$titleElement->init('h3', array('class' => self::$_config['className']['title']));
$linkElement = new Html\Element();
$linkElement->init('a');
$listElement = new Html\Element();
$listElement->init('ul', array('class' => self::$_config['className']['list']));
/* fetch articles */
$articles = Db::forTablePrefix('articles')->where('status', 1)->whereIn('language', array(Registry::get('language'), ''))->orderByDesc('category')->findArray();
/* process articles */
if (!$articles) {
$error = Language::get('article_no') . Language::get('point');
} else {
$accessValidator = new Validator\Access();
$accessDeny = 0;
$lastCategory = 0;
foreach ($articles as $value) {
if ($accessValidator->validate($value['access'], Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) {
$currentCategory = $value['category'];
/* collect output */
if ($lastCategory != $currentCategory) {
if ($lastCategory > 0) {
$output .= $listElement->html($outputItem);
$outputItem = null;
}
$output .= $titleElement->text($currentCategory < 1 ? Language::get('uncategorized') : Db::forTablePrefix('categories')->whereIdIs($currentCategory)->findOne()->title);
}
/* collect item output */
$outputItem .= '<li>';
$outputItem .= $linkElement->attr(array('href' => $value['category'] < 1 ? $value['alias'] : build_route('articles', $value['id']), 'title' => $value['description'] ? $value['description'] : $value['title']))->text($value['title']);
$outputItem .= '</li>';
/* collect list output */
if (end($articles) === $value) {
$output .= $listElement->html($outputItem);
$outputItem = null;
}
$lastCategory = $currentCategory;
} else {
$accessDeny++;
}
}
/* handle access */
if (count($articles) === $accessDeny) {
$error = Language::get('access_no') . Language::get('point');
}
}
/* handle error */
if ($error) {
$output = $listElement->html('<li>' . $error . '</li>');
}
return $output;
}
示例4: render
/**
* render
*
* @since 2.2.0
*
* @return string
*/
public static function render()
{
$output = '';
$outputItem = '';
/* html elements */
$titleElement = new Element('h3', array('class' => self::$_config['className']['title']));
$linkElement = new Element('a');
$listElement = new Element('ul', array('class' => self::$_config['className']['list']));
/* fetch articles */
$articles = Db::forTablePrefix('articles')->selectExpr('*, YEAR(date) as year, MONTH(date) as month')->where('status', 1)->whereIn('language', array(Registry::get('language'), ''))->orderByDesc('date')->findArray();
/* process articles */
if (empty($articles)) {
$error = Language::get('article_no') . Language::get('point');
} else {
$accessValidator = new Validator\Access();
$accessDeny = 0;
$lastDate = 0;
foreach ($articles as $value) {
if ($accessValidator->validate($value['access'], Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) {
$currentDate = $value['month'] + $value['year'];
/* collect output */
if ($lastDate != $currentDate) {
if ($lastDate > 0) {
$output .= $listElement->html($outputItem);
$outputItem = '';
}
$output .= $titleElement->text(Language::get($value['month'] - 1, '_month') . ' ' . $value['year']);
}
/* collect item output */
$outputItem .= '<li>';
$outputItem .= $linkElement->attr(array('href' => $value['category'] < 1 ? $value['alias'] : build_route('articles', $value['id']), 'title' => $value['description'] ? $value['description'] : $value['title']))->text($value['title']);
$outputItem .= '</li>';
/* collect list output */
if (end($articles) === $value) {
$output .= $listElement->html($outputItem);
$outputItem = '';
}
$lastDate = $currentDate;
} else {
$accessDeny++;
}
}
/* handle access */
if (count($articles) === $accessDeny) {
$error = Language::get('access_no') . Language::get('point');
}
}
/* handle error */
if ($error) {
$output = $listElement->html('<li>' . $error . '</li>');
}
return $output;
}
示例5: render
/**
* render
*
* @since 2.2.0
*
* @return string
*/
public static function render()
{
$output = null;
/* html elements */
$titleElement = new Html\Element();
$titleElement->init('h3', ['class' => self::$_configArray['className']['title']]);
$linkElement = new Html\Element();
$linkElement->init('a');
$listElement = new Html\Element();
$listElement->init('ul', ['class' => self::$_configArray['className']['list']]);
/* query articles */
$articles = Db::forTablePrefix('articles')->where('status', 1)->whereLanguageIs(Registry::get('language'))->orderByDesc('date')->findMany();
/* process articles */
if (!$articles) {
$error = Language::get('article_no') . Language::get('point');
} else {
$accessValidator = new Validator\Access();
$accessDeny = 0;
$lastDate = 0;
foreach ($articles as $value) {
if ($accessValidator->validate($value->access, Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) {
$month = date('n', strtotime($value->date));
$year = date('Y', strtotime($value->date));
$currentDate = $month + $year;
/* collect output */
if ($lastDate != $currentDate) {
$output .= $titleElement->text(Language::get($month - 1, '_month') . ' ' . $year);
}
$lastDate = $currentDate;
/* collect item output */
$outputItem = '<li>';
$outputItem .= $linkElement->attr(['href' => Registry::get('parameterRoute') . build_route('articles', $value->id), 'title' => $value->description ? $value->description : $value->title])->text($value->title);
$outputItem .= '</li>';
/* collect list output */
$output .= $listElement->html($outputItem);
} else {
$accessDeny++;
}
}
/* handle access */
if (count($articles) === $accessDeny) {
$error = Language::get('access_no') . Language::get('point');
}
}
/* handle error */
if ($error) {
$output = $listElement->html('<li>' . $error . '</li>');
}
return $output;
}
示例6: sitemap_xml
/**
* sitemap xml
*
* @since 1.2.1
* @deprecated 2.0.0
*
* @package Redaxscript
* @category Modules
* @author Henry Ruhs
*/
function sitemap_xml()
{
/* query categories */
$categories_query = 'SELECT id, alias, parent FROM ' . PREFIX . 'categories WHERE status = 1 && access = 0 ORDER BY rank ASC';
$categories_result = mysql_query($categories_query);
/* collect output */
$output = '<?xml version="1.0" encoding="' . s('charset') . '"?>' . PHP_EOL;
$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;
$output .= '<url><loc>' . ROOT . '</loc><lastmod>' . TODAY . '</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url>' . PHP_EOL;
if ($categories_result) {
while ($r = mysql_fetch_assoc($categories_result)) {
if ($r) {
foreach ($r as $key => $value) {
${$key} = stripslashes($value);
}
}
/* build route */
if ($parent == 0) {
$route = $alias;
} else {
$route = build_route('categories', $id);
}
/* collect output */
$output .= '<url><loc>' . ROOT . '/' . REWRITE_ROUTE . $route . '</loc><lastmod>' . TODAY . '</lastmod><changefreq>weekly</changefreq><priority>0.5</priority></url>' . PHP_EOL;
}
}
/* query articles */
$articles_query = 'SELECT id, alias, category FROM ' . PREFIX . 'articles WHERE status = 1 && access = 0 ORDER BY rank ASC';
$articles_result = mysql_query($articles_query);
/* collect output */
if ($articles_result) {
while ($r = mysql_fetch_assoc($articles_result)) {
if ($r) {
foreach ($r as $key => $value) {
${$key} = stripslashes($value);
}
}
/* build route */
if ($category == 0) {
$route = $alias;
} else {
$route = build_route('articles', $id);
}
$output .= '<url><loc>' . ROOT . '/' . REWRITE_ROUTE . $route . '</loc><lastmod>' . TODAY . '</lastmod><changefreq>weekly</changefreq><priority>0.5</priority></url>' . PHP_EOL;
}
}
$output .= '</urlset>';
echo $output;
}
示例7: render
/**
* render the view
*
* @since 3.0.0
*
* @param array $resultArray array for the result
*
* @return string
*/
public function render($resultArray = [])
{
$output = Hook::trigger('resultListStart');
$accessValidator = new Validator\Access();
/* html elements */
$titleElement = new Html\Element();
$titleElement->init('h2', ['class' => 'rs-title-result']);
$listElement = new Html\Element();
$listElement->init('ol', ['class' => 'rs-list-result']);
$itemElement = new Html\Element();
$itemElement->init('li');
$linkElement = new Html\Element();
$linkElement->init('a', ['class' => 'rs-link-result']);
$textElement = new Html\Element();
$textElement->init('span', ['class' => 'rs-text-result-date']);
/* process result */
foreach ($resultArray as $table => $result) {
$outputItem = null;
if ($result) {
/* collect item output */
foreach ($result as $value) {
if ($accessValidator->validate($result->access, $this->_registry->get('myGroups')) === Validator\ValidatorInterface::PASSED) {
$textDate = date(Db::getSetting('date'), strtotime($value->date));
$linkElement->attr('href', $this->_registry->get('parameterRoute') . build_route($table, $value->id))->text($value->title ? $value->title : $value->author);
$textElement->text($textDate);
$outputItem .= $itemElement->html($linkElement . $textElement);
}
}
/* collect output */
if ($outputItem) {
$titleElement->text($this->_language->get($table));
$listElement->html($outputItem);
$output .= $titleElement . $listElement;
}
}
}
$output .= Hook::trigger('resultListEnd');
return $output;
}
示例8: render
/**
* render
*
* @since 2.2.0
*
* @return string
*/
public static function render()
{
/* fetch categories */
$categories = Db::forTablePrefix('categories')->where('status', 1)->whereNull('access')->orderByAsc('rank')->findArray();
/* fetch articles */
$articles = Db::forTablePrefix('articles')->where('status', 1)->whereNull('access')->orderByAsc('rank')->findArray();
/* collect output */
$output = '<?xml version="1.0" encoding="' . Db::getSettings('charset') . '"?>';
$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$output .= '<url><loc>' . Registry::get('root') . '</loc></url>';
/* process categories */
foreach ($categories as $value) {
$route = $value['parent'] < 1 ? $value['alias'] : build_route('categories', $value['id']);
$output .= '<url><loc>' . Registry::get('root') . '/' . Registry::get('rewriteRoute') . $route . '</loc></url>';
}
/* process articles */
foreach ($articles as $value) {
$route = $value['category'] < 1 ? $value['alias'] : build_route('articles', $value['id']);
$output .= '<url><loc>' . Registry::get('root') . '/' . Registry::get('rewriteRoute') . $route . '</loc></url>';
}
$output .= '</urlset>';
return $output;
}
示例9: navigation_list
//.........这里部分代码省略.........
} 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;
}
示例10: search_post
/**
* search post
*
* @since 1.2.1
* @deprecated 2.0.0
*
* @package Redaxscript
* @category Search
* @author Henry Ruhs
*/
function search_post()
{
/* clean post */
if (ATTACK_BLOCKED < 10) {
$search_terms = clean($_POST['search_terms'], 5);
$table = clean($_POST['table']);
}
/* validate post */
if (strlen($search_terms) < 3 || $search_terms == l('search_terms')) {
$error = l('input_incorrect');
} else {
/* fetch result */
$result = Redaxscript\Db::forTablePrefix($table)->where('status', 1)->whereIn('language', array(Redaxscript\Registry::get('language'), ''))->whereLikeMany(array('title', 'description', 'keywords', 'text'), array('%' . $search_terms . '%', '%' . $search_terms . '%', '%' . $search_terms . '%', '%' . $search_terms . '%'))->orderByDesc('date')->findArray();
/* process result */
$num_rows = count($result);
if (!$result) {
$error = l('search_no');
} else {
if ($result) {
$accessValidator = new Redaxscript\Validator\Access();
$output = '<h2 class="title_content title_search_result">' . l('search') . '</h2>';
$output .= form_element('fieldset', '', 'set_search_result', '', '', '') . '<ol class="list_search_result">';
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);
}
}
/* prepare metadata */
if ($description == '') {
$description = $title;
}
$date = date(s('date'), strtotime($date));
/* 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="item_search_result">' . anchor_element('internal', '', 'link_search_result', $title, $route, $description) . '<span class="date_search_result">' . $date . '</span></li>';
} else {
$counter++;
}
}
$output .= '</ol></fieldset>';
/* handle access */
if ($num_rows == $counter) {
$error = l('access_no');
}
}
}
}
/* handle error */
if ($error) {
notification(l('something_wrong'), $error);
} else {
echo $output;
}
}
示例11: feed_generator
/**
* feed generator
*
* @since 1.2.1
* @deprecated 2.0.0
*
* @package Redaxscript
* @category Modules
* @author Henry Ruhs
*
* param string $table
*/
function feed_generator($table = '')
{
if ($_GET['l']) {
$language = LANGUAGE;
$language_route = LANGUAGE_ROUTE;
}
/* query table contents */
$query = 'SELECT * FROM ' . PREFIX . $table . ' WHERE (language = \'' . $language . '\' || language = \'all\') && status = 1 && access = 0 ORDER BY rank ' . s('order') . ' LIMIT ' . s('limit');
$result = mysql_query($query);
if ($result) {
/* define variables */
$title = s('title');
$description = s('description');
$author = s('author');
$email = s('email');
$copyright = s('copyright');
$route = ROOT . '/' . REWRITE_ROUTE . FULL_ROUTE . $language_route . $language;
/* collect feed header output */
$output = '<?xml version="1.0" encoding="' . s('charset') . '"?>' . PHP_EOL;
$output .= '<feed xmlns="http://www.w3.org/2005/Atom">' . PHP_EOL;
$output .= '<id>' . $route . '</id>' . PHP_EOL;
if ($title) {
$output .= '<title type="text">' . $title . '</title>' . PHP_EOL;
}
if ($description) {
$output .= '<subtitle type="text">' . $description . '</subtitle>' . PHP_EOL;
}
$output .= '<link type="application/atom+xml" href="' . $route . '" rel="self" />' . PHP_EOL;
$output .= '<updated>' . date('c', strtotime(NOW)) . '</updated>' . PHP_EOL;
if ($author || $email) {
$output .= '<author>' . PHP_EOL;
if ($author) {
$output .= '<name>' . $author . '</name>' . PHP_EOL;
}
if ($email) {
$output .= '<email>' . $email . '</email>' . PHP_EOL;
}
$output .= '</author>' . PHP_EOL;
}
if ($copyright) {
$output .= '<rights>' . $copyright . '</rights>' . PHP_EOL;
}
$output .= '<generator>' . l('redaxscript') . ' ' . l('redaxscript_version') . '</generator>' . PHP_EOL . PHP_EOL;
/* collect feed body output */
while ($r = mysql_fetch_assoc($result)) {
if ($r) {
foreach ($r as $key => $value) {
${$key} = stripslashes($value);
}
}
/* define variables */
$date = date('c', strtotime($date));
$text = htmlspecialchars(strip_tags($text));
if ($table == 'comments') {
$title = $author;
}
/* build route */
$route = ROOT . '/' . REWRITE_ROUTE;
if ($table == 'articles' && $category == 0) {
$route .= $alias;
} else {
$route .= build_route($table, $id);
}
$route .= $language_route;
/* collect entry output */
$output .= '<entry>' . PHP_EOL;
$output .= '<id>' . $route . '</id>' . PHP_EOL;
$output .= '<title type="text">' . $title . '</title>' . PHP_EOL;
$output .= '<link href="' . $route . '" />' . PHP_EOL;
$output .= '<updated>' . $date . '</updated>' . PHP_EOL;
if ($description) {
$output .= '<summary type="text">' . $description . '</summary>' . PHP_EOL;
}
$output .= '<content type="html">' . $text . '</content>' . PHP_EOL;
$output .= '</entry>' . PHP_EOL;
}
$output .= '</feed>';
}
echo $output;
}
示例12: archive
/**
* archive
*
* @since 1.2.1
* @deprecated 2.0.0
*
* @package Redaxscript
* @category Modules
* @author Henry Ruhs
*
* @return string
*/
function archive()
{
$query = 'SELECT id, title, alias, description, date, category, access FROM ' . PREFIX . 'articles WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && status = 1 ORDER BY date DESC';
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
if ($result == '' || $num_rows == '') {
$error = l('article_no') . l('point');
} else {
if ($result) {
$accessValidator = new Redaxscript\Validator\Access();
$month_names = explode(', ', l('month_names'));
$last = 0;
while ($r = mysql_fetch_assoc($result)) {
/* check for access */
$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;
}
$year = substr($date, 0, 4);
$month = substr($date, 5, 2) - 1;
/* build route */
if ($category == 0) {
$route = $alias;
} else {
$route = build_route('articles', $id);
}
/* collect output */
if ($last != $month + $year) {
if ($last > 0) {
$output .= '</ul></fieldset>';
}
$output .= form_element('fieldset', '', 'set_archive', '', '', '<span class="title_content_sub title_archive_sub">' . $month_names[$month] . ' ' . $year . '</span>') . '<ul class="list_default list_archive">';
}
$output .= '<li>' . anchor_element('internal', '', '', $title, $route, $description) . '</li>';
$last = $month + $year;
} else {
$counter++;
}
}
/* handle access */
if ($num_rows == $counter) {
$error = l('access_no') . l('point');
}
}
}
/* handle error */
if ($error) {
$output = form_element('fieldset', '', 'set_archive', '', '', '<span class="title_content_sub title_archive_sub">' . l('error') . '</span>') . '<ul class="list_default list_archive">';
$output .= '<li>' . $error . '</li>';
}
$output .= '</ul></fieldset>';
return $output;
}
示例13: comment_post
/**
* comment post
*
* @since 1.2.1
* @deprecated 2.0.0
*
* @package Redaxscript
* @category Comments
* @author Henry Ruhs
*/
function comment_post()
{
$emailValidator = new Redaxscript\Validator\Email();
$captchaValidator = new Redaxscript\Validator\Captcha();
$urlValidator = new Redaxscript\Validator\Url();
/* clean post */
if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/comment'] == 'visited') {
$author = $r['author'] = clean($_POST['author'], 0);
$email = $r['email'] = clean($_POST['email'], 3);
$url = $r['url'] = clean($_POST['url'], 4);
$text = break_up($_POST['text']);
$text = $r['text'] = clean($text, 1);
$r['language'] = clean($_POST['language'], 0);
$r['date'] = clean($_POST['date'], 1);
$article = $r['article'] = clean($_POST['article'], 0);
$r['rank'] = query_plumb('rank', 'comments', 'max') + 1;
$r['access'] = clean($_POST['access'], 0);
if ($r['access'] == '') {
$r['access'] = 0;
}
$task = $_POST['task'];
$solution = $_POST['solution'];
$route = build_route('articles', $article);
}
/* validate post */
if ($author == '') {
$error = l('author_empty');
} else {
if ($email == '') {
$error = l('email_empty');
} else {
if ($text == '') {
$error = l('comment_empty');
} else {
if ($emailValidator->validate($email) == Redaxscript\Validator\Validator::FAILED) {
$error = l('email_incorrect');
} else {
if ($url && $urlValidator->validate($url) == Redaxscript\Validator\Validator::FAILED) {
$error = l('url_incorrect');
} else {
if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\Validator::FAILED) {
$error = l('captcha_incorrect');
} else {
if (COMMENTS_NEW == 0 && s('moderation') == 1) {
$r['status'] = 0;
$success = l('comment_moderation');
} else {
$r['status'] = 1;
$success = l('comment_sent');
}
/* send comment notification */
if (s('notification') == 1) {
/* prepare body parts */
$emailLink = anchor_element('email', '', '', $email);
if ($url) {
$urlLink = anchor_element('external', '', '', $url);
}
$articleRoute = ROOT . '/' . REWRITE_ROUTE . $route;
$articleLink = anchor_element('external', '', '', $articleRoute, $articleRoute);
/* prepare mail inputs */
$toArray = array(s('author') => s('email'));
$fromArray = array($author => $email);
$subject = l('comment_new');
$bodyArray = array('<strong>' . l('author') . l('colon') . '</strong> ' . $author . ' (' . MY_IP . ')', '<strong>' . l('email') . l('colon') . '</strong> ' . $emailLink, '<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink, '<br />', '<strong>' . l('comment') . l('colon') . '</strong> ' . $text, '<br />', '<strong>' . l('article') . l('colon') . '</strong> ' . $articleLink);
/* mailer object */
$mailer = new Redaxscript\Mailer($toArray, $fromArray, $subject, $bodyArray);
$mailer->send();
}
/* build key and value strings */
$r_keys = array_keys($r);
$last = end($r_keys);
foreach ($r as $key => $value) {
$key_string .= $key;
$value_string .= '\'' . $value . '\'';
if ($last != $key) {
$key_string .= ', ';
$value_string .= ', ';
}
}
/* insert comment */
$query = 'INSERT INTO ' . PREFIX . 'comments (' . $key_string . ') VALUES (' . $value_string . ')';
mysql_query($query);
}
}
}
}
}
}
/* handle error */
if ($error) {
//.........这里部分代码省略.........
示例14: navigation_list
//.........这里部分代码省略.........
} 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;
}
示例15: contents
/**
* 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) {
//.........这里部分代码省略.........