fix widgets style

master
Jean-Christian Paul Denis 2021-08-28 20:39:58 +02:00
parent 9607d9d86d
commit 2d5d611e56
4 changed files with 299 additions and 267 deletions

View File

@ -1,96 +1,96 @@
todo todo
- Added public page of the list of know urls and in/visible status - Added public page of the list of know urls and in/visible status
- Added passworded links - Added passworded links
- fix widgets rendering
- move setting to config file
- fix dashboard rendering
- fix deprecated external service - fix deprecated external service
2021.08.27 2021.08.28
- add dashboard icon - add dashboard icon
- clean PSR-2 codding style and short array - clean PSR-2 codding style and short array
- fix php 7.3+ and php 8.0.x compatibility - fix php 7.3+ and php 8.0.x compatibility
- fix compatibility with Dotclear 2.19 - fix compatibility with Dotclear 2.19
- create readme file - create readme file
- merge index file sub parts
- remove custom js
- fix widgets rendering
2011.04.01 2011.04.01
* Changed version numbering - Changed version numbering
* Added service su.pr (stumbleUpon) - Added service su.pr (stumbleUpon)
* Fixed wiki settings (thanks @ploum ) - Fixed wiki settings (thanks @ploum )
1.0 20110213 1.0 - 2011.02.13
* Added generic class to easlily access services - Added generic class to easlily access services
* Changed generic service class (and class extend it) - Changed generic service class (and class extend it)
* Fixed config of default service - Fixed config of default service
* Fixed display of admin fake section - Fixed display of admin fake section
* Added checkbox helpers on admin - Added checkbox helpers on admin
0.6.1 20110130 0.6.1 - 2011.01.30
* Cleaned up script - Cleaned up script
0.6 20110118 'prepare the soCial révolution' 0.6 - 2011.01.18
* Added default defined service (for all blogs of a multiblog) - Added default defined service (for all blogs of a multiblog)
* Added configurable external service - Added configurable external service
* Added goog.gl client service (first step) - Added goog.gl client service (first step)
* Added default settings for third part plugins - Added default settings for third part plugins
* Added behaviors after short link creation - Added behaviors after short link creation
* Added attribute to disable URL shortining on template tag with 'active mode' (fixed bug on URL of POST form) - Added attribute to disable URL shortining on template tag with 'active mode' (fixed bug on URL of POST form)
* Remove all messenger functions: this is to another plugin to do that - Remove all messenger functions: this is to another plugin to do that
* Remove priority in plugin definition - Remove priority in plugin definition
0.5 20100909 0.5 - 2010.09.09
* Removed old Twitter functions - Removed old Twitter functions
* Added StatusNet small functions (Identica) - Added StatusNet small functions (Identica)
* Required plugin Tac for Twitter ability - Required plugin Tac for Twitter ability
* Added YOURLS client service - Added YOURLS client service
0.4.2 20100809 0.4.2 - 2010.08.09
* Fixed bug on dcTwitter shorten service - Fixed bug on dcTwitter shorten service
* Fixed bug on custom local link - Fixed bug on custom local link
* Added category URL to active mode - Added category URL to active mode
* Added priority to plugin definition - Added priority to plugin definition
0.4.1 20100701 0.4.1 - 2010.07.01
* Fixed multiple bugs - Fixed multiple bugs
0.4 20100628 0.4 - 2010.06.28
* Switched to DC 2.2 - Switched to DC 2.2
* Fixed no short urls on preview mode - Fixed no short urls on preview mode
* Fixed lock hash of deleted urls - Fixed lock hash of deleted urls
* Fixed hide new short url widget on kutrl pages - Fixed hide new short url widget on kutrl pages
* Fixed typo - Fixed typo
* Added active mode that shorten urls on default template values - Added active mode that shorten urls on default template values
* Added special tweeter message for post (can include post title) - Added special tweeter message for post (can include post title)
* Added kutrl special 404 page - Added kutrl special 404 page
0.3.3 20100528 0.3.3 - 2010.05.28
* Fixed settings in tweeter class - Fixed settings in tweeter class
* Renamed tweeter class - Renamed tweeter class
0.3.2 20100525 0.3.2 - 2010.05.25
* FIxed minor bugs - FIxed minor bugs
* Fixed DC 2.1.7 - Fixed DC 2.1.7
0.3 20100414 0.3 2010.04.14
* Added DC 2.2 compatibility (new settings) - Added DC 2.2 compatibility (new settings)
* Added semi-custom hash on kUtRL service - Added semi-custom hash on kUtRL service
* Added status update for Twitter/Identi.ca on new short link - Added status update for Twitter/Identi.ca on new short link
* Added services error management (first step) - Added services error management (first step)
* Added options to widgets - Added options to widgets
* Upgraded bitly service to v3 - Upgraded bitly service to v3
* Changed admin design - Changed admin design
0.2 20091223 0.2 - 2009.12.23
* Fixed public redirection with suffix - Fixed public redirection with suffix
* Added short.to service - Added short.to service
0.1.2 20091212 0.1.2 - 2009.12.12
* Added option to short url of new entry by default - Added option to short url of new entry by default
* Fixed typo - Fixed typo
0.1.1 20091212 0.1.1 - 2009.12.12
* Added option to display long url when unactive - Added option to display long url when unactive
* Fixed support of kutrl in feeds - Fixed support of kutrl in feeds
0.1 20091209 0.1 - 2009.12.09
* First lab release - First lab release

View File

@ -19,7 +19,7 @@ $this->registerModule(
'kUtRL', 'kUtRL',
'Use, create and serve short url on your blog', 'Use, create and serve short url on your blog',
'Jean-Christian Denis and contributors', 'Jean-Christian Denis and contributors',
'2021.08.27', '2021.08.28',
[ [
'permissions' => 'admin', 'permissions' => 'admin',
'type' => 'plugin', 'type' => 'plugin',

View File

@ -11,74 +11,105 @@
# #
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')){return;} if (!defined('DC_RC_PATH')) {
return null;
}
$core->addBehavior('initWidgets',array('widgetKutrl','adminShorten')); $core->addBehavior('initWidgets', ['widgetKutrl', 'adminShorten']);
$core->addBehavior('initWidgets',array('widgetKutrl','adminRank')); $core->addBehavior('initWidgets', ['widgetKutrl', 'adminRank']);
class widgetKutrl class widgetKutrl
{ {
public static function adminShorten($w) public static function adminShorten($w)
{ {
$w->create('shortenkutrl',__('Links shortener'), $w
array('widgetKutrl','publicShorten') ->create(
); 'shortenkutrl',
$w->shortenkutrl->setting('title', __('Links shortener'),
__('Title:'),__('Shorten link'),'text' ['widgetKutrl', 'publicShorten']
); )
$w->shortenkutrl->setting('homeonly', ->addTitle(__('Shorten link'))
__('Home page only'),1,'check' ->addHomeOnly()
); ->addContentOnly()
->addClass()
->addOffline();
} }
public static function adminRank($w) public static function adminRank($w)
{ {
$w->create('rankkutrl',__('Top of short links'), $w
array('widgetKutrl','publicRank') ->create(
); 'rankkutrl',
$w->rankkutrl->setting('title', __('Top of short links'),
__('Title:'),__('Top of short links'),'text' ['widgetKutrl', 'publicRank']
); )
$w->rankkutrl->setting('text', ->addTitle(__('Top of short links'))
__('Text: (Use wildcard %rank%, %hash%, %url%, %count%, %counttext%)'),'%rank% - %url% - %counttext%','text' ->setting(
); 'text',
$w->rankkutrl->setting('urllen', __('Text: (Use wildcard %rank%, %hash%, %url%, %count%, %counttext%)'),
__('URL length (if truncate)'),20,'text' '%rank% - %url% - %counttext%',
); 'text'
$w->rankkutrl->setting('type', )
__('Type:'),'all','combo',array( ->setting(
'urllen',
__('URL length (if truncate)'),
20,
'text'
)
->setting(
'type',
__('Type:'),
'all',
'combo',[
__('All') => '-', __('All') => '-',
__('Mini URL') => 'localnormal', __('Mini URL') => 'localnormal',
__('Custom URL') => 'localcustom', __('Custom URL') => 'localcustom',
__('Semi-custom') => 'localmix' __('Semi-custom') => 'localmix'
]
) )
); ->setting(
$w->rankkutrl->setting('mixprefix', 'mixprefix',
__('Semi-custom prefix: (only if you want limit to a particular prefix)'), __('Semi-custom prefix: (only if you want limit to a particular prefix)'),
'','text' '',
); 'text'
$w->rankkutrl->setting('sortby', )
__('Sort by:'),'kut_counter','combo',array( ->setting(
'sortby',
__('Sort by:'),
'kut_counter',
'combo',
[
__('Date') => 'kut_dt', __('Date') => 'kut_dt',
__('Rank') => 'kut_counter', __('Rank') => 'kut_counter',
__('Hash') => 'kut_hash' __('Hash') => 'kut_hash'
]
) )
); ->setting(
$w->rankkutrl->setting('sort', 'sort',
__('Sort:'),'desc','combo',array( __('Sort:'),
'desc',
'combo',
[
__('Ascending') => 'asc', __('Ascending') => 'asc',
__('Descending') => 'desc' __('Descending') => 'desc'
]
) )
); ->setting(
$w->rankkutrl->setting('limit', 'limit',
__('Limit:'),'10','text' __('Limit:'),
); '10',
$w->rankkutrl->setting('hideempty', 'text'
__('Hide no followed links'),0,'check' )
); ->setting(
$w->rankkutrl->setting('homeonly', 'hideempty',
__('Home page only'),1,'check' __('Hide no followed links'),
); 0,
'check'
)
->addHomeOnly()
->addContentOnly()
->addClass()
->addOffline();
} }
public static function publicShorten($w) public static function publicShorten($w)
@ -88,31 +119,35 @@ class widgetKutrl
if (!$s->kutrl_active if (!$s->kutrl_active
|| !$s->kutrl_srv_local_public || !$s->kutrl_srv_local_public
|| $w->homeonly && $core->url->type != 'default' || ($w->homeonly == 1 && !$core->url->isHome($core->url->type)) || ($w->homeonly == 2 && $core->url->isHome($core->url->type))
|| $core->url->type == 'kutrl') return; || $core->url->type == 'kutrl') {
return null;
}
$hmf = hmfKutrl::create(); $hmf = hmfKutrl::create();
$hmfp = hmfKutrl::protect($hmf); $hmfp = hmfKutrl::protect($hmf);
return return $w->renderDiv(
'<div class="shortenkutrlwidget">'. $w->content_only,
($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 'shortenkutrlwidget ' . $w->class,
'<form name="shortenkutrlwidget" method="post" action="'. '',
$core->blog->url.$core->url->getBase('kutrl').'">'. ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
'<p><label>'. '<form name="shortenkutrlwidget" method="post" action="' .
__('Long link:').'<br />'. $core->blog->url . $core->url->getBase('kutrl') . '">' .
form::field('longurl',20,255,''). '<p><label>' .
'</label></p>'. __('Long link:') . '<br />' .
'<p><label>'. form::field('longurl', 20, 255, '') .
sprintf(__('Rewrite "%s" in next field to show that you are not a robot:'),$hmf).'<br />'. '</label></p>' .
form::field('hmf',20,255,''). '<p><label>' .
'</label></p>'. sprintf(__('Rewrite "%s" in next field to show that you are not a robot:'), $hmf) . '<br />' .
'<p><input class="submit" type="submit" name="submiturl" value="'.__('Create').'" />'. form::field('hmf',20,255,'') .
form::hidden('hmfp',$hmfp). '</label></p>' .
$core->formNonce(). '<p><input class="submit" type="submit" name="submiturl" value="' . __('Create') . '" />' .
'</p>'. form::hidden('hmfp',$hmfp) .
'</form>'. $core->formNonce() .
'</div>'; '</p>' .
'</form>'
);
} }
public static function publicRank($w) public static function publicRank($w)
@ -121,92 +156,89 @@ class widgetKutrl
$s = $core->blog->settings->kUtRL; $s = $core->blog->settings->kUtRL;
if (!$s->kutrl_active if (!$s->kutrl_active
|| $w->homeonly && $core->url->type != 'default') return; || ($w->homeonly == 1 && !$core->url->isHome($core->url->type)) || ($w->homeonly == 2 && $core->url->isHome($core->url->type))) {
return null;
}
$type = in_array($w->type,array('localnormal','localmix','localcustom')) ? $type = in_array($w->type, ['localnormal', 'localmix', 'localcustom']) ?
"AND kut_type ='".$w->type."' " : "AND kut_type ='" . $w->type . "' " :
"AND kut_type ".$core->con->in(array('localnormal','localmix','localcustom'))." "; "AND kut_type " . $core->con->in(['localnormal', 'localmix', 'localcustom']) . " ";
$hide = (boolean) $w->hideempty ? 'AND kut_counter > 0 ' : ''; $hide = (boolean) $w->hideempty ? 'AND kut_counter > 0 ' : '';
$more = ''; $more = '';
if ($w->type == 'localmix' && '' != $w->mixprefix) if ($w->type == 'localmix' && '' != $w->mixprefix) {
{ $more = "AND kut_hash LIKE '" . $core->con->escape($w->mixprefix) . "%' ";
$more = "AND kut_hash LIKE '".$core->con->escape($w->mixprefix)."%' ";
} }
$order = ($w->sortby && in_array($w->sortby,array('kut_dt','kut_counter','kut_hash'))) ? $order = ($w->sortby && in_array($w->sortby, ['kut_dt', 'kut_counter', 'kut_hash'])) ?
$w->sortby.' ' : 'kut_dt '; $w->sortby : 'kut_dt';
$order .= $w->sort == 'desc' ? 'DESC' : 'ASC'; $order .= $w->sort == 'desc' ? ' DESC' : ' ASC';
$limit = $core->con->limit(abs((integer) $w->limit)); $limit = $core->con->limit(abs((integer) $w->limit));
$rs = $core->con->select( $rs = $core->con->select(
'SELECT kut_counter, kut_hash '. 'SELECT kut_counter, kut_hash ' .
"FROM ".$core->prefix."kutrl ". "FROM " . $core->prefix . "kutrl " .
"WHERE blog_id='".$core->con->escape($core->blog->id)."' ". "WHERE blog_id='" . $core->con->escape($core->blog->id) . "' " .
"AND kut_service = 'local' ". "AND kut_service = 'local' " .
$type.$hide.$more.'ORDER BY '.$order.$limit $type . $hide . $more . 'ORDER BY ' . $order . $limit
); );
if ($rs->isEmpty()) return; if ($rs->isEmpty()) {
return null;
}
$content = ''; $content = '';
$i = 0; $i = 0;
while($rs->fetch()) {
while($rs->fetch())
{
$i++; $i++;
$rank = '<span class="rankkutrl-rank">'.$i.'</span>'; $rank = '<span class="rankkutrl-rank">' . $i . '</span>';
$hash = $rs->kut_hash; $hash = $rs->kut_hash;
$url = $core->blog->url.$core->url->getBase('kutrl').'/'.$hash; $url = $core->blog->url . $core->url->getBase('kutrl') . '/' . $hash;
$cut_len = - abs((integer) $w->urllen); $cut_len = - abs((integer) $w->urllen);
if (strlen($url) > $cut_len) if (strlen($url) > $cut_len) {
{ $url = '...' . substr($url, $cut_len);
$url = '...'.substr($url,$cut_len);
} }
/* /*
if (strlen($hash) > $cut_len) if (strlen($hash) > $cut_len) {
{ $url = '...'.substr($hash, $cut_len);
$url = '...'.substr($hash,$cut_len);
} }
//*/ //*/
if ($rs->kut_counter == 0) if ($rs->kut_counter == 0) {
{
$counttext = __('never followed'); $counttext = __('never followed');
} } elseif ($rs->kut_counter == 1) {
elseif ($rs->kut_counter == 1)
{
$counttext = __('followed one time'); $counttext = __('followed one time');
} } else {
else $counttext = sprintf(__('followed %s times'), $rs->kut_counter);
{
$counttext = sprintf(__('followed %s times'),$rs->kut_counter);
} }
$content .= $content .=
'<li><a href="'. '<li><a href="' .
$core->blog->url.$core->url->getBase('kutrl').'/'.$rs->kut_hash. $core->blog->url . $core->url->getBase('kutrl') . '/' . $rs->kut_hash .
'">'. '">' .
str_replace( str_replace(
array('%rank%','%hash%','%url%','%count%','%counttext%'), ['%rank%', '%hash%', '%url%', '%count%', '%counttext%'],
array($rank,$hash,$url,$rs->kut_counter,$counttext), [$rank, $hash, $url, $rs->kut_counter, $counttext],
$w->text $w->text
). ) .
'</a></li>'; '</a></li>';
} }
if (!$content) return; if (empty($content)) {
return null;
}
return $w->renderDiv(
$w->content_only,
'lastblogupdate ' . $w->class,
'',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
sprintf('<ul>%s</ul>', $content)
);
return
'<div class="rankkutrlwidget">'.
($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : '').
'<ul>'.$content.'</ul>'.
'</div>';
} }
} }
?>

View File

@ -411,7 +411,7 @@ if ($part == 'service') {
dcPage::notices() . dcPage::notices() .
'<h3>' . __('Services configuration') . '</h3>' . '<h3>' . __('Services configuration') . '</h3>' .
'<p><a class="back" href="' . $p_url . '">' . __('Back to links list') . '</a></p>'; '<p><a class="back" href="' . $p_url . '">' . __('Back to links list') . '</a></p>' .
'<form id="service-form" method="post" action="' . $p_url . '">'; '<form id="service-form" method="post" action="' . $p_url . '">';
foreach(kutrl::getServices($core) as $service_id => $service) { foreach(kutrl::getServices($core) as $service_id => $service) {
@ -429,7 +429,7 @@ if ($part == 'service') {
echo $o->error->toHTML(); echo $o->error->toHTML();
//} //}
} }
if (!empty($o->home)) { if ($o->home != '') {
echo '<p><a title="' . __('homepage') . '" href="' . $o->home . '">' . sprintf(__('Learn more about %s.'), $o->name) . '</a></p>'; echo '<p><a title="' . __('homepage') . '" href="' . $o->home . '">' . sprintf(__('Learn more about %s.'), $o->name) . '</a></p>';
} }
$o->settingsForm(); $o->settingsForm();