diff --git a/boot.php b/boot.php index b655626..cb1032a 100644 --- a/boot.php +++ b/boot.php @@ -10,7 +10,6 @@ */ if (rex::isBackend() && rex::getUser()) { - $providers = \Watson\Foundation\Watson::loadProviders(); if (count($providers)) { diff --git a/lib/Cheatsheet/CheatsheetServiceProvider.php b/lib/Cheatsheet/CheatsheetServiceProvider.php index 7d5b432..8514cf5 100644 --- a/lib/Cheatsheet/CheatsheetServiceProvider.php +++ b/lib/Cheatsheet/CheatsheetServiceProvider.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Cheatsheet; use Cheatsheet\Page; @@ -15,13 +16,12 @@ class CheatsheetServiceProvider extends ServiceProvider { - /** * {@inheritdoc} */ public function i18n() { - return __DIR__ . '/lang'; + return __DIR__.'/lang'; } /** @@ -37,6 +37,7 @@ public function page() $subpage = new \rex_be_page('watson', \rex_i18n::msg('watson_cheatsheet_docs_title')); $subpage->setHref(['page' => 'cheatsheet/addoff/watson']); + $subpage->setIcon('watson-icon-logo'); $subpage->setSubPath(\rex_path::addon('watson', 'lib/Cheatsheet/pages/docs.php')); $page->addSubpage($subpage); diff --git a/lib/Cheatsheet/pages/docs.php b/lib/Cheatsheet/pages/docs.php index 5954f87..01967e9 100644 --- a/lib/Cheatsheet/pages/docs.php +++ b/lib/Cheatsheet/pages/docs.php @@ -21,16 +21,14 @@ if (strpos($index, '/') !== false) { $navAttributes['class'][] = 'is-plugin'; } - $nav[] = '' . $label . ''; + $nav[] = ''.$label.''; } $fragment = new rex_fragment(); $fragment->setVar('title', rex_i18n::msg('watson_cheatsheet_docs_title')); -$fragment->setVar('body', '', false); +$fragment->setVar('body', '', false); $sidebar = $fragment->parse('core/page/section.php'); - - if ($requestIndex == 'use') { $body = '
@@ -147,7 +145,6 @@ $fragment->setVar('title', $navigation[$requestIndex]); $fragment->setVar('body', $body, false); $content .= $fragment->parse('core/page/section.php'); - } else { $fragment = new rex_fragment(); $fragment->setVar('title', $navigation[$requestIndex]); @@ -155,10 +152,8 @@ $content .= $fragment->parse('core/page/section.php'); } - - echo '
-
' . $sidebar . '
-
' . $content . '
+
'.$sidebar.'
+
'.$content.'
'; diff --git a/lib/Watson/Foundation/Command.php b/lib/Watson/Foundation/Command.php index d01d84d..f85144b 100644 --- a/lib/Watson/Foundation/Command.php +++ b/lib/Watson/Foundation/Command.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Foundation; class Command @@ -15,9 +16,8 @@ class Command private $command; private $command_parts; private $input; - private $arguments = array(); - private $options = array(); - + private $arguments = []; + private $options = []; public function __construct($input) { @@ -27,178 +27,136 @@ public function __construct($input) $this->parseInput(); } - public function parseInput() { $command_parts = $this->command_parts; if (isset($command_parts['0'])) { - $this->command = $command_parts['0']; unset($command_parts[0]); - } - foreach ($command_parts as $name => $value) { - if (0 === strpos($name, '--')) { // Check for an option notation. // Notation: --option="my option" - + $name = substr($name, 2); - - if (empty($name)) { + if (empty($name)) { throw new \Exception('An option name cannot be empty.'); - } $this->options[$name] = $value; - unset($command_parts['--' . $name]); - + unset($command_parts['--'.$name]); } elseif (is_numeric($name) && 0 === strpos($value, '--')) { - // Check for an option notation. // Notation: --option $value = substr($value, 2); - - if (empty($value)) { + if (empty($value)) { throw new \Exception('An option name cannot be empty.'); - } $this->options[$value] = 1; unset($command_parts[$name]); - } } $this->arguments = $command_parts; - } - public function getCommand() { return $this->command; } - - public function getInput() { return $this->input; } - - public function getCommandParts() { return $this->command_parts; } - - public function getCommandPartsAsString() { return implode(' ', $this->getCommandParts()); } - - public function deleteCommandFromCommandParts() { foreach ($this->command_parts as $key => $command_part) { - if ($this->command == $command_part) { - unset($this->command_parts[$key]); - } } } - - public function getArgument($position) { return isset($this->arguments[$position]) ? $this->arguments[$position] : null; } - - public function getArguments() { return $this->arguments; } - - public function getOption($option) { return isset($this->options[$option]) ? $this->options[$option] : null; } - - public function getOptions() { return $this->options; } - - public function getSqlWhere($fields) { - $where = array(); + $where = []; foreach ($fields as $field) { - - $w = array(); + $w = []; foreach ($this->getCommandParts() as $command_part) { - - $w[] = $field . ' LIKE "%' . $command_part . '%"'; - + $w[] = $field.' LIKE "%'.$command_part.'%"'; } - $where[] = '(' . implode(' AND ', $w) . ')'; + $where[] = '('.implode(' AND ', $w).')'; } return implode(' OR ', $where); } - - - - - /** * Splits a string by spaces - * (Strings with quotes will be regarded) + * (Strings with quotes will be regarded). * * Examples: * "a b 'c d'" -> array('a', 'b', 'c d') * "a=1 b='c d'" -> array('a' => 1, 'b' => 'c d') * * @param string $string + * * @return array */ protected function split($string) { $string = trim($string); if (empty($string)) { - return array(); + return []; } - $result = array(); + $result = []; $spacer = '@@@WATSON@@@'; - $quoted = array(); + $quoted = []; - $pattern = '@(["\'])((?:.*[^\\\\])?(?:\\\\\\\\)*)\\1@Us'; + $pattern = '@(["\'])((?:.*[^\\\\])?(?:\\\\\\\\)*)\\1@Us'; $callback = function ($match) use ($spacer, &$quoted) { - $quoted[] = str_replace(array('\\' . $match[1], '\\\\'), array($match[1], '\\'), $match[2]); + $quoted[] = str_replace(['\\'.$match[1], '\\\\'], [$match[1], '\\'], $match[2]); return $spacer; }; $string = preg_replace_callback($pattern, $callback, $string); @@ -218,6 +176,4 @@ protected function split($string) return $result; } - - } diff --git a/lib/Watson/Foundation/Documentation.php b/lib/Watson/Foundation/Documentation.php index dd74f9e..cca32e8 100644 --- a/lib/Watson/Foundation/Documentation.php +++ b/lib/Watson/Foundation/Documentation.php @@ -8,128 +8,83 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -namespace Watson\Foundation; +namespace Watson\Foundation; class Documentation { - private $command; private $examples; private $description; private $options; private $usage; - - - public function __construct($command) { - $this->setCommand($command); - } - - public function setCommand($value) { - $this->command = $value; - } public function getCommand() { - return $this->command; - } - public function setExample($example) { - $this->examples[] = $example; - } - public function setExamples(array $examples) { - foreach ($examples as $example) { - $this->setExample($example); - } - } public function getExamples() { - return $this->examples; - } - - public function setDescription($value) { - $this->description = $value; - } public function getDescription() { - return $this->description; - } - public function setOption($option, $description) { - - $this->options[] = array('option' => $option, 'description' => $description); - + $this->options[] = ['option' => $option, 'description' => $description]; } - public function setOptions(array $options) { - foreach ($options as $option => $option) { - $this->setOption($option, $description); - } - } public function getOptions() { - return $this->options; - } - - public function setUsage($value) { - $this->usage = $value; - } public function getUsage() { - return $this->usage; - } - } diff --git a/lib/Watson/Foundation/Extension.php b/lib/Watson/Foundation/Extension.php index 699ed63..d6a2081 100644 --- a/lib/Watson/Foundation/Extension.php +++ b/lib/Watson/Foundation/Extension.php @@ -11,9 +11,6 @@ namespace Watson\Foundation; -use Watson\Foundation\Command; -use Watson\Foundation\Watson; - class Extension { public static function head(\rex_extension_point $ep) @@ -25,18 +22,18 @@ public static function head(\rex_extension_point $ep) 'quicklookHotkey' => Watson::getQuicklookHotkey(), 'backend' => true, 'backendUrl' => \rex_url::backendPage('watson', [], false), - 'backendRemoteUrl' => \rex_url::backendPage('watson', ['watson_query' => ''], false) . '%QUERY', + 'backendRemoteUrl' => \rex_url::backendPage('watson', ['watson_query' => ''], false).'%QUERY', 'wildcard' => '%QUERY', ] ); if ($js_properties) { - $ep->setSubject($ep->getSubject() . "\n" . ' + $ep->setSubject($ep->getSubject()."\n".' ' @@ -62,12 +59,12 @@ public static function agent(\rex_extension_point $ep) - + '; $panel .= '
'; - $ep->setSubject(str_replace('', $panel . '', $ep->getSubject())); + $ep->setSubject(str_replace('', $panel.'', $ep->getSubject())); } public static function run(\rex_extension_point $ep) @@ -96,9 +93,8 @@ public static function run(\rex_extension_point $ep) if (in_array($command->getCommand(), $workflow->commands())) { $saveWorkflows = [$workflow]; break; - } else { - unset($workflows[$key]); // Workflow aus dem Sammelarray löschen. Wird ansonsten verwendet, wenn kein Commando gefunden wurde } + unset($workflows[$key]); // Workflow aus dem Sammelarray löschen. Wird ansonsten verwendet, wenn kein Commando gefunden wurde } elseif (in_array($command->getCommand(), $workflow->commands())) { $saveWorkflows[] = $workflow; } @@ -146,7 +142,7 @@ public static function callWatsonFunc(\rex_extension_point $ep) $callMethod = urldecode(rex_request('watsonCallMethod', 'string')); $callParams = urldecode(rex_request('watsonCallParams', 'string')); if ($callClass != '' && $callMethod != '') { - call_user_func_array(array($callClass, $callMethod), array(json_decode($callParams, true))); + call_user_func_array([$callClass, $callMethod], [json_decode($callParams, true)]); } } } diff --git a/lib/Watson/Foundation/GeneratorWorkflow.php b/lib/Watson/Foundation/GeneratorWorkflow.php index 431148f..28b898a 100644 --- a/lib/Watson/Foundation/GeneratorWorkflow.php +++ b/lib/Watson/Foundation/GeneratorWorkflow.php @@ -22,9 +22,10 @@ abstract protected function getTemplatePath(); /** * Try to mold user's input - * to one of the CRUD operations + * to one of the CRUD operations. * * @param $commandName + * * @return string */ protected function normalizeCommandName($commandName) diff --git a/lib/Watson/Foundation/Result.php b/lib/Watson/Foundation/Result.php index df0827f..c1e3ac0 100644 --- a/lib/Watson/Foundation/Result.php +++ b/lib/Watson/Foundation/Result.php @@ -8,9 +8,8 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -namespace Watson\Foundation; -use \Watson\Foundation\Watson; +namespace Watson\Foundation; class Result { @@ -18,17 +17,12 @@ class Result private $header; private $footer; - - public function __construct() { - } - - /** - * Sets result entry + * Sets result entry. * * @param ResultEntry $entry */ @@ -37,83 +31,80 @@ public function addEntry($entry) $this->entries[] = $entry; } - - /** - * render all result entries + * render all result entries. */ public function render($displayKey) { $entries = $this->entries; - $returns = array(); + $returns = []; if (count($entries) > 0) { foreach ($entries as $entry) { - $return = array(); + $return = []; - $classes = array(); - $styles = array(); + $classes = []; + $styles = []; $value = $entry->getValue(); - $return['value_name'] = $entry->getValue(); - $return['description'] = ''; + $return['value_name'] = $entry->getValue(); + $return['description'] = ''; if ($entry->hasLegend()) { - $return['legend'] = ' ' . $entry->getLegend(); + $return['legend'] = ' '.$entry->getLegend(); } if ($entry->hasValueSuffix()) { // Suffix anhängen, da sonst nur ein Ergebnis erscheint // Bspl. gleicher Artikelname in 2 Sprachen - $value .= ' ' . $entry->getValueSuffix(); + $value .= ' '.$entry->getValueSuffix(); - $classes[] = 'watson-has-value-suffix'; - $return['value_suffix'] = $entry->getValueSuffix(); + $classes[] = 'watson-has-value-suffix'; + $return['value_suffix'] = $entry->getValueSuffix(); } if ($entry->hasIcon()) { - $classes[] = 'watson-has-icon'; - $return['icon'] = ' ' . $entry->getIcon(); + $classes[] = 'watson-has-icon'; + $return['icon'] = ' '.$entry->getIcon(); } if ($entry->hasDescription()) { - $classes[] = 'watson-has-description'; - $return['description'] = $entry->getDescription(); + $classes[] = 'watson-has-description'; + $return['description'] = $entry->getDescription(); } if ($entry->hasUrl()) { - $return['url'] = $entry->getUrl(); - $return['url_open_window'] = $entry->getUrlOpenWindow(); + $return['url'] = $entry->getUrl(); + $return['url_open_window'] = $entry->getUrlOpenWindow(); } if ($entry->hasQuickLookUrl()) { - $classes[] = 'watson-has-quick-look'; - $return['quick_look_url'] = $entry->getQuickLookUrl(); + $classes[] = 'watson-has-quick-look'; + $return['quick_look_url'] = $entry->getQuickLookUrl(); } if ($entry->hasHtmlFields()) { - $classes[] = 'watson-has-html-fields'; - $return['html_fields'] = $entry->getHtmlFields(); + $classes[] = 'watson-has-html-fields'; + $return['html_fields'] = $entry->getHtmlFields(); } if ($entry->hasAjax()) { $return['ajax'] = $entry->getAjax(); } - $return['value'] = $value; - $return['tokens'] = array($value); - $return['displayKey'] = $displayKey; + $return['value'] = $value; + $return['tokens'] = [$value]; + $return['displayKey'] = $displayKey; - $class = count($classes) > 0 ? ' ' . implode(' ', $classes) : ''; + $class = count($classes) > 0 ? ' '.implode(' ', $classes) : ''; $style = count($styles) > 0 ? implode(' ', $styles) : ''; - $return['class'] = $class; - $return['style'] = $style; + $return['class'] = $class; + $return['style'] = $style; $returns[] = $return; } - } return $returns; diff --git a/lib/Watson/Foundation/ResultEntry.php b/lib/Watson/Foundation/ResultEntry.php index 96db6b8..cfefdfc 100644 --- a/lib/Watson/Foundation/ResultEntry.php +++ b/lib/Watson/Foundation/ResultEntry.php @@ -8,9 +8,8 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -namespace Watson\Foundation; -use \Watson\Foundation\Watson; +namespace Watson\Foundation; class ResultEntry { @@ -25,17 +24,12 @@ class ResultEntry private $html_fields; private $ajax; - - public function __construct() { - } - - /** - * Sets a value + * Sets a value. * * @param string $value */ @@ -49,7 +43,7 @@ public function setValue($value, $suffix = null) } /** - * Returns the value + * Returns the value. * * @return string */ @@ -59,7 +53,7 @@ public function getValue() } /** - * Returns whether a value is set + * Returns whether a value is set. * * @return bool */ @@ -68,10 +62,8 @@ public function hasValue() return !empty($this->value); } - - /** - * Sets a value_suffix + * Sets a value_suffix. * * @param string $value */ @@ -81,7 +73,7 @@ public function setValueSuffix($value) } /** - * Returns the value_suffix + * Returns the value_suffix. * * @return string */ @@ -91,7 +83,7 @@ public function getValueSuffix() } /** - * Returns whether a value_suffix is set + * Returns whether a value_suffix is set. * * @return bool */ @@ -100,10 +92,8 @@ public function hasValueSuffix() return !empty($this->value_suffix); } - - /** - * Sets a legend + * Sets a legend. * * @param string $value */ @@ -113,7 +103,7 @@ public function setLegend($value) } /** - * Returns the legend + * Returns the legend. * * @return string */ @@ -123,7 +113,7 @@ public function getLegend() } /** - * Returns whether a legend is set + * Returns whether a legend is set. * * @return bool */ @@ -132,10 +122,8 @@ public function hasLegend() return !empty($this->legend); } - - /** - * Sets a icon + * Sets a icon. * * @param string $value */ @@ -145,7 +133,7 @@ public function setIcon($value) } /** - * Returns the icon + * Returns the icon. * * @return string */ @@ -155,7 +143,7 @@ public function getIcon() } /** - * Returns whether a icon is set + * Returns whether a icon is set. * * @return bool */ @@ -164,10 +152,8 @@ public function hasIcon() return !empty($this->icon); } - - /** - * Sets a description + * Sets a description. * * @param string $value */ @@ -177,7 +163,7 @@ public function setDescription($value) } /** - * Returns the icon + * Returns the icon. * * @return string */ @@ -187,7 +173,7 @@ public function getDescription() } /** - * Returns whether a icon is set + * Returns whether a icon is set. * * @return bool */ @@ -196,22 +182,20 @@ public function hasDescription() return !empty($this->description); } - - /** - * Sets a url + * Sets a url. * * @param string $url * @param bool $new_window */ public function setUrl($url, $open_window = false) { - $this->url = htmlspecialchars_decode($url); + $this->url = htmlspecialchars_decode($url); $this->url_open_window = $open_window; } /** - * Returns the url class + * Returns the url class. * * @return string */ @@ -221,7 +205,7 @@ public function getUrl() } /** - * Returns whether a url is set + * Returns whether a url is set. * * @return string */ @@ -231,7 +215,7 @@ public function hasUrl() } /** - * Returns the url open window class + * Returns the url open window class. * * @return bool */ @@ -240,10 +224,8 @@ public function getUrlOpenWindow() return $this->url_open_window; } - - /** - * Sets a quick look url + * Sets a quick look url. * * @param string $value */ @@ -254,7 +236,7 @@ public function setQuickLookUrl($value) } /** - * Returns the quick look url class + * Returns the quick look url class. * * @return string */ @@ -264,7 +246,7 @@ public function getQuickLookUrl() } /** - * Returns whether a quick look url is set + * Returns whether a quick look url is set. * * @return bool */ @@ -273,10 +255,8 @@ public function hasQuickLookUrl() return !empty($this->quick_look_url); } - - /** - * Sets html fields + * Sets html fields. * * @param string $value */ @@ -286,7 +266,7 @@ public function setHtmlFields($value) } /** - * Returns the html fields + * Returns the html fields. * * @return string */ @@ -296,7 +276,7 @@ public function getHtmlFields() } /** - * Returns whether html fields are set + * Returns whether html fields are set. * * @return bool */ @@ -306,7 +286,7 @@ public function hasHtmlFields() } /** - * Sets a ajax + * Sets a ajax. * * @param string $value */ @@ -316,7 +296,7 @@ public function setAjax($value) } /** - * Returns the ajax + * Returns the ajax. * * @return string */ @@ -326,7 +306,7 @@ public function getAjax() } /** - * Returns whether a ajax is set + * Returns whether a ajax is set. * * @return bool */ diff --git a/lib/Watson/Foundation/SupportProvider.php b/lib/Watson/Foundation/SupportProvider.php index 1cde681..86b0335 100644 --- a/lib/Watson/Foundation/SupportProvider.php +++ b/lib/Watson/Foundation/SupportProvider.php @@ -8,24 +8,22 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -namespace Watson\Foundation; +namespace Watson\Foundation; abstract class SupportProvider { - /** * Register the directory to search a translation file. * * @return string */ - abstract function i18n(); - + abstract public function i18n(); /** * Register the search provider. * * @return Workflow|array */ - abstract function register(); + abstract public function register(); } diff --git a/lib/Watson/Foundation/Watson.php b/lib/Watson/Foundation/Watson.php index ee33f5b..0820037 100644 --- a/lib/Watson/Foundation/Watson.php +++ b/lib/Watson/Foundation/Watson.php @@ -60,7 +60,7 @@ public static function getConsoleInterpreterUrl() { global $REX; - return realpath($REX['HTDOCS_PATH'] . 'redaxo') . '/index.php?watson_console=1'; + return realpath($REX['HTDOCS_PATH'].'redaxo').'/index.php?watson_console=1'; } public static function getAssetsDir() @@ -68,9 +68,9 @@ public static function getAssetsDir() return \rex_path::addonAssets('watson'); } - public static function translate($key,...$params) + public static function translate($key, ...$params) { - return \rex_i18n::msg($key,...$params); + return \rex_i18n::msg($key, ...$params); } public static function loadProviders() @@ -116,7 +116,6 @@ public static function getRegisteredPageParam($param, $default = false) return $default; } - public static function saveRegisteredPageParams(array $providerParams) { $watsonParams = \rex_request::session('watson_params', []); @@ -140,14 +139,13 @@ public static function buildQuery(array $params, $argSeparator = '&') { $query = []; $func = function (array $params, $fullkey = null) use (&$query, &$func) { - foreach ($params as $key => $value) { - $key = $fullkey ? $fullkey . '[' . urlencode($key) . ']' : urlencode($key); + $key = $fullkey ? $fullkey.'['.urlencode($key).']' : urlencode($key); if (is_array($value)) { $func($value, $key); } else { - $query[] = $key . '=' . str_replace('%2F', '/', urlencode($value)); + $query[] = $key.'='.str_replace('%2F', '/', urlencode($value)); } } }; @@ -170,9 +168,8 @@ public static function getUrl(array $params = [], $backend = true) if ($backend) { return htmlspecialchars(\rex_url::backendController($params)); - } else { - return \rex_url::backendController($params); } + return \rex_url::backendController($params); } /** diff --git a/lib/Watson/Foundation/Workflow.php b/lib/Watson/Foundation/Workflow.php index 42a7f37..bf35b41 100644 --- a/lib/Watson/Foundation/Workflow.php +++ b/lib/Watson/Foundation/Workflow.php @@ -11,9 +11,6 @@ namespace Watson\Foundation; -use Watson\Foundation\Command; -use Watson\Foundation\Watson; - abstract class Workflow { /** @@ -44,7 +41,6 @@ abstract public function registerPageParams(); */ abstract public function fire(Command $command); - protected function getDatabaseResults($query) { $query = str_replace(["\r\n", "\r", "\n"], '', $query); @@ -55,8 +51,7 @@ protected function getDatabaseResults($query) $query = substr($query, 0, $limit); } - $query .= ' LIMIT ' . Watson::getResultLimit(); - + $query .= ' LIMIT '.Watson::getResultLimit(); $sql = \rex_sql::factory(); //$sql->setDebug(); diff --git a/lib/Watson/Parsers/OptionFieldsParser.php b/lib/Watson/Parsers/OptionFieldsParser.php index 1dcfaf2..09d9d0d 100644 --- a/lib/Watson/Parsers/OptionFieldsParser.php +++ b/lib/Watson/Parsers/OptionFieldsParser.php @@ -15,7 +15,7 @@ class OptionFieldsParser { /** * Parse a string of fields, like - * name:text, text:textarea:textile, categories:select(SELECT id, name FROM table), yesno:select([0 => 'no', 1 => 'yes']) + * name:text, text:textarea:textile, categories:select(SELECT id, name FROM table), yesno:select([0 => 'no', 1 => 'yes']). * * @param string $fields * @@ -88,7 +88,8 @@ public function parse($fields) return $parsed; } - protected function splitFields($string) { + protected function splitFields($string) + { // number of nested sets of brackets $level = 0; // array to return @@ -96,7 +97,7 @@ protected function splitFields($string) { // current index in the array to return, for convenience $currentIndex = 0; - for ($i = 0; $i < strlen($string); $i++) { + for ($i = 0; $i < strlen($string); ++$i) { switch ($string[$i]) { case '(': $level++; @@ -108,11 +109,12 @@ protected function splitFields($string) { break; case ',': if ($level == 0) { - $currentIndex++; + ++$currentIndex; $return[$currentIndex] = ''; break; } // else fallthrough + // no break default: if (isset($return[$currentIndex])) { $return[$currentIndex] .= $string[$i]; @@ -125,14 +127,14 @@ protected function splitFields($string) { return array_map('trim', $return); } - protected function splitArgs($string) { + protected function splitArgs($string) + { preg_match_all("/\[(?:[^\[\]]|(?R))+\]|'[^']*'|[^\[\],]+/", $string, $matches); return $this->removeEmptyValuesAndRebuildKeys($matches[0]); } - protected function removeEmptyValuesAndRebuildKeys($array) { + protected function removeEmptyValuesAndRebuildKeys($array) + { return array_values(array_filter(array_map('trim', $array))); } - - } diff --git a/lib/Watson/Workflows/Media/MediaProvider.php b/lib/Watson/Workflows/Media/MediaProvider.php index 0a65725..5057a82 100644 --- a/lib/Watson/Workflows/Media/MediaProvider.php +++ b/lib/Watson/Workflows/Media/MediaProvider.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Media; use Watson\Foundation\SupportProvider; @@ -15,7 +16,6 @@ class MediaProvider extends SupportProvider { - /** * Register the directory to search a translation file. * diff --git a/lib/Watson/Workflows/Media/MediaSearch.php b/lib/Watson/Workflows/Media/MediaSearch.php index d2118a7..109b4a9 100644 --- a/lib/Watson/Workflows/Media/MediaSearch.php +++ b/lib/Watson/Workflows/Media/MediaSearch.php @@ -8,14 +8,15 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Media; -use \Watson\Foundation\Documentation; -use \Watson\Foundation\Command; -use \Watson\Foundation\Result; -use \Watson\Foundation\ResultEntry; -use \Watson\Foundation\Watson; -use \Watson\Foundation\Workflow; +use Watson\Foundation\Command; +use Watson\Foundation\Documentation; +use Watson\Foundation\Result; +use Watson\Foundation\ResultEntry; +use Watson\Foundation\Watson; +use Watson\Foundation\Workflow; class MediaSearch extends Workflow { @@ -26,11 +27,10 @@ class MediaSearch extends Workflow */ public function commands() { - return array('m', 'f'); + return ['m', 'f']; } /** - * * @return Documentation */ public function documentation() @@ -44,7 +44,7 @@ public function documentation() } /** - * Return array of registered page params + * Return array of registered page params. * * @return array */ @@ -54,80 +54,68 @@ public function registerPageParams() } /** - * Execute the command for the given Command + * Execute the command for the given Command. + * + * @param Command $command * - * @param Command $command * @return Result */ public function fire(Command $command) { - $result = new Result(); - $fields = array( + $fields = [ 'filename', 'title', - ); + ]; $s = \rex_sql::factory(); - $s->setQuery('SELECT * FROM ' . Watson::getTable('media') .' LIMIT 0'); + $s->setQuery('SELECT * FROM '.Watson::getTable('media').' LIMIT 0'); $fieldnames = $s->getFieldnames(); foreach ($fieldnames as $fieldname) { - if (substr($fieldname, 0, 4) == 'med_') { - $fields[] = $fieldname; - } - } - - $sql_query = ' SELECT id, + $sql_query = ' SELECT id, filename, title - FROM ' . Watson::getTable('media') . ' - WHERE ' . $command->getSqlWhere($fields) . ' + FROM '.Watson::getTable('media').' + WHERE '.$command->getSqlWhere($fields).' ORDER BY filename'; $items = $this->getDatabaseResults($sql_query); if (count($items)) { - $counter = 0; foreach ($items as $item) { + $title = ($item['title'] != '') ? ' ('.Watson::translate('watson_media_title').': '.$item['title'].')' : ''; - $title = ($item['title'] != '') ? ' (' . Watson::translate('watson_media_title') . ': ' . $item['title'] . ')' : ''; - - $counter++; + ++$counter; $entry = new ResultEntry(); if ($counter == 1) { $entry->setLegend(Watson::translate('watson_media_legend')); } $entry->setValue($item['filename']); - $entry->setDescription(Watson::translate('watson_open_media') . $title); + $entry->setDescription(Watson::translate('watson_open_media').$title); $entry->setIcon('watson-icon-media'); - $entry->setUrl('javascript:newPoolWindow(\'' . Watson::getUrl(array('page' => 'mediapool/media', 'file_id' => $item['id'])) . '\')'); + $entry->setUrl('javascript:newPoolWindow(\''.Watson::getUrl(['page' => 'mediapool/media', 'file_id' => $item['id']]).'\')'); $m = \rex_media::get($item['filename']); if ($m instanceof \rex_media) { - if ($m->isImage()) { - - $entry->setQuickLookUrl(Watson::getUrl(array('rex_media_type' => 'rex_mediapool_maximized', 'rex_media_file' => $item['filename']), false)); + $entry->setQuickLookUrl(Watson::getUrl(['rex_media_type' => 'rex_mediapool_maximized', 'rex_media_file' => $item['filename']], false)); } } $result->addEntry($entry); - } } - return $result; } - } diff --git a/lib/Watson/Workflows/Module/ModuleData.php b/lib/Watson/Workflows/Module/ModuleData.php index 54ded3d..11317f0 100644 --- a/lib/Watson/Workflows/Module/ModuleData.php +++ b/lib/Watson/Workflows/Module/ModuleData.php @@ -18,6 +18,7 @@ class ModuleData { /** * The max number of fields in module table. + * * @var array */ private $maxFields = [ @@ -30,6 +31,7 @@ class ModuleData /** * Count the fields from user input. + * * @var array */ private $countFields = [ @@ -47,6 +49,7 @@ class ModuleData /** * Replace variables in templates. + * * @var array */ private $replaceVariables = [ @@ -61,43 +64,50 @@ class ModuleData ]; /** - * Fields + * Fields. + * * @var array */ private $fields = []; /** - * Tabs + * Tabs. + * * @var int */ private $inputTabs = 0; /** * Module id. + * * @var int */ private $id = ''; /** * Module name. + * * @var string */ private $name = ''; /** * Module input. + * * @var string */ private $input = ''; /** * Module output. + * * @var string */ private $output = ''; /** - * Template Path + * Template Path. + * * @var string */ private $templatePath = ''; @@ -117,6 +127,52 @@ public function __construct($name, $fields) $this->fields = $fieldParser->parse($fields); } + public function create() + { + $this->fields = $this->checkFieldsAndRemoveWhenTooMuch($this->fields); + if ($this->inputTabs >= 1) { + $this->buildTabModule(); + } else { + $this->buildNormalModule(); + } + + $sql = \rex_sql::factory(); + $sql->setTable(Watson::getTable('module')); + $sql->setValue('name', $this->name); + $sql->setValue('input', $this->input); + $sql->setValue('output', $this->output); + $sql->addGlobalCreateFields(); + $sql->insert(); + $this->id = $sql->getLastId(); + echo json_encode(['url' => \rex_url::backendPage('modules/modules', ['function' => 'edit', 'module_id' => $this->id], false)]); + } + + public function setInputTabs($tabs) + { + $tabs = (int) $tabs; + if ($tabs >= 1 && $tabs <= max($this->maxFields)) { + $this->inputTabs = $tabs; + foreach ($this->maxFields as $fieldName => $maxAmount) { + switch ($fieldName) { + case 'LINK': + case 'LINKLIST': + case 'MEDIA': + case 'MEDIALIST': + $this->maxFields[$fieldName] = floor($maxAmount / $this->inputTabs); + break; + } + } + } + } + + /** + * Set the path to the module templates. + */ + public function setTemplatePath($templatePath) + { + $this->templatePath = $templatePath; + } + private function checkFieldsAndRemoveWhenTooMuch($fields) { if (count($fields)) { @@ -130,7 +186,6 @@ private function checkFieldsAndRemoveWhenTooMuch($fields) $fields[$index]['internal']['template']['$ARGS_OPTIONS_QUERY$'] = $field['args'][0]; } - if ($this->moduleFileExists($fieldTemplateDir)) { $upperType = strtoupper($field['type']); $upperType = isset($this->countFields[$upperType]) ? $upperType : 'VALUE'; @@ -157,7 +212,7 @@ private function checkFieldsAndRemoveWhenTooMuch($fields) if (isset($field['args'][1]) && is_array($field['args'][1])) { // args[1] = Attributes > must be an array. if (isset($field['args'][1]['class'])) { - $fields[$index]['internal']['template']['$ARGS_ATTRIBUTE_CLASS$'] = ' ' . $field['args'][1]['class']; + $fields[$index]['internal']['template']['$ARGS_ATTRIBUTE_CLASS$'] = ' '.$field['args'][1]['class']; unset($field['args'][1]['class']); } $fields[$index]['internal']['template']['$ARGS_ATTRIBUTES_ARRAY$'] = $field['args_input'][1]; @@ -171,7 +226,7 @@ private function checkFieldsAndRemoveWhenTooMuch($fields) default: if (isset($field['args'][0]) && is_array($field['args'][0])) { if (isset($field['args'][0]['class'])) { - $fields[$index]['internal']['template']['$ARGS_ATTRIBUTE_CLASS$'] = ' ' . $field['args'][0]['class']; + $fields[$index]['internal']['template']['$ARGS_ATTRIBUTE_CLASS$'] = ' '.$field['args'][0]['class']; unset($field['args'][0]['class']); } $fields[$index]['internal']['template']['$ARGS_ATTRIBUTES_ARRAY$'] = $field['args_input'][0]; @@ -197,19 +252,19 @@ private function moduleFileExists($fieldTemplateDir) private function getInputTemplate($fieldTemplateDir) { - return $this->getTemplatePath() . $fieldTemplateDir . '/input.txt'; + return $this->getTemplatePath().$fieldTemplateDir.'/input.txt'; } private function getOutputTemplate($fieldTemplateDir) { - return $this->getTemplatePath() . $fieldTemplateDir . '/output.txt'; + return $this->getTemplatePath().$fieldTemplateDir.'/output.txt'; } private function buildNormalModule() { $search = array_keys($this->replaceVariables); - $this->input .= '
' . "\n"; - $this->output .= 'input .= '
'."\n"; + $this->output .= 'fields as $field) { $templateParams = $field['internal']['template']; $templateDir = $field['internal']['field_template_dir']; @@ -227,48 +282,10 @@ private function buildNormalModule() private function buildTabModule() { echo '
';
-        echo print_r($this->fields) . '
'; + echo print_r($this->fields).'
'; echo '
'; } - public function create() - { - $this->fields = $this->checkFieldsAndRemoveWhenTooMuch($this->fields); - if ($this->inputTabs >= 1) { - $this->buildTabModule(); - } else { - $this->buildNormalModule(); - } - - $sql = \rex_sql::factory(); - $sql->setTable(Watson::getTable('module')); - $sql->setValue('name', $this->name); - $sql->setValue('input', $this->input); - $sql->setValue('output', $this->output); - $sql->addGlobalCreateFields(); - $sql->insert(); - $this->id = $sql->getLastId(); - echo json_encode(['url' => \rex_url::backendPage('modules/modules', ['function' => 'edit', 'module_id' => $this->id], false)]); - } - - public function setInputTabs($tabs) - { - $tabs = (int) $tabs; - if ($tabs >= 1 && $tabs <= max($this->maxFields)) { - $this->inputTabs = $tabs; - foreach ($this->maxFields as $fieldName => $maxAmount) { - switch ($fieldName) { - case 'LINK': - case 'LINKLIST': - case 'MEDIA': - case 'MEDIALIST': - $this->maxFields[$fieldName] = floor($maxAmount / $this->inputTabs); - break; - } - } - } - } - /** * Fetch the template data. * @@ -288,14 +305,4 @@ private function getTemplatePath() { return $this->templatePath; } - - /** - * Set the path to the module templates. - * - */ - public function setTemplatePath($templatePath) - { - $this->templatePath = $templatePath; - } - } diff --git a/lib/Watson/Workflows/Module/ModuleGenerator.php b/lib/Watson/Workflows/Module/ModuleGenerator.php index 3623e56..cc2d487 100644 --- a/lib/Watson/Workflows/Module/ModuleGenerator.php +++ b/lib/Watson/Workflows/Module/ModuleGenerator.php @@ -8,14 +8,15 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Module; -use \Watson\Foundation\Documentation; -use \Watson\Foundation\Command; -use \Watson\Foundation\Result; -use \Watson\Foundation\ResultEntry; -use \Watson\Foundation\Watson; -use \Watson\Foundation\GeneratorWorkflow; +use Watson\Foundation\Command; +use Watson\Foundation\Documentation; +use Watson\Foundation\GeneratorWorkflow; +use Watson\Foundation\Result; +use Watson\Foundation\ResultEntry; +use Watson\Foundation\Watson; class ModuleGenerator extends GeneratorWorkflow { @@ -26,11 +27,10 @@ class ModuleGenerator extends GeneratorWorkflow */ public function commands() { - return array('m:make', 'module:make'); + return ['m:make', 'module:make']; } /** - * * @return Documentation */ public function documentation() @@ -46,18 +46,17 @@ public function documentation() } /** - * * @return array of registered page params */ public function registerPageParams() { - } /** - * Execute the command for the given Command + * Execute the command for the given Command. + * + * @param Command $command * - * @param Command $command * @return Result */ public function fire(Command $command) @@ -70,7 +69,7 @@ public function fire(Command $command) $moduleFields = isset($commandOptions['fields']) ? $commandOptions['fields'] : []; $moduleInputTabs = isset($commandOptions['tabs']) ? $commandOptions['tabs'] : 0; - $url = Watson::getUrl(array('page' => 'modules/modules', 'function' => 'add')); + $url = Watson::getUrl(['page' => 'modules/modules', 'function' => 'add']); $entry = new ResultEntry(); $entry->setLegend(Watson::translate('watson_module_legend')); @@ -80,7 +79,7 @@ public function fire(Command $command) //$entry->setUrl($url); //$entry->setQuickLookUrl($url); - $ajax = array(); + $ajax = []; $ajax['class'] = '\Watson\Workflows\Module\ModuleGenerator'; $ajax['method'] = 'call'; $ajax['params']['name'] = $moduleName; @@ -109,6 +108,6 @@ public static function call($params) */ protected function getTemplatePath() { - return __DIR__ . '/templates/'; + return __DIR__.'/templates/'; } } diff --git a/lib/Watson/Workflows/Module/ModuleProvider.php b/lib/Watson/Workflows/Module/ModuleProvider.php index 43d77b1..4ea929d 100644 --- a/lib/Watson/Workflows/Module/ModuleProvider.php +++ b/lib/Watson/Workflows/Module/ModuleProvider.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Module; use Watson\Foundation\GeneratorWorkflow; @@ -16,7 +17,6 @@ class ModuleProvider extends SupportProvider { - /** * Register the directory to search a translation file. * @@ -43,7 +43,6 @@ public function register() return $register; } - /** * Register module search. * @@ -54,7 +53,6 @@ public function registerModuleSearch() return new ModuleSearch(); } - /** * Register module generator. * diff --git a/lib/Watson/Workflows/Module/ModuleSearch.php b/lib/Watson/Workflows/Module/ModuleSearch.php index 8a02746..b3155d9 100644 --- a/lib/Watson/Workflows/Module/ModuleSearch.php +++ b/lib/Watson/Workflows/Module/ModuleSearch.php @@ -11,8 +11,8 @@ namespace Watson\Workflows\Module; -use Watson\Foundation\Documentation; use Watson\Foundation\Command; +use Watson\Foundation\Documentation; use Watson\Foundation\Result; use Watson\Foundation\ResultEntry; use Watson\Foundation\Watson; @@ -46,7 +46,7 @@ public function documentation() } /** - * Return array of registered page params + * Return array of registered page params. * * @return array */ @@ -66,12 +66,10 @@ public function fire(Command $command) { if ($command->getCommand() == 'm:inuse') { return $this->searchModuleInUse($command); - } else { - return $this->searchInModules($command); } + return $this->searchInModules($command); } - /** * Execute the command for the given Command. * @@ -91,8 +89,8 @@ protected function searchInModules(Command $command) $sql_query = ' SELECT id, name - FROM ' . Watson::getTable('module') . ' - WHERE ' . $command->getSqlWhere($fields) . ' + FROM '.Watson::getTable('module').' + WHERE '.$command->getSqlWhere($fields).' ORDER BY name'; $items = $this->getDatabaseResults($sql_query); @@ -122,7 +120,6 @@ protected function searchInModules(Command $command) return $result; } - /** * Execute the command for the given m:inuse Command. * @@ -134,21 +131,21 @@ protected function searchModuleInUse(Command $command) { $result = new Result(); - if ((int)$command->getArgument(1) > 0) { - $moduleId = (int)$command->getArgument(1); - $query = ' SELECT s.article_id AS id, + if ((int) $command->getArgument(1) > 0) { + $moduleId = (int) $command->getArgument(1); + $query = ' SELECT s.article_id AS id, s.clang_id, s.ctype_id, m.name AS module_name, CONCAT(s.article_id, "|", s.clang_id) as bulldog - FROM ' . Watson::getTable('article_slice') . ' AS s + FROM '.Watson::getTable('article_slice').' AS s LEFT JOIN - ' . Watson::getTable('article') . ' AS a + '.Watson::getTable('article').' AS a ON (s.article_id = a.id AND s.clang_id = a.clang_id) LEFT JOIN - ' . Watson::getTable('module') . ' AS m + '.Watson::getTable('module').' AS m ON s.module_id = m.id - WHERE s.module_id = "' . $moduleId . '" + WHERE s.module_id = "'.$moduleId.'" GROUP BY bulldog'; $items = $this->getDatabaseResults($query); @@ -160,7 +157,6 @@ protected function searchModuleInUse(Command $command) } } - // Ergebnisse auf Rechte prüfen und bereitstellen // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (count($searchResults)) { @@ -182,8 +178,8 @@ protected function searchModuleInUse(Command $command) $path[] = $article->getName(); } - $path = '/' . implode('/', $path); - $url = Watson::getUrl(array('page' => 'content/edit', 'article_id' => $article->getId(), 'mode' => 'edit', 'clang' => $clang_id, 'ctype' => $item['ctype_id'])); + $path = '/'.implode('/', $path); + $url = Watson::getUrl(['page' => 'content/edit', 'article_id' => $article->getId(), 'mode' => 'edit', 'clang' => $clang_id, 'ctype' => $item['ctype_id']]); $suffix = []; $suffix[] = $article->getId(); @@ -191,9 +187,9 @@ protected function searchModuleInUse(Command $command) $suffix[] = \rex_clang::get($clang_id)->getName(); } $suffix = implode(', ', $suffix); - $suffix = $suffix != '' ? '(' . $suffix . ')' : ''; + $suffix = $suffix != '' ? '('.$suffix.')' : ''; - $counter++; + ++$counter; $entry = new ResultEntry(); if ($counter == 1) { $entry->setLegend(str_replace('{0}', $item['module_name'], Watson::translate('watson_module_inuse_legend'))); @@ -202,11 +198,10 @@ protected function searchModuleInUse(Command $command) $entry->setDescription($path); $entry->setIcon('watson-icon-article'); $entry->setUrl($url); - $entry->setQuickLookUrl('../index.php?article_id=' . $article->getId() . '&clang=' . $article->getClang()); + $entry->setQuickLookUrl('../index.php?article_id='.$article->getId().'&clang='.$article->getClang()); $result->addEntry($entry); } - } } } diff --git a/lib/Watson/Workflows/Sprog/SprogProvider.php b/lib/Watson/Workflows/Sprog/SprogProvider.php index dd64920..9826fe8 100644 --- a/lib/Watson/Workflows/Sprog/SprogProvider.php +++ b/lib/Watson/Workflows/Sprog/SprogProvider.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Sprog; use Watson\Foundation\SupportProvider; @@ -15,7 +16,6 @@ class SprogProvider extends SupportProvider { - /** * Register the directory to search a translation file. * @@ -23,9 +23,7 @@ class SprogProvider extends SupportProvider */ public function i18n() { - return __DIR__; - } /** @@ -35,7 +33,7 @@ public function i18n() */ public function register() { - $register = array(); + $register = []; if (\rex_addon::get('sprog')->isAvailable() && \rex::getUser()->hasPerm('sprog[wildcard]')) { $register[] = $this->registerWildcardCreate(); @@ -45,7 +43,6 @@ public function register() return $register; } - /** * Register wildcard create. * @@ -56,7 +53,6 @@ public function registerWildcardCreate() return new WildcardCreate(); } - /** * Register wildcard search. * diff --git a/lib/Watson/Workflows/Sprog/WildcardCreate.php b/lib/Watson/Workflows/Sprog/WildcardCreate.php index ea5c486..8102dc3 100644 --- a/lib/Watson/Workflows/Sprog/WildcardCreate.php +++ b/lib/Watson/Workflows/Sprog/WildcardCreate.php @@ -8,14 +8,15 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Sprog; -use \Watson\Foundation\Documentation; -use \Watson\Foundation\Command; -use \Watson\Foundation\Result; -use \Watson\Foundation\ResultEntry; -use \Watson\Foundation\Watson; -use \Watson\Foundation\Workflow; +use Watson\Foundation\Command; +use Watson\Foundation\Documentation; +use Watson\Foundation\Result; +use Watson\Foundation\ResultEntry; +use Watson\Foundation\Watson; +use Watson\Foundation\Workflow; class WildcardCreate extends Workflow { @@ -26,11 +27,10 @@ class WildcardCreate extends Workflow */ public function commands() { - return array('sp:make', 'sp:miss'); + return ['sp:make', 'sp:miss']; } /** - * * @return Documentation */ public function documentation() @@ -45,7 +45,7 @@ public function documentation() } /** - * Return array of registered page params + * Return array of registered page params. * * @return array */ @@ -55,18 +55,18 @@ public function registerPageParams() } /** - * Execute the command for the given Command + * Execute the command for the given Command. + * + * @param Command $command * - * @param Command $command * @return Result */ public function fire(Command $command) { if ($command->getCommand() == 'sp:miss' && \rex_addon::get('structure')->isAvailable() && \rex_plugin::get('structure', 'content')->isAvailable()) { return $this->createMissingWildcard($command); - } else { - return $this->createWildcard($command); } + return $this->createWildcard($command); } public function createMissingWildcard(Command $command) @@ -80,7 +80,7 @@ public function createMissingWildcard(Command $command) $urlParams = [ 'page' => 'sprog/wildcard', - 'func' => 'add' + 'func' => 'add', ]; if (\Sprog\Wildcard::isClangSwitchMode()) { $urlParams['page'] = 'sprog/wildcard/clang1'; @@ -89,12 +89,12 @@ public function createMissingWildcard(Command $command) $urlParams['wildcard_name'] = $params['wildcard']; $url = Watson::getUrl($urlParams); - $counter++; + ++$counter; $entry = new ResultEntry(); if ($counter == 1) { $entry->setLegend(Watson::translate('watson_wildcard_legend_missing')); } - $entry->setValue( $params['wildcard'] ); + $entry->setValue($params['wildcard']); $entry->setDescription(Watson::translate('watson_wildcard_create_description')); $entry->setIcon('watson-icon-wildcard'); $entry->setUrl($url); @@ -106,20 +106,18 @@ public function createMissingWildcard(Command $command) return $result; } - public function createWildcard(Command $command) { $result = new Result(); $sql = \rex_sql::factory(); - $sql->setQuery('SELECT pid FROM ' . Watson::getTable('sprog_wildcard') . ' WHERE wildcard = "' . $command->getCommandPartsAsString() . '"'); - - if ($sql->getRows() == 0 && count($command->getOptions()) == 0 && in_array($command->getCommand(), $this->commands() )) { + $sql->setQuery('SELECT pid FROM '.Watson::getTable('sprog_wildcard').' WHERE wildcard = "'.$command->getCommandPartsAsString().'"'); + if ($sql->getRows() == 0 && count($command->getOptions()) == 0 && in_array($command->getCommand(), $this->commands())) { $urlParams = [ 'page' => 'sprog/wildcard', 'func' => 'add', - 'wildcard_name' => $command->getCommandPartsAsString(), + 'wildcard_name' => $command->getCommandPartsAsString(), ]; if (\Sprog\Wildcard::isClangSwitchMode()) { $urlParams['page'] = 'sprog/wildcard/clang1'; @@ -129,7 +127,7 @@ public function createWildcard(Command $command) $entry = new ResultEntry(); $entry->setLegend(Watson::translate('watson_wildcard_legend_create')); - $entry->setValue( $command->getCommandPartsAsString() ); + $entry->setValue($command->getCommandPartsAsString()); $entry->setDescription(Watson::translate('watson_wildcard_create_description')); $entry->setIcon('watson-icon-wildcard'); $entry->setUrl($url); @@ -139,5 +137,4 @@ public function createWildcard(Command $command) } return $result; } - } diff --git a/lib/Watson/Workflows/Sprog/WildcardSearch.php b/lib/Watson/Workflows/Sprog/WildcardSearch.php index f8935c0..963e31c 100644 --- a/lib/Watson/Workflows/Sprog/WildcardSearch.php +++ b/lib/Watson/Workflows/Sprog/WildcardSearch.php @@ -8,14 +8,15 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Sprog; -use \Watson\Foundation\Documentation; -use \Watson\Foundation\Command; -use \Watson\Foundation\Result; -use \Watson\Foundation\ResultEntry; -use \Watson\Foundation\Watson; -use \Watson\Foundation\Workflow; +use Watson\Foundation\Command; +use Watson\Foundation\Documentation; +use Watson\Foundation\Result; +use Watson\Foundation\ResultEntry; +use Watson\Foundation\Watson; +use Watson\Foundation\Workflow; class WildcardSearch extends Workflow { @@ -26,11 +27,10 @@ class WildcardSearch extends Workflow */ public function commands() { - return array('sp'); + return ['sp']; } /** - * * @return Documentation */ public function documentation() @@ -45,7 +45,7 @@ public function documentation() } /** - * Return array of registered page params + * Return array of registered page params. * * @return array */ @@ -55,42 +55,40 @@ public function registerPageParams() } /** - * Execute the command for the given Command + * Execute the command for the given Command. + * + * @param Command $command * - * @param Command $command * @return Result */ public function fire(Command $command) { - $result = new Result(); - $fields = array( + $fields = [ '`wildcard`', '`replace`', - ); + ]; - $sql_query = ' SELECT id, + $sql_query = ' SELECT id, clang_id, wildcard, `replace` - FROM ' . Watson::getTable('sprog_wildcard') . ' - WHERE ' . $command->getSqlWhere($fields) . ' + FROM '.Watson::getTable('sprog_wildcard').' + WHERE '.$command->getSqlWhere($fields).' ORDER BY wildcard'; $items = $this->getDatabaseResults($sql_query); if (count($items)) { - $counter = 0; $clangs = \rex_clang::getAll(); foreach ($items as $item) { + $url = Watson::getUrl(['page' => 'sprog/wildcard', 'wildcard_id' => $item['id'], 'func' => 'edit']); - $url = Watson::getUrl(array('page' => 'sprog/wildcard', 'wildcard_id' => $item['id'], 'func' => 'edit')); - - $counter++; + ++$counter; $entry = new ResultEntry(); if ($counter == 1) { @@ -99,14 +97,14 @@ public function fire(Command $command) $value = $item['wildcard']; $value_suffix = ''; - if (isset($clangs[ $item['clang_id'] ])) { - $value_suffix .= ' › ' . $clangs[ $item['clang_id'] ]->getCode(); + if (isset($clangs[$item['clang_id']])) { + $value_suffix .= ' › '.$clangs[$item['clang_id']]->getCode(); } if ($item['replace'] != '') { - $value_suffix .= ' › ' . $item['replace']; + $value_suffix .= ' › '.$item['replace']; } - $entry->setValue( $value ); + $entry->setValue($value); $entry->setValueSuffix($value_suffix); $entry->setDescription(Watson::translate('watson_open_wildcard')); $entry->setIcon('watson-icon-wildcard'); @@ -114,11 +112,9 @@ public function fire(Command $command) $entry->setQuickLookUrl($url); $result->addEntry($entry); - } } return $result; } - } diff --git a/lib/Watson/Workflows/Structure/ArticleSearch.php b/lib/Watson/Workflows/Structure/ArticleSearch.php index 29607fe..8e1cc7e 100644 --- a/lib/Watson/Workflows/Structure/ArticleSearch.php +++ b/lib/Watson/Workflows/Structure/ArticleSearch.php @@ -8,14 +8,15 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Structure; -use \Watson\Foundation\Documentation; -use \Watson\Foundation\Command; -use \Watson\Foundation\Result; -use \Watson\Foundation\ResultEntry; -use \Watson\Foundation\Watson; -use \Watson\Foundation\Workflow; +use Watson\Foundation\Command; +use Watson\Foundation\Documentation; +use Watson\Foundation\Result; +use Watson\Foundation\ResultEntry; +use Watson\Foundation\Watson; +use Watson\Foundation\Workflow; class ArticleSearch extends Workflow { @@ -26,11 +27,10 @@ class ArticleSearch extends Workflow */ public function commands() { - return array('a'); + return ['a']; } /** - * * @return Documentation */ public function documentation() @@ -45,7 +45,7 @@ public function documentation() } /** - * Return array of registered page params + * Return array of registered page params. * * @return array */ @@ -55,41 +55,38 @@ public function registerPageParams() } /** - * Execute the command for the given Command + * Execute the command for the given Command. + * + * @param Command $command * - * @param Command $command * @return Result */ public function fire(Command $command) { - $result = new Result(); - - $searchResults = array(); + $searchResults = []; $command_parts = $command->getCommandParts(); // Artikelnamen und Id in der Struktur durchsuchen // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $fields = array( + $fields = [ 'a.id', 'a.name', - ); + ]; $where = $command->getSqlWhere($fields); - if (count($command_parts) == 1 && (int)$command_parts[0] >= 1) { - - $where = 'a.id = "' . (int)$command_parts[0] .'"'; - + if (count($command_parts) == 1 && (int) $command_parts[0] >= 1) { + $where = 'a.id = "'.(int) $command_parts[0].'"'; } - $sql_query = ' SELECT a.id, + $sql_query = ' SELECT a.id, a.clang_id, CONCAT(a.id, "|", a.clang_id) as bulldog - FROM ' . Watson::getTable('article') . ' AS a - WHERE ' . $where . ' + FROM '.Watson::getTable('article').' AS a + WHERE '.$where.' GROUP BY bulldog '; @@ -97,76 +94,60 @@ public function fire(Command $command) if (count($items)) { foreach ($items as $item) { - - $searchResults[ $item['bulldog'] ] = $item; - + $searchResults[$item['bulldog']] = $item; } } - - // Slices der Artikel durchsuchen // Werden Slices gefunden, dann die Strukturartikel überschreiben // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $fields = array( - 's.value' => range('1', '20'), - 's.media' => range('1', '10'), + $fields = [ + 's.value' => range('1', '20'), + 's.media' => range('1', '10'), 's.medialist' => range('1', '10'), - ); + ]; - $searchFields = array(); + $searchFields = []; foreach ($fields as $field => $numbers) { - foreach ($numbers as $number) { - - $searchFields[] = $field . $number; - + $searchFields[] = $field.$number; } - } - $fields = $searchFields; - $sql_query = ' SELECT s.article_id AS id, + $sql_query = ' SELECT s.article_id AS id, s.clang_id, s.ctype_id, CONCAT(s.article_id, "|", s.clang_id) as bulldog - FROM ' . Watson::getTable('article_slice') . ' AS s + FROM '.Watson::getTable('article_slice').' AS s LEFT JOIN - ' . Watson::getTable('article') . ' AS a + '.Watson::getTable('article').' AS a ON (s.article_id = a.id AND s.clang_id = a.clang_id) - WHERE ' . $command->getSqlWhere($fields) . ' + WHERE '.$command->getSqlWhere($fields).' GROUP BY bulldog'; $items = $this->getDatabaseResults($sql_query); if (count($items)) { foreach ($items as $item) { - - $searchResults[ $item['bulldog'] ] = $item; - + $searchResults[$item['bulldog']] = $item; } } - // Ergebnisse auf Rechte prüfen und bereitstellen // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (count($searchResults)) { - $counter = 0; foreach ($searchResults as $item) { - - $clang_id = $item['clang_id']; - $article = \rex_article::get($item['id'], $clang_id); + $clang_id = $item['clang_id']; + $article = \rex_article::get($item['id'], $clang_id); $category_id = $article->getCategoryId(); - // Rechte prüfen if (\rex::getUser()->getComplexPerm('clang')->hasPerm($clang_id) && \rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($category_id)) { - - $path = array(); + $path = []; $tree = $article->getParentTree(); foreach ($tree as $o) { @@ -177,28 +158,24 @@ public function fire(Command $command) $path[] = $article->getName(); } - $path = '/' . implode('/', $path); - + $path = '/'.implode('/', $path); - $url = Watson::getUrl(array('page' => 'structure', 'category_id' => $article->getCategoryId(), 'clang' => $clang_id)); + $url = Watson::getUrl(['page' => 'structure', 'category_id' => $article->getCategoryId(), 'clang' => $clang_id]); if (isset($item['ctype_id'])) { - - $url = Watson::getUrl(array('page' => 'content/edit', 'article_id' => $article->getId(), 'mode' => 'edit', 'clang' => $clang_id, 'ctype' => $item['ctype_id'])); - + $url = Watson::getUrl(['page' => 'content/edit', 'article_id' => $article->getId(), 'mode' => 'edit', 'clang' => $clang_id, 'ctype' => $item['ctype_id']]); } - - $suffix = array(); + $suffix = []; $suffix[] = $article->getId(); if (count(\rex_clang::getAll()) > 1) { $suffix[] = \rex_clang::get($clang_id)->getName(); } $suffix = implode(', ', $suffix); - $suffix = $suffix != '' ? '(' . $suffix . ')' : ''; + $suffix = $suffix != '' ? '('.$suffix.')' : ''; - $counter++; + ++$counter; $entry = new ResultEntry(); if ($counter == 1) { @@ -208,15 +185,13 @@ public function fire(Command $command) $entry->setDescription($path); $entry->setIcon('watson-icon-article'); $entry->setUrl($url); - $entry->setQuickLookUrl('../index.php?article_id=' . $article->getId() . '&clang=' . $article->getClang()); + $entry->setQuickLookUrl('../index.php?article_id='.$article->getId().'&clang='.$article->getClang()); $result->addEntry($entry); } - } } return $result; } - } diff --git a/lib/Watson/Workflows/Structure/CategoryData.php b/lib/Watson/Workflows/Structure/CategoryData.php index dc69f41..7be5700 100644 --- a/lib/Watson/Workflows/Structure/CategoryData.php +++ b/lib/Watson/Workflows/Structure/CategoryData.php @@ -50,5 +50,4 @@ public function create() } echo json_encode(['url' => \rex_url::backendPage('structure', ['category_id' => $this->categoryId, 'clang' => $this->clangId], false)]); } - } diff --git a/lib/Watson/Workflows/Structure/CategoryGenerator.php b/lib/Watson/Workflows/Structure/CategoryGenerator.php index 22e088b..53c0071 100644 --- a/lib/Watson/Workflows/Structure/CategoryGenerator.php +++ b/lib/Watson/Workflows/Structure/CategoryGenerator.php @@ -8,14 +8,15 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Structure; -use \Watson\Foundation\Documentation; -use \Watson\Foundation\Command; -use \Watson\Foundation\Result; -use \Watson\Foundation\ResultEntry; -use \Watson\Foundation\Watson; -use \Watson\Foundation\GeneratorWorkflow; +use Watson\Foundation\Command; +use Watson\Foundation\Documentation; +use Watson\Foundation\GeneratorWorkflow; +use Watson\Foundation\Result; +use Watson\Foundation\ResultEntry; +use Watson\Foundation\Watson; class CategoryGenerator extends GeneratorWorkflow { @@ -26,11 +27,10 @@ class CategoryGenerator extends GeneratorWorkflow */ public function commands() { - return array('c:make'); + return ['c:make']; } /** - * * @return Documentation */ public function documentation() @@ -41,28 +41,28 @@ public function documentation() } /** - * * @return array of registered page params */ public function registerPageParams() { - return array('category_id', 'clang'); + return ['category_id', 'clang']; } /** - * Execute the command for the given Command + * Execute the command for the given Command. + * + * @param Command $command * - * @param Command $command * @return Result */ public function fire(Command $command) { //$category_id = rex_request('category_id', 'int'); $categoryId = Watson::getRegisteredPageParam('category_id'); - $categoryId = (int)$categoryId > 0 ? $categoryId : 0; + $categoryId = (int) $categoryId > 0 ? $categoryId : 0; $clangId = Watson::getRegisteredPageParam('clang'); - $clangId = (int)$clangId > 0 ? $clangId : 1; + $clangId = (int) $clangId > 0 ? $clangId : 1; $categoriesAsString = implode(',', $command->getArguments()); $commandOptions = $command->getOptions(); @@ -75,7 +75,7 @@ public function fire(Command $command) $entry->setDescription(Watson::translate('watson_structure_add_categories')); $entry->setIcon('watson-icon-category'); - $ajax = array(); + $ajax = []; $ajax['class'] = '\Watson\Workflows\Structure\CategoryGenerator'; $ajax['method'] = 'call'; $ajax['params']['categories'] = $categoriesAsString; diff --git a/lib/Watson/Workflows/Structure/StructureProvider.php b/lib/Watson/Workflows/Structure/StructureProvider.php index 8647032..7be4055 100644 --- a/lib/Watson/Workflows/Structure/StructureProvider.php +++ b/lib/Watson/Workflows/Structure/StructureProvider.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Structure; use Watson\Foundation\GeneratorWorkflow; @@ -16,7 +17,6 @@ class StructureProvider extends SupportProvider { - /** * Register the directory to search a translation file. * @@ -34,7 +34,7 @@ public function i18n() */ public function register() { - $register = array(); + $register = []; $register[] = $this->registerArticleSearch(); if (\rex::getUser()->isAdmin()) { @@ -44,7 +44,6 @@ public function register() return $register; } - /** * Register article search. * @@ -55,7 +54,6 @@ public function registerArticleSearch() return new ArticleSearch(); } - /** * Register category generator. * diff --git a/lib/Watson/Workflows/Template/TemplateProvider.php b/lib/Watson/Workflows/Template/TemplateProvider.php index e52fb92..5ffd879 100644 --- a/lib/Watson/Workflows/Template/TemplateProvider.php +++ b/lib/Watson/Workflows/Template/TemplateProvider.php @@ -8,14 +8,14 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Template; -use \Watson\Foundation\SupportProvider; +use Watson\Foundation\SupportProvider; use Watson\Foundation\Workflow; class TemplateProvider extends SupportProvider { - /** * Register the directory to search a translation file. * @@ -39,7 +39,6 @@ public function register() return []; } - /** * Register template search. * @@ -49,6 +48,4 @@ public function registerTemplateSearch() { return new TemplateSearch(); } - - } diff --git a/lib/Watson/Workflows/Template/TemplateSearch.php b/lib/Watson/Workflows/Template/TemplateSearch.php index f3ea95a..c9d8060 100644 --- a/lib/Watson/Workflows/Template/TemplateSearch.php +++ b/lib/Watson/Workflows/Template/TemplateSearch.php @@ -8,14 +8,15 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\Template; -use \Watson\Foundation\Documentation; -use \Watson\Foundation\Command; -use \Watson\Foundation\Result; -use \Watson\Foundation\ResultEntry; -use \Watson\Foundation\Watson; -use \Watson\Foundation\Workflow; +use Watson\Foundation\Command; +use Watson\Foundation\Documentation; +use Watson\Foundation\Result; +use Watson\Foundation\ResultEntry; +use Watson\Foundation\Watson; +use Watson\Foundation\Workflow; class TemplateSearch extends Workflow { @@ -26,11 +27,10 @@ class TemplateSearch extends Workflow */ public function commands() { - return array('t'); + return ['t']; } /** - * * @return Documentation */ public function documentation() @@ -45,7 +45,7 @@ public function documentation() } /** - * Return array of registered page params + * Return array of registered page params. * * @return array */ @@ -55,37 +55,36 @@ public function registerPageParams() } /** - * Execute the command for the given Command + * Execute the command for the given Command. + * + * @param Command $command * - * @param Command $command * @return Result */ public function fire(Command $command) { $result = new Result(); - $fields = array( + $fields = [ 'name', 'content', - ); + ]; - $sql_query = ' SELECT id, + $sql_query = ' SELECT id, name - FROM ' . Watson::getTable('template') . ' - WHERE ' . $command->getSqlWhere($fields) . ' + FROM '.Watson::getTable('template').' + WHERE '.$command->getSqlWhere($fields).' ORDER BY name'; $items = $this->getDatabaseResults($sql_query); if (count($items)) { - $counter = 0; foreach ($items as $item) { + $url = Watson::getUrl(['page' => 'templates', 'template_id' => $item['id'], 'function' => 'edit']); - $url = Watson::getUrl(array('page' => 'templates', 'template_id' => $item['id'], 'function' => 'edit')); - - $counter++; + ++$counter; $entry = new ResultEntry(); if ($counter == 1) { @@ -98,12 +97,9 @@ public function fire(Command $command) $entry->setQuickLookUrl($url); $result->addEntry($entry); - } } - return $result; } - } diff --git a/lib/Watson/Workflows/YForm/YFormProvider.php b/lib/Watson/Workflows/YForm/YFormProvider.php index 65abaf2..4651fa9 100644 --- a/lib/Watson/Workflows/YForm/YFormProvider.php +++ b/lib/Watson/Workflows/YForm/YFormProvider.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\YForm; use Watson\Foundation\SupportProvider; @@ -15,7 +16,6 @@ class YFormProvider extends SupportProvider { - /** * Register the directory to search a translation file. * @@ -48,5 +48,4 @@ public function registerYFormSearch() { return new YFormSearch(); } - } diff --git a/lib/Watson/Workflows/YForm/YFormSearch.php b/lib/Watson/Workflows/YForm/YFormSearch.php index 6a0a086..92d42da 100644 --- a/lib/Watson/Workflows/YForm/YFormSearch.php +++ b/lib/Watson/Workflows/YForm/YFormSearch.php @@ -8,14 +8,15 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Watson\Workflows\YForm; -use \Watson\Foundation\Documentation; -use \Watson\Foundation\Command; -use \Watson\Foundation\Result; -use \Watson\Foundation\ResultEntry; -use \Watson\Foundation\Watson; -use \Watson\Foundation\Workflow; +use Watson\Foundation\Command; +use Watson\Foundation\Documentation; +use Watson\Foundation\Result; +use Watson\Foundation\ResultEntry; +use Watson\Foundation\Watson; +use Watson\Foundation\Workflow; class YFormSearch extends Workflow { @@ -26,11 +27,10 @@ class YFormSearch extends Workflow */ public function commands() { - return array('yf'); + return ['yf']; } /** - * * @return Documentation */ public function documentation() @@ -44,7 +44,7 @@ public function documentation() } /** - * Return array of registered page params + * Return array of registered page params. * * @return array */ @@ -54,9 +54,10 @@ public function registerPageParams() } /** - * Execute the command for the given Command + * Execute the command for the given Command. + * + * @param Command $command * - * @param Command $command * @return Result */ public function fire(Command $command) @@ -83,18 +84,18 @@ public function fire(Command $command) $selectFields = 'id'; foreach ($viewFields as $viewField) { if (isset($fields[$viewField])) { - $selectFields .= ', ' . $viewField . ' AS name'; + $selectFields .= ', '.$viewField.' AS name'; break; } } $searchFields = array_keys($fields); $orderByField = $table->getSortFieldName(); - $query = ' - SELECT ' . $selectFields .' - FROM ' . $table . ' - WHERE ' . $command->getSqlWhere($searchFields) . ' - ORDER BY ' . $orderByField; + $query = ' + SELECT '.$selectFields.' + FROM '.$table.' + WHERE '.$command->getSqlWhere($searchFields).' + ORDER BY '.$orderByField; $results[$table->getTableName()] = $this->getDatabaseResults($query); } @@ -106,15 +107,15 @@ public function fire(Command $command) $counter = 0; foreach ($items as $item) { - $url = Watson::getUrl(array('page' => 'yform/manager/data_edit', 'table_name' => $tableName, 'data_id' => $item['id'], 'func' => 'edit')); - $counter++; + $url = Watson::getUrl(['page' => 'yform/manager/data_edit', 'table_name' => $tableName, 'data_id' => $item['id'], 'func' => 'edit']); + ++$counter; $entry = new ResultEntry(); if ($counter == 1) { - $entry->setLegend(Watson::translate('watson_yform_legend') . ' :: ' . $tableName); + $entry->setLegend(Watson::translate('watson_yform_legend').' :: '.$tableName); } if (isset($item['name'])) { - $entry->setValue($item['name'], '(' . $item['id'] . ')'); + $entry->setValue($item['name'], '('.$item['id'].')'); } else { $entry->setValue($item['id']); } @@ -124,7 +125,6 @@ public function fire(Command $command) $entry->setQuickLookUrl($url); $result->addEntry($entry); - } } } diff --git a/package.php b/package.php index e8c1298..ce94e5b 100644 --- a/package.php +++ b/package.php @@ -1,254 +1,222 @@ 'watson', - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Application Title - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Application Title + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ 'title' => 'Watson', - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Version - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ 'version' => '0.1', - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Author - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ 'author' => 'Thomas Blum', - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Support Page - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ 'supportpage' => '', - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Permission - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ 'permission' => 'watson[]', - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Permission Options - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ - 'permission_options' => array( - - ), + 'permission_options' => [ + ], - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Permission Startpage - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ 'permission_startpage' => 'watson[]', - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Min REDAXO Version - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ 'rex_version' => '4.5', - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Min PHP Version - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ 'php_version' => '5.3', - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application AddOns Required * key = The key is the required addon name. * value = The value is the required version of the addon. - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ - 'required_addons' => array( - - - ), + 'required_addons' => [ + ], - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Subpages * key = The key is translated with prefixed name. * value = The value is the url subpage parameter. - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ - 'subpages' => array( - - 'first' => '', - 'second' => 'second-param', - 'third' => array('third-1', 'third-2', ), - - ), + 'subpages' => [ + 'first' => '', + 'second' => 'second-param', + 'third' => ['third-1', 'third-2'], + ], - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Classes Files - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ - 'classes' => array( - - 'lib/Watson/Foundation/Command.php', - 'lib/Watson/Foundation/Console.php', - 'lib/Watson/Foundation/ConsoleCommand.php', - 'lib/Watson/Foundation/Documentation.php', - 'lib/Watson/Foundation/Extension.php', - 'lib/Watson/Foundation/Search.php', - 'lib/Watson/Foundation/SearchCommand.php', - 'lib/Watson/Foundation/SearchResult.php', - 'lib/Watson/Foundation/SearchResultEntry.php', - 'lib/Watson/Foundation/SupportProvider.php', - 'lib/Watson/Foundation/Watson.php', + 'classes' => [ + 'lib/Watson/Foundation/Command.php', + 'lib/Watson/Foundation/Console.php', + 'lib/Watson/Foundation/ConsoleCommand.php', + 'lib/Watson/Foundation/Documentation.php', + 'lib/Watson/Foundation/Extension.php', + 'lib/Watson/Foundation/Search.php', + 'lib/Watson/Foundation/SearchCommand.php', + 'lib/Watson/Foundation/SearchResult.php', + 'lib/Watson/Foundation/SearchResultEntry.php', + 'lib/Watson/Foundation/SupportProvider.php', + 'lib/Watson/Foundation/Watson.php', - 'lib/Watson/Media/MediaSearch.php', - 'lib/Watson/Media/MediaProvider.php', + 'lib/Watson/Media/MediaSearch.php', + 'lib/Watson/Media/MediaProvider.php', - 'lib/Watson/Module/ModuleSearch.php', - 'lib/Watson/Module/ModuleProvider.php', + 'lib/Watson/Module/ModuleSearch.php', + 'lib/Watson/Module/ModuleProvider.php', - 'lib/Watson/Structure/ArticleSearch.php', - 'lib/Watson/Structure/StructureProvider.php', + 'lib/Watson/Structure/ArticleSearch.php', + 'lib/Watson/Structure/StructureProvider.php', - 'lib/Watson/Template/TemplateConsole.php', - 'lib/Watson/Template/TemplateSearch.php', - 'lib/Watson/Template/TemplateProvider.php', + 'lib/Watson/Template/TemplateConsole.php', + 'lib/Watson/Template/TemplateSearch.php', + 'lib/Watson/Template/TemplateProvider.php', + ], - - ), - - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Class Aliases - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ - 'aliases' => array( - - ), + 'aliases' => [ + ], /** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Providers - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ - 'providers' => array( - - 'Watson\Media\MediaProvider', - 'Watson\Module\ModuleProvider', - 'Watson\Structure\StructureProvider', - 'Watson\Template\TemplateProvider', - - ), + 'providers' => [ + 'Watson\Media\MediaProvider', + 'Watson\Module\ModuleProvider', + 'Watson\Structure\StructureProvider', + 'Watson\Template\TemplateProvider', + ], - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application CSS Files - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ - 'stylesheets' => array( - 'facebox.css', + 'stylesheets' => [ + 'facebox.css', 'watson.css', /* - 'jquery.terminal.css', + 'jquery.terminal.css', */ - ), + ], - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Javascript Files - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ - 'javascripts' => array( - - 'facebox.js', - 'hogan-3.0.2.min.js', - 'typeahead.bundle.js', + 'javascripts' => [ + 'facebox.js', + 'hogan-3.0.2.min.js', + 'typeahead.bundle.js', 'watson_searcher.js', - /* - //'jquery.terminal-min.js', - 'jquery.terminal.js', - 'json-rpc.js', + /* + //'jquery.terminal-min.js', + 'jquery.terminal.js', + 'json-rpc.js', 'watson_console.js', */ - ), - + ], - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Javascript Properties - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ - 'javascript_properties' => array( - - '', - - ), + 'javascript_properties' => [ + '', + ], - - /** - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + /** + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Application Extensions - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. */ - 'extensions' => array( -// '\Iffi\File::panel' => array('OUTPUT_FILTER', ), + 'extensions' => [ +// '\Iffi\File::panel' => array('OUTPUT_FILTER', ), /* - '\Watson\Feature\FeatureAgent::panel' => array('OUTPUT_FILTER', ), - '\Watson\Feature\FeatureAgent::register' => array('ADDONS_INCLUDED', array(), REX_EXTENSION_LATE, ), - '\Watson\Feature\FeatureAgent::run' => array('ADDONS_INCLUDED', array(), REX_EXTENSION_LATE, ), + '\Watson\Feature\FeatureAgent::panel' => array('OUTPUT_FILTER', ), + '\Watson\Feature\FeatureAgent::register' => array('ADDONS_INCLUDED', array(), REX_EXTENSION_LATE, ), + '\Watson\Feature\FeatureAgent::run' => array('ADDONS_INCLUDED', array(), REX_EXTENSION_LATE, ), */ - ), - -); \ No newline at end of file + ], +]; diff --git a/pages/index.php b/pages/index.php index b494410..da5ea1a 100644 --- a/pages/index.php +++ b/pages/index.php @@ -11,6 +11,6 @@ $subpage = rex_be_controller::getCurrentPagePart(2); -echo rex_view::title(rex_i18n::msg('watson_title') . ' ' . $this->getVersion() . ''); +echo rex_view::title(rex_i18n::msg('watson_title').' '.$this->getVersion().''); include rex_be_controller::getCurrentPageObject()->getSubPath(); diff --git a/pages/settings.php b/pages/settings.php index 45d797a..94b9400 100644 --- a/pages/settings.php +++ b/pages/settings.php @@ -8,9 +8,8 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -namespace Watson\Foundation; -use \Watson\Foundation\Watson; +namespace Watson\Foundation; $content = ''; @@ -35,11 +34,10 @@ $formElements = []; $n = []; - $n['label'] = ''; - $n['field'] = ''; + $n['label'] = ''; + $n['field'] = ''; $formElements[] = $n; - $agentHotkeysSelect = new \rex_select(); $agentHotkeysSelect->setName('agentHotkey'); $agentHotkeysSelect->setSize(1); @@ -51,11 +49,10 @@ $agentHotkeysSelect->setSelected(Watson::getAgentHotkey()); $n = []; - $n['label'] = ''; + $n['label'] = ''; $n['field'] = $agentHotkeysSelect->get(); $formElements[] = $n; - $quicklookHotkeysSelect = new \rex_select(); $quicklookHotkeysSelect->setName('quicklookHotkey'); $quicklookHotkeysSelect->setSize(1); @@ -67,11 +64,10 @@ $quicklookHotkeysSelect->setSelected(Watson::getQuicklookHotkey()); $n = []; - $n['label'] = ''; + $n['label'] = ''; $n['field'] = $quicklookHotkeysSelect->get(); $formElements[] = $n; - $toggleButtonSelect = new \rex_select(); $toggleButtonSelect->setName('toggleButton'); $toggleButtonSelect->setSize(1); @@ -82,12 +78,10 @@ $toggleButtonSelect->setSelected(Watson::getToggleButtonStatus()); $n = []; - $n['label'] = ''; + $n['label'] = ''; $n['field'] = $toggleButtonSelect->get(); $formElements[] = $n; - - $fragment = new \rex_fragment(); $fragment->setVar('flush', true); $fragment->setVar('elements', $formElements, false); @@ -96,11 +90,11 @@ $formElements = []; $n = []; - $n['field'] = '' . \rex_i18n::msg('form_abort') . ''; + $n['field'] = ''.\rex_i18n::msg('form_abort').''; $formElements[] = $n; $n = []; - $n['field'] = ''; + $n['field'] = ''; $formElements[] = $n; $fragment = new \rex_fragment(); @@ -118,8 +112,8 @@ $content = $fragment->parse('core/page/section.php'); $content = ' -
- ' . $content . ' + + '.$content.'
';