/**
  * Generate all required data from _POST
  *
  * @return array
  * @throws \Exception
  */
 protected function getMappedArguments()
 {
     $requiredArgs = array('client' => 'Prefix', 'tool-title' => 'Tool title', 'transparent' => '(1 or 0)', 'rotatable' => '(1 or 0)', 'movable' => '(1 or 0)', 'adjustable-x' => '(1 or 0)', 'adjustable-y' => '(1 or 0)');
     $argHelp = "<p>Required arguments are:</p><ul>";
     foreach ($requiredArgs as $key => $value) {
         $argHelp .= '<li>' . $key . ': ' . $value . '</li>';
     }
     $argHelp .= '</ul>';
     foreach ($requiredArgs as $key => $value) {
         // !string '0' is a valid entry!
         if (!isset($_POST[$key]) || $_POST[$key] === '') {
             throw new \Exception($argHelp);
             break;
         }
         // trim all, cast 0|1 to bool
         $_POST[$key] = trim($_POST[$key]);
         if (in_array($_POST[$key], array('0', '1'))) {
             $_POST[$key] = (bool) $_POST[$key];
         }
     }
     $_POST['client'] = strtoupper($_POST['client']);
     $_POST['tool-base'] = StringUtils::removeSpecChars($_POST['tool-title']);
     $_POST['tool-fn'] = StringUtils::camelize($_POST['tool-base']);
     $_POST['tool-obj'] = ucfirst($_POST['tool-fn']);
     $_POST['tool-id'] = strtolower($_POST['client']) . $_POST['tool-obj'];
     $_POST['is-transparent'] = json_encode($_POST['transparent']);
     $_POST['is-rotatable-tl'] = json_encode($_POST['rotatable']);
     // default position of rotator
     // only visible when not adjustable
     $_POST['is-rotatable-tr'] = json_encode($_POST['rotatable'] && (!$_POST['adjustable-x'] && !$_POST['adjustable-y']));
     $_POST['is-rotatable-br'] = json_encode($_POST['rotatable'] && (!$_POST['adjustable-x'] && !$_POST['adjustable-y']));
     $_POST['is-rotatable-bl'] = json_encode($_POST['rotatable']);
     // also default position of rotator
     // alternative positions, need to be configured manually
     $_POST['is-rotatable-t'] = json_encode(false);
     $_POST['is-rotatable-r'] = json_encode(false);
     $_POST['is-rotatable-b'] = json_encode(false);
     $_POST['is-rotatable-l'] = json_encode(false);
     $_POST['is-movable'] = json_encode($_POST['movable']);
     $_POST['is-adjustable-x'] = json_encode($_POST['adjustable-x']);
     $_POST['is-adjustable-y'] = json_encode($_POST['adjustable-y']);
     $_POST['is-adjustable-xy'] = json_encode($_POST['adjustable-x'] && $_POST['adjustable-y']);
     unset($_POST['transparent']);
     unset($_POST['rotatable']);
     unset($_POST['movable']);
     unset($_POST['adjustable-x']);
     unset($_POST['adjustable-y']);
     return $_POST;
 }
 /**
  * Adds sample code for theme support
  */
 protected function addSampleTheme()
 {
     // replacements
     $values = array('{themeLabel}' => $this->label . ' default theme', '{themeId}' => StringUtils::camelize($this->label . ' default theme'), '{platformTheme}' => StringUtils::camelize($this->label . ' default theme', true));
     $pathValues = array();
     foreach ($values as $key => $value) {
         $pathValues[trim($key, '{}')] = $value;
     }
     // copy templates
     $samplePath = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDevTools')->getDir() . 'models' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
     $paths = array(array('model', 'theme', '*.sample'), array('scripts', 'install', '*.sample'), array('views', 'templates', 'themes', 'platform', 'themeId', '*.sample'), array('views', 'scss', 'themes', 'items', '*.sample'), array('views', 'scss', 'themes', 'platform', 'themeId', '*.sample'));
     $templates = array();
     foreach ($paths as $path) {
         $templates = array_merge($templates, glob($samplePath . implode(DIRECTORY_SEPARATOR, $path)));
     }
     foreach ($templates as $template) {
         $template = \tao_helpers_File::getRelPath($samplePath, $template);
         $template = substr($template, 0, strrpos($template, '.'));
         $this->copyFile($template, str_replace(array_keys($pathValues), $pathValues, $template), $values);
     }
 }