skillset_inview-8.x-1.x-dev/skillset_inview.module
skillset_inview.module
<?php
/**
* @file
* Provides a block to show off your Skills! For portfolio sites/pages.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Link;
/**
* Implements hook_contextual_links_view_alter().
*/
function skillset_inview_contextual_links_view_alter(&$element, $items) {
// Remove context link for skillset module, from all other blocks.
// Yes, this seems dumb. TODO: sort out.
if (isset($element['#contextual_links']['block']) && $element['#contextual_links']['block']['route_parameters']['block'] != 'skillsetinview') {
unset($element['#links']['skillset-inviewmanage']);
}
}
/**
* HTML tags allowed.
*/
function _skillset_inview_allowed_tags() {
return [
'abbr',
'q',
'cite',
'em',
'strong',
'big',
'small',
'sub',
'sup',
'u',
'a',
'span',
];
}
/**
* HTML tags allowed.
*/
function _skillset_inview_allowed_tags_description() {
return t('<dl><dt>Allowed HTML </dt><dd><pre>:tags</pre></dd></dl>', [':tags' => skillset_inview_format_tags()]);
}
/**
* Format tags allowed for description on dragtable/add form.
*/
function skillset_inview_format_tags() {
$tags = _skillset_inview_allowed_tags();
$tagged = [];
foreach ($tags as $tag) {
$tagged[] = '<' . $tag . '>';
}
$string = implode(' ', $tagged);
return $string;
}
/**
* Implements hook_theme().
*/
function skillset_inview_theme($existing, $type, $theme, $path) {
return [
'skillset_inview_dl' => [
'variables' => [
'items' => [],
'color_active' => 0,
'color' => [],
],
],
'skillset_inview_meter' => [
'variables' => [
'items' => [],
'color_active' => 0,
'color' => [],
],
],
];
}
/**
* Implements hook_help().
*/
function skillset_inview_help($route_name, RouteMatchInterface $route_match) {
$help = FALSE;
switch ($route_name) {
case 'help.page.skillset_inview':
$controls_link = Link::createFromRoute(t('Skillset Inview Overview'), 'skillset_inview.order');
$help = t('<dl>
<dt>Where to begin:</dt>
<dd>@controls</dd>
<dt>Boostrape Grids<small>*</small></dt>
<dd>Pre-Responsive ready with <a href="http://bootstrapdocs.com/v3.3.4/docs/css/#grid" target="_blank"><cite>Bootstrap</cite> (version 3)</a> classes. Comes with Twig template for overrides as themer may require.
<br><small>*No Bootstrap components are included/add by this module.</small></dd>
<dt>Translation Note</dt>
<dd>"Section Heading" and all "Skills" will be rendered through <code>t()</code> function on Twig template for string translation as use is most likely limited to default site language. You can use <a href="https://www.drupal.org/project/stringoverrides" target="_blank"><cite>stringoverrides</cite></a> to due so…</dd>
<dt>Uses jQuery plugins:</dt>
<dd>
<ul>
<li><a href="https://github.com/protonet/jquery.inview/tree/v1.1.2" target="_blank">jQuery.inview</a></li>
<li><a href="https://github.com/gdsmith/jquery.easing/tree/1.3.2" target="_blank">jQuery.easing</a></li>
<li><a href="https://github.com/mattfarina/farbtastic/tree/2.0.0-alpha.1" target="_blank">jQuery.farbtastic</a></li>
</ul>
</dd>
</dl>', ['@controls' => $controls_link->toString()]);
break;
}
return $help;
}
