Created
January 10, 2015 06:23
-
-
Save dlenettr/50641b9fd57435a3c8eb to your computer and use it in GitHub Desktop.
DLE önceki konu, sonraki konu eklentisi (PHP) (632)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="next-prev-news"> | |
<style> | |
.next-prev-news { } | |
.prev-news { float: left; width: 320px; border: 1px solid #ccc; border-radius: 4px; padding: 5px; } | |
.prev-news img { width: 300px; height: 90px; } | |
.next-news { float: right; width: 320px; border: 1px solid #ccc; border-radius: 4px; padding: 5px; } | |
.next-news img { width: 300px; height: 90px; } | |
</style> | |
[prev-news] | |
<div class="prev-news"> | |
<a href="{prev-link}"><h3>{prev-title}</h3></a> | |
<img src="{prev-img}" alt="" /> | |
<p>{prev-text limit="100"}</p> | |
<p>{prev-cat}</p> | |
<i>{prev-date}</i> | |
</div> | |
[/prev-news] | |
[next-news] | |
<div class="next-news"> | |
<a href="{next-link}"><h3>{next-title}</h3></a> | |
<img src="{next-img}" alt="" /> | |
<p>{next-text limit="50"}</p> | |
<p>{next-cat}</p> | |
<i>{next-date}</i> | |
</div> | |
[/next-news] | |
<div style="clear: both;"></div> | |
</div> | |
_______________________________________________________________ | |
// Önceki sonraki konu eklentisi | |
function get_full_link( $id, $category, $alt_name, $date ) { | |
global $config; | |
if ( $config['allow_alt_url'] ) { | |
if ( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) { | |
if ( $category and $config['seo_type'] == 2 ) { | |
$full_link = $config['http_home_url'] . get_url( $category ) . "/" . $id . "-" . $alt_name . ".html"; | |
} else { | |
$full_link = $config['http_home_url'] . $id . "-" . $alt_name . ".html"; | |
} | |
} else { | |
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $date ) . $alt_name . ".html"; | |
} | |
} else { | |
$full_link = $config['http_home_url'] . "index.php?newsid=" . $id; | |
} | |
return $full_link; | |
} | |
function get_story( $count, $story ) { | |
global $config; | |
$story = str_replace( "</p><p>", " ", $story ); | |
$story = strip_tags( $story, "<br>" ); | |
$story = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $story ) ) ) )); | |
if ( $count AND dle_strlen( $story, $config['charset'] ) > $count ) { | |
$story = dle_substr( $story, 0, $count, $config['charset'] ); | |
if ( ($temp_dmax = dle_strrpos( $story, ' ', $config['charset'] )) ) $story = dle_substr( $story, 0, $temp_dmax, $config['charset'] ); | |
} | |
return $story; | |
} | |
function get_title( $count, $title ) { | |
global $config; | |
if ( $count AND dle_strlen( $title, $config['charset'] ) > $count ) { | |
$title = dle_substr( $title, 0, $count, $config['charset'] ); | |
if ( ($temp_dmax = dle_strrpos( $title, ' ', $config['charset'] )) ) $title = dle_substr( $title, 0, $temp_dmax, $config['charset'] ); | |
} | |
return $title; | |
} | |
$prev_news = $db->super_query("SELECT title, category, id, alt_name, autor, date, xfields, short_story FROM " . PREFIX . "_post WHERE id < " . NEWS_ID . " ORDER BY id DESC LIMIT 0,1"); | |
$next_news = $db->super_query("SELECT title, category, id, alt_name, autor, date, xfields, short_story FROM " . PREFIX . "_post WHERE id > " . NEWS_ID . " ORDER BY id ASC LIMIT 0,1"); | |
if ( $prev_news ) { | |
$tpl->set( '{prev-link}', get_full_link( $prev_news['id'], $prev_news['category'], $prev_news['alt_name'], $prev_news['date'] ) ); | |
$tpl->set( '{prev-cat}', get_categories( $prev_news['category'] ) ); | |
if ( preg_match( "#\\{prev-text limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) { $count = intval($matches[1]); $tpl->set( $matches[0], get_story( $count, $prev_news['short_story'] ) ); } | |
else $tpl->set( '{prev-text}', $prev_news['short_story'] ); | |
if ( preg_match( "#\\{prev-title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) { $count = intval( $matches[1] ); $tpl->set( $matches[0], get_title( $count, $prev_news['title'] ) ); } | |
else $tpl->set( '{prev-title}', strip_tags( stripslashes( $prev_news['title'] ) ) ); | |
if ( preg_match( "#<img src=\"(.+?)\"\s#", $prev_news['short_story'], $m ) ) { $tpl->set( '{prev-img}', $m[1] ); } | |
else { $tpl->set( '{prev-img}', "{THEME}/dleimages/no_image.jpg" ); } | |
$tpl->set( '{prev-date}', langdate( $config['timestamp_active'], strtotime( $prev_news['date'] ) ) ); | |
$news_date = $prev_news['date']; | |
$tpl->copy_template = preg_replace_callback ( "#\{prev-date=(.+?)\}#i", "formdate", $tpl->copy_template ); | |
$tpl->set_block( "'\\[prev-news\\](.*?)\\[/prev-news\\]'si", "\\1" ); | |
} else $tpl->set_block( "'\\[prev-news\\].*?\\[/prev-news\\]'si", "" ); | |
if ( $next_news ) { | |
$tpl->set( '{next-link}', get_full_link( $next_news['id'], $next_news['category'], $next_news['alt_name'], $next_news['date'] ) ); | |
$tpl->set( '{next-cat}', get_categories( $next_news['category'] ) ); | |
if ( preg_match( "#\\{next-text limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) { $count = intval($matches[1]); $tpl->set( $matches[0], get_story( $count, $next_news['short_story'] ) ); } | |
else $tpl->set( '{next-text}', $next_news['short_story'] ); | |
if ( preg_match( "#\\{next-title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) { $count = intval( $matches[1] ); $tpl->set( $matches[0], get_title( $count, $next_news['title'] ) ); } | |
else $tpl->set( '{next-title}', strip_tags( stripslashes( $next_news['title'] ) ) ); | |
if ( preg_match( "#<img src=\"(.+?)\"\s#", $next_news['short_story'], $m ) ) { $tpl->set( '{next-img}', $m[1] ); } | |
else { $tpl->set( '{next-img}', "{THEME}/dleimages/no_image.jpg" ); } | |
$tpl->set( '{next-date}', langdate( $config['timestamp_active'], strtotime( $next_news['date'] ) ) ); | |
$news_date = $next_news['date']; | |
$tpl->copy_template = preg_replace_callback ( "#\{next-date=(.+?)\}#i", "formdate", $tpl->copy_template ); | |
$tpl->set_block( "'\\[next-news\\](.*?)\\[/next-news\\]'si", "\\1" ); | |
} else $tpl->set_block( "'\\[next-news\\].*?\\[/next-news\\]'si", "" ); | |
// Önceki sonraki konu eklentisi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment