Elgg  Version 6.1
icons.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
7 if (get_input('icon_remove')) {
8  $site->deleteIcon();
9  $site->deleteIcon('favicon');
10 } else {
11  $site->saveIconFromUploadedFile('icon');
12  $site->saveIconFromUploadedFile('icon', 'favicon');
13 }
14 
15 $remove_zip = function() {
16  elgg_delete_directory(elgg_get_data_path() . 'fontawesome');
17  elgg_remove_config('font_awesome_zip');
18 
19  // view locations and simplecache need to be updated
21 };
22 
23 $zip = elgg_get_uploaded_file('font_awesome_zip');
24 if (get_input('remove_font_awesome_zip')) {
25  $remove_zip();
26 } elseif ($zip instanceof UploadedFile && extension_loaded('zip')) {
27  $archive = new \ZipArchive();
28  if ($archive->open($zip->getPathname()) !== true) {
29  return elgg_error_response(elgg_echo('admin:site_icons:font_awesome:zip:error'));
30  }
31 
32  // remove existing upload
33  $remove_zip();
34 
35  // extraction could take some time
36  set_time_limit(0);
37 
38  $base_folder = elgg_get_data_path() . 'fontawesome';
39  $archive->extractTo($base_folder);
40 
41  // rename folder for easier mapping in the future
42  foreach (glob($base_folder . '/*', GLOB_ONLYDIR) as $item) {
43  // rename the first folder we find
44  rename($item, $base_folder . '/webfont');
45  break;
46  }
47 
48  elgg_save_config('font_awesome_zip', $zip->getClientOriginalName());
49 }
50 
51 return elgg_ok_response('', elgg_echo('save:success'));
if(!$items) $item
Definition: delete.php:13
elgg_ok_response($content= '', string|array $message= '', string $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
elgg_get_uploaded_file(string $input_name, bool $check_for_validity=true)
Returns a single valid uploaded file object.
Definition: filestore.php:156
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$remove_zip
Definition: icons.php:15
$site
Definition: icons.php:5
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
Definition: item.php:48
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
$zip
Definition: icons.php:23
elgg_invalidate_caches()
Invalidate all the registered caches.
Definition: cache.php:88
elgg_error_response(string|array $message= '', string $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST)
Prepare an error response to be returned by a page or an action handler.
elgg_save_config(string $name, $value)
Save a configuration setting.
elgg_remove_config(string $name)
Removes a config setting.
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:101
elgg_delete_directory(string $directory, bool $leave_base_directory=false)
Delete a directory and all its contents.
Definition: filestore.php:51
elgg_get_data_path()
Get the data directory path for this installation, ending with slash.