Skip to content

Commit

Permalink
Merge pull request #105 from Extendy/local-mshannaq-work
Browse files Browse the repository at this point in the history
refactor: small fixes
  • Loading branch information
mshannaq authored Dec 8, 2023
2 parents f1197ab + d7a18b3 commit 1e45bec
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/Config/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Email extends BaseConfig
/**
* The "user agent"
*/
public string $userAgent = 'SmartyURL/Dev';
public string $userAgent = 'SmartyURL';

/**
* The mail sending protocol: mail, sendmail, smtp
Expand Down
4 changes: 2 additions & 2 deletions app/Controllers/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public function listData()
if (auth()->user()->can('admin.manageotherurls', 'super.admin')) {
// he is manager so i must let him know the url owner
$url_owner_id = smarty_get_user_username($result->url_user_id);
$url_owner = "<div class='mt-1'>" . lang('Url.UrlOwner') . ": {$url_owner_id}</div>";
$url_owner = "<div class='mt-1'>" . lang('Url.UrlOwner') . ": <a class='link-dark' href='" . site_url("url/user/{$result->url_user_id}") . "'> {$url_owner_id}</a></div>";
} else {
$url_owner = '';
}
Expand All @@ -289,7 +289,7 @@ public function listData()
<a title='" . lang('Url.UpdateUrlSubmitbtn') . "' href='" . site_url("url/edit/{$result->url_id}") . "' class='link-dark edit-link'><i class='bi bi-pencil edit-link-btn'></i></a>
<i title='" . lang('Url.CopyURL') . "' class='bi bi-clipboard copy-button' data-content='{$Go_Url}' data-target='link2'></i> ",
'url_title_col' => " {$urlTitle}
<a target='_blank' title='" . lang('Url.visitOriginalUrl') . ' ' . $result->url_targeturl . "' href='{$result->url_targeturl}' class='link-dark edit-link'><i class='bi bi-box-arrow-up-right'></i></a>
<a target='_blank' title='" . lang('Url.visitOriginalUrl') . ' ' . create_nice_url_for_show($result->url_targeturl) . "' href='{$result->url_targeturl}' class='link-dark edit-link'><i class='bi bi-box-arrow-up-right'></i></a>
",
'url_hits_col' => "<a class='text-secondary' href='" . site_url("url/hits/{$result->url_id}") . "'>" . $result->url_hitscounter . '</a>',
'url_id' => $result->url_id,
Expand Down
21 changes: 21 additions & 0 deletions app/Helpers/smarty_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,24 @@ function smarty_svg_error($text)
</svg>';
}
}

if (! function_exists('create_nice_url_for_show')) {
/**
* Create a nice URL to show on screen and not for real use on visits
*
* @return mixed|string
*/
function create_nice_url_for_show($original_url, $max_length = 50)
{
// Check if the original URL is longer than the specified maximum length
if (mb_strlen($original_url, 'UTF-8') > $max_length) {
// Trim the URL to the maximum length and add "..." at the end
$nice_url = mb_substr($original_url, 0, $max_length - 3, 'UTF-8') . '...';
} else {
// If the URL is within the maximum length, use the original URL
$nice_url = $original_url;
}

return $nice_url;
}
}
14 changes: 8 additions & 6 deletions app/Views/basic/url/urlinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ class='bi bi-pencil edit-link-btn'></i></a>


<div class="mb-2">
<?= lang('Url.OriginalUrl'); ?>: <?= urldecode($url_targeturl); ?>
<?= lang('Url.OriginalUrl'); ?>:
<div><span><?= urldecode($url_targeturl); ?></span>
<a data-bs-toggle="tooltip" data-bs-placement="top" target='_blank'
title='<?= lang('Url.visitOriginalUrl') . ' ' . $url_targeturl; ?>'
href='<?= $url_targeturl; ?>' class='link-dark edit-link'><i
title='<?= lang('Url.visitOriginalUrl') . ' ' . create_nice_url_for_show($url_targeturl); ?>'
href='<?= $url_targeturl; ?>' class='link-primary edit-link'><i
class='bi bi-box-arrow-up-right'></i></a>
</div>
</div>


Expand Down Expand Up @@ -231,9 +233,9 @@ class='bi bi-pencil edit-link-btn'></i></a>
<?= esc($link); ?>
<a data-bs-toggle="tooltip" data-bs-placement="top"
target='_blank'
title='<?= lang('Url.visitOriginalUrl'); ?>'
title='<?= lang('Url.visitOriginalUrl') . ' ' . create_nice_url_for_show($link); ?>'
href='<?= $link ?>'
class='link-dark edit-link'><i
class='link-primary edit-link'><i
class='bi bi-box-arrow-up-right'></i></a>
</td>
</tr>
Expand Down Expand Up @@ -301,7 +303,7 @@ class="btn btn-sm btn-outline-dark"><?= lang('Url.urlInfoSeeAllHits'); ?></a>
target='_blank'
title='<?= lang('Url.visitOriginalUrl'); ?>'
href='<?= $hit->urlhit_finaltarget; ?>'
class='link-dark edit-link'><i
class='link-primary edit-link'><i
class='bi bi-box-arrow-up-right'></i></a>

</td>
Expand Down
2 changes: 1 addition & 1 deletion env
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ smartyurl.urltags_shared_between_users = true
email.string $protocol = 'mail';

#choose the default sender mail
email.fromEmail = noreplay@example.com
email.fromEmail = 'noreplay@example.com'

#choose the default sender name
email.fromName = 'SmartyURL'
Expand Down

0 comments on commit 1e45bec

Please sign in to comment.