本文整理汇总了PHP中elgg_language_key_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_language_key_exists函数的具体用法?PHP elgg_language_key_exists怎么用?PHP elgg_language_key_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_language_key_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDisplayName
/**
* {@inheritdoc}
*/
public function getDisplayName()
{
if ($this->template && elgg_language_key_exists("notification:{$this->template}")) {
return elgg_echo("notification:{$this->template}");
}
return $this->subject;
}
示例2: getPlaceholder
/**
* Returns the placeholder text
*
* @return string
*/
public function getPlaceholder()
{
$result = $this->metadata_placeholder;
if (empty($result) && elgg_language_key_exists("profile:placeholder:{$this->metadata_name}")) {
$result = elgg_echo("profile:placeholder:{$this->metadata_name}");
}
return $result;
}
示例3: getDescription
/**
* Returns the description (potentially translated) of the type
*
* @return string
*/
public function getDescription()
{
$description = $this->metadata_description;
if (empty($description) && elgg_language_key_exists("profile:types:{$this->metadata_name}:description")) {
$description = elgg_echo("profile:types:{$this->metadata_name}:description");
}
return $description;
}
示例4: getUntranslatableCodeLanguageKeys
public function getUntranslatableCodeLanguageKeys()
{
$result = [];
foreach ($this->getCodeLanguageKeys() as $key) {
if (!elgg_language_key_exists($key)) {
$result[] = $key;
}
}
return $result;
}
示例5: getTitle
/**
* Returns the title of the field
*
* @return string
*/
public function getTitle()
{
if ($this->metadata_label) {
return $this->metadata_label;
}
if (elgg_language_key_exists("groups:{$this->metadata_name}")) {
return elgg_echo("groups:{$this->metadata_name}");
}
return $this->metadata_name;
}
示例6: csv_exporter_get_exportable_values
/**
* Get a list of all the exportable values for the given type/subtype
*
* @param string $type the entity type
* @param string $subtype the entity subtype
* @param bool $readable readable values or just for processing (default: false)
*
* @return array
*/
function csv_exporter_get_exportable_values($type, $subtype = '', $readable = false)
{
$result = [];
if (empty($type)) {
return $result;
}
if ($type == 'object' && empty($subtype)) {
return $result;
}
$class = get_subtype_class($type, $subtype);
if (!empty($class)) {
$dummy = new $class();
} else {
switch ($type) {
case 'object':
$dummy = new ElggObject();
break;
case 'group':
$dummy = new ElggGroup();
break;
case 'site':
$dummy = new ElggSite();
break;
case 'user':
$dummy = new ElggUser();
break;
}
}
$exports = (array) $dummy->toObject();
$defaults = array_keys($exports);
if ($readable) {
$new_defaults = [];
foreach ($defaults as $name) {
if (elgg_language_key_exists($name)) {
$lan = elgg_echo($name);
} elseif (elgg_language_key_exists("csv_exporter:exportable_value:{$name}")) {
$lan = elgg_echo("csv_exporter:exportable_value:{$name}");
} else {
$lan = $name;
}
$new_defaults[$lan] = $name;
}
$defaults = $new_defaults;
}
$params = ['type' => $type, 'subtype' => $subtype, 'readable' => $readable, 'defaults' => $defaults];
$result = elgg_trigger_plugin_hook('get_exportable_values', 'csv_exporter', $params, $defaults);
if (is_array($result)) {
// prevent duplications
$result = array_unique($result);
}
return $result;
}
示例7: getTitle
/**
* Returns the title of the field
*
* @return string
*/
public function getTitle()
{
// make title
$title = $this->metadata_label;
if (empty($title)) {
if (elgg_language_key_exists("profile:{$this->metadata_name}")) {
$title = elgg_echo("profile:{$this->metadata_name}");
} else {
$title = $this->metadata_name;
}
}
return $title;
}
示例8: getDisplayName
/**
* (non-PHPdoc)
* @see ElggObject::getDisplayName()
*/
public function getDisplayName()
{
$type = $this->getFormData('type');
$subtype = $this->getFormData('subtype');
$lan_keys = ["item:{$type}:{$subtype}", "item:{$type}"];
$content_type = '';
foreach ($lan_keys as $lan_key) {
if (elgg_language_key_exists($lan_key)) {
$content_type = elgg_echo($lan_key);
break;
}
}
if ($this->title) {
return elgg_echo('csv_exporter:object:csv_export:title:custom', [$content_type, $this->title]);
}
return elgg_echo('csv_exporter:object:csv_export:title', [$content_type]);
}
示例9: getTitle
/**
* Returns the title of the field
*
* @param bool $input set to true if you need the title for an input field
*
* @return string
*/
public function getTitle($input = false)
{
if ($input) {
if ($this->metadata_input_label) {
return $this->metadata_input_label;
}
if (elgg_language_key_exists("profile:{$this->metadata_name}:input")) {
return elgg_echo("profile:{$this->metadata_name}:input");
}
}
if ($this->metadata_label) {
return $this->metadata_label;
}
if (elgg_language_key_exists("profile:{$this->metadata_name}")) {
return elgg_echo("profile:{$this->metadata_name}");
}
return $this->metadata_name;
}
示例10: factory
/**
* Create an WidgetDefinition from an associative array. Required key is id.
*
* @param array $options Option array of key value pairs
*
* id => STR Widget identifier (required)
* name => STR Name of the widget
* description => STR Description of the widget
* context => ARRAY contexts in which the widget is available
* multiple => BOOL can the widget be added multiple times
*
* @throws InvalidParameterException
* @return \Elgg\WidgetDefinition
*/
public static function factory(array $options)
{
$id = elgg_extract('id', $options);
$definition = new WidgetDefinition($id);
$name = elgg_extract('name', $options);
if (empty($name)) {
if (elgg_language_key_exists("widgets:{$id}:name")) {
$definition->name = elgg_echo("widgets:{$id}:name");
} elseif (elgg_language_key_exists($id)) {
$definition->name = elgg_echo($id);
} else {
$definition->name = $id;
}
} else {
$definition->name = $name;
}
$description = elgg_extract('description', $options);
if (empty($description)) {
if (elgg_language_key_exists("widgets:{$id}:description")) {
$definition->description = elgg_echo("widgets:{$id}:description");
}
} else {
$definition->description = $description;
}
$context = (array) elgg_extract('context', $options, ['all']);
if (in_array('all', $context)) {
$context[] = 'profile';
$context[] = 'dashboard';
_elgg_services()->logger->notice("The widget '{$id}' need to be registered for explicit contexts");
$pos = array_search('all', $context);
unset($context[$pos]);
$context = array_unique($context);
}
$definition->context = $context;
$definition->multiple = (bool) elgg_extract('multiple', $options, false);
return $definition;
}
示例11: translation_editor_gatekeeper
*/
translation_editor_gatekeeper();
elgg_require_js('translation_editor/edit');
// get inputs
$q = get_input('q');
if (empty($q)) {
forward(REFERER);
}
$language = get_input('language', 'en');
$found = translation_editor_search_translation($q, $language);
$trans = get_installed_translations();
if (!array_key_exists($language, $trans)) {
forward('translation_editor');
}
$trans_lan = elgg_echo($language);
if (elgg_language_key_exists($language, $language)) {
$trans_lan = elgg_echo($language, [], $language);
}
$title_text = elgg_echo('translation_editor:search', [$q, $trans_lan]);
// breadcrumb
elgg_push_breadcrumb(elgg_echo('translation_editor:menu:title'), 'translation_editor');
elgg_push_breadcrumb($trans_lan, "translation_editor/{$language}");
// build page elements
// build search form
$form_vars = ['id' => 'translation_editor_search_form', 'action' => 'translation_editor/search', 'disable_security' => true, 'class' => 'mbl', 'method' => 'GET'];
$body_vars = ['current_language' => $language, 'query' => $q];
$body = elgg_view_form('translation_editor/search', $form_vars, $body_vars);
// display search results
if (!empty($found)) {
$body_vars = ['results' => $found, 'current_language' => $language];
$body .= elgg_view('translation_editor/search_results', $body_vars);
示例12: csv_exporter_get_exportable_values_hook
/**
* Extend the default exportable values with some extra's
*
* @param string $hook 'get_exportable_values'
* @param string $type 'csv_exporter'
* @param array $returnvalue the current exportable values
* @param array $params supplied params
*
* @return void|array
*/
function csv_exporter_get_exportable_values_hook($hook, $type, $returnvalue, $params)
{
if (empty($params) || !is_array($params)) {
return;
}
$type = elgg_extract('type', $params);
$readable = (bool) elgg_extract('readable', $params, false);
if ($readable) {
// defaults
$returnvalue = array_merge($returnvalue, [elgg_echo('csv_exporter:exportable_value:owner_name') => 'csv_exporter_owner_name', elgg_echo('csv_exporter:exportable_value:owner_username') => 'csv_exporter_owner_username', elgg_echo('csv_exporter:exportable_value:owner_email') => 'csv_exporter_owner_email', elgg_echo('csv_exporter:exportable_value:owner_url') => 'csv_exporter_owner_url', elgg_echo('csv_exporter:exportable_value:container_name') => 'csv_exporter_container_name', elgg_echo('csv_exporter:exportable_value:container_username') => 'csv_exporter_container_username', elgg_echo('csv_exporter:exportable_value:container_email') => 'csv_exporter_container_email', elgg_echo('csv_exporter:exportable_value:container_url') => 'csv_exporter_container_url', elgg_echo('csv_exporter:exportable_value:time_created_readable') => 'csv_exporter_time_created_readable', elgg_echo('csv_exporter:exportable_value:time_updated_readable') => 'csv_exporter_time_updated_readable', elgg_echo('csv_exporter:exportable_value:url') => 'csv_exporter_url']);
switch ($type) {
case 'object':
$returnvalue[elgg_echo('tags')] = 'csv_exporter_object_tags';
break;
case 'user':
// add profile fields
$profile_fields = elgg_get_config('profile_fields');
if (!empty($profile_fields)) {
foreach ($profile_fields as $metadata_name => $input_type) {
$lan = $metadata_name;
if (elgg_language_key_exists("profile:{$metadata_name}")) {
$lan = elgg_echo("profile:{$metadata_name}");
}
$returnvalue[$lan] = $metadata_name;
}
}
// others
$returnvalue[elgg_echo('email')] = 'email';
$returnvalue[elgg_echo('csv_exporter:exportable_value:user:last_action')] = 'csv_exporter_user_last_action';
$returnvalue[elgg_echo('csv_exporter:exportable_value:user:last_action_readable')] = 'csv_exporter_user_last_action_readable';
break;
case 'group':
// add profile fields
$profile_fields = elgg_get_config('group');
if (!empty($profile_fields)) {
foreach ($profile_fields as $metadata_name => $input_type) {
$lan = $metadata_name;
if (elgg_language_key_exists("groups:{$metadata_name}")) {
$lan = elgg_echo("groups:{$metadata_name}");
}
$returnvalue[$lan] = $metadata_name;
}
}
// others
$returnvalue[elgg_echo('csv_exporter:exportable_value:group:member_count')] = 'csv_exporter_group_member_count';
$returnvalue[elgg_echo('csv_exporter:exportable_value:group:last_activity')] = 'csv_exporter_group_last_activity';
$returnvalue[elgg_echo('csv_exporter:exportable_value:group:last_activity_readable')] = 'csv_exporter_group_last_activity_readable';
break;
}
} else {
// defaults
$returnvalue = array_merge($returnvalue, ['csv_exporter_owner_name', 'csv_exporter_owner_username', 'csv_exporter_owner_email', 'csv_exporter_owner_url', 'csv_exporter_container_name', 'csv_exporter_container_username', 'csv_exporter_container_email', 'csv_exporter_container_url', 'csv_exporter_time_created_readable', 'csv_exporter_time_updated_readable', 'csv_exporter_url']);
switch ($type) {
case 'object':
$returnvalue[] = 'csv_exporter_object_tags';
break;
case 'user':
// add profile fields
$profile_fields = elgg_get_config('profile_fields');
if (!empty($profile_fields)) {
foreach ($profile_fields as $metadata_name => $input_type) {
$returnvalue[] = $metadata_name;
}
}
//others
$returnvalue[] = 'email';
break;
case 'group':
// add profile fields
$profile_fields = elgg_get_config('group');
if (!empty($profile_fields)) {
foreach ($profile_fields as $metadata_name => $input_type) {
$returnvalue[] = $metadata_name;
}
}
// others
$returnvalue[] = 'csv_exporter_group_member_count';
$returnvalue[] = 'csv_exporter_group_last_activity';
$returnvalue[] = 'csv_exporter_group_last_activity_readable';
break;
}
}
return $returnvalue;
}
示例13: get_input
*/
$key = get_input('key');
$translation = get_input('translation');
if (empty($key) || empty($translation)) {
register_error(elgg_echo('translation_editor:action:add_custom_key:missing_input'));
forward(REFERER);
}
if (is_numeric($key)) {
register_error(elgg_echo('translation_editor:action:add_custom_key:key_numeric'));
forward(REFERER);
}
if (!preg_match('/^[a-zA-Z0-9_:]{1,}$/', $key)) {
register_error(elgg_echo('translation_editor:action:add_custom_key:invalid_chars'));
forward(REFERER);
}
if (elgg_language_key_exists($key, 'en')) {
register_error(elgg_echo('translation_editor:action:add_custom_key:exists'));
forward(REFERER);
}
// save
$custom_translations = translation_editor_get_plugin('en', 'custom_keys');
if (!empty($custom_translations)) {
$custom_translations = $custom_translations['en'];
} else {
$custom_translations = array();
}
$custom_translations[$key] = $translation;
$base_dir = elgg_get_data_path() . 'translation_editor' . DIRECTORY_SEPARATOR;
if (!file_exists($base_dir)) {
mkdir($base_dir, 0755, true);
}
示例14: seo_prepare_entity_data
/**
* Prepare entity SEF data
*
* @param \ElggEntity $entity Entity
* @return array|false
*/
function seo_prepare_entity_data(\ElggEntity $entity)
{
$path = seo_get_path($entity->getURL());
if (!$path || $path == '/') {
return false;
}
$type = $entity->getType();
switch ($type) {
case 'user':
if (elgg_is_active_plugin('profile')) {
$sef_path = "/profile/{$entity->username}";
}
break;
case 'group':
$subtype = $entity->getSubtype();
$registered = (array) get_registered_entity_types('group');
if (!$subtype || in_array($subtype, $registered)) {
if ($subtype && elgg_language_key_exists("item:group:{$subtype}", 'en')) {
$prefix = elgg_get_friendly_title(elgg_echo("item:group:{$subtype}", array(), 'en'));
} else {
$prefix = elgg_get_friendly_title(elgg_echo('item:group', array(), 'en'));
}
$friendly_title = elgg_get_friendly_title($entity->getDisplayName() ?: '');
$sef_path = "/{$prefix}/{$entity->guid}-{$friendly_title}";
}
break;
case 'object':
$subtype = $entity->getSubtype();
$registered = (array) get_registered_entity_types('object');
if (in_array($subtype, $registered)) {
if (elgg_language_key_exists("item:object:{$subtype}", 'en')) {
$prefix = elgg_get_friendly_title(elgg_echo("item:object:{$subtype}", array(), 'en'));
} else {
$prefix = elgg_get_friendly_title($subtype);
}
$friendly_title = elgg_get_friendly_title($entity->getDisplayName() ?: '');
$sef_path = "/{$prefix}/{$entity->guid}-{$friendly_title}";
}
break;
}
if (!$sef_path) {
$sef_path = $path;
}
$sef_data = seo_get_data($entity->getURL());
if (!is_array($sef_data)) {
$sef_data = array();
}
$entity_sef_data = ['path' => $path, 'sef_path' => $sef_path, 'title' => $entity->getDisplayName(), 'description' => elgg_get_excerpt($entity->description), 'keywords' => is_array($entity->tags) ? implode(',', $entity->tags) : $entity->tags, 'guid' => $entity->guid];
if ($entity->guid != $entity->owner_guid) {
$owner = $entity->getOwnerEntity();
if ($owner) {
$entity_sef_data['owner'] = seo_prepare_entity_data($owner);
}
}
if ($entity->guid != $entity->container_guid && $entity->owner_guid != $entity->container_guid) {
$container = $entity->getContainerEntity();
if ($container) {
$entity_sef_data['container'] = seo_prepare_entity_data($container);
}
}
if (empty($sef_data['admin_defined'])) {
$sef_data = array_merge($sef_data, $entity_sef_data);
} else {
foreach ($entity_sef_data as $key => $value) {
if (empty($sef_data[$key])) {
$sef_data[$key] = $value;
}
}
}
$entity_sef_metatags = elgg_trigger_plugin_hook('metatags', 'discovery', ['entity' => $entity, 'url' => elgg_normalize_url($sef_path)], []);
if (!empty($entity_sef_metatags)) {
foreach ($entity_sef_metatags as $key => $value) {
if (empty($sef_data['admin_defined']) || empty($sef_data['metatags'][$key])) {
$sef_data['metatags'][$key] = $value;
}
}
}
return $sef_data;
}
示例15: elgg_extract
<?php
/**
* Display one group tool option
*
* @uses $vars['group_tool'] the group tool options
* @uses $vars['value'] the current value of this option
* @uses $vars['name'] (optional) the name of the input
* @uses $vars['class'] (optional) class to be put on the wrapper div
*/
$group_tool = elgg_extract('group_tool', $vars);
$value = elgg_extract('value', $vars);
$group_tool_toggle_name = elgg_extract('name', $vars, "{$group_tool->name}_enable");
$attr = ['class' => elgg_extract('class', $vars)];
$content = elgg_view('input/checkbox', ['name' => $group_tool_toggle_name, 'value' => 'yes', 'default' => 'no', 'checked' => $value === 'yes' ? true : false, 'label' => $group_tool->label, 'class' => 'mrs']);
// optional description
$lan_key = "{$group_tool->name}:group_tool_option:description";
if (elgg_language_key_exists($lan_key)) {
$content .= elgg_view('output/longtext', ['value' => elgg_echo($lan_key), 'class' => 'elgg-quiet mtn']);
}
echo elgg_format_element('div', $attr, $content);