/** * 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); }
<?php elgg_gatekeeper(); $assets = ''; if (elgg_is_admin_logged_in()) { $views = elgg_list_views(); $images = array_filter($views, function ($view) { $extension = pathinfo($view, PATHINFO_EXTENSION); return 0 === strpos($view, 'ckeditor/assets/') && in_array($extension, ['jpg', 'gif', 'png', 'svg']); }); if (!empty($images)) { $assets .= '<ul class="elgg-gallery">'; foreach ($images as $image) { $assets .= '<li class="elgg-item">'; $img = elgg_format_element('img', array('src' => elgg_normalize_url($image), 'class' => 'ckeditor-browser-image', 'data-callback' => get_input('CKEditorFuncNum'), 'width' => 100)); $assets .= elgg_format_element('div', array('class' => 'elgg-photo'), $img); $assets .= '</li>'; } $assets .= '</ul>'; $assets = elgg_view_module('info', elgg_echo('ckeditor:browse:assets'), $assets); } } $user = elgg_get_logged_in_user_entity(); $images = elgg_list_entities(array('types' => 'object', 'subtypes' => 'ckeditor_file', 'owner_guids' => (int) $user->guid, 'limit' => 20, 'pagination' => elgg_is_active_plugin('hypeLists'), 'pagination_type' => 'default', 'list_type' => 'gallery', 'ckeditor_callback' => get_input('CKEditorFuncNum'), 'no_results' => elgg_echo('ckeditor:browse:no_uploads'))); $images = elgg_view_module('info', elgg_echo('ckeditor:browse:uploads'), $images); $head = elgg_view('page/elements/head', array('title' => '')); $foot = elgg_view('page/elements/foot'); echo elgg_view('page/elements/html', array('head' => $head, 'body' => elgg_format_element('div', array('class' => 'ckeditor-addons-browser'), $assets . $images . $foot))); ?> <script> require(['jquery'], function ($) {