<?php namespace phpList\plugin\Common; /** * Get a config value then split it into lines. * * @param string $item * * @return array */ function getConfigLines($item) { return splitIntoLines(getConfig($item)); } /** * Split a string into lines allowing for any line-ending. * * @param string $string * * @return array */ function splitIntoLines($value) { $lines = []; if ($value !== '') { foreach (preg_split('|\R+|', $value) as $line) { $line = trim($line); if ($line !== '') { $lines[] = $line; } } } return $lines; } /* * shortenText * * Shorten text for use by shortenTextDisplay() but also stand-alone. * * Define multibyte-string aware/unaware function depending on whether the mbstring extension is available * see https://github.com/phpList/phplist3/pull/10 */ if (!function_exists('mb_strlen')) { // mbstring unavailable function shortenText($text, $max = 30) { if (strlen($text) > $max) { if ($max < 30) { $shortened = substr($text, 0, $max - 4).' ... '; } else { $shortened = substr($text, 0, 20).' ... '.substr($text, -10); } } else { $shortened = $text; } return $shortened; } } else { // mbstring available function shortenText($text, $max = 30) { if (mb_strlen($text) > $max) { if ($max < 30) { $shortened = mb_substr($text, 0, $max - 4).' ... '; } else { $shortened = mb_substr($text, 0, 20).' ... '.mb_substr($text, -10); } } else { $shortened = $text; } return $shortened; } } /* * shortenTextDisplay * * mostly used for columns in listings to retrict the width, particularly on mobile devices * it will show the full text as the title tip but restrict the size of the output * * will also place a space after / and @ to facilitate wrapping in the browser * */ function shortenTextDisplay($text, $max = 30) { $display = preg_replace('!^https?://!i', '', $text); $display = shortenText($display, $max); $display = str_replace('/', '/​', $display); $display = str_replace('@', '@​', $display); return sprintf('<span title="%s">%s</span>', htmlspecialchars($text), $display); } /* * Log a message when the logging threshold is DEBUG. * * @param message $string * * @return array */ function debug($message) { global $log_options, $tmpdir; static $logger; if (($log_options['threshold'] ?? '') != 'DEBUG') { return; } if ($logger === null) { $dir = $log_options['dir'] ?? $tmpdir; $logger = new \Katzgrau\KLogger\Logger($dir, \Psr\Log\LogLevel::DEBUG); $logger->setDateFormat('H:i:s'); } $logger->debug($message); } /* * Construct the base URL for a public page, without trailing /. * * @return string */ function publicBaseUrl() { global $public_scheme, $pageroot; static $url = null; if ($url === null) { if (defined('USER_WWWROOT')) { $url = USER_WWWROOT; } else { $url = sprintf('%s://%s%s', $public_scheme, getConfig('website'), $pageroot); } } return $url; } /* * Construct a public URL. * * @param string $page optional page * @param array $params query parameters * * @return string */ function publicUrl(...$args) { $page = ''; $params = []; if (count($args) == 2) { $page = $args[0]; $params = $args[1]; } elseif (count($args) == 1) { $params = $args[0]; } $url = sprintf('%s/%s?%s', publicBaseUrl(), $page, http_build_query($params)); return $url; } /* * Construct the base URL for an admin page, without trailing /. * * @return string */ function adminBaseUrl() { global $admin_scheme, $pageroot; static $url = null; if ($url === null) { $url = sprintf('%s://%s%s/admin', $admin_scheme, getConfig('website'), $pageroot); } return $url; }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
DAO | Folder | 0755 |
|
|
images | Folder | 0755 |
|
|
lan | Folder | 0755 |
|
|
ui | Folder | 0755 |
|
|
vendor | Folder | 0755 |
|
|
Autoloader.php | File | 1.5 KB | 0644 |
|
BaseController.php | File | 503 B | 0644 |
|
Config.php | File | 394 B | 0644 |
|
Controller.php | File | 355 B | 0644 |
|
ControllerFactory.php | File | 488 B | 0644 |
|
ControllerFactoryBase.php | File | 490 B | 0644 |
|
DAO.php | File | 360 B | 0644 |
|
DB.php | File | 412 B | 0644 |
|
DBResultIterator.php | File | 432 B | 0644 |
|
Exception.php | File | 432 B | 0644 |
|
ExportCSV.php | File | 401 B | 0644 |
|
ExportXML.php | File | 401 B | 0644 |
|
HelpManager.php | File | 405 B | 0644 |
|
HtmlToPdf.php | File | 424 B | 0644 |
|
I18N.php | File | 641 B | 0644 |
|
IExportable.php | File | 428 B | 0644 |
|
IPopulator.php | File | 440 B | 0644 |
|
ImageTag.php | File | 456 B | 0644 |
|
Listing.php | File | 410 B | 0644 |
|
Logger.php | File | 513 B | 0644 |
|
Main.php | File | 414 B | 0644 |
|
Model.php | File | 425 B | 0644 |
|
PageLink.php | File | 412 B | 0644 |
|
PageURL.php | File | 433 B | 0644 |
|
Pager.php | File | 391 B | 0644 |
|
Populator.php | File | 443 B | 0644 |
|
StringStream.php | File | 608 B | 0644 |
|
Tabs.php | File | 388 B | 0644 |
|
Toolbar.php | File | 392 B | 0644 |
|
WebblerListing.php | File | 429 B | 0644 |
|
Widget.php | File | 398 B | 0644 |
|
class_map.php | File | 7.58 KB | 0644 |
|
config_file.php | File | 1.14 KB | 0644 |
|
dialog_js.php | File | 267 B | 0644 |
|
functions.php | File | 4.04 KB | 0644 |
|
image.php | File | 496 B | 0644 |
|
licence.txt | File | 1.72 KB | 0644 |
|
phpinfo.php | File | 2.1 KB | 0644 |
|
polyfill.php | File | 206 B | 0644 |
|
session.php | File | 549 B | 0644 |
|
version.txt | File | 15 B | 0644 |
|