forked from PerJensen/elgg_connect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to show logo image on the topbar
- Loading branch information
Nikolai Shcherbin
committed
Sep 12, 2023
1 parent
244697c
commit 092f4ac
Showing
11 changed files
with
148 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,20 @@ | |
'elgg_theme:settings:activity_sidebar:friends' => 'Show friends', | ||
|
||
'admin:elgg_theme' => 'Elgg Landing Theme', | ||
'admin:elgg_theme:config' => 'Settings', | ||
|
||
'admin:elgg_theme:cover' => 'Cover image', | ||
'elgg_theme:settings:cover' => 'Cover image (PNG format)', | ||
'elgg_theme:settings:cover:help' => 'Recommend an image with minimal width 2100px.', | ||
'elgg_theme:settings:cover:success' => 'Cover image has been saved.', | ||
'elgg_theme:settings:cover:invalid' => 'No cover image found.', | ||
|
||
'elgg_theme:settings:topbar_logo_text' => 'Show only site name on the topbar instead of logo image', | ||
'admin:elgg_theme:logo' => 'Logo image', | ||
'elgg_theme:settings:logo' => 'Logo image (PNG format)', | ||
'elgg_theme:settings:logo:help' => "Disable 'Show only site name' option via Elgg Landing Theme settings to display logo image on the topbar. Recommend an image with maximum width 40px.", | ||
'elgg_theme:settings:logo:success' => 'Logo image has been saved.', | ||
'elgg_theme:settings:logo:invalid' => 'No logo image found.', | ||
|
||
'index:content' => '<p>Many sites use <a href="https://es.wzm.me">the additional plugins</a> for this theme to place the custom modules on this landing page.</p><p>Contact with our developers to make beautiful and modern design for your site: <a href="mailto:[email protected]">[email protected]</a></p>', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
echo elgg_view_form('admin/elgg_theme/logo', [ | ||
'enctype' => 'multipart/form-data' | ||
], []); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
//logo | ||
$file_src = elgg_get_data_path() . 'elgg_theme/logo.png'; | ||
|
||
if (file_exists($file_src)) { | ||
$asset_src = elgg_get_simplecache_url('elgg_theme/logo.png'); | ||
} else { | ||
$asset_src = elgg_get_simplecache_url('graphics/logo.png'); | ||
} | ||
|
||
echo elgg_view('output/img', [ | ||
'src' => $asset_src, | ||
'class' => 'elgg-theme-logo__preview mbl', | ||
]); | ||
|
||
echo elgg_view_field([ | ||
'#type' => 'file', | ||
'#label' => elgg_echo('elgg_theme:settings:logo'), | ||
'name' => 'logo', | ||
'accept' => 'image/png', | ||
'#help' => elgg_echo('elgg_theme:settings:logo:help'), | ||
]); | ||
|
||
$footer = elgg_view_field([ | ||
'#type' => 'submit', | ||
'value' => elgg_echo('save'), | ||
]); | ||
|
||
elgg_set_form_footer($footer); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Elgg header logo | ||
*/ | ||
|
||
$text = elgg_get_site_entity()->getDisplayName(); | ||
|
||
$asset_src = false; | ||
|
||
$file_src = elgg_get_data_path() . 'elgg_theme/logo.png'; | ||
|
||
if (file_exists($file_src)) { | ||
$asset_src = elgg_get_simplecache_url('elgg_theme/logo.png'); | ||
|
||
$text = elgg_format_element('img', [ | ||
'src' => $asset_src, | ||
'alt' => elgg_get_site_entity()->getDisplayName(), | ||
]); | ||
} | ||
|
||
if ((bool) elgg_get_plugin_setting('topbar_logo_text', 'elgg_theme')) { | ||
$text = elgg_get_site_entity()->getDisplayName(); | ||
} | ||
|
||
echo elgg_format_element('div', [ | ||
'class' => 'elgg-heading-site elgg-loud' | ||
], elgg_view('output/url', [ | ||
'text' => $text, | ||
'href' => elgg_get_site_entity()->getURL(), | ||
'title' => elgg_get_site_entity()->getDisplayName(), | ||
])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters