<?
global $lang;
?>
<div class="clearfix" style="margin-bottom: 50px; width: 100%; height: 1px;"></div>
<?
include 'templates/site-search-form.php';

if ( $this -> _message )
  echo '<div class="alert">' . $this -> _message . '</div>';

if ( is_array( $this -> _articles ) ) foreach ( $this -> _articles as $art )
{
  if ( $art -> get_seo_link() )
    $link = $art -> get_seo_link();
  else
    $link = 'a,' . $art -> get_id() . ',' . \System::seo( $art -> get_title() );
  ?>
  <div class='article_entry' onClick='document.location.href="<?=$link;?>";'>
    <?
      if ( $art -> getImg() )
      {
        ?>
        <div class="article_img">
          <img src='resources/thumber.php?img=<?=$art -> getImg();?>&w=100'>
        </div>
        <?
      }
      ?>
      <div class='article_title'><a><?=stripslashes( $art -> get_title() );?></a></div>
      <div class='article_date'><?=$art -> get_date_add();?></div>
      <?
    ?>
    <div class="text">
      <?
        $text     = strip_tags( $art -> getModifyText( true ) );
        $position = strpos( $text , $this -> _text );

        $start = $position - 255;
        if ( $start < 0 )
          $start = 0;

        if ( $start > 0 )
          $out = '...';
        else
          $out = '';

        $end = 255;
        if ( $end > $position )
          $end = $position;

        $out .= mb_substr( $text , $start    , $end , 'UTF-8' );
        $out .= mb_substr( $text , $position , 255 , 'UTF-8' );
        $out .= '...';

        $out = str_replace( $this -> _text , '<b>' . $this -> _text . '</b>' , $out );

        echo $out;
      ?>
    </div>
    <a href="<?=$link;?>" class='article_more'><?=$lang -> getTrans( 'T_WIECEJ' );?></a>
    <p style='clear:both'></p>
  </div>
  <?
}
?>
