Skip to content

Commit

Permalink
Updates for Elgg 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai Shcherbin committed Jan 19, 2025
1 parent 3d6826a commit 00fff9f
Show file tree
Hide file tree
Showing 33 changed files with 1,743 additions and 804 deletions.
5 changes: 0 additions & 5 deletions CHANGES.txt

This file was deleted.

613 changes: 613 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
Elgg Connect
===========
Elgg Landing Theme
==================
![Elgg 6.1](https://img.shields.io/badge/Elgg-6.1-purple.svg?style=flat-square)

![Elgg 3.0](https://img.shields.io/badge/Elgg-3.0-green.svg?style=flat-square)

## Features

- Landing page with cover photo, latest users and groups
- Optional sidebar with content on the activity page
- Introduces group cover image and alternate layout of group profile page
- New standard icons for groups and users that match the color scheme
Responsive Elgg theme with landing page.

Based on [Elgg Connect plugin](https://github.com/PerJensen/elgg_connect)

## Note

After installation, go to the theme options and make your selections
## Features

This directory must be named 'elgg_connect' in your Elgg mod folder.
* Landing page with cover photo, latest users and groups
* Optional sidebar with content on the activity page
* New standard icons for groups and users that match the color scheme
* Logo image on the topbar
38 changes: 38 additions & 0 deletions classes/wZm/ElggTheme/Actions/CoverAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace wZm\ElggTheme\Actions;

use Symfony\Component\HttpFoundation\File\UploadedFile;

class CoverAction {

public function __invoke(\Elgg\Request $request) {
$asset = 'cover';
$upload = elgg_get_uploaded_file($asset);

if (!$upload instanceof UploadedFile || !$upload->isValid()) {
return elgg_error_response(elgg_echo('elgg_theme:settings:cover:invalid'));
}

$assets_dir = elgg_get_data_path() . '/elgg_theme/';

if (!is_dir($assets_dir)) {
mkdir($assets_dir, 0755, true);
}

$target = elgg_get_data_path() . 'elgg_theme/' . $asset . '.png';
if (file_exists($target)) {
unlink($target);
}

try {
$upload->move(elgg_get_data_path() . 'elgg_theme/', $asset . '.png');
elgg_invalidate_caches();
elgg_clear_caches();
} catch (\Exception $ex) {
return false;
}

return elgg_ok_response('', elgg_echo('elgg_theme:settings:cover:success'));
}
}
38 changes: 38 additions & 0 deletions classes/wZm/ElggTheme/Actions/LogoAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace wZm\ElggTheme\Actions;

use Symfony\Component\HttpFoundation\File\UploadedFile;

class LogoAction {

public function __invoke(\Elgg\Request $request) {
$asset = 'logo';
$upload = elgg_get_uploaded_file($asset);

if (!$upload instanceof UploadedFile || !$upload->isValid()) {
return elgg_error_response(elgg_echo('elgg_theme:settings:cover:invalid'));
}

$assets_dir = elgg_get_data_path() . '/elgg_theme/';

if (!is_dir($assets_dir)) {
mkdir($assets_dir, 0755, true);
}

$target = elgg_get_data_path() . 'elgg_theme/' . $asset . '.png';
if (file_exists($target)) {
unlink($target);
}

try {
$upload->move(elgg_get_data_path() . 'elgg_theme/', $asset . '.png');
elgg_invalidate_caches();
elgg_clear_caches();
} catch (\Exception $ex) {
return false;
}

return elgg_ok_response('', elgg_echo('elgg_theme:settings:cover:success'));
}
}
92 changes: 92 additions & 0 deletions classes/wZm/ElggTheme/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

namespace wZm\ElggTheme;

use Elgg\DefaultPluginBootstrap;

class Bootstrap extends DefaultPluginBootstrap {
/**
* Executed during 'plugin_boot:before', 'system' event
*
* Allows the plugin to require additional files, as well as configure services prior to booting the plugin
*
* @return void
*/
public function load() {

}

/**
* Executed during 'plugin_boot:before', 'system' event
*
* Allows the plugin to register handlers for 'plugin_boot', 'system' and 'init', 'system' events,
* as well as implement boot time logic
*
* @return void
*/
public function boot() {

}

/**
* Executed during 'init', 'system' event
*
* Allows the plugin to implement business logic and register all other handlers
*
* @return void
*/
public function init() {
elgg_register_esm('js/elgg_theme', elgg_get_simplecache_url('elgg_theme/settings.mjs'));
}

/**
* Executed during 'ready', 'system' event
*
* Allows the plugin to implement logic after all plugins are initialized
*
* @return void
*/
public function ready() {

}

/**
* Executed during 'shutdown', 'system' event
*
* Allows the plugin to implement logic during shutdown
*
* @return void
*/
public function shutdown() {

}

/**
* Executed when plugin is activated, after 'activate', 'plugin' event and before activate.php is included
*
* @return void
*/
public function activate() {

}

/**
* Executed when plugin is deactivated, after 'deactivate', 'plugin' event and before deactivate.php is included
*
* @return void
*/
public function deactivate() {

}

/**
* Registered as handler for 'upgrade', 'system' event
*
* Allows the plugin to implement logic during system upgrade
*
* @return void
*/
public function upgrade() {

}
}
46 changes: 46 additions & 0 deletions classes/wZm/ElggTheme/Menus/SettingsManu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace wZm\ElggTheme\Menus;

class SettingsManu {

public function __invoke(\Elgg\Event $event) {
if (!elgg_in_context('admin') || !elgg_is_admin_logged_in()) {
return;
}

$current_route = elgg_get_current_route();
if (elgg_extract('segments', $current_route->getMatchedParameters()) !== 'plugins' && $current_route->getName() !== 'admin:plugin_settings') {
return;
}

$menu = $event->getValue();
/* @var $menu \Elgg\Collections\Collection */

$menu->add(\ElggMenuItem::factory([
'name' => 'elgg_theme:config',
'text' => elgg_echo('admin:elgg_theme:config'),
'href' => elgg_normalize_url('admin/plugin_settings/elgg_theme'),
'parent_name' => 'plugin:settings:elgg_theme',
'section' => 'plugin_settings',
]));

$menu->add(\ElggMenuItem::factory([
'name' => 'elgg_theme:cover',
'text' => elgg_echo('admin:elgg_theme:cover'),
'href' => elgg_normalize_url('admin/elgg_theme/cover'),
'parent_name' => 'plugin:settings:elgg_theme',
'section' => 'plugin_settings',
]));

$menu->add(\ElggMenuItem::factory([
'name' => 'elgg_theme:logo',
'text' => elgg_echo('admin:elgg_theme:logo'),
'href' => elgg_normalize_url('admin/elgg_theme/logo'),
'parent_name' => 'plugin:settings:elgg_theme',
'section' => 'plugin_settings',
]));

return $menu;
}
}
35 changes: 35 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "rivervanrain/elgg_theme",
"type": "elgg-plugin",
"description": "Responsive Elgg theme with landing page",
"license": "AGPL-3.0-or-later",
"keywords": ["theme", "landing"],
"homepage": "https://wzm.me",
"authors": [
{
"name": "Per Jensen"
},
{
"name": "Nikolai Shcherbin",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"": "classes/"
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"conflict": {
"elgg/elgg": "<6.1",
"elgg/custom_index": "*"
},
"support": {
"source": "https://github.com/rivervanrain/elgg_theme"
}
}
81 changes: 81 additions & 0 deletions elgg-plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/**
* Elgg Landing Theme
* @author Nikolai Shcherbin
* @license GNU Affero General Public License version 3
* @copyright (c) Nikolai Shcherbin 2022
* @link https://wzm.me
**/

return [
'plugin' => [
'name' => 'Elgg Landing Theme',
'version' => '3.0.0',
'dependencies' => [
'activity' => [
'position' => 'after',
'must_be_active' => false,
],
'groups' => [
'position' => 'after',
'must_be_active' => false,
],
],
'activate_on_install' => true,
],

'bootstrap' => \wZm\ElggTheme\Bootstrap::class,

'actions' => [
'admin/elgg_theme/cover' => [
'controller' => \wZm\ElggTheme\Actions\CoverAction::class,
'access' => 'admin',
],

'admin/elgg_theme/logo' => [
'controller' => \wZm\ElggTheme\Actions\LogoAction::class,
'access' => 'admin',
],
],

'events' => [
'register' => [
'menu:page' => [
\wZm\ElggTheme\Menus\SettingsManu::class => [],
],
],
],

'view_extensions' => [
'admin.css' => [
'elgg_theme/elgg_theme_admin.css' => [],
],
'elgg.css' => [
'elgg_theme/elgg_theme.css' => [],
],
'river/sidebar' => [
'elgg_theme/sidebar' => [],
],
],

'view_options' => [
'graphics/cover.jpg' => ['simplecache' => true],
],

'views' => [
'default' => [
'elgg_theme/' => elgg_get_data_path() . 'elgg_theme/',
],
],

'settings' => [
'topbar_logo_text' => true,
'landing_action' => true,
'display_members' => true,
'display_groups' => false,
'activity_sidebar' => false,
'sidebar_profile_icon' => true,
'sidebar_friends' => true,
],
];

Loading

0 comments on commit 00fff9f

Please sign in to comment.