public function renderDefault()
 {
     $this->template->form = $this->getComponent('settingsForm');
     $this->template->form->setDefaults(Environment::getVariables());
 }
Esempio n. 2
0
/*use Nette\Environment;*/
echo "Getting variable 'foo':\n";
Debug::dump(Environment::getVariable('foo'));
try {
    echo "Getting variable 'tempDir':\n";
    Debug::dump(Environment::getVariable('tempDir'));
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
echo "Defining constant 'APP_DIR':\n";
define('APP_DIR', '/myApp');
echo "Getting variable 'appDir':\n";
Debug::dump(Environment::getVariable('appDir'));
echo "Getting variable 'tempDir' #2:\n";
Debug::dump(Environment::getVariable('tempDir'));
echo "Setting variable 'test'...\n";
Environment::setVariable('test', '%appDir%/test');
echo "Getting variable 'test':\n";
Debug::dump(Environment::getVariable('test'));
echo "Getting variables:\n";
Debug::dump(Environment::getVariables());
try {
    echo "Setting circular variables...\n";
    Environment::setVariable('bar', '%foo%');
    Environment::setVariable('foo', '%foobar%');
    Environment::setVariable('foobar', '%bar%');
    echo "Getting circular variable:\n";
    Debug::dump(Environment::getVariable('bar'));
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
Esempio n. 3
0
 public function handleBrowseFiles($dir, $ext)
 {
     $cache = Environment::getCache($this->getName());
     $ckey = __FUNCTION__ . $dir . $ext;
     fd(Environment::getVariables());
     if (!isset($cache[$ckey])) {
         $root = WWW_DIR . '/';
         $response = '';
         if (file_exists($root . $dir)) {
             $files = scandir($root . $dir);
             natcasesort($files);
             if (count($files) > 2) {
                 $response .= "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
                 foreach ($files as $file) {
                     if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && is_dir($root . $dir . $file)) {
                         $response .= "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . htmlentities($dir . $file) . "/\">" . htmlentities($file) . "</a></li>";
                     }
                 }
                 foreach ($files as $file) {
                     $file_info = pathinfo($file);
                     if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && !is_dir($root . $dir . $file) && $file_info['extension'] == $ext) {
                         $ext = preg_replace('/^.*\\./', '', $file);
                         $response .= "<li class=\"file ext_{$ext}\"><a href=\"#\" rel=\"" . htmlentities($dir . $file) . "\">" . htmlentities($file) . "</a></li>";
                     }
                 }
                 $response .= "</ul>";
             }
         }
         $cache->save($ckey, $response, array('expire' => time() + 60 * 10));
     }
     echo $cache[$ckey];
     $this->terminate();
 }