Example #1
0
 public function read_translations_from_file($file_name, $project = null)
 {
     if (is_null($project)) {
         return false;
     }
     $translations = $this->read_originals_from_file($file_name);
     if (!$translations) {
         return false;
     }
     $originals = GP::$original->by_project_id($project->id);
     $new_translations = new Translations();
     foreach ($translations->entries as $key => $entry) {
         // we have been using read_originals_from_file to parse the file
         // so we need to swap singular and translation
         if ($entry->context == $entry->singular) {
             $entry->translations = array();
         } else {
             $entry->translations = array($entry->singular);
         }
         $entry->singular = null;
         foreach ($originals as $original) {
             if ($original->context == $entry->context) {
                 $entry->singular = $original->singular;
                 break;
             }
         }
         if (!$entry->singular) {
             error_log(sprintf(__('Missing context %s in project #%d', 'glotpress'), $entry->context, $project->id));
             continue;
         }
         $new_translations->add_entry($entry);
     }
     return $new_translations;
 }
 function create_translations_with($entries)
 {
     $translations = new Translations();
     foreach ($entries as $entry) {
         $translations->add_entry($entry);
     }
     return $translations;
 }
Example #3
0
 function import($translations)
 {
     $this->set_memory_limit('256M');
     if (!isset($this->project) || !$this->project) {
         $this->project = GP::$project->get($this->project_id);
     }
     $locale = GP_Locales::by_slug($this->locale);
     $user = wp_get_current_user();
     $current_translations_list = GP::$translation->for_translation($this->project, $this, 'no-limit', array('status' => 'current', 'translated' => 'yes'));
     $current_translations = new Translations();
     foreach ($current_translations_list as $entry) {
         $current_translations->add_entry($entry);
     }
     unset($current_translations_list);
     $translations_added = 0;
     foreach ($translations->entries as $entry) {
         if (empty($entry->translations)) {
             continue;
         }
         $is_fuzzy = in_array('fuzzy', $entry->flags);
         if ($is_fuzzy && !apply_filters('gp_translation_set_import_fuzzy_translations', true, $entry, $translations)) {
             continue;
         }
         $create = false;
         if ($translated = $current_translations->translate_entry($entry)) {
             // we have the same string translated
             // create a new one if they don't match
             $entry->original_id = $translated->original_id;
             $translated_is_different = array_pad($entry->translations, $locale->nplurals, null) != $translated->translations;
             $create = apply_filters('gp_translation_set_import_over_existing', $translated_is_different);
         } else {
             // we don't have the string translated, let's see if the original is there
             $original = GP::$original->by_project_id_and_entry($this->project->id, $entry, '+active');
             if ($original) {
                 $entry->original_id = $original->id;
                 $create = true;
             }
         }
         if ($create) {
             if ($user) {
                 $entry->user_id = $user->ID;
             }
             $entry->translation_set_id = $this->id;
             $entry->status = apply_filters('gp_translation_set_import_status', $is_fuzzy ? 'fuzzy' : 'current');
             // check for errors
             $translation = GP::$translation->create($entry);
             $translation->set_status($entry->status);
             $translations_added += 1;
         }
     }
     gp_clean_translation_set_cache($this->id);
     do_action('gp_translations_imported', $this->id);
     return $translations_added;
 }
Example #4
0
 function test_translations_merge()
 {
     $host = new Translations();
     $host->add_entry(new Translation_Entry(array('singular' => 'pink')));
     $host->add_entry(new Translation_Entry(array('singular' => 'green')));
     $guest = new Translations();
     $guest->add_entry(new Translation_Entry(array('singular' => 'green')));
     $guest->add_entry(new Translation_Entry(array('singular' => 'red')));
     $host->merge_with($guest);
     $this->assertEquals(3, count($host->entries));
     $this->assertEquals(array(), array_diff(array('pink', 'green', 'red'), array_keys($host->entries)));
 }
Example #5
0
 function test_multiple_imports_multiple_singulars()
 {
     $originals = array(array('singular' => 'Good morning'), array('singular' => 'Good evening'));
     $translations1 = new Translations();
     $translations1->add_entry(new Translation_Entry(array('singular' => $originals[0]['singular'], 'translations' => array('Guten Morgen'))));
     $translations2 = new Translations();
     $translations2->add_entry(new Translation_Entry(array('singular' => $originals[1]['singular'], 'translations' => array('Guten Abend'))));
     $this->_verify_multiple_imports($originals, array(array('status' => 'current', 'translations' => $translations1, 'counts' => array('all_count' => 2, 'current_count' => 1, 'untranslated_count' => 1, 'waiting_count' => 0)), array('status' => 'current', 'translations' => $translations2, 'counts' => array('all_count' => 2, 'current_count' => 2, 'untranslated_count' => 0, 'waiting_count' => 0))));
     $this->_verify_multiple_imports($originals, array(array('status' => 'current', 'translations' => $translations1, 'counts' => array('all_count' => 2, 'current_count' => 1, 'untranslated_count' => 1, 'waiting_count' => 0)), array('status' => 'waiting', 'translations' => $translations2, 'counts' => array('all_count' => 2, 'current_count' => 1, 'untranslated_count' => 1, 'waiting_count' => 1))));
     $this->_verify_multiple_imports($originals, array(array('status' => 'waiting', 'translations' => $translations1, 'counts' => array('all_count' => 2, 'current_count' => 0, 'untranslated_count' => 2, 'waiting_count' => 1)), array('status' => 'waiting', 'translations' => $translations2, 'counts' => array('all_count' => 2, 'current_count' => 0, 'untranslated_count' => 2, 'waiting_count' => 2))));
     $this->_verify_multiple_imports($originals, array(array('status' => 'waiting', 'translations' => $translations1, 'counts' => array('all_count' => 2, 'current_count' => 0, 'untranslated_count' => 2, 'waiting_count' => 1)), array('status' => 'current', 'translations' => $translations1, 'counts' => array('all_count' => 2, 'current_count' => 1, 'untranslated_count' => 1, 'waiting_count' => 0))));
 }
 function test_filter_translation_set_import_over_existing()
 {
     $set = $this->factory->translation_set->create_with_project_and_locale();
     $original = $this->factory->original->create(array('project_id' => $set->project->id, 'status' => '+active', 'singular' => 'A string'));
     $translation = $this->factory->translation->create(array('translation_set_id' => $set->id, 'original_id' => $original->id, 'translations' => array('baba'), 'status' => 'current'));
     $translations_for_import = new Translations();
     $translations_for_import->add_entry(array('singular' => 'A string', 'translations' => array('abab')));
     add_filter('translation_set_import_over_existing', '__return_false');
     $translations_added = $set->import($translations_for_import);
     remove_filter('translation_set_import_over_existing', '__return_false');
     $this->assertEquals($translations_added, 0);
 }
Example #7
0
function setupGlobalVars($type, $opts = array())
{
    global $coach, $lng, $leagues, $divisions, $tours, $settings, $rules, $admin_menu;
    switch ($type) {
        case T_SETUP_GLOBAL_VARS__COMMON:
            $coach = isset($_SESSION['logged_in']) ? new Coach($_SESSION['coach_id']) : null;
            # Create global coach object.
            list($leagues, $divisions, $tours) = Coach::allowedNodeAccess(Coach::NODE_STRUCT__FLAT, is_object($coach) ? $coach->coach_id : false, $extraFields = array(T_NODE_TOURNAMENT => array('locked' => 'locked', 'type' => 'type', 'f_did' => 'f_did'), T_NODE_DIVISION => array('f_lid' => 'f_lid'), T_NODE_LEAGUE => array('tie_teams' => 'tie_teams')));
            setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS);
            $_LANGUAGE = is_object($coach) && isset($coach->settings['lang']) ? $coach->settings['lang'] : $settings['lang'];
            if (!is_object($lng)) {
                $lng = new Translations($_LANGUAGE);
            } else {
                $lng->setLanguage($_LANGUAGE);
            }
            break;
        case T_SETUP_GLOBAL_VARS__POST_LOAD_MODULES:
            $admin_menu = is_object($coach) ? $coach->getAdminMenu() : array();
            break;
        case T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS:
            // Local league settings exist?
            $file = "localsettings/settings_ID.php";
            // Update selected node $_SESSION vars if node selector form submission made (will make HTMLOUT::getSelectedNodeLid(), below, catch the correct league straight as opposed to on second page reload).
            HTMLOUT::updateNodeSelectorLeagueVars();
            // Selected
            if (isset($opts['lid']) && is_numeric($opts['lid'])) {
                $id = $opts['lid'];
            } else {
                if ($_lid = HTMLOUT::getSelectedNodeLid()) {
                    $id = $_lid;
                } else {
                    if (is_object($coach) && isset($coach->settings['home_lid'])) {
                        $id = $coach->settings['home_lid'];
                    } else {
                        $id = isset($settings['default_visitor_league']) ? $settings['default_visitor_league'] : '';
                    }
                }
            }
            $settingsFile = str_replace("ID", $id, $file);
            if ($localsettings = file_exists($settingsFile) ? $settingsFile : false) {
                include $localsettings;
            } else {
                include str_replace("ID", 'none', $file);
                # Empty settings file.
            }
            break;
        case T_SETUP_GLOBAL_VARS__POST_COACH_LOGINOUT:
            setupGlobalVars(T_SETUP_GLOBAL_VARS__COMMON);
            setupGlobalVars(T_SETUP_GLOBAL_VARS__POST_LOAD_MODULES);
            break;
    }
}
 public function set_header($header, $value)
 {
     parent::set_header($header, $value);
     if ('Plural-Forms' == $header) {
         $this->_gettext_select_plural_form = $this->_make_gettext_select_plural_form($value);
     }
 }
Example #9
0
 public static function find($id, $columns = array('*'))
 {
     if (is_array($id) && empty($id)) {
         return new Collection();
     }
     $instance = new static();
     $obj = $instance->newQuery()->find($id, $columns);
     if (is_array($id)) {
         $prop = new ReflectionProperty(get_class($obj), 'items');
     }
     $col = array();
     if (isset($prop->name)) {
         $prop->setAccessible(1);
         foreach ($prop->getValue($obj) as $k => $object) {
             $translation = Translations::find($object->table . "_" . $object->id . "_" . strtolower(Config::get('cms.currlang.code')));
             $object->setRawAttributes(json_decode($translation->translation, 1));
             $col[] = $object;
         }
         $prop->setValue($obj, $col);
     } else {
         $translation = Translations::find($obj->table . "_" . $obj->id . "_" . strtolower(Config::get('cms.currlang.code')));
         $obj->setRawAttributes(json_decode($translation->translation, 1));
         $seo = $obj->seo()->first();
         if (!is_null($seo)) {
             Config::set('cms.seo', $seo);
         }
     }
     //
     return $obj;
 }
Example #10
0
 function import($translations)
 {
     @ini_set('memory_limit', '256M');
     if (!isset($this->project) || !$this->project) {
         $this->project = GP::$project->get($this->project_id);
     }
     $locale = GP_Locales::by_slug($this->locale);
     $current_translations_list = GP::$translation->for_translation($this->project, $this, 'no-limit', array('status' => 'current', 'translated' => 'yes'));
     $current_translations = new Translations();
     foreach ($current_translations_list as $entry) {
         $current_translations->add_entry($entry);
     }
     unset($current_translations_list);
     $translations_added = 0;
     foreach ($translations->entries as $entry) {
         if (empty($entry->translations)) {
             continue;
         }
         if (in_array('fuzzy', $entry->flags)) {
             continue;
         }
         $create = false;
         if ($translated = $current_translations->translate_entry($entry)) {
             // we have the same string translated
             // create a new one if they don't match
             $entry->original_id = $translated->original_id;
             $create = array_pad($entry->translations, $locale->nplurals, null) != $translated->translations;
         } else {
             // we don't have the string translated, let's see if the original is there
             $original = GP::$original->by_project_id_and_entry($this->project->id, $entry);
             if ($original) {
                 $entry->original_id = $original->id;
                 $create = true;
             }
         }
         if ($create) {
             $entry->translation_set_id = $this->id;
             $entry->status = 'current';
             // check for errors
             $translation = GP::$translation->create($entry);
             $translation->set_as_current();
             $translations_added += 1;
         }
     }
     wp_cache_delete($this->id, 'translation_set_status_breakdown');
     return $translations_added;
 }
 /**
  * setUp
  */
 public function setUp()
 {
     parent::setUp();
     if (!CakePlugin::loaded('Translate')) {
         CakePlugin::load('Translate');
     }
     Translations::translateModels();
     $this->TranslateController = $this->generate('Translate.Translate', array('methods' => array('redirect'), 'components' => array('Auth' => array('user'), 'Session')));
     $this->TranslateController->Auth->staticExpects($this->any())->method('user')->will($this->returnCallback(array($this, 'authUserCallback')));
     $this->TranslateController->Security->Session = $this->getMock('CakeSession');
 }
 /**
  * @ticket 512
  */
 function test_filter_translation_set_import_fuzzy_translations()
 {
     $set = $this->factory->translation_set->create_with_project_and_locale();
     $translations_for_import = new Translations();
     // Create 3 originals and 3 fuzzy translations
     for ($i = 0; $i < 3; $i++) {
         $this->factory->original->create(array('project_id' => $set->project->id, 'status' => '+active', 'singular' => "A string #{$i}"));
         $translations_for_import->add_entry(array('singular' => "A string #{$i}", 'translations' => array("A translated string #{$i}"), 'flags' => array('fuzzy')));
     }
     // Create 3 originals and 3 non-fuzzy translations
     for ($i = 0; $i < 3; $i++) {
         $this->factory->original->create(array('project_id' => $set->project->id, 'status' => '+active', 'singular' => "A second string #{$i}"));
         $translations_for_import->add_entry(array('singular' => "A second string #{$i}", 'translations' => array("A second translated string #{$i}")));
     }
     // Import 6 translations
     add_filter('gp_translation_set_import_fuzzy_translations', '__return_false');
     $translations_added = $set->import($translations_for_import);
     remove_filter('gp_translation_set_import_fuzzy_translations', '__return_false');
     // Expect only 3 imported translations, fuzzy translations are ignored.
     $this->assertEquals($translations_added, 3);
 }
 /**
  * Renders an alternate language HTML link tag for each available translation into the HTML head.
  *
  * @since   3.0.0
  * @wp-hook wp_head
  *
  * @return bool Whether or not headers have been sent.
  */
 public function render()
 {
     $translations = $this->translations->to_array();
     if (!$translations) {
         return false;
     }
     array_walk($translations, function ($url, $language) {
         $html_link_tag = sprintf('<link rel="alternate" hreflang="%1$s" href="%2$s">', esc_attr($language), esc_url($url));
         /**
          * Filters the output of the hreflang links in the HTML head.
          *
          * @since 3.0.0
          *
          * @param string $html_link_tag Alternate language HTML link tag.
          * @param string $language      HTTP language code (e.g., "en-US").
          * @param string $url           Target URL.
          */
         echo apply_filters('multilingualpress.hreflang_html_link_tag', $html_link_tag, $language, $url);
     });
     return true;
 }
Example #14
0
 public function read_originals_from_file($file_name)
 {
     $errors = libxml_use_internal_errors(true);
     $data = simplexml_load_string(file_get_contents($file_name));
     libxml_use_internal_errors($errors);
     if (!is_object($data)) {
         return false;
     }
     $entries = new Translations();
     foreach ($data->string as $string) {
         if (isset($string['translatable']) && 'false' == $string['translatable']) {
             continue;
         }
         $entry = new Translation_Entry();
         $entry->context = (string) $string['name'];
         $entry->singular = $this->unescape((string) $string[0]);
         $entry->translations = array();
         if (isset($string['comment']) && $string['comment']) {
             $entry->extracted_comments = $string['comment'];
         }
         $entries->add_entry($entry);
     }
     foreach ($data->{'string-array'} as $string_array) {
         if (isset($string_array['translatable']) && 'false' == $string_array['translatable']) {
             continue;
         }
         $array_name = (string) $string_array['name'];
         $item_index = 0;
         foreach ($string_array->item as $item) {
             $entry = new Translation_Entry();
             $entry->context = $array_name . "[{$item_index}]";
             $entry->singular = $this->unescape($item[0]);
             $entry->translations = array();
             $entries->add_entry($entry);
             $item_index++;
         }
     }
     return $entries;
 }
 public static function db($set = false)
 {
     if ($set instanceof PDO) {
         self::$db = $set;
         self::$dbtype = self::DBTYPE_PDO;
         return true;
     }
     if ($set instanceof MySQLi) {
         self::$db = $set;
         self::$dbtype = self::DBTYPE_MYSQLI;
         return true;
     }
     return false;
 }
 public function read_originals_from_file($file_name)
 {
     $entries = new Translations();
     $file = file_get_contents($file_name);
     if (false === $file) {
         return false;
     }
     $file = mb_convert_encoding($file, 'UTF-8', 'UTF-16LE');
     $context = $comment = null;
     $lines = explode("\n", $file);
     foreach ($lines as $line) {
         if (is_null($context)) {
             if (preg_match('/^\\/\\*\\s*(.*)\\s*\\*\\/$/', $line, $matches)) {
                 $matches[1] = trim($matches[1]);
                 if ($matches[1] !== "No comment provided by engineer.") {
                     $comment = $matches[1];
                 } else {
                     $comment = null;
                 }
             } else {
                 if (preg_match('/^"(.*)" = "(.*)";$/', $line, $matches)) {
                     $entry = new Translation_Entry();
                     $entry->context = $this->unescape($matches[1]);
                     $entry->singular = $this->unescape($matches[2]);
                     if (!is_null($comment)) {
                         $entry->extracted_comments = $comment;
                         $comment = null;
                     }
                     $entry->translations = array();
                     $entries->add_entry($entry);
                 }
             }
         }
     }
     return $entries;
 }
Example #17
0
 public function read_originals_from_file($file_name)
 {
     $errors = libxml_use_internal_errors(true);
     $data = simplexml_load_string(file_get_contents($file_name));
     libxml_use_internal_errors($errors);
     if (!is_object($data)) {
         return false;
     }
     $entries = new Translations();
     foreach ($data->data as $string) {
         $entry = new Translation_Entry();
         if (isset($string['type']) && gp_in('System.Resources.ResXFileRef', (string) $string['type'])) {
             continue;
         }
         $entry->context = (string) $string['name'];
         $entry->singular = $this->unescape((string) $string->value);
         if (isset($string->comment) && $string->comment) {
             $entry->extracted_comments = (string) $string->comment;
         }
         $entry->translations = array();
         $entries->add_entry($entry);
     }
     return $entries;
 }
 /**
  * Sends an alternate language HTTP header for each available translation.
  *
  * @since   3.0.0
  * @wp-hook template_redirect
  *
  * @return bool Whether or not headers have been sent.
  */
 public function send()
 {
     $translations = $this->translations->to_array();
     if (!$translations) {
         return false;
     }
     array_walk($translations, function ($url, $language) {
         $header = sprintf('Link: <%1$s>; rel="alternate"; hreflang="%2$s"', esc_url($url), esc_attr($language));
         /**
          * Filters the output of the hreflang links in the HTTP header.
          *
          * @since 3.0.0
          *
          * @param string $header   Alternate language HTTP header.
          * @param string $language HTTP language code (e.g., "en-US").
          * @param string $url      Target URL.
          */
         $header = (string) apply_filters('multilingualpress.hreflang_http_header', $header, $language, $url);
         if ($header) {
             header($header, false);
         }
     });
     return true;
 }
 function test_digit_and_merge()
 {
     $entry_digit_1 = new Translation_Entry(array('singular' => 1, 'translations' => array('1')));
     $entry_digit_2 = new Translation_Entry(array('singular' => 2, 'translations' => array('2')));
     $domain = new Translations();
     $domain->add_entry($entry_digit_1);
     $domain->add_entry($entry_digit_2);
     $dummy_translation = new Translations();
     $this->assertEquals('1', $domain->translate('1'));
     $domain->merge_with($dummy_translation);
     $this->assertEquals('1', $domain->translate('1'));
 }
Example #20
0
?>
        </div><!-- /left -->

        <div class="right title clearfix">
            <?php 
$this->widget(Constants::CURRENTLY_USED_MODULE . '.widgets.ContactsPart', array('part' => 'right'));
?>
        </div><!-- /right -->
    </div><!-- /wrapper -->
</div><!-- /big-block -->

<div class="big-block clearfix">

    <div class="big-title">
        <h2><?php 
echo Translations::Translate('Feedback');
?>
</h2>
    </div><!-- /big-title -->

    <?php 
echo $content;
?>

</div><!-- /big-block -->

<div class="footer">
    <p>&copy; <?php 
echo date('Y', time());
?>
 Inlux<br> All right reserved</p>
Example #21
0
 /**
  * Merge the headers of two translations.
  * 
  * @param Translations $from
  * @param Translations $to
  * @param int          $options
  */
 public static function mergeHeaders(Translations $from, Translations $to, $options = self::DEFAULTS)
 {
     if ($options & self::HEADERS_REMOVE) {
         foreach (array_keys($to->getHeaders()) as $name) {
             if ($from->getHeader($name) === null) {
                 $to->deleteHeader($name);
             }
         }
     }
     foreach ($from->getHeaders() as $name => $value) {
         $current = $to->getHeader($name);
         if (empty($current)) {
             if ($options & self::HEADERS_ADD) {
                 $to->setHeader($name, $value);
             }
             continue;
         }
         if (empty($value)) {
             continue;
         }
         switch ($name) {
             case Translations::HEADER_LANGUAGE:
             case Translations::HEADER_PLURAL:
                 if ($options & self::LANGUAGE_OVERRIDE) {
                     $to->setHeader($name, $value);
                 }
                 break;
             case Translations::HEADER_DOMAIN:
                 if ($options & self::DOMAIN_OVERRIDE) {
                     $to->setHeader($name, $value);
                 }
                 break;
             default:
                 if ($options & self::HEADERS_OVERRIDE) {
                     $to->setHeader($name, $value);
                 }
         }
     }
 }
Example #22
0
<ul>
    <li><a href="#home"><?php 
echo Translations::Translate("Home");
?>
</a></li>
    <li><a href="#services"><?php 
echo Translations::Translate("Services");
?>
</a></li>
    <li><a href="#about"><?php 
echo Translations::Translate("About");
?>
</a></li>
    <li><a href="#contacts"><?php 
echo Translations::Translate("Contacts");
?>
</a></li>
</ul>
Example #23
0
 function test_translate_plural()
 {
     $entry_incomplete = new Translation_Entry(array('singular' => 'baba', 'plural' => 'babas', 'translations' => array('babax')));
     $entry_toomany = new Translation_Entry(array('singular' => 'wink', 'plural' => 'winks', 'translations' => array('winki', 'winka', 'winko')));
     $entry_2 = new Translation_Entry(array('singular' => 'dyado', 'plural' => 'dyados', 'translations' => array('dyadox', 'dyadoy')));
     $domain = new Translations();
     $domain->add_entry($entry_incomplete);
     $domain->add_entry($entry_toomany);
     $domain->add_entry($entry_2);
     $this->assertEquals('other', $domain->translate_plural('other', 'others', 1));
     $this->assertEquals('others', $domain->translate_plural('other', 'others', 111));
     // too few translations + cont logic
     $this->assertEquals('babas', $domain->translate_plural('baba', 'babas', 2));
     $this->assertEquals('babas', $domain->translate_plural('baba', 'babas', 0));
     $this->assertEquals('babas', $domain->translate_plural('baba', 'babas', -1));
     $this->assertEquals('babas', $domain->translate_plural('baba', 'babas', 999));
     // proper
     $this->assertEquals('dyadox', $domain->translate_plural('dyado', 'dyados', 1));
     $this->assertEquals('dyadoy', $domain->translate_plural('dyado', 'dyados', 0));
     $this->assertEquals('dyadoy', $domain->translate_plural('dyado', 'dyados', 18881));
     $this->assertEquals('dyadoy', $domain->translate_plural('dyado', 'dyados', -18881));
 }
Example #24
0
/**
* Alias for Translations::translate
*
* @param string $key
* @return string
*/
function t($key)
{
    return Translations::translate($key);
}
Example #25
0
File: init.php Project: cljk/kimai
    }
}
$view->users = $users;
// ==============================
// = display global roles table =
// ==============================
$view->globalRoles = $database->global_roles();
$view->globalRoles_display = $view->render("globalRoles.php");
// ==================================
// = display membership roles table =
// ==================================
$view->membershipRoles = $database->membership_roles();
$view->membershipRoles_display = $view->render("membershipRoles.php");
$view->showDeletedGroups = get_cookie('adminPanel_extension_show_deleted_groups', 0);
$view->showDeletedUsers = get_cookie('adminPanel_extension_show_deleted_users', 0);
$view->languages = Translations::langs();
$view->timezones = timezoneList();
$status = $database->get_statuses();
$view->arr_status = $status;
$admin['users'] = $view->render("users.php");
$admin['groups'] = $view->render("groups.php");
$admin['status'] = $view->render("status.php");
if ($kga['conf']['editLimit'] != '-') {
    $view->editLimitEnabled = true;
    $editLimit = $kga['conf']['editLimit'] / (60 * 60);
    // convert to hours
    $view->editLimitDays = (int) ($editLimit / 24);
    $view->editLimitHours = (int) ($editLimit % 24);
} else {
    $view->editLimitEnabled = false;
    $view->editLimitDays = '';
Example #26
0
        if ($server_ext_password[$dbnr] != '') {
            $kga['server_password'] = $server_ext_password[$dbnr];
        }
        if ($server_ext_prefix[$dbnr] != '') {
            $kga['server_prefix'] = $server_ext_prefix[$dbnr];
        }
    }
}
$database = new Kimai_Database_Mysql($kga);
$database->connect($kga['server_hostname'], $kga['server_database'], $kga['server_username'], $kga['server_password'], $kga['utf8'], $kga['server_type']);
if (!$database->isConnected()) {
    die('Kimai could not connect to database. Check your autoconf.php.');
}
Kimai_Registry::setDatabase($database);
global $translations;
$translations = new Translations($kga);
if ($kga['language'] != 'en') {
    $translations->load($kga['language']);
}
$vars = $database->configuration_get_data();
if (!empty($vars)) {
    $kga['currency_name'] = $vars['currency_name'];
    $kga['currency_sign'] = $vars['currency_sign'];
    $kga['show_sensible_data'] = $vars['show_sensible_data'];
    $kga['show_update_warn'] = $vars['show_update_warn'];
    $kga['check_at_startup'] = $vars['check_at_startup'];
    $kga['show_daySeperatorLines'] = $vars['show_daySeperatorLines'];
    $kga['show_gabBreaks'] = $vars['show_gabBreaks'];
    $kga['show_RecordAgain'] = $vars['show_RecordAgain'];
    $kga['show_TrackingNr'] = $vars['show_TrackingNr'];
    $kga['date_format'][0] = $vars['date_format_0'];
Example #27
0
      */
 /**
  * Display the preferences dialog.
  */
 case 'prefs':
     if (isset($kga['customer'])) {
         die;
     }
     $skins = array();
     $langs = array();
     $allSkins = glob(__DIR__ . "/../skins/*", GLOB_ONLYDIR);
     foreach ($allSkins as $skin) {
         $name = basename($skin);
         $skins[$name] = $name;
     }
     foreach (Translations::langs() as $lang) {
         $langs[$lang] = $lang;
     }
     $view->skins = $skins;
     $view->langs = $langs;
     $view->timezones = timezoneList();
     $view->user = $kga['user'];
     $view->rate = $database->get_rate($kga['user']['userID'], NULL, NULL);
     echo $view->render("floaters/preferences.php");
     break;
     /**
      * Display the dialog to add or edit a customer.
      */
 /**
  * Display the dialog to add or edit a customer.
  */
Example #28
0
 function extract_entries($code, $file_name)
 {
     $translations = new Translations();
     $function_calls = $this->find_function_calls(array_keys($this->rules), $code);
     foreach ($function_calls as $call) {
         $entry = $this->entry_from_call($call, $file_name);
         if (is_array($entry)) {
             foreach ($entry as $single_entry) {
                 $translations->add_entry_or_merge($single_entry);
             }
         } elseif ($entry) {
             $translations->add_entry_or_merge($entry);
         }
     }
     return $translations;
 }
 function set_header($header, $value)
 {
     parent::set_header($header, $value);
     if ('Plural-Forms' == $header) {
         list($nplurals, $expression) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));
         $this->_nplurals = $nplurals;
         $this->_gettext_select_plural_form = $this->make_plural_form_function($nplurals, $expression);
     }
 }
Example #30
0
    die("You need PHP 5.4 or higher");
}
header("X-UA-Compatible: IE=edge");
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
require __DIR__ . "/lib/functions.php";
require __DIR__ . "/lib/Translations.class.php";
require __DIR__ . "/lib/OMX.class.php";
try {
    $optionsFile = __DIR__ . "/options.json";
    $options = file_exists($optionsFile) ? json_decode(file_get_contents($optionsFile), true) : array();
    $folders = isset($options["folders"]) ? $options["folders"] : array();
    Translations::$language = isset($options["language"]) ? $options["language"] : "en";
    # json requests
    if (isset($_GET["json"])) {
        $data = NULL;
        switch ($_GET["action"]) {
            case "get-status":
                $data = array("status" => "stopped");
                $output = $return = "";
                exec('sh ' . escapeshellcmd(__DIR__ . "/omx-status.sh"), $output, $return);
                if ($return) {
                    $data["status"] = "playing";
                    if (file_exists(OMX::$fifoStatusFile)) {
                        $json = json_decode(file_get_contents(OMX::$fifoStatusFile), true);
                        $data["path"] = $json["path"];
                        # view cache
                        $hash = getPathHash($data["path"]);