Esempio n. 1
0
 public function process($data, $sep = ",", $start = "", $end = "")
 {
     if (empty($end)) {
         $end = $start;
     }
     return \ATP\MapReduce::process($data, new \ATP\Mapper\Wrapper($start, $end), new \ATP\Reducer\Concatenate($sep), "");
 }
Esempio n. 2
0
 public function __invoke($params)
 {
     $attributes = \ATP\MapReduce::process($params, function ($item, $index) {
         return "{$index}=\"{$item}\"";
     }, new \ATP\Reducer\Concatenate(" "));
     $html = "<input type=\"hidden\" {$attributes} />";
     return $html;
 }
Esempio n. 3
0
 public function toJson()
 {
     $json = "{";
     $json .= \ATP\MapReduce::process($this->toArray(), function ($obj) {
         return "\"" . $obj->id . "\": " . $obj->toJson();
     }, new \ATP\Reducer\Concatenate(","));
     $json .= "}";
     return $json;
 }
Esempio n. 4
0
 public function __invoke($params)
 {
     $label = $params['label'];
     unset($params['label']);
     $attributes = \ATP\MapReduce::process($params, function ($item, $index) {
         return "{$index}=\"{$item}\"";
     }, new \ATP\Reducer\Concatenate(" "));
     $html = "<label for=\"{$params['name']}\">{$label}</label>";
     $html .= "<input type=\"password\" {$attributes} />";
     return $html;
 }
Esempio n. 5
0
 public function __invoke($params)
 {
     $label = $params['label'];
     unset($params['label']);
     $params['value'] = str_replace(['{', '}'], ['\\{', '\\}'], htmlspecialchars($params['value']));
     $attributes = \ATP\MapReduce::process($params, function ($item, $index) {
         return "{$index}=\"{$item}\"";
     }, new \ATP\Reducer\Concatenate(" "));
     $html = "<label for=\"{$params['name']}\">{$label}</label>";
     $html .= "<input type=\"text\" {$attributes} />";
     return $html;
 }
Esempio n. 6
0
 public function __invoke($params)
 {
     $label = $params['label'];
     unset($params['label']);
     $text = isset($params['value']) ? $params['value'] : "";
     unset($params['value']);
     $text = str_replace(array('{', '}'), array('\\{', '\\}'), $text);
     $attributes = \ATP\MapReduce::process($params, function ($item, $index) {
         return "{$index}=\"{$item}\"";
     }, new \ATP\Reducer\Concatenate(" "));
     $html = "<label for=\"{$params['name']}\">{$label}</label>";
     $html .= "<textarea class=\"wysiwyg\" {$attributes}>{$text}</textarea>";
     return $html;
 }
Esempio n. 7
0
 public function __invoke($params)
 {
     $isChecked = $params['value'];
     unset($params['value']);
     $attributes = \ATP\MapReduce::process($params, function ($item, $index) {
         return "{$index}=\"{$item}\"";
     }, new \ATP\Reducer\Concatenate(" "));
     $html = "<label for=\"{$params['name']}\">{$params['label']}</label>";
     $html .= "<select type=\"yes-no\" {$attributes}>";
     $html .= "<option value=\"1\" " . ($isChecked ? "selected" : "") . ">Yes</option>";
     $html .= "<option value=\"0\" " . (!$isChecked ? "selected" : "") . ">No</option>";
     $html .= "</select>";
     //$html = "<input type=\"hidden\" name=\"{$params['name']}\" value=\"0\"/>";
     //$html .= "<input class=\"checkbox\" type=\"checkbox\" {$attributes} " . ($isChecked ? "checked" : "") . " value=\"1\"/>";
     return $html;
 }
Esempio n. 8
0
 public function __invoke($params, $options)
 {
     $label = $params['label'];
     unset($params['label']);
     $attributes = \ATP\MapReduce::process($params, function ($item, $index) {
         return "{$index}=\"{$item}\"";
     }, new \ATP\Reducer\Concatenate(" "));
     $html = "<label for=\"{$params['name']}\">{$label}</label>";
     $html .= "<select {$attributes}>";
     $selected = empty($obj->id) ? "selected" : "";
     $html .= "<option value=\"\" {$selected}>- Select an option -</option>";
     foreach ($options as $option) {
         $selected = strtolower($params['value']) == strtolower($option) ? "selected" : "";
         $html .= "<option value=\"{$option}\" {$selected}>{$option}</option>";
     }
     $html .= "</select>";
     return $html;
 }
Esempio n. 9
0
 public function __invoke($params, $options)
 {
     $label = $params['label'];
     unset($params['label']);
     $className = $options['className'];
     $attributes = \ATP\MapReduce::process($params, function ($item, $index) {
         return "{$index}=\"{$item}\"";
     }, new \ATP\Reducer\Concatenate(" "));
     $obj = new $className();
     $objects = $obj->loadMultiple();
     $html = "<label for=\"{$params['name']}\">{$label}</label>";
     $html .= "<select {$attributes}>";
     $selected = empty($obj->id) ? "selected" : "";
     $html .= "<option value=\"\" {$selected}>- Select an option -</option>";
     foreach ($objects as $obj) {
         $selected = $params['value'] == $obj->id ? "selected" : "";
         $html .= "<option value=\"{$obj->id}\" {$selected}>{$obj->displayName()}</option>";
     }
     $html .= "</select>";
     return $html;
 }
Esempio n. 10
0
 public function __invoke($fileName)
 {
     //Only include files once
     static $existingCssFiles = array();
     if (in_array($fileName, $existingCssFiles)) {
         return;
     }
     $existingCssFiles[] = $fileName;
     //Preprocess .less files first
     $fileParts = explode(".", $fileName);
     $ext = array_pop($fileParts);
     if ($ext == "less") {
         if (getenv('APPLICATION_ENV') == 'development') {
             //Resolve asset
             $pluginManager = $this->getView()->getHelperPluginManager();
             $sm = $pluginManager->getServiceLocator();
             $assetManager = $sm->get('AssetManager\\Service\\AssetManager');
             $resolver = $assetManager->getResolver();
             $asset = $resolver->resolve($fileName);
             $config = $sm->get('Config');
             $paths = $config['asset_manager']['resolver_configs']['prioritized_paths'];
             $themeDir = null;
             try {
                 $param = new \ATPCore\Model\Parameter();
                 $param->loadByIdentifier('core-theme');
                 $themeDir = $param->value;
             } catch (\Exception $e) {
             }
             if (empty($themeDir)) {
                 $themeDir = "Default";
             }
             $paths[] = array("path" => realpath("themes/{$themeDir}/public"), "priority" => 5000);
             usort($paths, function ($a, $b) {
                 return $b['priority'] - $a['priority'];
             });
             $paths = \ATP\MapReduce::process($paths, function ($pathData) {
                 return array($pathData['path'] => '');
             }, function ($joined, $cur) {
                 return array_merge($joined, $cur);
             }, array());
             //Set original and compiled filenames
             $originalFile = $asset ? $asset->getSourceDirectory() . '/' . $asset->getSourcePath() : getcwd() . "/public" . $fileName;
             $compiledFile = substr($originalFile, 0, -4) . "css";
             //Initialize less compiler
             $lessc = new \Less_Parser();
             //Make the definitions file available to all less files
             $lessc->SetImportDirs($paths);
             //Compile the less code
             try {
                 set_time_limit(60);
                 $lessc->parseFile($originalFile);
                 file_put_contents($compiledFile, $lessc->getCss());
             } catch (\Exception $e) {
                 echo "Less compilation error while compiling <b>{$fileName}</b>: <br/>" . $e->getMessage();
                 die;
             }
         }
         //Set new filename
         $fileName = substr($fileName, 0, -4) . "css";
     }
     $func = $this->_function;
     $this->getView()->headLink()->{$func}($this->getView()->basePath() . $fileName);
     return $this->getView();
 }
Esempio n. 11
0
 public function process($data, $sep = ",", $quoteChar = "'", $otherSubstitutions = array())
 {
     return \ATP\MapReduce::process($data, new \ATP\Mapper\Escaper($quoteChar, $otherSubstitutions), new \ATP\Reducer\Concatenate($sep), "");
 }