<commit_before><?php
/**
 * Abstract class for various services, e.g. Twitter, Facebook, Digg, ...
 *
 * PHP Version 5.3
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at http://mozilla.org/MPL/2.0/.
 *
 * @category  phpMyFAQ
 * @package   Services
 * @author    <NAME> <<EMAIL>>
 * @copyright 2010-2015 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2010-09-05
 */

/**
 * Services
 *
 * @category  phpMyFAQ
 * @package   Services
 * @author    <NAME> <<EMAIL>>
 * @copyright 2010-2015 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2010-09-05
 */
class PMF_Services
{
    /**
     * FAQ ID
     *
     * @var integer
     */
    protected $faqId;

    /**
     * Category ID
     *
     * @var integer
     */
    protected $categoryId;

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

    /**
     * Question of the FAQ
     *
     * @var string 
     */
    protected $question;

    /**
     * @var PMF_Configuration
     */
    private $_config;

    /**
     * Constructor
     *
     * @param PMF_Configuration $config
     *
     * @return PMF_Services
     */
    public function __construct(PMF_Configuration $config)
    {
        $this->_config = $config;
    }

    /**
     * Returns the current URL
     *
     * @return string
     */
    public function getLink()
    {
        $url = sprintf(
            '%sindex.php?action=artikel&cat=%s&id=%d&artlang=%s',
            $this->_config->get('main.referenceURL'),
            $this->getCategoryId(),
            $this->getFaqId(),
            $this->getLanguage()
        );

        $link = new PMF_Link($url, $this->_config);
        $link->itemTitle = $this->question;

        return urlencode($link->toString());
    }

    /**
     * Returns the current "Digg It!" URL
     *
     * @return string
     */
    public function getDiggLink()
    {
        $url = sprintf(
            '%sindex.php?action=artikel&cat=%s&id=%d&artlang=%s&title=%s',
            $this->_config->get('main.referenceURL'),
            $this->getCategoryId(),
            $this->getFaqId(),
            $this->getLanguage(),
            $this->getQuestion()
        );

        $link = new PMF_Link($url, $this->_config);
        $link->itemTitle = $this->question;

        return sprintf('http://digg.com/submit?phase=2&url=%s', urlencode($link->toString()));
    }

    /**
     * Returns the current "share on Facebook" URL
     *
     * @return string
     */
    public function getShareOnFacebookLink()
    {
        $url = sprintf(
            '%sindex.php?action=artikel&cat=%s&id=%d&artlang=%s',
            $this->_config->get('main.referenceURL'),
            $this->getCategoryId(),
            $this->getFaqId(),
            $this->getLanguage()
        );

        $link = new PMF_Link($url, $this->_config);
        $link->itemTitle = $this->question;

        return sprintf('https://www.facebook.com/sharer.php?u=%s', urlencode($link->toString()));
    }

    /**
     * Returns the current "share on Twitter" URL
     *
     * @return string
     */
    public function getShareOnTwitterLink()
    {
        $url = sprintf(
            '%sindex.php?action=artikel&cat=%s&id=%d&artlang=%s',
            $this->_config->get('main.referenceURL'),
            $this->getCategoryId(),
            $this->getFaqId(),
            $this->getLanguage()
        );

        $link = new PMF_Link($url, $this->_config);
        $link->itemTitle = $this->question;

        return sprintf(
            'https://twitter.com/share?url=%s&text=%s',
            urlencode($link->toString()),
            $this->getQuestion() . urlencode(' | ' . $url)
        );
    }

    /**<commit_msg>Fixed issue with missing rewrite links with Twitter, closes #968<commit_after><?php
/**
 * Abstract class for various services, e.g. Twitter, Facebook, Digg, ...
 *
 * PHP Version 5.3
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at http://mozilla.org/MPL/2.0/.
 *
 * @category  phpMyFAQ
 * @package   Services
 * @author    <NAME> <<EMAIL>>
 * @copyright 2010-2015 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2010-09-05
 */

/**
 * Services
 *
 * @category  phpMyFAQ
 * @package   Services
 * @author    <NAME> <<EMAIL>>
 * @copyright 2010-2015 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2010-09-05
 */
class PMF_Services
{
    /**
     * FAQ ID
     *
     * @var integer
     */
    protected $faqId;

    /**
     * Category ID
     *
     * @var integer
     */
    protected $categoryId;

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

    /**
     * Question of the FAQ
     *
     * @var string 
     */
    protected $question;

    /**
     * @var PMF_Configuration
     */
    private $_config;

    /**
     * Constructor
     *
     * @param PMF_Configuration $config
     *
     * @return PMF_Services
     */
    public function __construct(PMF_Configuration $config)
    {
        $this->_config = $config;
    }

    /**
     * Returns the current URL
     *
     * @return string
     */
    public function getLink()
    {
        $url = sprintf(
            '%sindex.php?action=artikel&cat=%s&id=%d&artlang=%s',
            $this->_config->get('main.referenceURL'),
            $this->getCategoryId(),
            $this->getFaqId(),
            $this->getLanguage()
        );

        $link = new PMF_Link($url, $this->_config);
        $link->itemTitle = $this->question;

        return urlencode($link->toString());
    }

    /**
     * Returns the current "Digg It!" URL
     *
     * @return string
     */
    public function getDiggLink()
    {
        $url = sprintf(
            '%sindex.php?action=artikel&cat=%s&id=%d&artlang=%s&title=%s',
            $this->_config->get('main.referenceURL'),
            $this->getCategoryId(),
            $this->getFaqId(),
            $this->getLanguage(),
            $this->getQuestion()
        );

        $link = new PMF_Link($url, $this->_config);
        $link->itemTitle = $this->question;

        return sprintf('http://digg.com/submit?phase=2&url=%s', urlencode($link->toString()));
    }

    /**
     * Returns the current "share on Facebook" URL
     *
     * @return string
     */
    public function getShareOnFacebookLink()
    {
        $url = sprintf(
            '%sindex.php?action=artikel&cat=%s&id=%d&artlang=%s',
            $this->_config->get('main.referenceURL'),
            $this->getCategoryId(),
            $this->getFaqId(),
            $this->getLanguage()
        );

        $link = new PMF_Link($url, $this->_config);
        $link->itemTitle = $this->question;

        return sprintf('https://www.facebook.com/sharer.php?u=%s', urlencode($link->toString()));
    }

    /**
     * Returns the current "share on Twitter" URL
     *
     * @return string
     */
    public function getShareOnTwitterLink()
    {
        $url = sprintf(
            '%sindex.php?action=artikel&cat=%s&id=%d&artlang=%s',
            $this->_config->get('main.referenceURL'),
            $this->getCategoryId(),
            $this->getFaqId(),
            $this->getLanguage()
        );

        $link = new PMF_Link($url, $this->_config);
        $link->itemTitle = $this->question;

        return sprintf(
            'https://twitter.com/share?url=%s&text=%s',
            urlencode($link->toString()),
            $this->getQuestion() . urlencode(' | ' . $link->toString())
        );
    }

    /**
{'fraction_non_alphanumeric': 0.15802530389481517, 'fraction_numerical': 0.012031753907219053, 'mean_word_length': 1.9437751004016064, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 94, 'https://': 4, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '640657', 'n_tokens_mistral': 2616, 'n_tokens_neox': 2498, 'n_words': 503}