コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getDisplayName()
 {
     if ($this->template && elgg_language_key_exists("notification:{$this->template}")) {
         return elgg_echo("notification:{$this->template}");
     }
     return $this->subject;
 }
コード例 #2
0
 /**
  * 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
0
 /**
  * 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
0
 public function getUntranslatableCodeLanguageKeys()
 {
     $result = [];
     foreach ($this->getCodeLanguageKeys() as $key) {
         if (!elgg_language_key_exists($key)) {
             $result[] = $key;
         }
     }
     return $result;
 }
コード例 #5
0
 /**
  * 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
0
ファイル: functions.php プロジェクト: coldtrick/csv_exporter
/**
 * 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
0
 /**
  * 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
0
ファイル: CSVExport.php プロジェクト: coldtrick/csv_exporter
 /**
  * (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
0
 /**
  * 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
0
ファイル: WidgetDefinition.php プロジェクト: elgg/elgg
 /**
  * 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
0
 */
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
0
ファイル: hooks.php プロジェクト: siteleas/csv_exporter
/**
 * 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
0
 */
$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
0
ファイル: functions.php プロジェクト: hypeJunction/Elgg-seo
/**
 * 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
0
ファイル: group_tool.php プロジェクト: coldtrick/group_tools
<?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);
コード例 #16
0
ファイル: user_settings.php プロジェクト: elgg/elgg
/**
 * Register menu items for the user settings page menu
 *
 * @param string $hook
 * @param string $type
 * @param array  $return
 * @param array  $params
 * @return array
 *
 * @access private
 *
 * @since 3.0
 */
function _elgg_user_settings_menu_register($hook, $type, $return, $params)
{
    $user = elgg_get_page_owner_entity();
    if (!$user) {
        return;
    }
    if (!elgg_in_context('settings')) {
        return;
    }
    $return[] = \ElggMenuItem::factory(['name' => '1_account', 'text' => elgg_echo('usersettings:user:opt:linktext'), 'href' => "settings/user/{$user->username}", 'section' => 'configure']);
    $return[] = \ElggMenuItem::factory(['name' => '1_plugins', 'text' => elgg_echo('usersettings:plugins:opt:linktext'), 'href' => '#', 'section' => 'configure']);
    $return[] = \ElggMenuItem::factory(['name' => '1_statistics', 'text' => elgg_echo('usersettings:statistics:opt:linktext'), 'href' => "settings/statistics/{$user->username}", 'section' => 'configure']);
    // register plugin user settings menu items
    $active_plugins = elgg_get_plugins();
    foreach ($active_plugins as $plugin) {
        $plugin_id = $plugin->getID();
        if (!elgg_view_exists("usersettings/{$plugin_id}/edit") && !elgg_view_exists("plugins/{$plugin_id}/usersettings")) {
            continue;
        }
        if (elgg_language_key_exists($plugin_id . ':usersettings:title')) {
            $title = elgg_echo($plugin_id . ':usersettings:title');
        } else {
            $title = $plugin->getFriendlyName();
        }
        $return[] = \ElggMenuItem::factory(['name' => $plugin_id, 'text' => $title, 'href' => "settings/plugins/{$user->username}/{$plugin_id}", 'parent_name' => '1_plugins', 'section' => 'configure']);
    }
    return $return;
}
コード例 #17
0
ファイル: ColumnFactory.php プロジェクト: elgg/elgg
 /**
  * Provide additional methods via hook and specified language keys.
  *
  * First, the hook `table_columns:call` is called. Details in `docs/guides/hooks-list.rst`.
  *
  * Then it checks existence of 3 language keys in order to defer processing to a local method:
  *
  * - "table_columns:fromView:$name" -> uses $this->fromView($name, ...).
  * - "table_columns:fromProperty:$name" -> uses $this->fromProperty($name, ...).
  * - "table_columns:fromMethod:$name" -> uses $this->fromMethod($name, ...).
  *
  * See the `from*()` methods for details.
  *
  * @param string $name      Method name
  * @param array  $arguments Arguments
  *
  * @return TableColumn
  */
 public function __call($name, $arguments)
 {
     // allow hook to hijack magic methods
     $column = elgg_trigger_plugin_hook('table_columns:call', $name, ['arguments' => $arguments]);
     if ($column instanceof TableColumn) {
         return $column;
     }
     if (elgg_language_key_exists("table_columns:fromView:{$name}")) {
         array_unshift($arguments, $name);
         return call_user_func_array([$this, 'fromView'], $arguments);
     }
     if (elgg_language_key_exists("table_columns:fromProperty:{$name}")) {
         array_unshift($arguments, $name);
         return call_user_func_array([$this, 'fromProperty'], $arguments);
     }
     if (elgg_language_key_exists("table_columns:fromMethod:{$name}")) {
         array_unshift($arguments, $name);
         return call_user_func_array([$this, 'fromMethod'], $arguments);
     }
     // empty column and error
     _elgg_services()->logger->error(__CLASS__ . ": No method defined '{$name}'");
     return new CallableColumn([Values::class, 'getNull'], '');
 }
コード例 #18
0
<?php

elgg_admin_gatekeeper();
elgg_push_breadcrumb(elgg_echo('notifications'), '/notifications');
elgg_push_breadcrumb(elgg_echo('notifications:editor'), '/notifications/editor');
elgg_push_breadcrumb(elgg_echo('notifications:editor:templates'));
$templates = notification_editor_get_templates();
$languages = get_installed_translations();
$title = elgg_echo('notifications:editor:templates');
$content = '';
foreach ($templates as $template) {
    $mod = '<ul class="elgg-menu-hz">';
    foreach ($languages as $language => $string) {
        $mod .= '<li class="pas">' . elgg_view('output/url', array('href' => "notifications/editor/edit?template={$template}&language={$language}", 'text' => elgg_echo($language))) . '</li>';
    }
    $mod .= '</ul>';
    $template_desc = $template;
    if (elgg_language_key_exists("notification:{$template}")) {
        $template_desc = elgg_echo("notification:{$template}");
    }
    $content .= elgg_view_module('info', $template_desc, $mod);
}
$layout = elgg_view_layout('content', array('filter' => false, 'title' => $title, 'content' => $content));
echo elgg_view_page($title, $layout);
コード例 #19
0
ファイル: list.php プロジェクト: elgg/elgg
$type_str = NULL;
if (array_key_exists('type', $vars['params']) && array_key_exists('subtype', $vars['params'])) {
    $type_str_tmp = "item:{$vars['params']['type']}:{$vars['params']['subtype']}";
    if (elgg_language_key_exists($type_str_tmp)) {
        $type_str = elgg_echo($type_str_tmp);
    }
}
if (!$type_str && array_key_exists('type', $vars['params'])) {
    $type_str = elgg_echo("item:{$vars['params']['type']}");
}
if (!$type_str) {
    $type_str = elgg_echo('search:unknown_entity');
}
// allow overrides for titles
$search_type = elgg_extract('search_type', $vars['params']);
if ($search_type && elgg_language_key_exists("search_types:{$search_type}")) {
    $type_str = elgg_echo("search_types:{$search_type}");
}
if ($show_more) {
    $more_str = elgg_echo('search:more', array($count, $type_str));
    $more_url = elgg_http_remove_url_query_element($url, 'limit');
    $more_link = "<li class='elgg-item'><a href=\"{$more_url}\">{$more_str}</a></li>";
} else {
    $more_link = '';
}
$body = elgg_view_title($type_str, array('class' => 'search-heading-category'));
$list_body = '';
$view_params = $vars['params'];
foreach ($entities as $entity) {
    $view_params['type'] = $entity->getType();
    $view_params['subtype'] = $entity->getSubtype();
コード例 #20
0
ファイル: settings.php プロジェクト: coldtrick/simplesaml
     $content .= elgg_view('simplesaml/settings/service_provider_basic', ['plugin' => $plugin, 'source' => $source, 'first_source' => $first_source, 'enabled' => $enabled, 'source_type_label' => $source_type_label]);
     // set a flag so we know we had at least 1 source
     $first_source = false;
 }
 $content .= '</table>';
 echo elgg_view_module('inline', $souces_title, $content);
 // settings for enabled sources
 if (!empty($enabled_sources)) {
     // build options to automaticly link accounts based on profile information
     $auto_link_options = ['0' => elgg_echo('simplesaml:settings:sources:configuration:auto_link:none'), 'username' => elgg_echo('username'), 'email' => elgg_echo('email')];
     // add profile fields
     $profile_fields = elgg_get_config('profile_fields');
     if (!empty($profile_fields) && is_array($profile_fields)) {
         foreach ($profile_fields as $name => $type) {
             $profile_label = $name;
             if (elgg_language_key_exists("profile:{$name}")) {
                 $profile_label = elgg_echo("profile:{$name}");
             }
             $auto_link_options[$name] = $profile_label;
         }
     }
     $access_type_options = ['allow' => elgg_echo('simplesaml:settings:sources:configuration:access_type:allow'), 'deny' => elgg_echo('simplesaml:settings:sources:configuration:access_type:deny')];
     $access_matching_options = ['exact' => elgg_echo('simplesaml:settings:sources:configuration:access_matching:exact'), 'regex' => elgg_echo('simplesaml:settings:sources:configuration:access_matching:regex')];
     // enabled sources are grouped by type
     foreach ($enabled_sources as $source_type => $sources) {
         // make sure we have sources of this type
         if (empty($sources) || !is_array($sources)) {
             continue;
         }
         // go through all sources of this type
         foreach ($sources as $source_id) {
コード例 #21
0
ファイル: user_settings.php プロジェクト: nirajkaushal/Elgg
/**
 * Set up the menu for user settings
 *
 * @return void
 * @access private
 */
function _elgg_user_settings_menu_setup()
{
    $user = elgg_get_page_owner_entity();
    if (!$user) {
        return;
    }
    if (!elgg_in_context("settings")) {
        return;
    }
    $params = array('name' => '1_account', 'text' => elgg_echo('usersettings:user:opt:linktext'), 'href' => "settings/user/{$user->username}", 'section' => 'configure');
    elgg_register_menu_item('page', $params);
    $params = array('name' => '1_plugins', 'text' => elgg_echo('usersettings:plugins:opt:linktext'), 'href' => '#', 'section' => 'configure');
    elgg_register_menu_item('page', $params);
    $params = array('name' => '1_statistics', 'text' => elgg_echo('usersettings:statistics:opt:linktext'), 'href' => "settings/statistics/{$user->username}", 'section' => 'configure');
    elgg_register_menu_item('page', $params);
    // register plugin user settings menu items
    $active_plugins = elgg_get_plugins();
    foreach ($active_plugins as $plugin) {
        $plugin_id = $plugin->getID();
        if (elgg_view_exists("usersettings/{$plugin_id}/edit") || elgg_view_exists("plugins/{$plugin_id}/usersettings")) {
            if (elgg_language_key_exists($plugin_id . ':usersettings:title')) {
                $title = elgg_echo($plugin_id . ':usersettings:title');
            } else {
                $title = $plugin->getFriendlyName();
            }
            $params = array('name' => $plugin_id, 'text' => $title, 'href' => "settings/plugins/{$user->username}/{$plugin_id}", 'parent_name' => '1_plugins', 'section' => 'configure');
            elgg_register_menu_item('page', $params);
        }
    }
    elgg_register_plugin_hook_handler("prepare", "menu:page", "_elgg_user_settings_menu_prepare");
}
コード例 #22
0
ファイル: functions.php プロジェクト: coldtrick/newsletter
/**
 * Returns all the available templates, these include those provided by themes
 * and the saved templates
 *
 * Other plugins/themes can provide their own template if the create a view
 * newsletter/templates/<some name>/{body|css}
 *
 * @param int $container_guid The container of the current newsletter
 * @return array The available templates
 */
function newsletter_get_available_templates($container_guid)
{
    $result = [];
    // detect templates provided by themes/plugins
    $locations = elgg_list_views();
    $pattern = '/^newsletter\\/templates\\/(?P<name>\\w+)\\/(body|css)$/';
    foreach ($locations as $view) {
        $matches = [];
        $res = preg_match($pattern, $view, $matches);
        if (empty($res)) {
            continue;
        }
        $name = elgg_extract('name', $matches);
        $lan_key = "newsletter:edit:template:select:{$name}";
        if (elgg_language_key_exists($lan_key)) {
            $title = elgg_echo($lan_key);
        } else {
            $title = $name;
        }
        $result[$name] = $title;
    }
    // get saved templates
    if (!empty($container_guid)) {
        $templates = elgg_get_entities(['type' => 'object', 'subtype' => NEWSLETTER_TEMPLATE, 'container_guid' => $container_guid, 'limit' => false]);
        if (!empty($templates)) {
            foreach ($templates as $template) {
                $result[$template->getGUID()] = $template->title;
            }
        }
    }
    // the custom selection option
    unset($result['custom']);
    // make sure custom is last in the list (shouldn't be provided by a plugin/theme)
    $result['custom'] = elgg_echo('newsletter:edit:template:select:custom');
    return elgg_trigger_plugin_hook('templates', 'newsletter', ['container_guid' => $container_guid], $result);
}
コード例 #23
0
<?php

$options = [];
$current_language = get_current_language();
$keys = Elgg\I18n\Translator::getAllLanguageCodes();
foreach ($keys as $lang_key) {
    $trans_key = $lang_key;
    if (elgg_language_key_exists($lang_key, $current_language) || elgg_language_key_exists($lang_key)) {
        $trans_key = elgg_echo($lang_key);
    }
    $options[$lang_key] = $trans_key;
}
$installed_languages = get_installed_translations();
foreach ($installed_languages as $index => $lang) {
    unset($options[$index]);
}
asort($options);
$form_body = elgg_view('input/dropdown', ['options_values' => $options, 'name' => 'code']);
$form_body .= elgg_view('input/submit', ['value' => elgg_echo('save'), 'class' => 'mls elgg-button-submit']);
echo $form_body;
コード例 #24
0
ファイル: MenuHooks.php プロジェクト: coldtrick/menu_builder
 /**
  * Adds the menu items to the menus managed by menu_builder
  *
  * @param string  $hook   name of the hook
  * @param string  $type   type of the hook
  * @param unknown $return return value
  * @param unknown $params hook parameters
  *
  * @return array
  */
 public static function registerAllMenu($hook, $type, $return, $params)
 {
     $current_menu = $params['name'];
     $return = [];
     // need to reset as there should be no other way to add menu items
     $menu = new \ColdTrick\MenuBuilder\Menu($current_menu);
     if (!elgg_in_context('admin') && $menu->getCachedData()) {
         // don't get menu as it will be handle by the cache @see menu_builder_view_navigation_menu_default_hook
         return $return;
     }
     // fix menu name if needed
     $lang_key = 'menu:' . elgg_get_friendly_title($current_menu) . ':header:default';
     if (!elgg_language_key_exists($lang_key)) {
         add_translation(get_current_language(), [$lang_key => $current_menu]);
     }
     // add configured menu items
     $menu_items = json_decode(elgg_get_plugin_setting("menu_{$current_menu}_config", 'menu_builder'), true);
     if (is_array($menu_items)) {
         foreach ($menu_items as $menu_item) {
             $can_add_menu_item = true;
             if (elgg_in_context('menu_builder_manage')) {
                 $menu_item['menu_builder_menu_name'] = $current_menu;
             } else {
                 if (empty($menu_item['target'])) {
                     unset($menu_item['target']);
                 }
                 $access_id = $menu_item['access_id'];
                 unset($menu_item['access_id']);
                 switch ($access_id) {
                     case ACCESS_PRIVATE:
                         if (!elgg_is_admin_logged_in()) {
                             $can_add_menu_item = false;
                         }
                         break;
                     case MENU_BUILDER_ACCESS_LOGGED_OUT:
                         if (elgg_is_logged_in()) {
                             $can_add_menu_item = false;
                         }
                         break;
                     case ACCESS_LOGGED_IN:
                         if (!elgg_is_logged_in()) {
                             $can_add_menu_item = false;
                         }
                         break;
                 }
             }
             if (!$can_add_menu_item) {
                 continue;
             }
             // strip out deprecated use of [wwwroot] as menu items will be normalized by default
             $menu_item['href'] = str_replace('[wwwroot]', '', $menu_item['href']);
             // add global replacable action tokens
             if ($menu_item['is_action'] && !elgg_in_context('menu_builder_manage')) {
                 unset($menu_item['is_action']);
                 $concat = '?';
                 if (stristr($menu_item['href'], '?')) {
                     $concat = '&';
                 }
                 $menu_item['href'] .= $concat . '__elgg_ts=[__elgg_ts]&__elgg_token[__elgg_token]';
             }
             if (empty($menu_item['href'])) {
                 $menu_item['href'] = false;
             }
             $return[] = \ElggMenuItem::factory($menu_item);
         }
     }
     // add 'new menu item' menu item
     if (elgg_in_context('menu_builder_manage')) {
         $return[] = \ElggMenuItem::factory(['name' => 'menu_builder_add', 'text' => '<strong>+</strong>&nbsp;&nbsp;' . elgg_echo('menu_builder:edit_mode:add'), 'href' => 'ajax/view/menu_builder/edit_item?item_name=menu_builder_add&menu_name=' . $current_menu, 'link_class' => 'elgg-lightbox', 'menu_builder_menu_name' => $current_menu, 'priority' => time()]);
     }
     return $return;
 }
コード例 #25
0
    $profile_field_search_form_soundex_values = json_decode($profile_field_search_form_soundex_values, true);
}
$profile_field_metadata_search_values = elgg_get_plugin_setting('user_profile_fields_metadata_search', 'search_advanced', []);
if (!empty($profile_field_metadata_search_values)) {
    $profile_field_metadata_search_values = json_decode($profile_field_metadata_search_values, true);
}
echo "<table class='elgg-table'>";
echo "<tr>";
echo "<th>" . elgg_echo("search_advanced:settings:profile_fields:field") . "</th>";
echo "<th class='center'>" . elgg_echo("search_advanced:settings:user_profile_fields:show_on_form") . "*";
echo elgg_view("input/hidden", array("name" => "params[user_profile_fields]", "value" => 0)) . "</th>";
echo "<th class='center'>" . elgg_echo("search_advanced:settings:user_profile_fields:use_soundex") . "</th>";
echo "<th class='center'>" . elgg_echo("search_advanced:settings:profile_fields:metadata_search") . "</th>";
echo "</tr>";
foreach ($profile_fields as $metadata_name => $type) {
    if (elgg_language_key_exists("profile:{$metadata_name}")) {
        $name = elgg_echo("profile:{$metadata_name}");
    } else {
        $name = $metadata_name;
    }
    $name .= " ({$type})";
    $show_field_options = array('name' => 'params[user_profile_fields_search_form][]', 'value' => $metadata_name, 'checked' => in_array($metadata_name, $profile_field_values_search_form));
    $soundex_field_options = array('name' => 'params[user_profile_fields_search_form_soundex][]', 'value' => $metadata_name, 'checked' => in_array($metadata_name, $profile_field_search_form_soundex_values));
    $metadata_search_field_options = array('name' => 'params[user_profile_fields_metadata_search][]', 'value' => $metadata_name, 'checked' => in_array($metadata_name, $profile_field_metadata_search_values));
    echo "<tr>";
    echo "<td><label>" . $name . "</label></td>";
    echo "<td class='center'>" . elgg_view("input/checkbox", $show_field_options) . "</td>";
    echo "<td class='center'>" . elgg_view("input/checkbox", $soundex_field_options) . "</td>";
    echo "<td class='center'>" . elgg_view("input/checkbox", $metadata_search_field_options) . "</td>";
    echo "</tr>";
}
コード例 #26
0
$tab = get_input('tab');
$tool_options = elgg_get_config('group_tool_options');
sort($tool_options);
$enabled_tools = array();
foreach ($tool_options as $option) {
    $option_name = "{$option->name}_enable";
    if ($group->{$option_name} === 'yes') {
        $enabled_tools[] = $option->name;
    }
}
if ($tab === null) {
    $tab = $enabled_tools[0];
}
$tabs = array();
foreach ($enabled_tools as $tool) {
    if (!elgg_language_key_exists($tool)) {
        continue;
    }
    $tabs[] = array('text' => elgg_echo($tool), 'href' => "groups/profile/{$group->guid}?tab={$tool}", 'selected' => $tab == $tool ? true : false);
}
$button = '';
if ($tab !== 'activity') {
    // The tool name and content type name are different for discussions
    $type = $tab == 'forum' ? 'discussion' : $tab;
    $button = elgg_view('output/url', array('href' => "{$type}/add/{$group->guid}", 'class' => 'elgg-button elgg-button-submit', 'text' => elgg_echo("{$tab}:add")));
}
$tabs = elgg_view('navigation/tabs', array('tabs' => $tabs));
$content = elgg_view("group_layout/{$tab}", $vars);
echo <<<HTML
<div class="group-profile-tabs tab-{$tab}">
\t{$button}
コード例 #27
0
ファイル: delete.php プロジェクト: elgg/elgg
if (!$entity->delete()) {
    register_error(elgg_echo('entity:delete:fail', array($display_name)));
    forward(REFERRER);
}
// determine forward URL
$forward_url = get_input('forward_url');
if (!$forward_url) {
    $forward_url = REFERRER;
    $referrer_url = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
    $site_url = elgg_get_site_url();
    if ($referrer_url && 0 == strpos($referrer_url, $site_url)) {
        $referrer_path = substr($referrer_url, strlen($site_url));
        $segments = explode('/', $referrer_path);
        if (in_array($guid, $segments)) {
            // referrer URL contains a reference to the entity that will be deleted
            $forward_url = $container ? $container->getURL() : '';
        }
    } else {
        if ($container) {
            $forward_url = $container->getURL() ?: '';
        }
    }
}
$success_keys = array("entity:delete:{$type}:{$subtype}:success", "entity:delete:{$type}:success", "entity:delete:success");
foreach ($success_keys as $success_key) {
    if (elgg_language_key_exists($success_key)) {
        system_message(elgg_echo($success_key, array($display_name)));
        break;
    }
}
forward($forward_url);
コード例 #28
0
ファイル: functions.php プロジェクト: coldtrick/simplesaml
/**
 * Get a readable name for an IDentity Provider (IDP).
 *
 * The names can be provided in translation files by adding the key 'simplesaml:idp:label:<idp name>'.
 *
 * @param string $idp_source the name of the IDP
 *
 * @return string
 */
function simplesaml_get_idp_label($idp_source)
{
    if (empty($idp_source)) {
        return $idp_source;
    }
    $lan_key = "simplesaml:idp:label:{$idp_source}";
    if (elgg_language_key_exists($lan_key)) {
        return elgg_echo($lan_key);
    }
    return $idp_source;
}
コード例 #29
0
 /**
  * Get the default exportable values for groups
  *
  * @return array
  */
 protected static function getGroupExportableValues()
 {
     $result = [];
     // 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}");
             }
             $result[$lan] = $metadata_name;
         }
     }
     // add defaults
     $result[elgg_echo('csv_exporter:exportable_value:group:membership')] = 'csv_exporter_group_membership';
     $result[elgg_echo('csv_exporter:exportable_value:group:visibility')] = 'csv_exporter_group_visibility';
     $result[elgg_echo('csv_exporter:exportable_value:group:member_count')] = 'csv_exporter_group_member_count';
     $result[elgg_echo('csv_exporter:exportable_value:group:last_activity')] = 'csv_exporter_group_last_activity';
     $result[elgg_echo('csv_exporter:exportable_value:group:last_activity_readable')] = 'csv_exporter_group_last_activity_readable';
     return $result;
 }
コード例 #30
0
ファイル: tools.php プロジェクト: bhargavgarlapati/Elgg
 * @subpackage Core
 */
// Only logged in users
elgg_gatekeeper();
// Make sure we don't open a security hole ...
if (!elgg_get_page_owner_entity() || !elgg_get_page_owner_entity()->canEdit()) {
    register_error(elgg_echo('noaccess'));
    forward('/');
}
$plugin_id = get_input("plugin_id");
if (empty($plugin_id)) {
    register_error(elgg_echo('ElggPlugin:MissingID'));
    forward(REFERER);
}
$plugin = elgg_get_plugin_from_id($plugin_id);
if (!$plugin) {
    register_error(elgg_echo('PluginException:InvalidID', array($plugin_id)));
    forward(REFERER);
}
if (elgg_language_key_exists($plugin_id . ':usersettings:title')) {
    $title = elgg_echo($plugin_id . ':usersettings:title');
} else {
    $title = $plugin->getManifest()->getName();
}
$username = get_input('username');
elgg_push_breadcrumb(elgg_echo('settings'), "settings/user/{$username}");
elgg_push_breadcrumb(elgg_echo('usersettings:plugins:opt:linktext'));
$content = elgg_view_form('plugins/usersettings/save', array(), array('entity' => $plugin));
$params = array('content' => $content, 'title' => $title);
$body = elgg_view_layout('one_sidebar', $params);
echo elgg_view_page($title, $body);