getDefault() public static method

Returns the default value for a given CONSTANT (see DEFAULT_*)
public static getDefault ( $config ) : array | null | string
$config
return array | null | string
Esempio n. 1
0
File: Skin.php Progetto: kimai/kimai
 /**
  * @return string
  */
 public function getName()
 {
     if (null === $this->skinName) {
         $skin = Kimai_Config::getDefault(Kimai_Config::DEFAULT_SKIN);
         $kga = Kimai_Registry::getConfig();
         if (!empty($kga->getSettings()->getSkin())) {
             $skin = $kga->getSettings()->getSkin();
         } else {
             if (!empty($kga->getSkin())) {
                 $skin = $kga->getSkin();
             }
         }
         $this->skinName = $this->view->escape($skin);
     }
     return $this->skinName;
 }
Esempio n. 2
0
File: Data.php Progetto: kimai/kimai
 /**
  * Adds the translations for the given language.
  *
  * @param $language
  * @throws Exception
  */
 public function addTranslations($language)
 {
     // no need to load the default or already requested language again!
     $default = Kimai_Config::getDefault(Kimai_Config::DEFAULT_LANGUAGE);
     if (empty($language) || $language == $default || $language == $this->language) {
         return;
     }
     $languageFile = WEBROOT . 'language/' . $language . '.php';
     if (!file_exists($languageFile)) {
         Kimai_Logger::logfile('Requested translation is missing: ' . $language);
         return;
     }
     $this->language = $language;
     $data = array_replace_recursive($this->getArrayCopy(), include $languageFile);
     $this->exchangeArray($data);
 }
Esempio n. 3
0
 /**
  * Return default settings for the application.
  *
  * @return array
  */
 protected function getDefaults()
 {
     return array('rowlimit' => 100, 'skin' => Kimai_Config::getDefault(Kimai_Config::DEFAULT_SKIN), 'autoselection' => 1, 'quickdelete' => 0, 'flip_project_display' => 0, 'project_comment_flag' => 0, 'showIDs' => 0, 'noFading' => 0, 'lang' => '', 'user_list_hidden' => 0, 'hideClearedEntries' => 0, 'durationWithSeconds' => 0, 'showQuickNote' => 0, 'defaultLocation' => '', 'showCommentsByDefault' => 0, 'hideOverlapLines' => 0, 'showTrackingNumber' => 0, 'sublistAnnotations' => 0);
 }
Esempio n. 4
0
File: func.php Progetto: kimai/kimai
/**
 * @param $database
 * @param $hostname
 * @param $username
 * @param $password
 * @param $charset
 * @param $prefix
 * @param $lang
 * @param $salt
 * @param $timezone
 * @return bool
 */
function write_config_file($database, $hostname, $username, $password, $charset, $prefix, $lang, $salt, $timezone = null)
{
    $kga = Kimai_Registry::getConfig();
    $database = addcslashes($database, '"$');
    $hostname = addcslashes($hostname, '"$');
    $username = addcslashes($username, '"$');
    $password = addcslashes($password, '"$');
    $file = fopen(realpath(dirname(__FILE__)) . '/autoconf.php', 'w');
    if (!$file) {
        return false;
    }
    // fallback if timezone was not provided
    if (!empty($timezone)) {
        $timezone = addcslashes($timezone, '"$');
        $timezone = '"' . $timezone . '"';
    } else {
        if (isset($kga['defaultTimezone'])) {
            $timezone = '"' . $kga['defaultTimezone'] . '"';
        } else {
            $timezone = 'date_default_timezone_get()';
        }
    }
    // fetch skin from global config with "standard" fallback
    $skin = !empty($kga->getSkin()) ? $kga->getSkin() : Kimai_Config::getDefault(Kimai_Config::DEFAULT_SKIN);
    $billable = !empty($kga->getBillable()) ? var_export($kga->getBillable(), true) : var_export(Kimai_Config::getDefault(Kimai_Config::DEFAULT_BILLABLE), true);
    $authenticator = !empty($kga->getAuthenticator()) ? $kga->getAuthenticator() : Kimai_Config::getDefault(Kimai_Config::DEFAULT_AUTHENTICATOR);
    $lang = !empty($lang) ? $lang : Kimai_Config::getDefault(Kimai_Config::DEFAULT_LANGUAGE);
    $config = <<<EOD
<?php
/**
 * This file is part of
 * Kimai - Open Source Time Tracking // http://www.kimai.org
 * (c) Kimai-Development-Team since 2006
 *
 * Kimai is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; Version 3, 29 June 2007
 *
 * Kimai is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Kimai; If not, see <http://www.gnu.org/licenses/>.
 */

// This file was automatically generated by the installer

\$server_hostname = "{$hostname}";
\$server_database = "{$database}";
\$server_username = "******";
\$server_password = "******";
\$server_charset = "{$charset}";
\$server_prefix = "{$prefix}";
\$language = "{$lang}";
\$password_salt = "{$salt}";
\$defaultTimezone = {$timezone};
\$skin = "{$skin}";
\$authenticator = "{$authenticator}";
\$billable = {$billable};

EOD;
    fputs($file, $config);
    fclose($file);
    return true;
}