Exemplo n.º 1
0
 public function testProcessTranslationsEnableKey()
 {
     $language = CMTest_TH::createLanguage('test');
     $languageKey = CM_Model_LanguageKey::create('Hello World');
     $this->assertSame(false, $languageKey->getJavascript());
     $site = CM_Site_Abstract::factory();
     $render = new CM_Frontend_Render(new CM_Frontend_Environment(null, null, $language));
     // Check that key is *not* included in the JS translations list
     $versionJavascript = CM_Model_Language::getVersionJavascript();
     $request = new CM_Http_Request_Get($render->getUrlResource('library-js', "translations/{$versionJavascript}.js"));
     $response = CM_Http_Response_Resource_Javascript_Library::createFromRequest($request, $site, $this->getServiceManager());
     $response->process();
     $this->assertNotContains('Hello World', $response->getContent());
     // Request JS-enabling of language key via RPC call
     $body = CM_Params::jsonEncode(['method' => 'CM_Model_Language.requestTranslationJs', 'params' => ['Hello World']]);
     $request = new CM_Http_Request_Post('/rpc', null, null, $body);
     $response = CM_Http_Response_RPC::createFromRequest($request, $site, $this->getServiceManager());
     $response->process();
     CMTest_TH::reinstantiateModel($languageKey);
     $this->assertSame(true, $languageKey->getJavascript());
     // Check that key *is* included in the JS translations list
     $versionJavascript = CM_Model_Language::getVersionJavascript();
     $request = new CM_Http_Request_Get($render->getUrlResource('library-js', "translations/{$versionJavascript}.js"));
     $response = CM_Http_Response_Resource_Javascript_Library::createFromRequest($request, $site, $this->getServiceManager());
     $response->process();
     $this->assertContains('Hello World', $response->getContent());
 }
Exemplo n.º 2
0
 protected function _initialize()
 {
     $this->registerField(new CM_FormField_Text(['name' => 'text']));
     $this->registerField(new CM_FormField_Email(['name' => 'email']));
     $this->registerField(new CM_FormField_Password(['name' => 'password']));
     $this->registerField(new CM_FormField_Textarea(['name' => 'textarea']));
     $this->registerField(new CM_FormField_Float(['name' => 'float']));
     $this->registerField(new CM_FormField_Money(['name' => 'money']));
     $this->registerField(new CM_FormField_Url(['name' => 'url']));
     $this->registerField(new CM_FormField_Integer(['name' => 'int']));
     $this->registerField(new CM_FormField_Slider(['name' => 'slider', 'min' => 0, 'max' => 2.5, 'step' => 0.1]));
     $this->registerField(new CM_FormField_Distance(['name' => 'locationSlider']));
     $this->registerField(new CM_FormField_Location(['name' => 'location', 'fieldNameDistance' => 'locationSlider']));
     $this->registerField(new CM_FormField_File(['name' => 'file', 'cardinality' => 2]));
     $this->registerField(new CM_FormField_FileImage(['name' => 'image', 'cardinality' => 2]));
     $this->registerField(new CM_FormField_Color(['name' => 'color']));
     $this->registerField(new CM_FormField_Date(['name' => 'date']));
     $this->registerField(new CM_FormField_DateTimeInterval(['name' => 'dateTimeInterval', 'yearFirst' => date('Y'), 'yearLast' => (int) date('Y') + 1]));
     $this->registerField(new CM_FormField_Birthdate(['name' => 'birthdate', 'minAge' => 18, 'maxAge' => 30]));
     $this->registerField(new CM_FormField_GeoPoint(['name' => 'geopoint']));
     $this->registerField(new CM_FormField_Set(['name' => 'set', 'values' => array(1 => 'Eins', 2 => 'Zwei'), 'labelsInValues' => true]));
     $this->registerField(new CM_FormField_Boolean(['name' => 'boolean']));
     $this->registerField(new CM_FormField_Boolean(['name' => 'booleanSwitch']));
     $this->registerField(new CM_FormField_Set_Select(['name' => 'setSelect1', 'values' => [1 => 'Eins', 2 => 'Zwei'], 'labelsInValues' => true]));
     $this->registerField(new CM_FormField_Set_Select(['name' => 'setSelect2', 'values' => [1 => 'Eins', 2 => 'Zwei'], 'labelsInValues' => true]));
     $this->registerField(new CM_FormField_Set_Select(['name' => 'setSelect3', 'values' => [1 => 'Foo', 2 => 'Bar'], 'labelsInValues' => true]));
     $this->registerField(new CM_FormField_TreeSelect(['name' => 'treeselect', 'tree' => CM_Model_LanguageKey::getTree()]));
     $this->registerField(new CM_FormField_Geometry_Vector2(['name' => 'vector2']));
     $this->registerField(new CM_FormField_Geometry_Vector3(['name' => 'vector3']));
     $this->registerField(new CM_FormField_Captcha(['name' => 'captcha']));
     $this->registerAction(new CM_FormAction_Example_Submit($this));
 }
Exemplo n.º 3
0
 /**
  * @param string $phrase
  */
 public function remove($phrase)
 {
     $languageKey = CM_Model_LanguageKey::findByName($phrase);
     if (!$languageKey) {
         return;
     }
     CM_Db_Db::delete('cm_languageValue', array('languageKeyId' => $languageKey->getId(), 'languageId' => $this->_language->getId()));
     $this->_change();
     (new self($this->_language, !$this->_javascriptOnly))->_change();
 }
Exemplo n.º 4
0
Arquivo: 54.php Projeto: cargomedia/cm
<?php

CM_Model_LanguageKey::deleteByName('Placeholder');
CM_Model_LanguageKey::deleteByName('Textarea');
CM_Model_LanguageKey::deleteByName('Float');
CM_Model_LanguageKey::deleteByName('Money');
CM_Model_LanguageKey::deleteByName('Integer');
CM_Model_LanguageKey::deleteByName('Radius');
CM_Model_LanguageKey::deleteByName('Upload {$count} Photos');
CM_Model_LanguageKey::deleteByName('Color');
CM_Model_LanguageKey::deleteByName('Date');
CM_Model_LanguageKey::deleteByName('Birth Date between 18 and 30');
CM_Model_LanguageKey::deleteByName('Geo Point');
CM_Model_LanguageKey::deleteByName('Set');
CM_Model_LanguageKey::deleteByName('Bool');
CM_Model_LanguageKey::deleteByName('Bool Switch');
CM_Model_LanguageKey::deleteByName('Set Select');
CM_Model_LanguageKey::deleteByName('Set Select with Prefix');
CM_Model_LanguageKey::deleteByName('Tree select');
Exemplo n.º 5
0
 /**
  * @param CM_Model_LanguageKey $languageKey
  * @return CM_Model_LanguageKey
  */
 protected static function _replaceWithExisting(CM_Model_LanguageKey $languageKey)
 {
     $name = $languageKey->getName();
     $languageKeyIdList = CM_Db_Db::select('cm_model_languagekey', 'id', array('name' => $name), 'id ASC')->fetchAllColumn();
     if (count($languageKeyIdList) > 1) {
         $languageKeyId = array_shift($languageKeyIdList);
         CM_Db_Db::exec("DELETE FROM `cm_model_languagekey` WHERE `name` = ? AND `id` != ?", array($name, $languageKeyId));
         $languageKey = new self($languageKeyId);
     }
     return $languageKey;
 }
Exemplo n.º 6
0
Arquivo: 25.php Projeto: cargomedia/cm
<?php

CM_Model_LanguageKey::deleteByName('Please Confirm');
Exemplo n.º 7
0
Arquivo: 74.php Projeto: cargomedia/cm
<?php

CM_Model_LanguageKey::deleteByName('Select Photos');
Exemplo n.º 8
0
 public function testGetTreeCaching()
 {
     $this->assertNull(CM_Model_LanguageKey::getTree()->findNodeById('.foo'));
     CM_Model_LanguageKey::create('.foo');
     $this->assertNotNull(CM_Model_LanguageKey::getTree()->findNodeById('.foo'));
 }
Exemplo n.º 9
0
Arquivo: 23.php Projeto: cargomedia/cm
<?php

CM_Model_LanguageKey::deleteByName('Upload Photos');
Exemplo n.º 10
0
Arquivo: 43.php Projeto: cargomedia/cm
<?php

CM_Model_LanguageKey::deleteByName('First');
CM_Model_LanguageKey::deleteByName('Next');
CM_Model_LanguageKey::deleteByName('Previous');
CM_Model_LanguageKey::deleteByName('Last');
if ($en = CM_Model_Language::findByAbbreviation('en')) {
    $en->setTranslation('.pagination.first', 'First');
    $en->setTranslation('.pagination.next', 'Next');
    $en->setTranslation('.pagination.previous', 'Previous');
    $en->setTranslation('.pagination.last', 'Last');
}
if ($de = CM_Model_Language::findByAbbreviation('de')) {
    $de->setTranslation('.pagination.first', 'Erste');
    $de->setTranslation('.pagination.next', 'Weiter');
    $de->setTranslation('.pagination.previous', 'Zurück');
    $de->setTranslation('.pagination.last', 'Letzte');
}
Exemplo n.º 11
0
 public function testRpcRequestTranslationJs()
 {
     $languageKey = CM_Model_LanguageKey::create('foo');
     $this->assertFalse($languageKey->getJavascript());
     CM_Model_Language::rpc_requestTranslationJs('foo');
     $languageKey = CM_Model_LanguageKey::findByName('foo');
     $this->assertTrue($languageKey->getJavascript());
 }
Exemplo n.º 12
0
 /**
  * @param string $phrase
  * @throws CM_Exception_Invalid
  */
 public static function rpc_requestTranslationJs($phrase)
 {
     $languageKey = CM_Model_LanguageKey::findByName($phrase);
     if (!$languageKey) {
         throw new CM_Exception_Invalid('Language key not found', null, ['phrase' => $phrase]);
     }
     if (!$languageKey->getJavascript()) {
         $languageKey->enableJavascript();
         self::updateVersionJavascript();
     }
 }
Exemplo n.º 13
0
 public function testSetName()
 {
     $language = CMTest_TH::createLanguage();
     $key = CM_Model_LanguageKey::create('foo');
     $key->setName('bar');
     $this->assertSame('bar', $key->getName());
     $this->assertTrue(Functional\some($language->getTranslations()->getItems(), function ($translation) {
         return $translation['key'] === 'bar';
     }));
 }
Exemplo n.º 14
0
Arquivo: 52.php Projeto: cargomedia/cm
<?php

if (!CM_Model_LanguageKey::exists('No Internet connection')) {
    CM_Model_LanguageKey::create('No Internet connection');
}
Exemplo n.º 15
0
Arquivo: 53.php Projeto: cargomedia/cm
<?php

CM_Model_LanguageKey::deleteByName('or');
CM_Model_LanguageKey::deleteByName('Drag files here');
CM_Model_LanguageKey::deleteByName('Drag photos here');
Exemplo n.º 16
0
Arquivo: 51.php Projeto: cargomedia/cm
<?php

if (!CM_Model_LanguageKey::exists('Unable to detect location')) {
    CM_Model_LanguageKey::create('Unable to detect location');
}
Exemplo n.º 17
0
Arquivo: 50.php Projeto: cargomedia/cm
<?php

CM_Model_LanguageKey::deleteByName('If you are using IE 9 or later, make sure you <a href="{$url}">turn off "Compatibility View"</a>.');