<?
global $lang;
?>
<div class="clearfix"></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 )
{
  $art -> _values['seo_link'] ? $link = $art -> _values['seo_link'] : $link = 'a,' . $art -> _values['id'] . ',' . \System::seo( $art -> _values['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>
    <? endif;?>
    <div class='article_title'><a><?= stripslashes( $art -> _values['title'] );?></a></div>
    <? if ( $art -> _values['show_date'] ):?>
      <div class='article_date'><?= date( 'H:i d/m/Y', strtotime( $art -> _values['date_add'] ) );?></div>
    <? endif;?>
    <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 -> _values['text'] , '<b>' . $this -> _values['text'] . '</b>' , $out );

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