SimplePortal

Support => International Support => Turkish (Türkçe) => Topic started by: xxman on May 21, 2014, 05:31:16 PM

Title: otomatik slider
Post by: xxman on May 21, 2014, 05:31:16 PM
(http://i.hizliresim.com/ZNXYOo.png)
simpleportal da yeni bir php block oluşturun
içine yapıştırın
Code: [Select]
global $scripturl, $txt, $settings, $modSettings, $context, $smcFunc, $color_profile;
$parameters = array(
  'board' => array(1,2,5),
  'limit' => '4',
  'length' => '400',
);
teknoromi($parameters);

function teknoromi($parameters)
{
global $scripturl, $txt, $settings, $modSettings, $context, $smcFunc, $color_profile;
$block_parameters = array(
'board' => 'boards',
'limit' => 'int',
'start' => 'int',
'length' => 'int',
'avatar' => 'check',

);

if ($return_parameters)
return $block_parameters;

$board = !empty($parameters['board']) ? explode('|', $parameters['board']) : null;
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 30;
$start = !empty($parameters['start']) ? (int) $parameters['start'] : 0;
$length = isset($parameters['length']) ? (int) $parameters['length'] : 500;
$avatars = !empty($parameters['avatar']);


$limit = max(0, $limit);
$start = max(0, $start);

loadLanguage('Stats');

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';


if (!$parameters['perms_override'])
{
$board_count = count($parameters['board']);

$board_limit = 1;
$where = 'FIND_IN_SET(-1, member_groups)';
if ($board_count > 1)
{
$where = 'id_board IN ({array_int:board_list}) AND ' . $where;
$board_limit = $board_count;
}
$request = $smcFunc['db_query']('', '
SELECT id_board
FROM {db_prefix}boards
WHERE ' . $where . '
LIMIT {int:limit}',
array(
'board_list' => $parameters['board'],
'limit' => $board_limit,
)
);
if ($smcFunc['db_num_rows']($request) == 0)
{
if ($output_method == 'echo')
die($txt['ssi_no_guests']);
else
return array();
}

$allowed_boards = array();
while($row = $smcFunc['db_fetch_row']($request))
$allowed_boards[] = $row[0];
$smcFunc['db_free_result']($request);

if ($board_count > 0)
$parameters['board'] = array_intersect($parameters['board'], $allowed_boards);
else
$parameters['board'] = $allowed_boards;

if (count($parameters['board']) == 0)
$parameters['board'] = array(0);
}
// Find the post ids.
$request = $smcFunc['db_query']('', '
SELECT id_first_msg, icon
FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS m ON (t.id_first_msg = m.id_msg)
WHERE t.id_board IN ({array_int:board_list})' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}' : '') . '
ORDER BY id_first_msg DESC
LIMIT ' . $start . ', ' . $limit,
array(
'board_list' => $parameters['board'],
'is_approved' => 1,

)
);
$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$posts[] = $row['id_first_msg'];
$smcFunc['db_free_result']($request);


$request = $smcFunc['db_query']('', '
SELECT
m.icon, m.subject, m.body, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time,
t.num_replies, t.id_topic, m.id_member, m.smileys_enabled, m.id_msg, t.locked, mem.avatar,
a.id_attach, a.attachment_type, a.filename, t.num_views
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE t.id_first_msg IN ({array_int:post_list})
ORDER BY t.id_first_msg DESC
LIMIT ' . (!empty($per_page) ? '{int:start}, ' : '') . '{int:limit}',
array(
'post_list' => $posts,
'start' => $start,
'limit' => !empty($per_page) ? $per_page : $limit,
)
);
$return = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$limited = false;
if (($cutoff = $smcFunc['strpos']($row['body'], '')) !== false)
{
$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
$limited = true;
}
elseif (!empty($length) && $smcFunc['strlen']($row['body']) > $length)
{
$row['body'] = $smcFunc['substr']($row['body'], 0, $length);
$limited = true;
}

$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);

// Only place an ellipsis if the body has been shortened.
if ($limited)
$row['body'] .= '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0" title="' . $row['subject'] . '">...</a>';

if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';


// If we want to limit the length of the post.
if (!empty($length) && $smcFunc['strlen']($row['body']) > $length)
{
$row['body'] = $smcFunc['substr']($row['body'], 0, $length);
$cutoff = false;
$last_space = strrpos($row['body'], ' ');
$last_open = strrpos($row['body'], '<');
$last_close = strrpos($row['body'], '>');
if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6)
$cutoff = $last_open;
elseif (empty($last_close) || $last_close < $last_open)
$cutoff = $last_space;

if ($cutoff !== false)
$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
$row['body'] .= '...';
}

$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);

if (!empty($recycle_board) && $row['id_board'] == $recycle_board)
$row['icon'] = 'recycled';

// Check that this message icon is there...
if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
 // $row['body'] içerisinde <img> kodu ara
   $secimyap = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $row['body'], $sonuc);
   // src="" içindekini al.
 if(!empty($sonuc[0]) && !empty($sonuc[1]))
   $ilkresim = $sonuc [1] [0];
  else{ // Resim bulunmazsa default resim ekle
     $ilkresim = $settings['theme_url'] . '/images/boardnew.png';
   }
censorText($row['subject']);
censorText($row['body']);

if ($modSettings['sp_resize_images'])
$row['body'] = preg_replace('~class="bbc_img~i', 'class="bbc_img sp_article', $row['body']);

if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];

$return[] = array(
'id' => $row['id_topic'],
'message_id' => $row['id_msg'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 33),
'resim' => $ilkresim,
'time' => timeformat($row['poster_time']),
'views' => $row['num_views'],
'body' => $row['body'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'link' => '<a class="yorum" href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['num_replies'] . ' ' . ($row['num_replies'] == 1 ? $txt['ssi_comment'] : $txt['ssi_comments']) . '</a>',
'replies' => $row['num_replies'],
'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'],
'comment_link' => !empty($row['locked']) ? '' : '| <a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>',
'new_comment' => !empty($row['locked']) ? '' : '| <a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>',
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
'link' => !empty($row['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>' : $row['poster_name']
),
'locked' => !empty($row['locked']),
'is_last' => false,
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),
);
}
$smcFunc['db_free_result']($request);


$return[count($return) - 1]['is_last'] = true;

if (!empty($colorids) &&($colorids) !== false)
{
foreach ($return as $k => $p)
{
if (!empty($color_profile[$p['poster']['id']]['link']))
$return[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
}
}

       echo '<style type="text/css" >
#featured .ui-tabs-panel .info{
display:none;
}
</style> <center> <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/jquery-1.3.2.min.js" ></script>
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/jquery-ui-1.7.2.custom.min.js" ></script>
<script type="text/javascript">
$(document).ready(function(){
$("#featured").tabs({fx:[{opacity: "toggle", duration: \'slow\'}, {opacity: "toggle", duration: \'normal\'}],
show: function(event, ui){
$(\'#featured .ui-tabs-panel .info\').hide();
var infoheight=$(\'.info\', ui.panel).height();
$(\'.info\', ui.panel).css(\'height\', \'0px\').animate({ \'height\': infoheight }, 500);
}
}).tabs("rotate", 5000, true);
$(\'#featured\').hover(
function(){ $(\'#featured\').tabs(\'rotate\', 0, true); },
function(){ $(\'#featured\').tabs(\'rotate\', 5000, true); }
);
$(\'#featured .ui-tabs-panel a.hideshow\').click(function(){
if($(this).text()==\'Hide\'){
$(this).parent(\'.info\').animate({ \'height\': \'0px\' }, 500);
$(this).text(\'Show\');
}
else{
$(this).parent(\'.info\').animate({ \'height\': \'70px\' }, 500);
$(this).text(\'Hide\');
}
return false;
});
});
</script>
   <div id="featured" >
  <ul class="ui-tabs-nav"> ';
         foreach ($return as $news)
          {
  echo '      <li class="ui-tabs-nav-item" id="nav-fragment-', $news['id'], '"><a href="#fragment-', $news['id'], '"><img src="', $news['resim'], '" alt="', $news['subject'], '" class="smallimg"/><span>', $news['short_subject'], '</span></a></li> ';
  }       
  echo '  </ul>';
foreach ($return as $news)
     {
  echo '
  <div id="fragment-', $news['id'], '" class="ui-tabs-panel" style="">
<a  href="', $news['href'], '"><img src="', $news['resim'], '" alt="', $news['subject'], '" class="bigimg"/></a>
<div class="info" >
<a  href="', $news['href'], '">', $news['subject'], '</a>
<p>', temizle($news['body']), ' </p>
</div></div>';
     }
          echo'</div></center>

';
}

function temizle($haber) {
     $strs=explode('<',$haber);
     $res=$strs[0];
     for($i=1;$i<count($strs);$i++)
     {
         if(!strpos($strs[$i],'>'))
             $res = $res.'&lt;'.$strs[$i];
         else
             $res = $res.'<'.$strs[$i];
     }
     return strip_tags($res);   
 }
index.css en alta ekle
Code: [Select]
#featured{
 width:400px;
 padding-right:250px;
 position:relative;
 border:5px solid #ccc;
 height:250px; overflow:hidden;
 background:#fff;
}
#featured ul.ui-tabs-nav{
 position:absolute;
 top:0; left:400px;
 list-style:none;
 padding:0; margin:0;
 width:250px; height:250px;
 overflow:auto;
 overflow-x:hidden;
}
#featured ul.ui-tabs-nav li{
 padding:1px 0; padding-left:13px; 
 font-size:12px;
 color:#666;
}
#featured ul.ui-tabs-nav li img{
 float:left; margin:2px 5px;
 background:#fff;
 padding:2px;
 border:1px solid #eee;
}
#featured ul.ui-tabs-nav li span{
 font-size:11px; font-family:Verdana;
 line-height:18px;
}
#featured li.ui-tabs-nav-item a{
 display:block;
 height:60px; text-decoration:none;
 color:#333;  background:#fff;
 line-height:20px; outline:none;
}
#featured li.ui-tabs-nav-item a:hover{
 background:#f2f2f2;
}
#featured li.ui-tabs-selected, #featured li.ui-tabs-active{
 background:url(../images/selected-item.gif) top left no-repeat; 
}
#featured ul.ui-tabs-nav li.ui-tabs-selected a, #featured ul.ui-tabs-nav li.ui-tabs-active a{
 background:#ccc;
}
#featured .ui-tabs-panel{
 width:400px; height:250px;
 background:#999; position:relative;
}
#featured .ui-tabs-panel .info{
 position:absolute;
 bottom:0; left:0;
 height:70px;
 background: url(../images/transparent-bg.png);
}


#featured .info p{
 margin:0 5px;
 font-family:Verdana; font-size:11px;
 line-height:15px; color:#fff;
}
#featured .info a{
 font-size:1.2em; font-family:Georgia, serif;
 color:wheat; padding:5px; margin:0; font-weight:normal;
 overflow:hidden;
}
#featured .info a:hover{
 text-decoration:underline;
}
#featured .ui-tabs-hide{
 display:none;
}
.smallimg{width:60px;height: 50px;}
.bigimg{width:400px;height: 250px;}

ekte verdiğim js dosyalarını temanızın /scripts klasörüne
ekte verdiğim resim dosyalarınıda  kullandığınız temanın images klasörüne atınız
 kodların içindeki şu kısımı 'board' => array(1,2,5), kendinize göre düzeltin
http://smf.teknoromi.com/index.php?topic=61.0
SimplePortal 2.3.8 © 2008-2024, SimplePortal