blog->settings->noodles; $__noodles = noodles::decode($s->noodles_object); if ($__noodles->isEmpty()) { $__noodles = $__default_noodles; } else { $default_noodles_array = $__default_noodles->noodles(); foreach($default_noodles_array AS $id => $noodle) { if ($__noodles->exists($id)) { continue; } $__noodles->set($id, $noodle); } } $public_path = path::real($core->blog->public_path); if (!is_dir($public_path) || !is_writable($public_path)) { $public_path = false; } $default_images = files::scandir(dirname(__FILE__) . '/default-templates/img/'); if (!is_array($default_images)) { $default_images = []; } $default_image = $s->noodles_image; $combo_place = [ __('Begin') => 'prepend', __('End') => 'append', __('Before') => 'before', __('After') => 'after' ]; $combo_rating = [ 'G' => 'g', 'PG' => 'pg', 'R' => 'r', 'X' => 'x' ]; $combo_size = [ '16px' => 16, '24px' => 24, '32px' => 32, '48px' => 48, '56px' => 56, '64px' => 64, '92px' => 92, '128px' => 128, '256px' => 256 ]; if (!empty($_POST['save'])) { try { $public_file = $public_path . '/noodles-default-image.png'; $s->put('noodles_active', !empty($_POST['noodles_active']), 'boolean'); // user upload image if ($_POST['noodles_image'] == 'user' && !empty($public_path)) { if (2 == $_FILES['noodlesuserfile']['error']) { throw new Exception(__('Maximum file size exceeded')); } if (0 != $_FILES['noodlesuserfile']['error']) { throw new Exception(__('Something went wrong while download file')); } if (!in_array($_FILES['noodlesuserfile']['type'], ['image/png', 'image/x-png'])) { throw new Exception(__('Image must be in png format')); } if (move_uploaded_file($_FILES['noodlesuserfile']['tmp_name'], $public_file)) { $s->put('noodles_image', 1, 'boolean'); } else { throw new Exception(__('Failed to save image')); } // Default gravatar.com avatar } elseif ($_POST['noodles_image'] == 'gravatar.com') { $s->put('noodles_image', 0, 'boolean'); // existsing noodles image on blog } elseif ($_POST['noodles_image'] == 'existing') { $s->put('noodles_image', 1, 'boolean'); // noodles image } elseif (preg_match('/^gravatar-[0-9]+.png$/', $_POST['noodles_image']) && !empty($public_path)) { $source = dirname(__FILE__) . '/default-templates/img/' . $_POST['noodles_image']; if (!file_exists($source)) { throw new Exception(__('Something went wrong while search file')); } if (files::putContent($public_file, file_get_contents($source))) { $s->put('noodles_image', 1, 'boolean'); } // Default gravatar.com avatar } else { //if ($_POST['noodles_image'] == 'gravatar.com') { $s->put('noodles_image', 0, 'boolean'); } // behaviors foreach($_POST['noodle'] as $id => $bloc) { $__noodles->get($id) ->set('active', !empty($bloc['active'])) ->set('rating', $bloc['rating'] ?? 'g') ->set('size', $bloc['size'] ?? '16') ->set('css', $bloc['css'] ?? '') ->set('target', $bloc['target'] ?? '') ->set('place', $bloc['place'] ?? 'prepend') ; } $s->put('noodles_object', $__noodles->encode(), 'string'); $core->blog->triggerBlog(); dcPage::addSuccessNotice(__('Configuration successfully updated')); $core->adminurl->redirect('admin.plugin.noodles'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } echo '