<commit_before><?php
/**
 * The News class for phpMyFAQ news
 *
 * @package    phpMyFAQ
 * @subpackage PMF_News
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @since      2006-06-25
 * @version    SVN: $Id$
 * @copyright  2006-2009 phpMyFAQ Team
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */

/**
 * The News class for phpMyFAQ news
 *
 * @package    phpMyFAQ
 * @subpackage PMF_News
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @since      2006-06-25
 * @version    SVN: $Id$
 * @copyright  2006-2009 phpMyFAQ Team
 */
class PMF_News
{
    /**
     * DB handle
     *
     * @var PMF_DB
     */
    private $db;

    /**
    * Language
    *
    * @var  string
    */
    private $language;

    /**
    * Language strings
    *
    * @var  string
    */
    private $pmf_lang;

    /**
    * Constructor
    *
    */
    public function __construct()
    {
        global $PMF_LANG;

        $this->db       = PMF_Db::getInstance();
        $this->language = PMF_Language::$language;
        $this->pmf_lang = $PMF_LANG;
    }

    /**
     * Return the latest news data
     *
     * @param   boolean $showArchive    Show archived news
     * @param   boolean $active         Show active news
     * @param   boolean $forceConfLimit Force to limit in configuration
     * @return  string
     */
    public function getLatestData($showArchive = false, $active = true, $forceConfLimit = false)
    {
        $news      = array();
        $counter   = 0;
        $now       = date('YmdHis');
        $faqconfig = PMF_Configuration::getInstance();

        $query = sprintf("
            SELECT
                *
            FROM
                %sfaqnews
            WHERE
                date_start <= '%s'
            AND 
                date_end   >= '%s'
            %s
            AND
                lang = '%s'
            ORDER BY
                datum DESC",
            SQLPREFIX,
            $now,
            $now,
            $active ? "AND active = 'y'" : '',
            $this->language);
            
        $result = $this->db->query($query);

        if ($faqconfig->get('main.numberOfShownNewsEntries') > 0 && $this->db->num_rows($result) > 0) {
        	
            while (($row = $this->db->fetch_object($result))) {
            	
                $counter++;
                if (($showArchive  && ($counter > $faqconfig->get('main.numberOfShownNewsEntries'))) || 
                   ((!$showArchive) && (!$forceConfLimit) && 
                   ($counter <= $faqconfig->get('main.numberOfShownNewsEntries'))) || 
                   ((!$showArchive) && $forceConfLimit)) {
                   	
                    $item = array(
                        'id'            => $row->id,
                        'lang'          => $row->lang,
                        'date'          => $row->datum,
                        'lang'          => $row->lang,
                        'header'        => $row->header,
                        'content'       => $row->artikel,
                        'authorName'    => $row->author_name,
                        'authorEmail'   => $row->author_email,
                        'dateStart'     => $row->date_start,
                        'dateEnd'       => $row->date_end,
                        'active'        => ('y' == $row->active),
                        'allowComments' => ('y' == $row->comment),
                        'link'          => $row->link,
                        'linkTitle'     => $row->linktitel,
                        'target'        => $row->target);
                    $news[] = $item;
                }
            }
        }

        return $news;
    }

    /**
     * Function for generating the HTML fro the current news
     *
     * @param   boolean $showArchive Show archived news
     * @param   boolean $active      Show active news
     * @return  string
     */
    public function getNews($showArchive = false, $active = true)
    {
        $output = '';

        $news = $this->getLatestData($showArchive, $active);

        foreach ($news as $item) {
        	
        	$url = sprintf('%s?action=news&amp;newsid=%d&amp;newslang=%s',
        	   PMF_Link::getSystemRelativeUri(),
        	   $item['id'],
        	   $item['lang']);
            $oLink = new PMF_Link($url);
            
            if (isset($item['header'])) {
                $oLink->itemTitle =$item['header'];
            }
            $output .= sprintf('<h3><a name="news_%d" href="%s">%s <img class="goNews" src="images/more.gif" width="11" height="11" alt="%s" /></a></h3><div class="block">%s',
                $item['id'],
                $oLink->toString(),
                $item['header'],
                $item['header'],
                $item['content']);
            
            if ('' != $item['link']) {
                $output .= sprintf('<br />%s <a href="%s" target="_%s">%s</a>',
                    $this->pmf_lang['msgInfo'],
                    $item['link'],
                    $item['target'],
                    $item['linkTitle']);
            }
            
            $output .= sprintf('</div><div class="date">%s</div>', makeDate($item['date']));
        }<commit_msg>MFB: Fixed issue with MS SQL<commit_after><?php
/**
 * The News class for phpMyFAQ news
 *
 * @package    phpMyFAQ
 * @subpackage PMF_News
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @since      2006-06-25
 * @version    SVN: $Id$
 * @copyright  2006-2009 phpMyFAQ Team
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */

/**
 * The News class for phpMyFAQ news
 *
 * @package    phpMyFAQ
 * @subpackage PMF_News
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @since      2006-06-25
 * @version    SVN: $Id$
 * @copyright  2006-2009 phpMyFAQ Team
 */
class PMF_News
{
    /**
     * DB handle
     *
     * @var PMF_DB
     */
    private $db;

    /**
    * Language
    *
    * @var  string
    */
    private $language;

    /**
    * Language strings
    *
    * @var  string
    */
    private $pmf_lang;

    /**
    * Constructor
    *
    */
    public function __construct()
    {
        global $PMF_LANG;

        $this->db       = PMF_Db::getInstance();
        $this->language = PMF_Language::$language;
        $this->pmf_lang = $PMF_LANG;
    }

    /**
     * Return the latest news data
     *
     * @param   boolean $showArchive    Show archived news
     * @param   boolean $active         Show active news
     * @param   boolean $forceConfLimit Force to limit in configuration
     * @return  string
     */
    public function getLatestData($showArchive = false, $active = true, $forceConfLimit = false)
    {
        $news      = array();
        $counter   = 0;
        $now       = date('YmdHis');
        $faqconfig = PMF_Configuration::getInstance();

        $query = sprintf("
            SELECT
                *
            FROM
                %sfaqnews
            WHERE
                date_start <= '%s'
            AND 
                date_end   >= '%s'
            %s
            AND
                lang = '%s'
            ORDER BY
                datum DESC",
            SQLPREFIX,
            $now,
            $now,
            $active ? "AND active = 'y'" : '',
            $this->language);
            
        $result = $this->db->query($query);

        if ($faqconfig->get('main.numberOfShownNewsEntries') > 0 && $this->db->num_rows($result) > 0) {
        	
            while (($row = $this->db->fetch_object($result))) {
            	
                $counter++;
                if (($showArchive  && ($counter > $faqconfig->get('main.numberOfShownNewsEntries'))) || 
                   ((!$showArchive) && (!$forceConfLimit) && 
                   ($counter <= $faqconfig->get('main.numberOfShownNewsEntries'))) || 
                   ((!$showArchive) && $forceConfLimit)) {
                   	
                    $item = array(
                        'id'            => $row->id,
                        'lang'          => $row->lang,
                        'date'          => $row->datum,
                        'lang'          => $row->lang,
                        'header'        => $row->header,
                        'content'       => $row->artikel,
                        'authorName'    => $row->author_name,
                        'authorEmail'   => $row->author_email,
                        'dateStart'     => $row->date_start,
                        'dateEnd'       => $row->date_end,
                        'active'        => ('y' == $row->active),
                        'allowComments' => ('y' == $row->comment),
                        'link'          => $row->link,
                        'linkTitle'     => $row->linktitel,
                        'target'        => $row->target);
                    $news[] = $item;
                }
            }
        }

        return $news;
    }

    /**
     * Function for generating the HTML fro the current news
     *
     * @param   boolean $showArchive Show archived news
     * @param   boolean $active      Show active news
     * @return  string
     */
    public function getNews($showArchive = false, $active = true)
    {
        $output = '';

        $news = $this->getLatestData($showArchive, $active);

        foreach ($news as $item) {
        	
        	$url = sprintf('%s?action=news&amp;newsid=%d&amp;newslang=%s',
        	   PMF_Link::getSystemRelativeUri(),
        	   $item['id'],
        	   $item['lang']);
            $oLink = new PMF_Link($url);
            
            if (isset($item['header'])) {
                $oLink->itemTitle =$item['header'];
            }
            $output .= sprintf('<h3><a name="news_%d" href="%s">%s <img class="goNews" src="images/more.gif" width="11" height="11" alt="%s" /></a></h3><div class="block">%s',
                $item['id'],
                $oLink->toString(),
                $item['header'],
                $item['header'],
                $item['content']);
            
            if (strlen($item['link']) > 1) {
                $output .= sprintf('<br />%s <a href="%s" target="_%s">%s</a>',
                    $this->pmf_lang['msgInfo'],
                    $item['link'],
                    $item['target'],
                    $item['linkTitle']);
            }
            
            $output .= sprintf('</div><div class="date">%s</div>', makeDate($item['date']));
        }
{'fraction_non_alphanumeric': 0.14511152252490522, 'fraction_numerical': 0.0076699285903200215, 'mean_word_length': 1.408492569002123, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 154, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7182044', 'n_tokens_mistral': 3372, 'n_tokens_neox': 3177, 'n_words': 738}