Example #1
0
 protected function _isSubmit()
 {
     if (is_string($this->submitButton)) {
         if ($this->dataIn->has(strval($this->submitButton))) {
             $this->mode = $this->submitButton;
             return true;
         }
     } else {
         if (is_array($this->submitButton)) {
             foreach ($this->submitButton as $id) {
                 if ($this->dataIn->has($id)) {
                     $this->mode = $id;
                     return true;
                 }
             }
         }
     }
     $button = $this->dataIn->get('CT_Form_SubmitButton');
     if ($button) {
         if (is_string($this->submitButton) && $this->submitButton == $button || is_array($this->submitButton) && in_array($button, $this->submitButton)) {
             $this->mode = $button;
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
Example #2
0
 /** @param $task Task */
 public function processTask($task)
 {
     parent::processTask($task);
     $data = $task->request->post->get('commands');
     if (!is_string($data)) {
         $this->postResults(array(ServiceResult::createWithError('error', 'No data', '::GLOBAL::')));
         return;
     }
     if (strlen($data) > $this->maxPackageSize) {
         $this->postResults(array(ServiceResult::createWithError('error', 'Data too large', '::GLOBAL::')));
         return;
     }
     $data = json_decode($data, true);
     if (json_last_error() != JSON_ERROR_NONE || !is_array($data)) {
         $this->postResults(array(ServiceResult::createWithError('error', 'Invalid data', '::GLOBAL::')));
         return;
     }
     $results = array();
     $f = new ArrayFilter();
     foreach ($data as $command) {
         if (!is_array($command)) {
             $this->postResults(array(ServiceResult::createWithError('error', 'Invalid data', '::GLOBAL::')));
             return;
         }
         $f->setData($command);
         $id = $f->get('id');
         $command = $f->get('command');
         $data = $f->asFilter('data');
         $results[] = $this->_executeCommand($command, $data, $id);
     }
     $this->postResults($results);
 }
Example #3
0
 public function setTemplateResult($template, $templateData = null, $settings = null)
 {
     $settings = new ArrayFilter($settings);
     $content = $this->factory()->appTemplates()->load($template, $templateData)->content;
     $baseTemplate = $settings->get('baseTemplate');
     if ($baseTemplate === null) {
         $baseTemplate = 'AppModule::base.html';
     }
     if ($baseTemplate !== null && $baseTemplate !== false) {
         $content = $this->factory()->appTemplates()->load($baseTemplate, array('content' => $content))->content;
     }
     $this->setResult($content, $settings->get('contentType'), $settings->get('responseCode'));
 }
Example #4
0
 protected function _retrieveUrl()
 {
     if ($this->usesModRewrite) {
         $self = $this->_server->needs('PHP_SELF');
         //            if(($pathInfo = $this->_server->get('PATH_INFO')) || ($pathInfo = $this->_server->get('ORIG_PATH_INFO'))){
         //                $self = substr($self, 0, strlen($self) - strlen($pathInfo));
         //            }
         if (($pos = strrpos($self, '/')) !== false) {
             $self = substr($self, 0, $pos);
         } else {
             $self = substr($self, 0, strrpos($self, '\\'));
         }
         $url = substr($this->_server->needs('REQUEST_URI'), strlen($self));
         if ($url === false) {
             $url = '';
         } elseif ($url !== '') {
             $posQueryString = strpos($url, '?');
             if ($posQueryString !== false) {
                 $url = substr($url, 0, $posQueryString);
             }
         }
         $url = substr($url, 1);
     } else {
         if ($this->_server->has('PATH_INFO')) {
             $url = substr($this->_server->get('PATH_INFO'), 1);
         } else {
             $url = substr($this->_server->get('ORIG_PATH_INFO'), 1);
         }
     }
     if (substr($url, -1, 1) != '/') {
         $url .= '/';
     }
     return $url;
 }
 public function fetch(ArrayFilter $data)
 {
     $v = $data->get($this->name);
     foreach ($this->_filters as $filter) {
         $v = $filter->doFiltering($v);
     }
     $this->value = $v;
     return $this->value;
 }
Example #6
0
 protected function _isSubmit()
 {
     if (is_string($this->submitButton)) {
         if ($this->dataIn->has(strval($this->submitButton))) {
             $this->mode = $this->submitButton;
             $this->action = 'next';
             return true;
         }
     } else {
         if (is_array($this->submitButton)) {
             foreach ($this->submitButton as $id => $action) {
                 if ($this->dataIn->has($id)) {
                     $this->mode = $id;
                     $this->action = $action;
                     return true;
                 }
             }
         }
     }
     for ($i = 1; $i <= $this->steps; $i++) {
         if ($this->dataIn->has('step' . $i)) {
             $this->mode = 'step' . $i;
             $this->action = $i;
             return true;
         }
     }
     $button = $this->dataIn->get('CT_Form_SubmitButton');
     if ($button) {
         $this->mode = $button;
         if (is_array($this->submitButton)) {
             $this->action = ArrayTools::get($this->submitButton, $button);
         } else {
             if ($button == $this->submitButton) {
                 $this->action = 'next';
             }
         }
         if ($this->action) {
             return true;
         }
         if (!$this->action) {
             for ($i = 1; $i <= $this->steps; $i++) {
                 if ($button == 'step' . $i) {
                     $this->action = $i;
                     return true;
                 }
             }
         }
         return false;
     }
     return false;
 }
Example #7
0
 public function getAppTool($tool)
 {
     $t = $this->_tools->get($tool);
     if ($t) {
         return $t;
     }
     if (method_exists($this, $tool)) {
         return $this->{$tool}();
     }
     $event = $this->events->trigger($tool);
     if ($event->data) {
         $this->_tools->set($tool, $event->data);
         return $event->data;
     }
     return null;
 }
Example #8
0
 public function postSuccess($code, $message = null, $messageReplaces = null)
 {
     $this->set->status->addSuccess($this->name);
     if ($message) {
         if ($messageReplaces === null) {
             $messageReplaces = array();
         }
         $messageReplaces['%name%'] = $this->config->get('label');
         //            $message = str_replace(array_keys($messageReplaces), array_values($messageReplaces), $message);
     }
     $m = new SetMessage();
     $m->content = $this;
     $m->code = $this->name . '.' . $code;
     $m->message = $message;
     $m->values = $messageReplaces;
     $this->set->status->addSuccess($this->name . '.' . $code, $m);
     //        $this->set->status->postSuccess($this->name.'.'.$code, $message);
 }
Example #9
0
 public function listSets($options)
 {
     /*
     $options = array(
         'offset' => 0,
         'count' => '20',
         'sort' => array(
             'field' => 'id',
             'direction' => 'desc'
         ),
         'search' => 'testsuche'
     );
     */
     $options = new ArrayFilter($options);
     $directory = $this->_getDirectory();
     if (is_dir($directory)) {
         $dir = opendir($directory);
         $offset = $options->get('offset', 0);
         $count = $options->get('count', 0);
         $extension = $this->_getExtension();
         $extensionLength = strlen($extension);
         $i = 0;
         $files = array();
         while (($file = readdir($dir)) !== false) {
             if ($file === '.' || $file === '..') {
                 continue;
             }
             $fileLength = strlen($file);
             if (substr($file, $fileLength - $extensionLength, $extensionLength) !== $extension) {
                 continue;
             }
             if ($i >= $offset && $i < $offset + $count) {
                 $files[] = substr($file, 0, $fileLength - $extensionLength);
             }
             $i++;
         }
         $result = new FileSetListResult($this, $files);
         $result->countAll = $i;
         return $result;
     }
     $result = new FileSetListResult($this, array());
     $result->countAll = 0;
     return $result;
 }
Example #10
0
 public function checkSession()
 {
     $f = new ArrayFilter($this->bucket->data);
     if ($f->get('name') != $this->name) {
         return false;
     }
     if (!$f->get('lastAction') || time() - $f->get('lastAction') > $this->expirationTime) {
         return false;
     }
     if ($this->checkIp && $f->get('ip') != $this->ip) {
         return false;
     }
     if ($this->checkUserAgent && $f->get('userAgent') != $this->userAgent) {
         return false;
     }
     return true;
 }
Example #11
0
 public function listSets($options)
 {
     $options = new ArrayFilter($options);
     $search = $options->get('search');
     $sorting = $options->asFilter('sort');
     $sortingField = $sorting->get('field');
     $sortingDirection = $sorting->get('direction');
     $offset = $options->get('offset', 0);
     $count = $options->get('count', 0);
     $parameters = array();
     // Create queries
     $data = $this->_getListQueryData($options);
     // Create search queries
     $searchQueries =& $data['searchQueries'];
     if ($search != '') {
         foreach ($this->contents as $content) {
             if ($content->searchable) {
                 $parameters['search'] = '%' . $search . '%';
                 $searchQueries[] = 'e.' . $content->name . ' LIKE :search';
             }
         }
     }
     // Create query parts
     if ($searchQueries) {
         $filterClause = '(' . implode(' OR ', $searchQueries) . ')';
     } else {
         $filterClause = '1 = 1';
     }
     // Check for ordering
     $orderClause = '';
     if ($sortingField) {
         foreach ($this->contents as $content) {
             if ($content->sortable && $content->name == $sortingField) {
                 $orderClause = 'e.' . $content->name . ' ' . $sortingDirection;
                 break;
             }
         }
     }
     if ($orderClause === '') {
         if ($data['select']['defaultOrder']) {
             $orderClause = $data['select']['defaultOrder'];
         } else {
             $orderField = $this->config->get('order');
             if ($orderField) {
                 $orderClause = 'e.' . $orderField;
             } else {
                 $identifiers = $this->_getEntityManager()->getClassMetadata($this->_getEntityClass())->getIdentifierFieldNames();
                 $orderClause = 'e.' . $identifiers[0] . ' DESC';
             }
         }
     }
     $queryLookUps = array('{where}', '{order}', '{e}', '{entity}');
     $queryReplaces = array($filterClause, $orderClause, 'e', $this->_getEntityClass() . ' e');
     $queryClauseLookUps = array('{select-clause}', '{where-clause}', '{order-clause}', '{from-clause}');
     $queryClauseReplaces = array($data['clauses']['select'], $data['clauses']['where'], $data['clauses']['order'], $data['clauses']['from']);
     // Get items
     $queryData = $data['select'];
     $query = str_replace($queryClauseLookUps, $queryClauseReplaces, $queryData['query']);
     $query = str_replace($queryLookUps, $queryReplaces, $query);
     $parameters = array_merge($parameters, $queryData['parameters'], $data['parameters']);
     $query = $this->_getEntityManager()->createQuery($query);
     if ($offset) {
         $query->setFirstResult($offset);
     }
     if ($count) {
         $query->setMaxResults($count);
     }
     if ($parameters) {
         $query->setParameters($parameters);
     }
     $result = new DoctrineSetListResult($this, $query->getResult());
     // Get count
     $queryData = $data['count'];
     $query = str_replace($queryClauseLookUps, $queryClauseReplaces, $queryData['query']);
     $query = str_replace($queryLookUps, $queryReplaces, $query);
     $query = $this->_getEntityManager()->createQuery($query);
     if ($parameters) {
         $query->setParameters($parameters);
     }
     $result->countAll = $query->getSingleScalarResult();
     return $result;
 }
Example #12
0
 public function validateField(ArrayFilter $filter, $field, $defaultValue = null)
 {
     $this->validate($field, $filter->get($field, $defaultValue));
     return $this;
 }
if ($f->appManagedSessionData()->isLoggedIn()) {
    ?>
        <div id="menu">
            <ul>
                <?php 
    $activeMenu = $this->task->vars->get('menu');
    $filter = new ArrayFilter();
    $menuLinks = $m->menuLinks;
    foreach ($menuLinks as $menuLink) {
        $filter->setData($menuLink);
        /** @var AccessRule $access */
        $access = ArrayTools::get($menuLink, 'access');
        if ($access && !$f->hasAccess($access)) {
            continue;
        }
        $id = $filter->get('id');
        $url = $menuLink['url'];
        $active = $id !== null && $id === $activeMenu || $filter->get('route') == $this->task->route;
        $c = '<li' . ($active ? ' class="active"' : '') . '><a href="' . $q->e($url) . '">' . $q->e($filter->get('title')) . '</a></li>';
        echo $c;
    }
    ?>
            </ul>
        </div>
    <?php 
}
?>
    <div id="content">
        <?php 
echo $this->in->get('content');
?>
 public function fetch(ArrayFilter $data)
 {
     $this->value = FileUpload::fromPhpFileArray($data->get($this->name));
     return $this->value;
 }
Example #15
0
<?php

use Cyantree\Grout\AutoLoader;
use Cyantree\Grout\Filter\ArrayFilter;
use Cyantree\Mosaic\Outputs\ReadableOutput;
use Cyantree\Mosaic\Outputs\JsonOutput;
use Cyantree\Mosaic\Mosaic;
require_once __DIR__ . '/../../../autoload.php';
ini_set('memory_limit', '1024M');
AutoLoader::init();
$options = new ArrayFilter(getopt('f:c:j:o:', ['debug']));
$outputMode = $options->get('o', 'readable');
$s = new Mosaic();
$s->debug = $options->has('debug');
$s->basePath = realpath(dirname($options->needs('f'))) . '/';
$s->applicationPath = __DIR__ . '/../src/';
$s->configuration->load($options->needs('f'));
if ($options->has('c')) {
    $s->configuration->extend(json_decode(rawurldecode($options->get('c'))));
}
if ($options->has('j')) {
    $includedJobs = explode(',', $options->get('j'));
} else {
    $includedJobs = null;
}
$jobs = $s->compile($includedJobs);
switch ($outputMode) {
    case 'json':
        $output = new JsonOutput();
        break;
    default: