コード例 #1
0
ファイル: LibraryTest.php プロジェクト: cargomedia/cm
 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());
 }
コード例 #2
0
ファイル: Example.php プロジェクト: cargomedia/cm
 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));
 }
コード例 #3
0
ファイル: All.php プロジェクト: cargomedia/cm
 /**
  * @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();
 }
コード例 #4
0
ファイル: 54.php プロジェクト: 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');
コード例 #5
0
ファイル: LanguageKey.php プロジェクト: cargomedia/cm
 /**
  * @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;
 }
コード例 #6
0
ファイル: 25.php プロジェクト: cargomedia/cm
<?php

CM_Model_LanguageKey::deleteByName('Please Confirm');
コード例 #7
0
ファイル: 74.php プロジェクト: cargomedia/cm
<?php

CM_Model_LanguageKey::deleteByName('Select Photos');
コード例 #8
0
ファイル: LanguageKeyTest.php プロジェクト: NicolasSchmutz/cm
 public function testGetTreeCaching()
 {
     $this->assertNull(CM_Model_LanguageKey::getTree()->findNodeById('.foo'));
     CM_Model_LanguageKey::create('.foo');
     $this->assertNotNull(CM_Model_LanguageKey::getTree()->findNodeById('.foo'));
 }
コード例 #9
0
ファイル: 23.php プロジェクト: cargomedia/cm
<?php

CM_Model_LanguageKey::deleteByName('Upload Photos');
コード例 #10
0
ファイル: 43.php プロジェクト: 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');
}
コード例 #11
0
ファイル: LanguageTest.php プロジェクト: cargomedia/cm
 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());
 }
コード例 #12
0
ファイル: Language.php プロジェクト: cargomedia/cm
 /**
  * @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();
     }
 }
コード例 #13
0
ファイル: LanguageKeyTest.php プロジェクト: cargomedia/cm
 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';
     }));
 }
コード例 #14
0
ファイル: 52.php プロジェクト: cargomedia/cm
<?php

if (!CM_Model_LanguageKey::exists('No Internet connection')) {
    CM_Model_LanguageKey::create('No Internet connection');
}
コード例 #15
0
ファイル: 53.php プロジェクト: cargomedia/cm
<?php

CM_Model_LanguageKey::deleteByName('or');
CM_Model_LanguageKey::deleteByName('Drag files here');
CM_Model_LanguageKey::deleteByName('Drag photos here');
コード例 #16
0
ファイル: 51.php プロジェクト: cargomedia/cm
<?php

if (!CM_Model_LanguageKey::exists('Unable to detect location')) {
    CM_Model_LanguageKey::create('Unable to detect location');
}
コード例 #17
0
ファイル: 50.php プロジェクト: 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>.');