本文整理汇总了PHP中iaLanguage::addPhrase方法的典型用法代码示例。如果您正苦于以下问题:PHP iaLanguage::addPhrase方法的具体用法?PHP iaLanguage::addPhrase怎么用?PHP iaLanguage::addPhrase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iaLanguage
的用法示例。
在下文中一共展示了iaLanguage::addPhrase方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert
/**
* Insert block
* @param array $blockData
* @return bool|int
*/
public function insert(array $blockData)
{
if (empty($blockData['lang']) || $blockData['lang'] && !array_key_exists($blockData['lang'], $this->iaCore->languages)) {
$blockData['lang'] = $this->iaView->language;
}
if (!isset($blockData['type']) || !in_array($blockData['type'], $this->getTypes())) {
$blockData['type'] = self::TYPE_PLAIN;
}
if (self::TYPE_MENU == $blockData['type']) {
$blockData['tpl'] = self::DEFAULT_MENU_TEMPLATE;
}
if (!empty($blockData['filename'])) {
$blockData['external'] = 1;
}
$order = $this->iaDb->getMaxOrder(self::getTable());
$blockData['order'] = $order ? $order + 1 : 1;
if (isset($blockData['pages'])) {
$pagesList = $this->_preparePages($blockData['pages']);
unset($blockData['pages']);
}
if (isset($blockData['multilingual'])) {
if (!$blockData['multilingual'] && isset($blockData['languages'])) {
$languages = $blockData['languages'];
$titles = $blockData['titles'];
$contents = $blockData['contents'];
unset($blockData['languages'], $blockData['titles'], $blockData['contents']);
}
}
$id = parent::insert($blockData);
if ($id) {
if (isset($languages)) {
foreach ($languages as $language) {
iaLanguage::addPhrase(self::LANG_PATTERN_TITLE . $id, $titles[$language], $language);
iaLanguage::addPhrase(self::LANG_PATTERN_CONTENT . $id, $contents[$language], $language);
}
}
if (isset($pagesList)) {
$this->setVisiblePages($id, $pagesList, $blockData['sticky']);
}
}
return $id;
}
示例2: _postSaveEntry
protected function _postSaveEntry(array &$entry, array $data, $action)
{
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
foreach ($this->_iaCore->languages as $code => $language) {
$title = utf8_is_valid($data['title'][$code]) ? $data['title'][$code] : utf8_bad_replace($data['title'][$code]);
iaLanguage::addPhrase('usergroup_' . $entry['name'], $title, $code);
}
// copy privileges
$copyFrom = isset($data['copy_from']) ? (int) $data['copy_from'] : 0;
if ($copyFrom) {
$this->_iaDb->setTable('acl_privileges');
$rows = $this->_iaDb->all(iaDb::ALL_COLUMNS_SELECTION, "`type_id` = '{$copyFrom}' AND `type` = 'group'");
foreach ($rows as $key => &$row) {
$row['type_id'] = $entry['id'];
unset($rows[$key]['id']);
}
$this->_iaDb->insert($rows);
$this->_iaDb->resetTable();
}
}
示例3: _gridUpdate
protected function _gridUpdate($params)
{
$output = array('result' => false, 'message' => iaLanguage::get('invalid_parameters'));
$params = $_POST;
if (isset($params['id']) && $params['id']) {
$stmt = '`id` IN (' . implode($params['id']) . ')';
unset($params['id']);
} elseif (isset($params['key'])) {
$stmt = '`key` = :key';
empty($params['lang']) || ($stmt .= ' AND `code` = :lang');
$this->_iaDb->bind($stmt, $params);
if (!$this->_iaDb->exists($stmt) && ($row = $this->_iaDb->row_bind(array('extras', 'category'), '`key` = :key AND `code` != :lang', $params))) {
$insertion = iaLanguage::addPhrase($params['key'], $params['value'], $params['lang'], $row['extras'], $row['category'], true);
}
unset($params['key'], $params['lang']);
}
if (isset($stmt)) {
$output['result'] = isset($insertion) ? $insertion : (bool) $this->_iaDb->update($params, $stmt);
$output['message'] = iaLanguage::get($output['result'] ? $this->_phraseEditSuccess : $this->_phraseSaveError);
empty($output['result']) || $this->getHelper()->createJsCache(true);
}
return $output;
}
示例4: _postSaveEntry
protected function _postSaveEntry(array &$entry, array $data, $action)
{
foreach ($this->_iaCore->languages as $code => $language) {
iaLanguage::addPhrase(self::PATTERN_TITLE . $this->getEntryId(), iaSanitize::tags($this->_languages['title'][$code]), $code);
iaLanguage::addPhrase(self::PATTERN_DESCRIPTION . $this->getEntryId(), $this->_languages['description'][$code], $code);
}
}
示例5: _addPhrase
protected function _addPhrase($key, $value, $category = iaLanguage::CATEGORY_COMMON)
{
foreach ($this->iaCore->languages as $isoCode => $language) {
iaLanguage::addPhrase($key, $value, $isoCode, $this->itemData['name'], $category, false);
}
}
示例6: _processPhrases
protected function _processPhrases(array $entries)
{
$languages = iaCore::instance()->languages;
foreach ($entries as $phrase) {
foreach ($languages as $code => $data) {
iaLanguage::addPhrase($phrase['key'], $phrase['value'], $code, '', $phrase['category']);
}
}
$this->_logInfo(':num phrases added.', self::LOG_SUCCESS, array('num' => count($entries)));
}
示例7: _insert
private function _insert(array $fieldData)
{
$iaDb =& $this->_iaDb;
if ($fieldData['parents']) {
$this->_setParents($fieldData['name'], $fieldData['parents']);
}
if (isset($fieldData['children']) && iaField::TREE != $fieldData['type']) {
$this->_setChildren($fieldData['name'], $fieldData['item'], $fieldData['values'], $fieldData['children']);
}
unset($fieldData['parents'], $fieldData['children']);
$this->_setRelations();
$pagesList = $fieldData['pages'];
unset($fieldData['pages'], $fieldData['groups']);
foreach ($this->_iaCore->languages as $code => $language) {
if (!empty($fieldData['title'][$code])) {
iaLanguage::addPhrase('field_' . $fieldData['name'], $fieldData['title'][$code], $code);
}
if (isset($fieldData['annotation'][$code]) && !empty($fieldData['annotation'][$code])) {
iaLanguage::addPhrase('field_' . $fieldData['name'] . '_annotation', $fieldData['annotation'][$code], $code);
}
}
unset($fieldData['title'], $fieldData['annotation']);
if (isset($fieldData['group']) && !isset($fieldData['fieldgroup_id'])) {
$fieldData['fieldgroup_id'] = 0;
$rows = $iaDb->all(array('id', 'name', 'item'), "`item` = '{$fieldData['name']}' ORDER BY `item`, `name`", null, null, iaField::getTableGroups());
foreach ($rows as $val) {
if ($fieldData['group'] == $val['name']) {
$fieldData['fieldgroup_id'] = $val['id'];
}
}
unset($fieldData['group']);
}
//add language number field search ranges
if (isset($fieldData['_numberRangeForSearch']) && is_array($fieldData['_numberRangeForSearch'])) {
foreach ($fieldData['_numberRangeForSearch'] as $number) {
iaLanguage::addPhrase('field_' . $fieldData['name'] . '_range_' . $number, $number);
}
}
unset($fieldData['_numberRangeForSearch']);
$keys = array();
if (isset($fieldData['values']) && is_array($fieldData['values'])) {
foreach ($fieldData['values'] as $key => $value) {
$key = $keys[$key] = isset($fieldData['keys'][$key]) ? $fieldData['keys'][$key] : $key;
iaLanguage::addPhrase('field_' . $fieldData['name'] . '_' . $key, $value);
}
} elseif (iaField::TREE != $fieldData['type']) {
unset($fieldData['values']);
} elseif (iaField::TREE == $fieldData['type']) {
$iaDb->setTable('fields_tree_nodes');
if ($fieldData['tree_nodes']) {
foreach ($fieldData['tree_nodes'] as $id => $node) {
$node['field'] = $fieldData['name'];
$node['item'] = $fieldData['item'];
$iaDb->insert($node);
}
}
$iaDb->resetTable();
unset($fieldData['tree_nodes']);
}
if (isset($fieldData['lang_values']) && is_array($fieldData['lang_values'])) {
foreach ($fieldData['lang_values'] as $lng_code => $lng_phrases) {
foreach ($lng_phrases as $ph_key => $ph_value) {
iaLanguage::addPhrase('field_' . $fieldData['name'] . '_' . $ph_key, $ph_value, $lng_code);
}
}
unset($fieldData['lang_values']);
}
if (isset($fieldData['values']) && $fieldData['values'] && isset($fieldData['keys'])) {
$fieldData['values'] = implode(',', $fieldData['keys']);
}
unset($fieldData['keys']);
if (isset($fieldData['lang_values'])) {
unset($fieldData['lang_values']);
}
$fieldData['order'] = $iaDb->getMaxOrder() + 1;
$fieldId = $iaDb->insert($fieldData);
if ($fieldId && $pagesList) {
$this->_setPagesList($fieldId, $pagesList);
}
$fieldData['table_name'] = $this->_iaCore->factory('item')->getItemTable($fieldData['item']);
$fields = $iaDb->describe($fieldData['table_name']);
$exists = false;
foreach ($fields as $f) {
if ($f['Field'] == $fieldData['name']) {
$exists = true;
break;
}
}
$exists || $this->_alterDbTable($fieldData);
return $fieldId;
}
示例8: _postSaveEntry
protected function _postSaveEntry(array &$entry, array $data, $action)
{
// saving selected menus
$selectedMenus = empty($data['menus']) ? array() : $data['menus'];
$this->_saveMenus($entry['name'], $selectedMenus);
// setting as the home page if needed
if (isset($data['home_page']) && $data['home_page']) {
$iaAcl = $this->_iaCore->factory('acl');
if ($iaAcl->checkAccess($this->getName() . 'home')) {
$this->_iaCore->set('home_page', $entry['name'], true);
}
}
// saving multilingual content
$currentLanguage = $this->_iaCore->iaView->language;
$extras = $data['extras'];
foreach (array('title', 'content') as $type) {
if (isset($data[$type . 's']) && is_array($data[$type . 's'])) {
foreach ($data[$type . 's'] as $languageCode => $value) {
utf8_is_valid($value) || ($value = utf8_bad_replace($value));
iaLanguage::addPhrase('page_' . $type . '_' . $entry['name'], $value, $languageCode, $extras, iaLanguage::CATEGORY_PAGE);
}
isset($title) || ($title = $data[$type . 's'][$currentLanguage]);
}
}
// writing to log
$iaLog = $this->_iaCore->factory('log');
$actionCode = iaCore::ACTION_ADD == $action ? iaLog::ACTION_CREATE : iaLog::ACTION_UPDATE;
$iaLog->write($actionCode, array('item' => 'page', 'name' => $title, 'id' => $this->getEntryId()));
}
示例9: _processPhrases
protected function _processPhrases(array $phrases)
{
if ($phrases) {
$defaultLangCode = $this->iaView->language;
foreach ($phrases as $key => $phrase) {
foreach ($this->iaCore->languages as $languageCode => $language) {
$value = isset($phrase['values'][$languageCode]) ? $phrase['values'][$languageCode] : $phrase['values'][$defaultLangCode];
iaLanguage::addPhrase($key, $value, $languageCode, $this->itemData['name'], $phrase['category'], false);
}
}
}
}
示例10: _postSaveEntry
protected function _postSaveEntry(array &$entry, array $data, $action)
{
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
foreach ($this->_iaCore->languages as $code => $language) {
$title = iaSanitize::tags($data['title'][$code]);
utf8_is_valid($title) || ($title = utf8_bad_replace($title));
iaLanguage::addPhrase('usergroup_' . $entry['name'], $title, $code);
}
// copy privileges
if ($data['copy_from']) {
$this->_iaDb->setTable('acl_privileges');
$where = '`type_id` = :id AND `type` = :type';
$this->_iaDb->bind($where, array('id' => (int) $data['copy_from'], 'type' => 'group'));
$rows = $this->_iaDb->all(iaDb::ALL_COLUMNS_SELECTION, $where);
foreach ($rows as $key => &$row) {
$row['type_id'] = $this->getEntryId();
unset($rows[$key]['id']);
}
$this->_iaDb->insert($rows);
$this->_iaDb->resetTable();
}
}
示例11: _savePhrases
private function _savePhrases(array &$data, $name, $item)
{
$this->_iaDb->setTable(iaLanguage::getTable());
$phraseKeyTitle = 'fieldgroup_' . $name;
$phraseKeyDescription = "fieldgroup_description_{$item}_{$name}";
foreach ($this->_iaCore->languages as $code => $language) {
$stmt = '`key` = :phrase AND `code` = :language';
$this->_iaDb->bind($stmt, array('phrase' => $phraseKeyTitle, 'language' => $code));
$this->_iaDb->exists($stmt) ? $this->_iaDb->update(array('value' => iaSanitize::html($data['titles'][$code])), $stmt) : iaLanguage::addPhrase($phraseKeyTitle, iaSanitize::html($data['titles'][$code]), $code);
$stmt = '`key` = :phrase && `code` = :language';
$this->_iaDb->bind($stmt, array('phrase' => $phraseKeyDescription, 'language' => $code));
$this->_iaDb->exists($stmt) ? $this->_iaDb->update(array('value' => iaSanitize::html($data['description'][$code])), $stmt) : iaLanguage::addPhrase($phraseKeyDescription, iaSanitize::html($data['description'][$code]), $code);
}
$this->_iaDb->resetTable();
}
示例12: _preSaveEntry
protected function _preSaveEntry(array &$entry, array $data, $action)
{
$iaAcl = $this->_iaCore->factory('acl');
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
$entry['id'] = $iaAcl->obtainFreeId();
$entry['assignable'] = $data['visible'];
$entry['visible'] = $data['visible'];
if (iaCore::ACTION_ADD == $action) {
if (empty($data['name'])) {
$this->addMessage('error_usergroup_incorrect');
} else {
$entry['name'] = strtolower(iaSanitize::paranoid($data['name']));
if (!iaValidate::isAlphaNumericValid($entry['name'])) {
$this->addMessage('error_usergroup_incorrect');
} elseif ($this->_iaDb->exists('`name` = :name', array('name' => $entry['name']))) {
$this->addMessage('error_usergroup_exists');
}
}
}
foreach ($this->_iaCore->languages as $iso => $title) {
if (empty($data['title'][$iso])) {
$this->addMessage(iaLanguage::getf('error_lang_title', array('lang' => $this->_iaCore->languages[$iso])), false);
} elseif (!utf8_is_valid($data['title'][$iso])) {
$data['title'][$iso] = utf8_bad_replace($data['title'][$iso]);
}
}
if (!$this->getMessages()) {
foreach ($this->_iaCore->languages as $iso => $title) {
iaLanguage::addPhrase('usergroup_' . $entry['name'], $data['title'][$iso], $iso);
}
}
return !$this->getMessages();
}