protected function sendContactEmail($values) {
		
		$mail = new Mail;
		
		$mailConfig = Nette\Environment::getConfig('mail');
		
		$mail->setFrom($values['email']);
		$mail->addTo($mailConfig->to); //load from config.ini
//		$mail->setSubject($mailConfig->subject);
		
		$mail->setBody($values['message']);
		
		$template = $this->createTemplate();
		$template->setFile(APP_DIR . '/templates/emails/contact.latte');
		
		$template->title = $mailConfig->subject;
		$template->values = $values;
		
		$mail->setHtmlBody($template);
		
		$mail->send();
		
		$this->flashMessage('Správa bola odoslaná');
		
		$this->redirect('this');
		
	}
 public function createComponentForm($name)
 {
     $form = new Form($this, $name);
     $form->addTextArea("html", "Upravte data", 80, 50)->controlPrototype->class[] = "tinymce";
     $form->addSubmit("doPDFka", "Do PDFka!");
     $appDir = Nette\Environment::getVariable('appDir');
     $form->setDefaults(array("html" => $this->createTemplate()->setFile($appDir . "/templates/Homepage/pdf-source.latte")->__toString()));
     $form->onSuccess[] = array($this, "onSubmit");
 }
Exemple #3
0
/**
 * Translates the given string with plural and vsprintf.
 *
 * @deprecated
 * @param string
 * @param string
 * @param int plural form (positive number)
 * @param array for vsprintf
 * @return string
 */
function _nx($single, $plural, $number, array $args)
{
	trigger_error(__FUNCTION__ . '() is deprecated; use __(array(\$single, \$plural), array(\$number, $args[0], $args[1], ...) instead.', E_USER_DEPRECATED);
	return Nette\Environment::getService('translator')
		->translate(array($single, $plural), array_merge(array($number), $args));
}
/**
 * My Application bootstrap file.
 *
 * @copyright  Copyright (c) 2009 John Doe
 * @package    MyApplication
 */
// Step 1: Load Nette Framework
// this allows load Nette Framework classes automatically so that
// you don't have to litter your code with 'require' statements
require __DIR__ . '/../../vendor/autoload.php';
// Step 2: Configure environment
// 2a) enable Nette\Debug for better exception and error visualisation
\Nette\Diagnostics\Debugger::enable(\Nette\Diagnostics\Debugger::DEVELOPMENT, APP_DIR . "/log");
// 2b) load configuration from config.ini file
//Nette\Environment::loadConfig();
// Step 3: Configure application
// 3a) get and setup a front controller
$application = Nette\Environment::getApplication();
$application->errorPresenter = 'Error';
//$application->catchExceptions = TRUE;
$loader = new \Nette\Loaders\RobotLoader();
$loader->setCacheStorage(Nette\Environment::getContext()->cacheStorage);
$loader->addDirectory(APP_DIR);
$loader->register();
use Nette\Application\Routers\Route;
// Step 4: Setup application router
$router = $application->getRouter();
$router[] = new Route('index.php', array('presenter' => 'Download', 'action' => 'default'), Route::ONE_WAY);
$router[] = new Route('<presenter>/<action>/<id>', array('presenter' => 'Download', 'action' => 'default', 'id' => NULL));
// Step 5: Run the application!
$application->run();
Exemple #5
0
// Nette Framework Microblog example

use Nette\Diagnostics\Debugger;


// load libraries
require __DIR__ . '/../../../Nette/loader.php';
require __DIR__ . '/data/TemplateRouter.php';


// enable Debugger
Debugger::$logDirectory = __DIR__ . '/data/log';
Debugger::$strictMode = TRUE;
Debugger::enable();


// enable template router
$context = Nette\Environment::getContext();
$context->params['tempDir'] = __DIR__ . '/data/temp';
$context->application->router[] = new TemplateRouter('data/templates');


// add access to database
$context->addService('database', function() {
	return new Nette\Database\Connection('sqlite2:data/blog.sdb');
});


// run the application!
$context->application->run();
Exemple #6
0
	Nette\Utils\Json;


// load framework
require __DIR__ . '/../../../Nette/loader.php';


// enable Debugger
Debugger::$logDirectory = __DIR__ . '/data/log';
Debugger::$strictMode = TRUE;
Debugger::enable();


// create application
$application = Nette\Environment::getApplication();
Nette\Environment::setVariable('tempDir', __DIR__ . '/data/temp');


$application->router[] = new Route('[index.php]', function() {
	return 'Hello! Would you like to search <a href="search/nettefw">#nettefw</a> on Twitter?';
});

$application->router[] = new Route('search/<hashtag \w+>', function($hashtag, $presenter) {
	$params['response'] = Json::decode(file_get_contents('http://search.twitter.com/search.json?q=' . urlencode("#$hashtag")));
	return array('
		<h1>Results for #{$hashtag}</h1>

		{foreach $response->results as $item}
			<p><img src="{$item->profile_image_url}" width="48"><em>{$item->from_user}</em>: {$item->text}
				<small>at {$item->created_at|date:"j.n.Y H:i"}</small></p>
		{/foreach}
Exemple #7
0
	),
	'database' => array(
		'driver' => "pdo_mysql",
		'memory' => TRUE,
	),
);
$container->addService('cacheStorage', 'Nette\Caching\Storages\DevNullStorage');
$container->addService('templateCacheStorage', function(Nette\DI\Container $container) {
	return $container->cacheStorage;
});
$container->addService('user', 'NellaTests\Mocks\User');
$container->addService('httpRequest', function() {
	$factory = new Nette\Http\RequestFactory;
	$factory->setEncoding('UTF-8');
	return $factory->createHttpRequest();
});
$container->addService('httpResponse', 'Nette\Http\Response');
$container->addService('components', 'Nella\Application\UI\ComponentContainer');
$container->addService('macros', 'Nella\Latte\Macros');
$container->addService('model', function() {
	$context = new \Nella\Doctrine\Container;
	$context->addService('entityManager', \Doctrine\Tests\Mocks\EntityManagerMock::create(
		new \Doctrine\DBAL\Connection(array(), new \Doctrine\DBAL\Driver\PDOSqlite\Driver)
	));
	return $context;
});
$container->addService('latteEngine', 'Nella\Latte\Engine');

// Set DI Container
Nette\Environment::setContext($container);
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @author     Jan Kuchař
 * @copyright  Copyright (c) 2009 Jan Kuchař (http://mujserver.net)
 * @license    New BSD License
 * @link       http://filedownloader.projekty.mujserver.net
 * @version    $Id$
 */
require_once __DIR__ . "/vendor/autoload.php";
define("TEMP_DIR", APP_DIR . "/cache");
date_default_timezone_set("Europe/Prague");
//$loader = new Nette\Loaders\RobotLoader();
//$loader->addDirectory(APP_DIR);
//$loader->addDirectory(dirname(__FILE__)."/../FileDownloader");
//$loader->addDirectory(dirname(__FILE__)."/../libs/BigFileTools");
//$loader->register();
\Nette\Diagnostics\Debugger::enable(\Nette\Diagnostics\Debugger::DEVELOPMENT, APP_DIR . "/log");
Nette\Environment::getHttpResponse()->setContentType("text/html", "UTF-8");
Exemple #9
0
 /**
  * Gets nicer date format
  * @param mixed date (MySQL DateTime or timestamp)
  * @param bool withoutTime (returns only date without time)
  * @return string
  */
 public static function formatDate($date, $withoutTime = false)
 {
     if (!is_int($date)) {
         $date = strtotime($date);
     }
     switch (Nette\Environment::getVariable('lang')) {
         case 'cs':
             if ($withoutTime) {
                 return date('j.n.Y', $date);
             }
             return date('j.n.Y G:i', $date);
         case 'en':
             if ($withoutTime) {
                 return date('j.n.Y', $date);
             }
             return date('j.n.Y G:i', $date);
         default:
             if ($withoutTime) {
                 return date('j.n.Y', $date);
             }
             return date('Y/m/d H:i', $date);
     }
 }