當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JLanguage::hasKey方法代碼示例

本文整理匯總了PHP中JLanguage::hasKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP JLanguage::hasKey方法的具體用法?PHP JLanguage::hasKey怎麽用?PHP JLanguage::hasKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在JLanguage的用法示例。


在下文中一共展示了JLanguage::hasKey方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testHasKey

 /**
  * Test...
  *
  * @covers JLanguage::hasKey
  * @todo Implement testHasKey().
  *
  * @return void
  */
 public function testHasKey()
 {
     // Key doesn't exist, returns false
     $this->assertFalse($this->object->hasKey('com_admin.key'));
     // Remove the following lines when you implement this test.
     $this->markTestIncomplete('This test has not been implemented yet.');
 }
開發者ID:rdiaztushman,項目名稱:joomla-platform,代碼行數:15,代碼來源:JLanguageTest.php

示例2: doExecute

 /**
  * Method to run this controller.
  *
  * @throws \Exception
  * @return  mixed
  */
 protected function doExecute()
 {
     $db = $this->model->getDb();
     $this->useTransaction ? $db->transactionStart(true) : null;
     try {
         $this->preSaveHook();
         $validData = $this->doSave();
         // Invoke the postSave method to allow for the child class to access the model.
         $this->postSaveHook($this->model, $validData);
         // Set success message
         $this->setMessage(\JText::_(($this->lang->hasKey(strtoupper($this->option) . ($this->recordId == 0 && $this->app->isSite() ? '_SUBMIT' : '') . '_SAVE_SUCCESS') ? strtoupper($this->option) : 'JLIB_APPLICATION') . ($this->recordId == 0 && $this->app->isSite() ? '_SUBMIT' : '') . '_SAVE_SUCCESS'), Message::MESSAGE_GREEN);
     } catch (ValidateFailException $e) {
         $this->useTransaction ? $db->transactionRollback(true) : null;
         $errors = $e->getErrors();
         foreach ($errors as $error) {
             if ($error instanceof \Exception) {
                 $this->setMessage($error->getMessage(), Message::WARNING_YELLOW);
             } else {
                 $this->setMessage($error, Message::WARNING_YELLOW);
             }
         }
         // Save the data in the session.
         $this->app->setUserState($this->context . '.data', $this->data);
         // Redirect back to the edit screen.
         $this->setRedirect($this->getFailRedirect());
         return false;
     } catch (\Exception $e) {
         $this->useTransaction ? $db->transactionRollback(true) : null;
         if (JDEBUG) {
             throw $e;
         }
         $this->setRedirect($this->getFailRedirect(), $e->getMessage(), Message::ERROR_RED);
         return false;
     }
     $this->useTransaction ? $db->transactionCommit(true) : null;
     return true;
 }
開發者ID:Biromain,項目名稱:windwalker-joomla-rad,代碼行數:43,代碼來源:SaveController.php

示例3: testHasKey

 /**
  * @todo Implement testHasKey().
  */
 public function testHasKey()
 {
     $string1 = 'com_admin.key';
     $lang = new JLanguage('');
     // HasKey doesn't exist, returns FALSE
     $this->assertFalse($lang->hasKey($string1));
 }
開發者ID:nguyen1986vn,項目名稱:atj25,代碼行數:10,代碼來源:JLanguageTest.php

示例4: testHasKey

 /**
  * Test...
  *
  * @return void
  */
 public function testHasKey()
 {
     // Key doesn't exist, returns false
     $this->assertFalse($this->object->hasKey('com_admin.key'));
 }
開發者ID:eshiol,項目名稱:joomla-cms,代碼行數:10,代碼來源:JLanguageTest.php

示例5: _install


//.........這裏部分代碼省略.........
                 // If the admin exists say so.
                 JLog::add(JText::sprintf('JLIB_INSTALLER_ABORT', JText::sprintf('JLIB_INSTALLER_ERROR_FOLDER_IN_USE', $this->parent->getPath('extension_administrator'))), JLog::WARNING, 'jerror');
             }
             return false;
         }
     }
     /*
      * If we created the language directory we will want to remove it if we
      * have to roll back the installation, so let's add it to the installation
      * step stack
      */
     if ($created) {
         $this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_site')));
     }
     // Copy all the necessary files
     if ($this->parent->parseFiles($element) === false) {
         // Install failed, rollback changes
         $this->parent->abort();
         return false;
     }
     // Parse optional tags
     $this->parent->parseMedia($this->getManifest()->media);
     // Copy all the necessary font files to the common pdf_fonts directory
     $this->parent->setPath('extension_site', $basePath . '/language/pdf_fonts');
     $overwrite = $this->parent->setOverwrite(true);
     if ($this->parent->parseFiles($this->getManifest()->fonts) === false) {
         // Install failed, rollback changes
         $this->parent->abort();
         return false;
     }
     $this->parent->setOverwrite($overwrite);
     // Get the language description
     $description = (string) $this->getManifest()->description;
     if ($description) {
         $this->parent->set('message', JText::_($description));
     } else {
         $this->parent->set('message', '');
     }
     // Add an entry to the extension table with a whole heap of defaults
     $row = JTable::getInstance('extension');
     $row->set('name', $this->get('name'));
     $row->set('type', 'language');
     $row->set('element', $this->get('tag'));
     // There is no folder for languages
     $row->set('folder', '');
     $row->set('enabled', 1);
     $row->set('protected', 0);
     $row->set('access', 0);
     $row->set('client_id', $clientId);
     $row->set('params', $this->parent->getParams());
     $row->set('manifest_cache', $this->parent->generateManifestCache());
     if (!$row->store()) {
         // Install failed, roll back changes
         $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT', $row->getError()));
         return false;
     }
     // Create an unpublished content language.
     if ((int) $clientId === 0) {
         // Load the site language manifest.
         $siteLanguageManifest = JLanguage::parseXMLLanguageFile(JPATH_SITE . '/language/' . $this->tag . '/' . $this->tag . '.xml');
         // Set the content language title as the language metadata name.
         $contentLanguageTitle = $siteLanguageManifest['name'];
         // Set, as fallback, the content language native title to the language metadata name.
         $contentLanguageNativeTitle = $contentLanguageTitle;
         // If exist, load the native title from the language xml metadata.
         if (isset($siteLanguageMetadata['nativeName']) && $siteLanguageMetadata['nativeName']) {
             $contentLanguageNativeTitle = $siteLanguageMetadata['nativeName'];
         }
         // Try to load a language string from the installation language var. Will be removed in 4.0.
         if ($contentLanguageNativeTitle === $contentLanguageTitle) {
             if (file_exists(JPATH_INSTALLATION . '/language/' . $this->tag . '/' . $this->tag . '.xml')) {
                 $installationLanguage = new JLanguage($this->tag);
                 $installationLanguage->load('', JPATH_INSTALLATION);
                 if ($installationLanguage->hasKey('INSTL_DEFAULTLANGUAGE_NATIVE_LANGUAGE_NAME')) {
                     // Make sure it will not use the en-GB fallback.
                     $defaultLanguage = new JLanguage('en-GB');
                     $defaultLanguage->load('', JPATH_INSTALLATION);
                     $defaultLanguageNativeTitle = $defaultLanguage->_('INSTL_DEFAULTLANGUAGE_NATIVE_LANGUAGE_NAME');
                     $installationLanguageNativeTitle = $installationLanguage->_('INSTL_DEFAULTLANGUAGE_NATIVE_LANGUAGE_NAME');
                     if ($defaultLanguageNativeTitle != $installationLanguageNativeTitle) {
                         $contentLanguageNativeTitle = $installationLanguage->_('INSTL_DEFAULTLANGUAGE_NATIVE_LANGUAGE_NAME');
                     }
                 }
             }
         }
         // Prepare language data for store.
         $languageData = array('lang_id' => 0, 'lang_code' => $this->tag, 'title' => $contentLanguageTitle, 'title_native' => $contentLanguageNativeTitle, 'sef' => $this->getSefString($this->tag), 'image' => strtolower(str_replace('-', '_', $this->tag)), 'published' => 0, 'ordering' => 0, 'access' => (int) JFactory::getConfig()->get('access', 1), 'description' => '', 'metakey' => '', 'metadesc' => '', 'sitename' => '');
         $tableLanguage = JTable::getInstance('language');
         if (!$tableLanguage->bind($languageData) || !$tableLanguage->check() || !$tableLanguage->store() || !$tableLanguage->reorder()) {
             JLog::add(JText::sprintf('JLIB_INSTALLER_WARNING_UNABLE_TO_INSTALL_CONTENT_LANGUAGE', $siteLanguageManifest['name'], $tableLanguage->getError()), JLog::WARNING, 'jerror');
         }
     }
     // Clobber any possible pending updates
     $update = JTable::getInstance('update');
     $uid = $update->find(array('element' => $this->get('tag'), 'type' => 'language', 'folder' => ''));
     if ($uid) {
         $update->delete($uid);
     }
     return $row->get('extension_id');
 }
開發者ID:eshiol,項目名稱:joomla-cms,代碼行數:101,代碼來源:language.php


注:本文中的JLanguage::hasKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。