/**
  * Initializes component into different contexts.
  *
  * @param string $ctx The context to load. Defaults to web.
  * @param array $scriptProperties
  *
  * @return boolean
  */
 public function initialize($ctx = 'web', $scriptProperties = array())
 {
     $this->config = array_merge($this->config, $scriptProperties);
     $this->config['ctx'] = $ctx;
     if (empty($this->initialized[$ctx])) {
         $properties = $this->ms2Gallery->getSourceProperties();
         $config_js = array('ctx' => $ctx, 'jsUrl' => $this->config['jsUrl'] . 'web/', 'cssUrl' => $this->config['cssUrl'] . 'web/', 'actionUrl' => $this->config['actionUrl'], 'source' => array('size' => !empty($properties['maxUploadSize']) ? $properties['maxUploadSize'] : 3145728, 'height' => !empty($properties['maxUploadHeight']) ? $properties['maxUploadHeight'] : 1080, 'width' => !empty($properties['maxUploadWidth']) ? $properties['maxUploadWidth'] : 1920, 'extensions' => !empty($properties['allowedFileTypes']) ? $properties['allowedFileTypes'] : 'jpg,jpeg,png,gif'));
         $this->modx->regClientStartupScript('<script type="text/javascript">ms2GalleryFormConfig=' . $this->modx->toJSON($config_js) . '</script>', true);
         $css = !empty($this->config['frontend_css']) ? $this->config['frontend_css'] : $this->config['cssUrl'] . 'web/default.css';
         if (!empty($css) && preg_match('/\\.css/i', $css)) {
             $this->modx->regClientCSS($css);
         }
         $js = !empty($this->config['frontend_js']) ? $this->config['frontend_js'] : $this->config['jsUrl'] . 'web/default.js';
         if (!empty($js) && preg_match('/\\.js/i', $js)) {
             $this->modx->regClientScript($js);
         }
         $this->modx->regClientScript($this->config['jsUrl'] . 'web/lib/plupload/plupload.full.min.js');
         $this->modx->regClientScript($this->config['jsUrl'] . 'web/files.js');
         $lang = $this->modx->getOption('cultureKey');
         if ($lang != 'en' && file_exists($this->config['jsUrl'] . 'web/lib/plupload/i18n/' . $lang . '.js')) {
             $this->modx->regClientScript($this->config['jsUrl'] . 'web/lib/plupload/i18n/' . $lang . '.js');
         }
         $this->initialized[$ctx] = true;
     }
     return true;
 }