Verified Commit ff2550f5 authored by Hendrik Rombach's avatar Hendrik Rombach
Browse files

Merge branch '2.4' into 3.1

parents 89c4487f c6631df3
PLUGIN_NAME="NetiToolKit"
#EXCLUDES=( "exclude dir" "exclude file" )
#PLUGINS_BUILD=( "npm-install" "npm-build" )
#PLUGINS_DIST=( "detect-license-check" )
#NPM_INSTALL=( "npm app dir" )
#NPM_BUILD=( "npm app dir" )
\ No newline at end of file
/.gtm/
/.build/plugins
build:
nodes:
analysis:
dependencies:
before:
- git clone ssh://git@gitlab.netinventors.de:2202/shopware/plugins/NetiFoundation.git
environment:
php:
version: 5.6.16
filter:
dependency_paths:
- "NetiFoundation/*"
checks:
php:
code_rating: true
duplication: true
\ No newline at end of file
preset: psr2
risky: false
enabled:
- align_double_arrow # Align double arrow symbols (=>) in consecutive lines
- align_equals # Align equals symbols in consecutive lines
- alpha_ordered_imports # alternatively: length_ordered_imports
- blank_line_before_return # An empty line feed should precede a return statement.
- combine_consecutive_unsets # Calling unset on multiple items should be done in one call
- concat_with_spaces # Concatenation should be used with at least one whitespace around
- function_typehint_space # Add missing space between function's argument and its typehint
- hash_to_slash_comment # Single line comments should use double slashes // and not hash #
- linebreak_after_opening_tag # Ensure there is no code on the same line as the PHP open tag
- lowercase_cast # Cast should be written in lower case
- native_function_casing # Function defined by PHP should be called using the correct casing
- no_blank_lines_after_phpdoc # There should not be blank lines between docblock and the documented element
- no_blank_lines_after_return # Removes empty lines following a return statement
- no_blank_lines_after_throw # Removes empty lines following a throw statement
- no_blank_lines_between_imports # Removes empty lines inbetween import use statements
- no_empty_comment # There should not be any empty comments
- no_empty_phpdoc # There should not be empty PHPDoc blocks
- no_extra_consecutive_blank_lines # Removes extra consecutive empty lines
- no_short_bool_cast # Short cast bool using double exclamation mark should not be used
#- no_unreachable_default_argument_value # In method arguments there must not be arguments with default values before non-default ones
- no_unused_imports # Unused use statements must be removed
- no_useless_else # There should not be useless else cases
- no_useless_return # There should not be an empty return statement at the end of a function
- no_whitespace_in_blank_line # Remove trailing whitespace at the end of blank lines
- object_operator_without_whitespace # There should not be space before or after object T_OBJECT_OPERATOR
#- ordered_class_elements # Orders the elements of classes/interfaces/traits
- phpdoc_add_missing_param_annotation # phpdoc_add_missing_param_annotation
- phpdoc_align # All items of the @param, @throws, @return, @var, and @type phpdoc tags must be aligned vertically
- phpdoc_indent # Docblocks should have the same indentation as the documented subject
- phpdoc_order # Annotations in phpdocs should be ordered so that param annotations come first, then throws annotations, then return annotations
- phpdoc_scalar # Scalar types should always be written in the same form. int not integer, bool not boolean, float not real or double
- phpdoc_separation # Annotations of the same type should immediately follow each other, and annotations of different types should be separated
- phpdoc_single_line_var_spacing # Single line @var PHPDoc should have proper spacing
- phpdoc_trim # Phpdocs should start and end with content, excluding the very first and last line of the docblocks
- pre_increment # Pre incrementation/decrementation should be used if possible
- short_array_syntax # Arrays should use the short syntax
- short_scalar_cast # Cast (boolean) and (integer) should be written as (bool) and (int), (double) and (real) as (float)
- single_blank_line_before_namespace # There should be exactly one blank line before a namespace declaration
- single_quote # Convert double quotes to single quotes for simple strings
- standardize_not_equals # Replace all <> with !=
- ternary_operator_spaces # Standardize spaces around ternary operator
- trailing_comma_in_multiline_array # PHP multi-line arrays should have a trailing comma
- unary_operator_spaces # Unary operators should be placed adjacent to their operands
- whitespace_after_comma_in_array # In array declaration, there MUST be a whitespace after each comma
finder:
name:
- "*.php"
not-path:
- "Views"
......@@ -18,6 +18,7 @@ class PluginConfig extends AbstractClass
const SHOW_PROPERTIES_ON_TOP_SELLER = 'topSeller';
const SHOW_PROPERTIES_ON_LISTING = 'listing';
const SHOW_PROPERTIES_ON_BOUGHT = 'bought';
const SHOW_PROPERTIES_ON_SEARCH = 'search';
/**
* @var bool - provide $netiUserData globally
......
......@@ -71,6 +71,7 @@ class FrontendProperties implements SubscriberInterface
'Enlight_Controller_Action_PostDispatchSecure_Widgets_Recommendation' => 'addPropsToBought',
'Enlight_Controller_Action_PostDispatchSecure_Widgets_Emotion' => 'addPropsToEmotion',
'Enlight_Controller_Action_PostDispatchSecure_Frontend_Detail' => 'onPostDispatchFrontendDetail',
'Enlight_Controller_Action_PostDispatchSecure_Frontend_Search' => 'onPostDispatchFrontendSearch',
'sArticles::sGetArticlesByCategory::after' => 'afterGetArticlesByCategory',
'sArticles::sGetArticleCharts::after' => 'afterGetArticleCharts',
'Shopware_Controllers_Widgets_Listing_fetchListing_preFetch' => 'onWidgetsListingFetchListingPreFetch',
......@@ -233,6 +234,26 @@ class FrontendProperties implements SubscriberInterface
$view->assign('sArticle', $sArticle);
}
public function onPostDispatchFrontendSearch(\Enlight_Controller_ActionEventArgs $args)
{
if (
!in_array(
PluginConfig::SHOW_PROPERTIES_ON_SEARCH,
$this->pluginConfig->getShowPropertiesOn(),
true
)
) {
return;
}
$view = $args->getSubject()->View();
$sSearchResults = $view->getAssign('sSearchResults');
$sArticles = $sSearchResults['sArticles'];
$sSearchResults['sArticles'] = $this->addPropertiesToArticlesArray($sArticles);
$view->assign('sSearchResults', $sSearchResults);
}
/**
* @param \Enlight_Controller_ActionEventArgs $args
*/
......
#!/bin/bash
WORKING_DIR=$(dirname $0)
PLUGIN_NAME=$(basename ${WORKING_DIR})
VERSION=$(php -r "echo preg_replace('/.*<version>([^<]+)<\/version>.*/ims', '\\1', file_get_contents('${WORKING_DIR}/plugin.xml'), 1);")
TEMP_DIR='/tmp/ShopwarePlugins/'${PLUGIN_NAME}
SCRIPT_VERSION='3.1.0'
CURRENT_DIR=$(pwd)
EXCLUDES="sftp-config.json nbproject .idea"
WORKING_DIR=$(cd $(dirname $0) && pwd)
BUILD_DIR="${WORKING_DIR}/.build"
PLUGIN_DIR="${BUILD_DIR}/plugins"
TEMP_DIR="${BUILD_DIR}/tmp"
UPDATE=1
PLUGIN_NAME=""
PLUGINS_BUILD=()
PLUGINS_DIST=()
TARGET_DIR=${CURRENT_DIR}
usage() {
echo "Usage: $0 [-h] [-n] [-t <string>]" 1>&2;
exit 1;
}
while getopts "hnt:" opt; do
case "${opt}" in
h)
usage
;;
n)
UPDATE=0
;;
t)
TARGET_DIR=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
# Remove existing package file
if [ -f "${CURRENT_DIR}/${PLUGIN_NAME}-${VERSION}.zip" ]; then
rm "${CURRENT_DIR}/${PLUGIN_NAME}-${VERSION}.zip"
if [[ "/" != "${TARGET_DIR:0:1}" ]]; then
TARGET_DIR="${WORKING_DIR}/${TARGET_DIR}"
fi
# Create temporary build folder
mkdir -p ${TEMP_DIR}
if [[ ! -d $TARGET_DIR ]]; then
echo "ERROR: Target dir doesn't exist"
exit 2
fi
if [[ ! -w $TARGET_DIR ]]; then
echo "ERROR: Can't write to target dir"
exit 2
fi
# Copy all files from source folder to temporary folder
cp -Rp ${WORKING_DIR}/* ${TEMP_DIR}
TARGET_DIR=$(cd "${TARGET_DIR}" && pwd)
# Remove build.sh from temporary folder
rm "${TEMP_DIR}/build.sh"
cleanup() {
echo "INFO: Cleanup ${1}"
rm -Rf ${1}
}
# Remove excludes from temporary folder
for i in ${EXCLUDES}; do
if [ -e "${TEMP_DIR}/$i" ]; then
rm -R "${TEMP_DIR}/$i"
selfUpdate() {
echo "INFO: Run self update process"
UPDATE_DIR="${BUILD_DIR}/update"
git clone --quiet ssh://git@gitlab.netinventors.de:2202/shopware/build-script.git ${UPDATE_DIR}
cp -Rp ${UPDATE_DIR}/.build/plugins ${WORKING_DIR}/.build
cp -p ${UPDATE_DIR}/build.sh ${WORKING_DIR}
cleanup ${UPDATE_DIR}
}
runPlugins() {
if [[ -z ${@} ]]; then
return 0
fi
done
# Step into the temporary build folder
cd ${TEMP_DIR}
for PLUGIN in "${@}"; do
EXECUTABLE="${PLUGIN_DIR}/${PLUGIN}.sh"
if [[ -r "${EXECUTABLE}" ]]; then
echo "INFO: Run plugin ${PLUGIN}"
source "${EXECUTABLE}"
__FN="__$(sed -r 's/(\-)([a-z])/\U\2/g' <<< "${PLUGIN}")"
${__FN}
__RETURN=$?
if [[ 2 -eq ${__RETURN} ]]; then
echo "ERROR: A plugin stops the build process"
cleanup ${TEMP_DIR}
exit 2
fi
else
echo "WARNING: Plugin executable ${EXECUTABLE} not found"
fi
done
}
build() {
mkdir -p ${BUILD_DIR}
if [[ 1 -eq ${UPDATE} ]]; then
selfUpdate
bash -c "$0 -n -t \"${TARGET_DIR}\""
exit $?
fi
echo "INFO: Start build script version ${SCRIPT_VERSION}"
if [[ ! -r "${BUILD_DIR}/build.cfg" ]]; then
echo "ERROR: Unable to load build configuration file ${BUILD_DIR}/build.cfg"
exit 2
fi
# Load build configuration file
source "${BUILD_DIR}/build.cfg"
if [[ -z "${PLUGIN_NAME}" ]]; then
echo 'ERROR: Unable to resolve plugin name'
exit 2
fi
if [[ ! -r "${WORKING_DIR}/plugin.xml" ]]; then
echo "ERROR: Plugin describing file ${WORKING_DIR}/plugin.xml not found"
exit 2
fi
DIST_DIR="${BUILD_DIR}/tmp/${PLUGIN_NAME}"
VERSION=$(php -r "echo preg_replace('/.*<version>([^<]+)<\/version>.*/ims', '\\1', file_get_contents('${WORKING_DIR}/plugin.xml'), 1);")
EXCLUDES=( ".build" ".idea" "build.sh" ".git" ".gitignore" "${EXCLUDES[@]}" )
ZIP_FILE="${TARGET_DIR}/${PLUGIN_NAME}-${VERSION}.zip"
if [[ -z "$VERSION" ]]; then
echo 'ERROR: Unable to resolve plugin version from plugin.xml'
exit 2
fi
# Remove existing package file
if [[ -w "${ZIP_FILE}" ]]; then
rm "${ZIP_FILE}"
fi
if [[ -f "${ZIP_FILE}" ]]; then
echo "ERROR: Cannot override existing build file ${ZIP_FILE}"
exit 2
fi
RSYNC_EXCLUDES=( --exclude="${PLUGIN_NAME}-*.zip" )
cd ${WORKING_DIR}
runPlugins "${PLUGINS_BUILD[@]}"
for EXCLUDE in "${EXCLUDES[@]}"; do
RSYNC_EXCLUDES+=( --exclude="${EXCLUDE}" )
done
# Remove old temp dir
if [[ -d ${TEMP_DIR} ]]; then
rm -Rf ${TEMP_DIR}
fi
# Create temporary build folder
mkdir -p ${DIST_DIR}
# Copy all files from source folder to temporary folder
rsync -avzq "${RSYNC_EXCLUDES[@]}" . ${DIST_DIR}
# Step into the temporary build folder
cd ${DIST_DIR}
runPlugins "${PLUGINS_DIST[@]}"
# Replace __SECRET__ in plugin bootstrap to detect manipulations
SECRET=$(head -c 1000 /dev/urandom | tr -dc 'A-Za-z0-9%,!_;:#@' | fold -w 32 | head -n 1)
sed -i "s/__SECRET__/${SECRET}/g" "${PLUGIN_NAME}.php"
# Create md5.json file including the md5 checksum of every file in the package and the plugin __SECRET__
echo "<?php return [" > md5checksum.php
for FILE in $(find -type f -printf '%P\n'); do
echo "'${FILE}' => '$(md5sum ${FILE} | awk '{ print $1 }')'," >> md5checksum.php
done;
echo "'__SECRET__' => '${SECRET}'," >> md5checksum.php
echo "];" >> md5checksum.php
# Create md5.json file including the md5 checksum of every file in the package
echo "<?php return [" > md5checksum.php
for i in $(find -path ./.git -prune -o -name build.sh -prune -o -type f -printf '%P\n'); do
echo "'$i' => '$(md5sum $i | awk '{ print $1 }')'," >> md5checksum.php
done;
echo "];" >> md5checksum.php
cd ${TEMP_DIR}
# Move one level up in folder structure
cd ..
# Zip temporary folder contents to package file in plugin folder
zip -qr "${ZIP_FILE}" $(basename ${DIST_DIR})
# Zip temporary folder contents to package file in plugin folder
zip -qr "${CURRENT_DIR}/${PLUGIN_NAME}-${VERSION}.zip" $(basename ${TEMP_DIR})
echo "INFO: Created build package is located in ${ZIP_FILE}"
# Step back into the current plugin folder
cd ${CURRENT_DIR}
cleanup ${TEMP_DIR}
echo "Package wurde erstellt unter ${CURRENT_DIR}/${PLUGIN_NAME}-${VERSION}.zip"
cd ${CURRENT_DIR}
}
# Remove temporary build folder
rm -R $(dirname ${TEMP_DIR})
build
......@@ -60,6 +60,7 @@ return [
['similarArticles', ['de_DE' => 'Ähnliche Artikel / Zubehör', 'en_GB' => 'Similar / similar articles']],
['bought', ['de_DE' => 'Kunden kauften auch', 'en_GB' => 'Bought articles']],
['topSeller', ['de_DE' => 'TopSeller', 'en_GB' => 'TopSellers']],
['search', ['de_DE' => 'Artikelsuche', 'en_GB' => 'Article Search']],
[
'emotionArticleSlider',
['de_DE' => 'Artikel-Slider-Einkaufsweltelement', 'en_GB' => 'Article slider emotion component'],
......
......@@ -5,11 +5,24 @@
<label lang="de">ToolKit</label>
<label lang="en">ToolKit</label>
<version>3.1.0</version>
<version>3.1.1</version>
<link>http://www.shopinventors.de</link>
<author>Net Inventors GmbH</author>
<compatibility minVersion="5.5.0"/>
<changelog version="3.1.1">
<changes lang="de">
<![CDATA[
[#30373] Artikel-Eigenschaften auch in der Suche verfügbar
]]>
</changes>
<changes lang="en">
<![CDATA[
[#30373] Article-Properties available in search.
]]>
</changes>
</changelog>
<changelog version="3.1.0">
<changes lang="de">
<![CDATA[
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment