public function init()
    {
        // Send default settings according to locale
        $locale = i18n::get_locale();
        $symbols = Zend_Locale_Data::getList($locale, 'symbols');
        $currency = Currency::config()->currency_symbol;
        $decimals = $symbols['decimal'];
        $thousands = $decimals == ',' ? ' ' : ',';
        // Accouting needs to be initialized globally
        FormExtraJquery::include_accounting();
        Requirements::customScript(<<<EOT
    window.accounting.settings = {
        currency: {
            symbol : "{$currency}",
            format: "%s%v",
            decimal : "{$decimals}",
            thousand: "{$thousands}",
            precision : 2
        },
        number: {
            precision : 0,
            thousand: "{$thousands}",
            decimal : "{$decimals}"
        }
    }
EOT
, 'accountingInit');
    }
Example #2
0
 function glossar_replace($string)
 {
     global $REX, $mypage;
     $I18N_GLOSSAR = new i18n($REX[LANG], $REX[INCLUDE_PATH] . "/addons/{$mypage}/lang/");
     // CREATE LANG OBJ FOR THIS ADDON
     $sql = new sql();
     $sql->setQuery("select * from rex__glossar order by shortcut");
     for ($i = 0; $i < $sql->getRows(); $i++) {
         $language = $sql->getValue("language");
         if ($language == "0") {
             $language = $I18N_GLOSSAR->msg('lang_de_short');
         } elseif ($language == "1") {
             $language = $I18N_GLOSSAR->msg('lang_en_short');
         } else {
             $language = $I18N_GLOSSAR->msg('lang_fr_short');
         }
         $id = $sql->getValue("short_id");
         $shortcut = htmlentities($sql->getValue("shortcut"));
         $escapedshortcut = str_replace('.', '\\.', $shortcut);
         $description = htmlentities($sql->getValue("description"));
         $language = trim($language);
         $casesense = $sql->getValue("casesense");
         $search = "/((<[^>]*)|{$escapedshortcut})/e";
         $replace = '"\\2"=="\\1"? "\\1":"<span lang=\\"' . $language . '\\" xml:lang=\\"' . $language . '\\" title=\\"' . $language . ': ' . $description . '\\" class=\\"shortcut\\">' . $shortcut . '</span>"';
         $subject = $string;
         if ($casesense == 0) {
             $search .= 'i';
         }
         $string = preg_replace($search, $replace, $subject);
         $sql->counter++;
     }
     return $string;
 }
Example #3
0
 function getList()
 {
     $application = Application::getInstance();
     $registry = Registry::getInstance();
     $i18n = new i18n($registry->get('i18n_path') . 'router.xml');
     $renderer = new Renderer(Page::MODE_NORMAL);
     $pTitle = $i18n->get('title');
     $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', RouterListView::get(['list' => Router::getList()]));
     $renderer->loadPage();
     $renderer->output();
 }
 public function tearDown()
 {
     parent::tearDown();
     i18n::set_locale($this->originalLocale);
     Config::inst()->remove('TimeField', 'default_config');
     Config::inst()->update('TimeField', 'default_config', $this->origTimeConfig);
 }
Example #5
0
 public static function getInstance()
 {
     if (!is_object(self::$instance)) {
         self::$instance = new i18n();
     }
     return self::$instance;
 }
Example #6
0
 public function init()
 {
     parent::init();
     Requirements::javascript(MCE_ROOT . "tiny_mce_src.js");
     Requirements::javascript("jsparty/tiny_mce_improvements.js");
     Requirements::javascript("jsparty/hover.js");
     Requirements::javascript("jsparty/scriptaculous/controls.js");
     Requirements::javascript("cms/javascript/SecurityAdmin.js");
     Requirements::javascript("cms/javascript/LeftAndMain_left.js");
     Requirements::javascript("cms/javascript/LeftAndMain_right.js");
     Requirements::javascript("cms/javascript/CMSMain_left.js");
     Requirements::javascript("cms/javascript/ReportAdmin_left.js");
     Requirements::javascript("cms/javascript/ReportAdmin_right.js");
     Requirements::css("cms/css/ReportAdmin.css");
     // TODO Find a better solution to integrate optional Requirements in a specific order
     if (Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
         Requirements::css("ecommerce/css/DataReportCMSMain.css");
     }
     if (Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
         Requirements::javascript("ecommerce/javascript/DataReport.js");
     }
     if (Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
         Requirements::css(project() . "/css/DataReportCMSMain.css");
     }
     if (Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
         Requirements::javascript(project() . "/javascript/DataReport.js");
     }
     // We don't want this showing up in every ajax-response, it should always be present in a CMS-environment
     if (!Director::is_ajax()) {
         Requirements::javascriptTemplate("cms/javascript/tinymce.template.js", array("ContentCSS" => project() . "/css/editor.css", "BaseURL" => Director::absoluteBaseURL(), "Lang" => i18n::get_tinymce_lang()));
     }
 }
Example #7
0
 public function Content()
 {
     if (i18n::get_locale() === 'zh_CN') {
         return $this->Content_cn;
     }
     return $this->Content;
 }
 function testTranslationCaching()
 {
     Configure::write('Config.language', 'cache_test_po');
     $i18n =& i18n::getInstance();
     // reset internally stored entries
     I18n::clear();
     Cache::clear(false, '_cake_core_');
     $lang = Configure::read('Config.language');
     #$i18n->l10n->locale;
     Cache::config('_cake_core_', Cache::config('default'));
     // make some calls to translate using different domains
     $this->assertEqual(I18n::translate('dom1.foo', false, 'dom1'), 'Dom 1 Foo');
     $this->assertEqual(I18n::translate('dom1.bar', false, 'dom1'), 'Dom 1 Bar');
     $this->assertEqual($i18n->__domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo'], 'Dom 1 Foo');
     // reset internally stored entries
     I18n::clear();
     // now only dom1 should be in cache
     $cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_');
     $this->assertEqual($cachedDom1['LC_MESSAGES']['dom1.foo'], 'Dom 1 Foo');
     $this->assertEqual($cachedDom1['LC_MESSAGES']['dom1.bar'], 'Dom 1 Bar');
     // dom2 not in cache
     $this->assertFalse(Cache::read('dom2_' . $lang, '_cake_core_'));
     // translate a item of dom2 (adds dom2 to cache)
     $this->assertEqual(I18n::translate('dom2.foo', false, 'dom2'), 'Dom 2 Foo');
     // verify dom2 was cached through manual read from cache
     $cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_');
     $this->assertEqual($cachedDom2['LC_MESSAGES']['dom2.foo'], 'Dom 2 Foo');
     $this->assertEqual($cachedDom2['LC_MESSAGES']['dom2.bar'], 'Dom 2 Bar');
     // modify cache entry manually to verify that dom1 entries now will be read from cache
     $cachedDom1['LC_MESSAGES']['dom1.foo'] = 'FOO';
     Cache::write('dom1_' . $lang, $cachedDom1, '_cake_core_');
     $this->assertEqual(I18n::translate('dom1.foo', false, 'dom1'), 'FOO');
 }
 /**
  * Convert country code to name
  *
  * @param string $code
  * @return string
  */
 public static function convertCountryCodeToName($code)
 {
     if (!$code) {
         return;
     }
     return Zend_Locale::getTranslation($code, 'territory', i18n::get_locale());
 }
Example #10
0
 /**
  * Initializing i18n
  *
  * @param array $options
  */
 public static function init($options = [])
 {
     $i18n = application::get('flag.global.i18n') ?? [];
     $i18n = array_merge_hard($i18n, $options ?? []);
     // determine final language
     $languages = factory::model('numbers_backend_i18n_languages_model_languages')->get();
     $final_language = application::get('flag.global.__language_code') ?? session::get('numbers.entity.format.language_code') ?? $i18n['language_code'] ?? 'sys';
     if (empty($languages[$final_language])) {
         $final_language = 'sys';
         $i18n['rtl'] = 0;
     }
     // put settings into system
     if (!empty($languages[$final_language])) {
         foreach ($languages[$final_language] as $k => $v) {
             $k = str_replace('lc_language_', '', $k);
             if (in_array($k, ['code', 'inactive'])) {
                 continue;
             }
             if (empty($v)) {
                 continue;
             }
             $i18n[$k] = $v;
         }
     }
     $i18n['language_code'] = $final_language;
     self::$options = $i18n;
     session::set('numbers.entity.format.language_code', $final_language);
     application::set('flag.global.i18n', $i18n);
     self::$initialized = true;
     // initialize the module
     return factory::submodule('flag.global.i18n.submodule')->init($i18n);
 }
Example #11
0
 public function tearDown()
 {
     parent::tearDown();
     i18n::set_locale($this->originalLocale);
     DateField::$default_config['dateformat'] = $this->origDateFormat;
     TimeField::$default_config['timeformat'] = $this->origTimeFormat;
 }
Example #12
0
 function run()
 {
     $id = (int) $this->get_param('id');
     $page = (int) $this->get_param('page');
     // @todo move pagination to filters?
     if (!$page) {
         $page = ($pf = $this->_controller->get_router()->get_filter('pagination')) ? $pf->get_start() : 0;
     }
     // load by id
     $searchs = $this->_controller->get_context()->get_search_handle();
     $search_results = $this->_controller->get_context()->get_search_result_handle();
     $item = $searchs->get_by_id($id);
     if ($item) {
         $this->renderer->set_return('keyword', $item->keyword);
         if ($item->c_count) {
             /** @var \tf\core\collection_filter*/
             $f = $search_results->set_order('time DESC')->get_filter('/search/' . $id . '/')->set_config(array('where_sql' => 'pid = ' . $item->id))->set_per_page($this->_per_page)->set_pagination($page);
             $this->renderer->set_return('posts', $f->apply()->as_array());
         } else {
             $this->renderer->set_message(i18n::T('sat.search_not_found'), false);
             return false;
         }
     } else {
         $this->renderer->set_return('keyword', '');
     }
 }
Example #13
0
 public function Special()
 {
     if (i18n::get_locale() === 'zh_CN') {
         return $this->Special_cn;
     }
     return $this->Special;
 }
Example #14
0
 public function setUp()
 {
     /* Setup Routine */
     $page = new RainTPL();
     $page::configure(array('cache_dir' => 'tmp/'));
     $page::$path_replace = false;
     // We escape it here because ENT_NOQUOTES can't be used in RainTPL templates.
     $page->assign('CIPHERDATA', htmlspecialchars(helper::getPaste()['data'], ENT_NOQUOTES));
     $page->assign('ERROR', self::$error);
     $page->assign('STATUS', self::$status);
     $page->assign('VERSION', self::$version);
     $page->assign('DISCUSSION', true);
     $page->assign('OPENDISCUSSION', true);
     $page->assign('MARKDOWN', true);
     $page->assign('SYNTAXHIGHLIGHTING', true);
     $page->assign('SYNTAXHIGHLIGHTINGTHEME', 'sons-of-obsidian');
     $page->assign('BURNAFTERREADINGSELECTED', false);
     $page->assign('PASSWORD', true);
     $page->assign('FILEUPLOAD', false);
     $page->assign('BASE64JSVERSION', '2.1.9');
     $page->assign('NOTICE', 'example');
     $page->assign('LANGUAGESELECTION', '');
     $page->assign('LANGUAGES', i18n::getLanguageLabels(i18n::getAvailableLanguages()));
     $page->assign('EXPIRE', self::$expire);
     $page->assign('EXPIREDEFAULT', self::$expire_default);
     $page->assign('EXPIRECLONE', true);
     ob_start();
     $page->draw('page');
     $this->_content = ob_get_contents();
     // run a second time from cache
     $page->cache('page');
     $page->draw('page');
     ob_end_clean();
 }
 public function CurrencySymbol()
 {
     require_once THIRDPARTY_PATH . "/Zend/Currency.php";
     $locale = new Zend_Locale(i18n::get_locale());
     $symbol = new Zend_Currency($locale);
     return $symbol->getSymbol();
 }
 public function testLinks()
 {
     // Run link checker
     $task = CheckExternalLinksTask::create();
     $task->setSilent(true);
     // Be quiet during the test!
     $task->runLinksCheck();
     // Get all links checked
     $status = BrokenExternalPageTrackStatus::get_latest();
     $this->assertEquals('Completed', $status->Status);
     $this->assertEquals(5, $status->TotalPages);
     $this->assertEquals(5, $status->CompletedPages);
     // Check all pages have had the correct HTML adjusted
     for ($i = 1; $i <= 5; $i++) {
         $page = $this->objFromFixture('ExternalLinksTest_Page', 'page' . $i);
         $this->assertNotEmpty($page->Content);
         $this->assertEquals($page->ExpectedContent, $page->Content, "Assert that the content of page{$i} has been updated");
     }
     // Check that the correct report of broken links is generated
     $links = $status->BrokenLinks()->sort('Link');
     $this->assertEquals(4, $links->count());
     $this->assertEquals(array('http://www.broken.com', 'http://www.broken.com/url/thing', 'http://www.broken.com/url/thing', 'http://www.nodomain.com'), array_values($links->map('ID', 'Link')->toArray()));
     // Check response codes are correct
     $expected = array('http://www.broken.com' => 403, 'http://www.broken.com/url/thing' => 404, 'http://www.nodomain.com' => 0);
     $actual = $links->map('Link', 'HTTPCode')->toArray();
     $this->assertEquals($expected, $actual);
     // Check response descriptions are correct
     i18n::set_locale('en_NZ');
     $expected = array('http://www.broken.com' => '403 (Forbidden)', 'http://www.broken.com/url/thing' => '404 (Not Found)', 'http://www.nodomain.com' => '0 (Server Not Available)');
     $actual = $links->map('Link', 'HTTPCodeDescription')->toArray();
     $this->assertEquals($expected, $actual);
 }
 /**
  * Get the locale of the Member, or if we're not logged in or don't have a locale, use the default one
  * @return string
  */
 protected function locale()
 {
     if (($member = Member::currentUser()) && $member->Locale) {
         return $member->Locale;
     }
     return i18n::get_locale();
 }
Example #18
0
 public function action_get()
 {
     try {
         if (is_numeric($id_ad = $this->request->param('id'))) {
             $ad = new Model_Ad($id_ad);
             if ($ad->loaded()) {
                 if ($ad->id_user == $this->user->id_user) {
                     $a = $ad->as_array();
                     $a['price'] = i18n::money_format($ad->price);
                     $a['images'] = array_values($ad->get_images());
                     $a['category'] = $ad->category->as_array();
                     $a['location'] = $ad->location->as_array();
                     $a['customfields'] = Model_Field::get_by_category($ad->id_category);
                     $this->rest_output(array('ad' => $a));
                 } else {
                     $this->_error(__('Not your advertisement'), 401);
                 }
             } else {
                 $this->_error(__('Advertisement not found'), 404);
             }
         } else {
             $this->_error(__('Advertisement not found'), 404);
         }
     } catch (Kohana_HTTP_Exception $khe) {
         $this->_error($khe);
         return;
     }
 }
Example #19
0
/**
 * I18N string
 * 
 * {"cars2\\body_type_id"|i18n}
 * {"Параметр"|i18n:'module.prefix':params}
 *
 * Type:     modifier<br>
 * Name:     lower<br>
 * Purpose:  convert string to lowercase
 * 
 * @param string
 * @return string
 */
function smarty_modifier_i18n($id, $prefix = '', $params = null)
{
    if ($prefix) {
        $id = $prefix . '.' . $id;
    }
    return i18n::T($id, $params);
}
Example #20
0
 function action_system()
 {
     $this->collection->toggle_system($this->params->id, 'true' == functions::request_var('to', 'false'));
     if ($this->in_ajax()) {
         $this->_ajax_answer(true, i18n::T('Status changed'));
     }
 }
 /**
  * @return void
  */
 public function onBeforeInit()
 {
     // Check if we are runing a dev build, if so check if DB needs
     // upgrading
     $controller = $this->owner->request->param("Controller");
     $action = $this->owner->request->param("Action");
     global $project;
     // Only check if the DB needs upgrading on a dev build
     if ($controller == "DevelopmentAdmin" && $action == "build") {
         // Now check if the files we need are installed
         // Check if we have the files we need, if not, create them
         if (!class_exists("Category")) {
             copy(BASE_PATH . "/catalogue/scaffold/Category", BASE_PATH . "/{$project}/code/model/Category.php");
         }
         if (!class_exists("Category_Controller")) {
             copy(BASE_PATH . "/catalogue/scaffold/Category_Controller", BASE_PATH . "/{$project}/code/control/Category_Controller.php");
         }
         if (!class_exists("Product")) {
             copy(BASE_PATH . "/catalogue/scaffold/Product", BASE_PATH . "/{$project}/code/model/Product.php");
         }
         if (!class_exists("Product_Controller")) {
             copy(BASE_PATH . "/catalogue/scaffold/Product_Controller", BASE_PATH . "/{$project}/code/control/Product_Controller.php");
         }
     }
     if ($controller != "DevelopmentAdmin") {
         if (class_exists('Subsite') && Subsite::currentSubsite()) {
             // Set the location
             i18n::set_locale(Subsite::currentSubsite()->Language);
         }
     }
 }
Example #22
0
File: check.php Project: rair/yacs
 function check_file($node)
 {
     global $context;
     global $footprints;
     $key = substr($node, strlen($context['path_to_root']));
     // no extension to check
     if (strpos($key, '.') === FALSE) {
     } elseif (!strncmp($node, 'scripts/staging', 16)) {
     } elseif (!strcmp($key, 'footprints.php')) {
     } elseif (!strncmp(substr($key, -9), 'index.php', 9) && ($content = Safe::file_get_contents($node)) && !strcmp($content, Safe::mkdir_index_content())) {
     } elseif (!strncmp($key, 'temporary/cache_i18n_locale_', 28)) {
     } elseif (!strncmp(substr($key, -4), '.php', 4)) {
         // one of the parameter files created by yacs
         if (preg_match('/parameters\\/(agents|control|feeds|files|hooks|letters|root|scripts|services|skins|users|virtual_.+)\\.include\\.php$/i', $key)) {
         } elseif (isset($footprints[$key])) {
             $expected = $footprints[$key];
             $actual = Scripts::hash($node);
             if ($expected[0] != $actual[0] || $expected[1] != $actual[1]) {
                 $context['text'] .= sprintf(i18n::s('ERROR: File %s is missing or corrupted.'), $key) . BR . "\n";
             }
         } else {
             $context['text'] .= sprintf(i18n::s('File %s is not part of Yacs.'), $key) . BR . "\n";
         }
         // not a safe file
     } elseif (!preg_match('/\\.(bak|bat|css|done|dtd|fdb|flv|gif|ico|jpeg|jpg|js|jsmin|htc|htm|html|mo|off|on|pdf|png|po|pot|reg|sh|sql|swf|tgz|txt|xml|zip)$/i', $key)) {
         $context['text'] .= sprintf(i18n::s('File %s is not part of Yacs.'), $key) . BR . "\n";
     }
 }
Example #23
0
 /**
  * list links
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // url is the link itself -- hack for xhtml compliance
         $url = str_replace('&', '&amp;', $item['link_url']);
         // initialize variables
         $prefix = $suffix = '';
         // flag links that are dead, or created or updated very recently
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix = NEW_FLAG;
         }
         // make a label
         $label = Links::clean($item['title'], $item['link_url']);
         // the main anchor link
         if (is_object($anchor)) {
             $suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #24
0
    public static function fileUploadBlock()
    {
        if (self::$invalid) {
            return;
        }
        i18n::set('admin');
        $uploader = new Uploader('editFiles', 'EditPage::handleUpload', false, array('multi' => true));
        queue_js_string("/*\$(function(){\$('.view-uploads').overlay({\n\tmask: {\n\t\tcolor: '#000',\n\t\tloadSpeed: 200,\n\t\topacity: 0.7\n\t},\n\n\tcloseOnClick: true\n});});*/");
        $uploadedButton = sprintf("<a href='#' class='action view-uploads' rel='#cc_uploaded_overlay'>%s%s</a>", icon('folder_picture'), __('admin', 'view-all-files'));
        $uploadedFiles = <<<EOT
<div class="cc_uploaded_files">
{$uploadedButton}
\t<div id="cc_uploaded_overlay" class="cc_modal">
\t\t<h2>%s</h2>
\t\t<ul class="cc_file_list">
\t\t\t%s
\t\t</ul>
\t</div>
</div>
EOT;
        //foreach(Uploads::getAllFiles() as $)
        $r .= sprintf("<h3>%s</h3>%s%s", __('upload-files'), sprintf($uploadedFiles, __('uploaded-files'), $files), $uploader->createHTML());
        i18n::restore();
        return $r;
    }
 /**
  * Format a value as a number
  *
  * @param string $value
  * @param int $precision
  * @return string
  */
 public static function format($value, $precision = null, $locale = null)
 {
     if ($precision === null) {
         $precision = self::$default_precision;
     }
     if ($locale) {
         $currentLocale = self::$_locale;
         self::$_locale = $locale;
     }
     if (is_array($value)) {
         foreach ($value as &$val) {
             $val = self::format($val, $precision);
         }
         return $value;
     }
     if (self::$_locale !== i18n::get_locale()) {
         self::initVariables();
     }
     if (self::$_decimals === null) {
         self::initVariables();
     }
     $rawValue = self::unformat($value);
     $formattedValue = number_format($rawValue, $precision, self::$_decimals, self::$_thousands);
     if ($locale) {
         self::$_locale = $currentLocale;
     }
     return $formattedValue;
 }
 /**
  * Create a new LanguageDropdownField
  * @param string $name
  * @param string $title
  * @param array $dontInclude list of languages that won't be included
  * @param string $translatingClass Name of the class with translated instances where to look for used languages
  * @param string $list Indicates the source language list. Can be either Common-English, Common-Native  Locale
  */
 function __construct($name, $title, $dontInclude = array(), $translatingClass = 'SiteTree', $list = 'Common-English')
 {
     $usedlangs = array_diff(i18n::get_existing_content_languages($translatingClass), $dontInclude);
     // we accept in dontInclude both language codes and names, so another diff is required
     $usedlangs = array_diff($usedlangs, array_flip($dontInclude));
     if (isset($usedlangs[Translatable::default_lang()])) {
         unset($usedlangs[Translatable::default_lang()]);
     }
     if ('Common-English' == $list) {
         $languageList = i18n::get_common_languages();
     } else {
         if ('Common-Native' == $list) {
             $languageList = i18n::get_common_languages(true);
         } else {
             $languageList = i18n::get_locale_list();
         }
     }
     $alllangs = array_diff($languageList, (array) $usedlangs, $dontInclude);
     $alllangs = array_flip(array_diff(array_flip($alllangs), $dontInclude));
     if (isset($alllangs[Translatable::default_lang()])) {
         unset($alllangs[Translatable::default_lang()]);
     }
     asort($alllangs);
     if (count($usedlangs)) {
         asort($usedlangs);
         $labelAvail = _t('Form.LANGAVAIL', "Available languages");
         $labelOther = _t('Form.LANGAOTHER', "Other languages");
         parent::__construct($name, $title, array($labelAvail => $usedlangs, $labelOther => $alllangs), reset($usedlangs));
     } else {
         parent::__construct($name, $title, $alllangs);
     }
 }
 function tearDown()
 {
     parent::tearDown();
     // Static publishing will just confuse things
     StaticPublisher::$disable_realtime = false;
     i18n::set_locale($this->origLocale);
 }
Example #28
0
 /**
  * Parses the $_FILES superglobal for uploaded files. An event is triggered for each file. Handlers
  * can then decide whether to keep the uploaded file. The action result is filled with the properties
  * of the $_FILES superglobal storing the corresponding result - whether the respective file was
  * removed or has been accepted.
  */
 protected function action_main($skipPermsCheck = false)
 {
     if (!$skipPermsCheck and !Permissions::has('sys_upload')) {
         return $this->redirectForbidden();
     }
     $lang = i18n::load('diamondmvc');
     $result = array();
     $success = true;
     if (!empty($_FILES)) {
         foreach ($_FILES as $prop => $file) {
             // Skip this file if not desired.
             if (!empty($this->filters) and !in_array($prop, $this->filters)) {
                 continue;
             }
             // Attempt to save the file.
             if (!$this->handleUpload($prop, $file)) {
                 $this->addMessage(str_replace('%name%', $file['name'], $lang->get('ERROR_TITLE', 'ControllerUpload')), $lang->get('ERROR_MESSAGE', 'ControllerUpload'), 'error');
                 $result[$prop] = false;
                 $success = false;
             } else {
                 $result[$prop] = true;
             }
         }
     }
     $this->result = array('success' => $success, 'details' => $result);
 }
 /**
  * @param $locale
  */
 public function __construct($locale = null)
 {
     $this->defaultLocale = $locale ? $locale : i18n::get_lang_from_locale(i18n::default_locale());
     $this->basePath = Director::baseFolder();
     $this->baseSavePath = Director::baseFolder();
     parent::__construct();
 }
 /**
  * applyParsley
  * @return this
  **/
 public function applyParsley()
 {
     $this->parsleyEnabled = true;
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(ZENVALIDATOR_PATH . '/javascript/parsley/parsley.remote.min.js');
     $lang = i18n::get_lang_from_locale(i18n::get_locale());
     if ($lang != 'en') {
         Requirements::javascript(ZENVALIDATOR_PATH . '/javascript/parsley/i18n/' . $lang . '.js');
     }
     if ($this->form) {
         if ($this->defaultJS) {
             $this->form->addExtraClass('parsley');
             Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
             Requirements::javascript(ZENVALIDATOR_PATH . '/javascript/zenvalidator.js');
         } else {
             $this->form->addExtraClass('custom-parsley');
         }
         foreach ($this->constraints as $fieldName => $constraints) {
             foreach ($constraints as $constraint) {
                 $constraint->applyParsley();
             }
         }
     }
     return $this;
 }