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

View File

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

View File

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