Esempio n. 1
0
 /**
  * Tests the JHtmlNumber::bytes method.
  *
  * @param	string	$result
  * @param	int		$btyes
  * @param	string	$unit
  * @param	int		$precision
  *
  * @dataProvider dataTestBytes
  */
 public function testBytes($result, $bytes, $unit = 'auto', $precision = 2)
 {
     $this->assertThat(JHtmlNumber::bytes($bytes, $unit, $precision), $this->equalTo($result));
 }
    public function save()
    {
        if (!JSession::checkToken()) {
            $this->setMessage('An error occurred. Please submit again.', 'error');
            $this->redirect();
        }
        $FUFUploadForm = $this->input->post->get('FUFUploadForm', array(), 'array');
        $captcharesponse = JArrayHelper::getValue($FUFUploadForm, 'captcha', null, null);
        $captcha = JCaptcha::getInstance(JFactory::getConfig()->get('captcha'));
        if ($captcha && !$captcha->checkAnswer($captcharesponse)) {
            $vars = JFactory::getSession()->get('mathcaptcha');
            $this->redirect();
        }
        $toEmails = FUFParams::getEmails();
        if (empty($toEmails)) {
            $this->setMessage('An error occurred.', 'error');
            $this->redirect();
        }
        $name = JArrayHelper::getValue($FUFUploadForm, 'name', '', 'string');
        if (empty($name)) {
            $this->setMessage('Please enter a name', 'error');
            $this->redirect();
        }
        $email = JArrayHelper::getValue($FUFUploadForm, 'email', '', 'string');
        if (!FUFValidate::email($email)) {
            $this->setMessage('Please enter a valid email', 'error');
            $this->redirect();
        }
        $phone = JArrayHelper::getValue($FUFUploadForm, 'phone', '', 'string');
        if (empty($phone)) {
            $this->setMessage('Please enter a phone', 'error');
            $this->redirect();
        }
        $FUFFilesUpload = array_filter($this->input->post->get('FUFFilesUpload', array(), 'array'));
        JLoader::import('cms.html.number');
        $mail = JFactory::getMailer();
        $mail->IsHTML();
        $mail->addReplyTo($email, $name);
        foreach ($toEmails as $toEmail) {
            $mail->addRecipient($toEmail);
        }
        $mail->setSubject(FUFParams::getSubject());
        ob_start();
        ?>
			<b>Company:</b> <?php 
        echo htmlspecialchars(JArrayHelper::getValue($FUFUploadForm, 'company', '', 'string'));
        ?>
<br />
			<b>Name:</b></u> <?php 
        echo htmlspecialchars($name);
        ?>
<br />
			<b>Email:</b></u> <?php 
        echo htmlspecialchars($email);
        ?>
<br />
			<b>Phone:</b></u> <?php 
        echo htmlspecialchars($phone);
        ?>
<br />
			<b>How they heard about CILE:</b></u> <?php 
        echo htmlspecialchars(JArrayHelper::getValue($FUFUploadForm, 'how', '', 'string'));
        ?>
<br />
			<b>Desired Completion Date:</b></u> <?php 
        echo htmlspecialchars(JArrayHelper::getValue($FUFUploadForm, 'completion', '', 'string'));
        ?>
<br />
			<u><b>Message:</b></u><br /><?php 
        echo htmlspecialchars(JArrayHelper::getValue($FUFUploadForm, 'message', '', 'string'));
        ?>
<br />
			<?php 
        if (!empty($FUFFilesUpload)) {
            ?>
				<u><b>Files:</b></u><br />
				<?php 
            foreach ($FUFFilesUpload as $key => $val) {
                $file = json_decode($val);
                ?>
					<a href="<?php 
                echo htmlspecialchars($file->url);
                ?>
" target="_blank">
						<?php 
                echo htmlspecialchars($file->name);
                ?>
					</a> - <?php 
                echo htmlspecialchars(JHtmlNumber::bytes($file->size));
                ?>
<br />
				<?php 
            }
            ?>
			<?php 
        } else {
            ?>
				<u><b>No Files Uploaded</b></u>
			<?php 
        }
        ?>
		<?php 
        $mail->setBody(ob_get_clean());
        $mail->Send();
        $this->setMessage('Thank you for your inquiry. A customer service representative will respond to your shortly.');
    }
 /**
  * Tests the JHtmlNumber::bytes method.
  *
  * @param   string   $result     The expected result to match against.
  * @param   string   $bytes      The number of bytes. Can be either numeric or suffixed format: 32M, 60K, 12G or 812b
  * @param   string   $unit       The type of unit to return, few special values are:
  *                               Blank string '' for no unit,
  *                               'auto' to choose automatically (default)
  *                               'binary' to choose automatically but use binary unit prefix
  * @param   integer  $precision  The number of digits to be used after the decimal place.
  * @param   bool     $iec        Whether to be aware of IEC standards. IEC prefixes are always acceptable in input.
  *                               When IEC is ON:  KiB = 1024 B, KB = 1000 B
  *                               When IEC is OFF: KiB = 1024 B, KB = 1024 B
  *
  * @return  void
  *
  * @since        3.1
  * @dataProvider dataTestBytes
  */
 public function testBytes($result, $bytes, $unit = 'auto', $precision = 2, $iec = false)
 {
     $this->assertEquals($result, JHtmlNumber::bytes($bytes, $unit, $precision, $iec));
 }