<commit_before><?php
/**
 * Abstract downloader class
 *
 * This class contains the common parts for all
 * downloader classes. The inherited class is
 * responsible for creating the right document type
 * and preparing/sending the response to the client.
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class Webenq_Download extends Webenq
{
	/**
	 * Questionnaire
	 *
	 * @var Webenq_Model_Questionnaire $_questionnaire
	 */
	protected $_questionnaire;

    /**
     * Array containing the questionnaire data.
     *
     * @var array $_data
     */
    protected $_data = array();

	/**
	 * Factory method for easily getting an instance
	 * of the right downloader class.
	 *
	 * @param string $format
	 * @param Webenq_Model_Questionnaire $questionnaire
	 */
	static public function factory($format, Webenq_Model_Questionnaire $questionnaire)
	{
		$class = 'Webenq_Download_' . ucfirst(strtolower($format));
		return new $class($questionnaire);
	}

	/**
	 * Class constructor
	 *
	 * Sets the questionnaire property and calls the
	 * init() method that must be implemented by all
	 * downloader classes.
	 *
	 * @param Webenq_Model_Questionnaire $questionnaire
	 */
	public function __construct(Webenq_Model_Questionnaire $questionnaire)
	{
		$this->_questionnaire = $questionnaire;
        $this->_data = $questionnaire->getDataAsSpreadsheetArray();
		$this->init();
	}

	/**
	 * Prepares the document
	 *
	 * This method must be implemented by all downloader
	 * classes and should prepare the document, so that
	 * it is ready to be send to the client.
	 */
	abstract function init();

	/**
	 * Sends the document
	 *
	 * This method must be implemented by all downloader
	 * classes and should send the document to the client,
	 * using the provided response object.
	 *
	 * @param Zend_Controller_Response_Http $response
	 */
	abstract function send(Zend_Controller_Response_Http $response);

	/**
	 * Returns the name of the file for download
	 */
	public function getDownloadFilename()
	{
	    if ($title = $this->_questionnaire->getQuestionnaireTitle()->title) {
	        $filename = strtolower(preg_replace('/[^a-zA-Z0-9]/', null, $title));
	    } else {
	        $filename = 'notitle';
	    }
	    $filename .= date('_Ymd_His.') . $this->_extension;
		return $filename;
	}

	/**
	 * Returns the MIME type of the file for download
	 */
	public function getMimeType()
	{
		return $this->_mimeType;
	}
}<commit_msg>[5367] fix: property 'text' ipv 'title' uit Webenq_Model_QuestionnaireTitle<commit_after><?php
/**
 * Abstract downloader class
 *
 * This class contains the common parts for all
 * downloader classes. The inherited class is
 * responsible for creating the right document type
 * and preparing/sending the response to the client.
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class Webenq_Download extends Webenq
{
	/**
	 * Questionnaire
	 *
	 * @var Webenq_Model_Questionnaire $_questionnaire
	 */
	protected $_questionnaire;

    /**
     * Array containing the questionnaire data.
     *
     * @var array $_data
     */
    protected $_data = array();

	/**
	 * Factory method for easily getting an instance
	 * of the right downloader class.
	 *
	 * @param string $format
	 * @param Webenq_Model_Questionnaire $questionnaire
	 */
	static public function factory($format, Webenq_Model_Questionnaire $questionnaire)
	{
		$class = 'Webenq_Download_' . ucfirst(strtolower($format));
		return new $class($questionnaire);
	}

	/**
	 * Class constructor
	 *
	 * Sets the questionnaire property and calls the
	 * init() method that must be implemented by all
	 * downloader classes.
	 *
	 * @param Webenq_Model_Questionnaire $questionnaire
	 */
	public function __construct(Webenq_Model_Questionnaire $questionnaire)
	{
		$this->_questionnaire = $questionnaire;
        $this->_data = $questionnaire->getDataAsSpreadsheetArray();
		$this->init();
	}

	/**
	 * Prepares the document
	 *
	 * This method must be implemented by all downloader
	 * classes and should prepare the document, so that
	 * it is ready to be send to the client.
	 */
	abstract function init();

	/**
	 * Sends the document
	 *
	 * This method must be implemented by all downloader
	 * classes and should send the document to the client,
	 * using the provided response object.
	 *
	 * @param Zend_Controller_Response_Http $response
	 */
	abstract function send(Zend_Controller_Response_Http $response);

	/**
	 * Returns the name of the file for download
	 */
	public function getDownloadFilename()
	{
	    if ($title = $this->_questionnaire->getQuestionnaireTitle()->text) {
	        $filename = strtolower(preg_replace('/[^a-zA-Z0-9]/', null, $title));
	    } else {
	        $filename = 'notitle';
	    }
	    $filename .= date('_Ymd_His.') . $this->_extension;
		return $filename;
	}

	/**
	 * Returns the MIME type of the file for download
	 */
	public function getMimeType()
	{
		return $this->_mimeType;
	}
}
{'fraction_non_alphanumeric': 0.10581039755351682, 'fraction_numerical': 0.0016309887869520897, 'mean_word_length': 3.4926739926739927, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '353563', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1372, 'n_words': 449}