Skip to content

Commit

Permalink
Merge branch 'release/2.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Oct 10, 2017
2 parents bdb6092 + 12077e9 commit afa94f3
Show file tree
Hide file tree
Showing 34 changed files with 1,346 additions and 1,094 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
GLPI Formcreator ChangeLog
===============================

Version 2.6.0
-------------
## Bugfixes
* fix CSS preventing access to entity selection in service catalog (simplified interface)
* fix error if plugin Tag not available but used in a form to display
* various JS fixes

Version 2.6.0 Release Candidate 1
---------------------------------

Expand Down
4 changes: 2 additions & 2 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ public function archiveBuild() {
}

if (!$this->tagExists($version)) {
//throw new Exception("The tag $version does not exists yet");
throw new Exception("The tag $version does not exists yet");
}

if (!$this->isTagMatchesCurrentCommit($version)) {
//throw new Exception("HEAD is not pointing to the tag of the version to build");
throw new Exception("HEAD is not pointing to the tag of the version to build");
}

$versionTag = $this->getVersionTagFromXML($version);
Expand Down
193 changes: 193 additions & 0 deletions RoboFilePlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFilePlugin extends \Robo\Tasks
{

protected $csignore = ['/vendor/', '/node_modules/', '/lib/'];
protected $csfiles = ['./'];

/**
* Minify all
*
* @return void
*/
public function minify() {
$this->minifyCSS()
->minifyJS();
}

/**
* Minify CSS stylesheets
*
* @return void
*/
public function minifyCSS() {
$css_dir = __DIR__ . '/css';
if (is_dir($css_dir)) {
foreach (glob("$css_dir/*.css") as $css_file) {
if (!$this->endsWith($css_file, 'min.css')) {
$this->taskMinify($css_file)
->to(str_replace('.css', '.min.css', $css_file))
->type('css')
->run();
}
}
}
return $this;
}

/**
* Minify JavaScript files stylesheets
*
* @return void
*/
public function minifyJS() {
$js_dir = __DIR__ . '/js';
if (is_dir($js_dir)) {
foreach (glob("$js_dir/*.js") as $js_file) {
if (!$this->endsWith($js_file, 'min.js')) {
$this->taskMinify($js_file)
->to(str_replace('.js', '.min.js', $js_file))
->type('js')
->run();
}
}
}
return $this;
}

/**
* Extract translatable strings
*
* @return void
*/
public function localesExtract() {
$this->_exec('tools/extract_template.sh');
return $this;
}

/**
* Push locales to transifex
*
* @return void
*/
public function localesPush() {
$this->_exec('tx push -s');
return $this;
}

/**
* Pull locales from transifex.
*
* @param integer $percent Completeness percentage
*
* @return void
*/
public function localesPull($percent = 70) {
$this->_exec('tx pull -a --minimum-perc=' .$percent);
return $this;
}

/**
* Build MO files
*
* @return void
*/
public function localesMo() {
$this->_exec('./tools/release --compile-mo');
return $this;
}

/**
* Extract and send locales
*
* @return void
*/
public function localesSend() {
$this->localesExtract()
->localesPush();
return $this;
}

/**
* Retrieve locales and generate mo files
*
* @param integer $percent Completeness percentage
*
* @return void
*/
public function localesGenerate($percent = 70) {
$this->localesPull($percent)
->localesMo();
return $this;
}

/**
* Checks if a string ends with another string
*
* @param string $haystack Full string
* @param string $needle Ends string
*
* @return boolean
* @see http://stackoverflow.com/a/834355
*/
private function endsWith($haystack, $needle) {
$length = strlen($needle);
if ($length == 0) {
return true;
}

return (substr($haystack, -$length) === $needle);
}

/**
* Code sniffer.
*
* Run the PHP Codesniffer on a file or directory.
*
* @param string $file A file or directory to analyze.
* @param array $options Options:
* @option $autofix Whether to run the automatic fixer or not.
* @option $strict Show warnings as well as errors.
* Default is to show only errors.
*
* @return void
*/
public function codeCs(
$file = null,
$options = [
'autofix' => false,
'strict' => false,
]
) {
if ($file === null) {
$file = implode(' ', $this->csfiles);
}

$csignore = '';
if (count($this->csignore)) {
$csignore .= '--ignore=';
$csignore .= implode(',', $this->csignore);
}

$strict = $options['strict'] ? '' : '-n';

$result = $this->taskExec("./vendor/bin/phpcs $csignore --standard=vendor/glpi-project/coding-standard/GlpiStandard/ {$strict} {$file}")->run();

if (!$result->wasSuccessful()) {
if (!$options['autofix'] && !$options['no-interaction']) {
$options['autofix'] = $this->confirm('Would you like to run phpcbf to fix the reported errors?');
}
if ($options['autofix']) {
$result = $this->taskExec("./vendor/bin/phpcbf $csignore --standard=vendor/glpi-project/coding-standard/GlpiStandard/ {$file}")->run();
}
}

return $result;
}

}
1 change: 0 additions & 1 deletion ajax/question.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
$question_id = intval($_REQUEST['question_id']);
$question->getFromDB($question_id);
}
$form_id = (int) $_REQUEST['form_id'];
$question->showForm($question_id);
51 changes: 7 additions & 44 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,8 @@ span.fc_list_icon {
height: 24px;
display: inline-block;
vertical-align: middle;
font-size: 1.7em;
color: #FFFFFF;
}

.plugin_formcreator_entityProfile {
Expand All @@ -1194,8 +1196,6 @@ span.fc_list_icon {
height: 40px;
}
.plugin_formcreator_entityProfile > li {
float: none !important;
display: inline-block;
line-height: normal;
top: 20%;
}
Expand All @@ -1210,31 +1210,6 @@ span.fc_list_icon {
white-space: nowrap;
}

.plugin_formcreator_serviceCatalogIcon span.fc_list_icon {
background: url('../pics/issue.png') left no-repeat;
background-size: contain;
}

.plugin_formcreator_myRequestsIcon span.fc_list_icon {
background: url('../pics/list.png') left no-repeat;
background-size: contain;
}

.plugin_formcreator_reservationsIcon span.fc_list_icon {
background: url('../pics/reservation.png') left no-repeat;
background-size: contain;
}

.plugin_formcreator_feedsIcon span.fc_list_icon {
background: url('../pics/feed.png') left no-repeat;
background-size: contain;
}

.plugin_formcreator_bookmarksIcon span.fc_list_icon {
background: url('../pics/bookmarks.png') left no-repeat;
background-size: contain;
}

.plugin_formcreator_leftMenu .plugin_formcreator_leftMenuItem_separator {
margin-bottom: 0;
}
Expand Down Expand Up @@ -1286,24 +1261,15 @@ span.fc_list_icon {
opacity: 1;
}

#plugin_formcreator_preferences_icon span {
background: url("../../../pics/preferences.png") no-repeat;
#plugin_formcreator_preferences_icon a, #plugin_formcreator_logoutIcon a {
display: inline-block;
width: 18px;
height: 18px;
width: 22px;
}

#plugin_formcreator_preferences_icon a, #plugin_formcreator_logoutIcon a {
color: white;
}

#plugin_formcreator_logoutIcon span {
background: url("../../../pics/logout.png") no-repeat;
display: inline-block;
width: 18px;
height: 18px;
}

#c_menu #myname {
display: inline-block;
color: #FFF;
Expand Down Expand Up @@ -1431,12 +1397,9 @@ span.fc_list_icon {
text-align: left;
}

.profile-selector {
float: none !important;
}

.plugin_formcreator_entityProfile {
width: initial;
#header_top .plugin_formcreator_entityProfile .profile-selector {
max-width: none;
padding: 0 !important;
}

.toggle_menu #c_menu li label {
Expand Down
2 changes: 1 addition & 1 deletion inc/fields.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static function showField($field, $data = null, $edit = true) {
$fieldClass = 'PluginFormcreator'.ucfirst($field['fieldtype']).'Field';

$plugin = new Plugin();
if ($fieldClass == 'tagField' &&(!$plugin->isInstalled('tag') || !$plugin->isActivated('tag'))) {
if ($fieldClass == 'PluginFormcreatorTagField' && !$plugin->isActivated('tag')) {
return;
}

Expand Down
10 changes: 5 additions & 5 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,7 @@ public function showForm($ID, $options=[]) {
echo '</select>';
echo '</div>';

echo '<script type="text/javascript">
function changeValidators(value) {
$script = 'function changeValidators(value) {
if (value == 1) {
document.getElementById("validators_users").style.display = "block";
document.getElementById("validators_groups").style.display = "none";
Expand All @@ -454,8 +453,9 @@ function changeValidators(value) {
}
fcInitMultiSelect();
}
changeValidators(' . $this->fields["validation_required"] . ');
</script>';
$(document).ready(function() {changeValidators(' . $this->fields["validation_required"] . ');});';
echo Html::scriptBlock($script);

echo '</td>';
echo '</tr>';

Expand Down Expand Up @@ -868,7 +868,7 @@ public function displayUserForm(CommonGLPI $item) {
}

// Print css media
echo Html::css(FORMCREATOR_ROOTDOC."/css/print_form.css", ['media' => 'print']);
echo Html::css("plugins/formcreator/css/print_form.css", ['media' => 'print']);

// Display form
echo "<form name='formcreator_form'".$item->getID()."' method='post' role='form' enctype='multipart/form-data'
Expand Down
8 changes: 7 additions & 1 deletion inc/form_answer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,13 @@ public function defineTabs($options = []) {
*/
public function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
if ($item instanceof PluginFormcreatorForm) {
$number = count($this->find("`".self::$items_id."` = ".$item->getID()));
$dbUtils = new DbUtils();
$number = $dbUtils->countElementsInTableForMyEntities(
static::getTable(),
[
self::$items_id => $item->getID()
]
);
return self::createTabEntry(self::getTypeName($number), $number);
} else {
return $this->getTypeName();
Expand Down
Loading

0 comments on commit afa94f3

Please sign in to comment.