filealias; $aliases = $o->getAliases(); $media = new dcMedia(); $a = new aliasMedia(); $part = $_REQUEST['part'] ?? 'list'; # Update aliases if (isset($_POST['a']) && is_array($_POST['a'])) { try { $o->updateAliases($_POST['a']); dcAdminNotices::addSuccessNotice(__('Aliases successfully updated.')); dcCore::app()->adminurl->redirect('admin.plugin.filesAlias'); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } } # New alias if (isset($_POST['filesalias_url'])) { $url = empty($_POST['filesalias_url']) ? PallazzoTools::rand_uniqid() : $_POST['filesalias_url']; $target = $_POST['filesalias_destination']; $totrash = isset($_POST['filesalias_disposable']) ? true : false; $password = empty($_POST['filesalias_password']) ? '' : $_POST['filesalias_password']; if (preg_match('/^' . preg_quote($media->root_url, '/') . '/', $target)) { $target = preg_replace('/^' . preg_quote($media->root_url, '/') . '/', '', $target); $found = $a->getMediaId($target); if (!empty($found)) { try { $o->createAlias($url, $target, $totrash, $password); dcAdminNotices::addSuccessNotice(__('Alias for this media created.')); dcCore::app()->adminurl->redirect('admin.plugin.filesAlias'); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } } else { dcCore::app()->error->add(__('Target is not in media manager.')); } } else { $found = $a->getMediaId($target); if (!empty($found)) { try { $o->createAlias($url, $target, $totrash, $password); dcAdminNotices::addSuccessNotice(__('Alias for this media modified.')); dcCore::app()->adminurl->redirect('admin.plugin.filesAlias'); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } } else { dcCore::app()->error->add(__('Target is not in media manager.')); } } } ?> <?php echo __('Media sharing'); ?> blog->name) => '', __('Media sharing') => dcCore::app()->adminurl->get('admin.plugin.filesAlias'), __('New alias') => '', ]) . dcPage::notices() . '
' . '

' . __('New alias') . '

' . '

' . form::field('filesalias_destination', 70, 255) . '

' . '

' . __('Destination file must be in media manager.') . '

' . '

' . form::field('filesalias_url', 70, 255) . '

' . '

' . __('Leave empty to get a randomize alias.') . '

' . '

' . form::field('filesalias_password', 70, 255) . '

' . '

' . form::checkbox('filesalias_disposable', 1) . '

' . '

' . dcCore::app()->formNonce() . form::hidden('part', 'new') . '

' . '

' . sprintf(__('Do not put blog media URL "%s" in fields or it will be removed.'), $media->root_url) . '

' . '
'; } else { echo dcPage::breadcrumb([ html::escapeHTML(dcCore::app()->blog->name) => '', __('Media sharing') => '', ]) . dcPage::notices() . '

' . __('New alias') . '

'; if (empty($aliases)) { echo '

' . __('No alias') . '

'; } else { echo '
' . '
' . '' . '' . '' . '' . '' . '' . '' . ''; foreach ($aliases as $k => $v) { $url = dcCore::app()->blog->url . dcCore::app()->url->getBase('filesalias') . '/' . html::escapeHTML($v['filesalias_url']); $link = '' . __('link') . ''; $v['filesalias_disposable'] ??= false; echo '' . '' . '' . '' . '' . ''; } echo '
' . __('Aliases list') . '
' . __('Destination') . ' - ' . html::escapeHTML($media->root_url) . '(-?-)' . __('Alias') . ' - ' . dcCore::app()->blog->url . dcCore::app()->url->getBase('filesalias') . '/' . '(-?-)' . __('Disposable') . '' . __('Password') . '
' . form::field(['a[' . $k . '][filesalias_destination]'], 40, 255, html::escapeHTML($v['filesalias_destination'])) . '' . form::field(['a[' . $k . '][filesalias_url]'], 20, 255, html::escapeHTML($v['filesalias_url'])) . '' . __('link') . '' . form::checkbox(['a[' . $k . '][filesalias_disposable]'], 1, $v['filesalias_disposable']) . '' . form::field(['a[' . $k . '][filesalias_password]'], 10, 255, html::escapeHTML($v['filesalias_password'])) . '
' . '

' . __('To remove a link, empty its alias or destination.') . '

' . '

' . dcCore::app()->formNonce() . form::hidden('part', 'list') . '

' . '
'; } } dcPage::helpBlock('filesAlias'); ?>