Beispiel #1
0
 public function folderPermissionsAction()
 {
     $jsonModel = new JsonModel();
     foreach ($this->config['component'] as $component) {
         if (@$component['image_path'] || @$component['video_path'] || @$component['file_path']) {
             if (isset($component['image_path']) && !empty($component['image_path'])) {
                 if (!file_exists($component['image_path'])) {
                     $oldmask = umask(0);
                     mkdir($component['image_path'], 0777);
                     umask($oldmask);
                     $jsonModel->setVariable($component['image_path'], $component['image_path']);
                 }
             }
             if (isset($component['video_path']) && !empty($component['video_path'])) {
                 if (!file_exists($component['video_path'])) {
                     $oldmask = umask(0);
                     mkdir($component['video_path'], 0777);
                     umask($oldmask);
                     $jsonModel->setVariable($component['video_path'], $component['video_path']);
                 }
             }
             if (isset($component['file_path']) && !empty($component['file_path'])) {
                 if (!file_exists($component['file_path'])) {
                     $oldmask = umask(0);
                     mkdir($component['file_path'], 0777);
                     umask($oldmask);
                     $jsonModel->setVariable($component['file_path'], $component['file_path']);
                 }
             }
         }
     }
     $response = $this->getResponse();
     $response->setContent(json_encode($jsonModel->getVariables()));
     return $response;
 }
 /**
  * @return JsonModel
  */
 public function indexAction()
 {
     $json = new JsonModel();
     $json->setVariable('nav', $this->navigation->getData());
     $json->setVariable('menu', $this->navigation->getMenuItems());
     $json->setVariable('main', $this->navigation->getMainItems());
     $json->setVariable('titles', $this->navigation->getTitles());
     return $json;
 }
Beispiel #3
0
 /**
  * Index Action
  *
  * @return JsonModel
  */
 public function startAction()
 {
     $this->log->clear();
     $json = new JsonModel();
     try {
         $data = array_merge($this->importDeploymentConfigForm(), $this->importUserConfigForm(), $this->importAdminUserForm());
         $this->installer->install($data);
         $json->setVariable('key', $this->installer->getInstallInfo()[SetupConfigOptionsList::KEY_ENCRYPTION_KEY]);
         $json->setVariable('success', true);
         $json->setVariable('messages', $this->installer->getInstallInfo()[Installer::INFO_MESSAGE]);
     } catch (\Exception $e) {
         $this->log->logError($e);
         $json->setVariable('success', false);
     }
     return $json;
 }
Beispiel #4
0
 /**
  * @param mixed $errors
  */
 public function setErrors(array $errors)
 {
     $this->errors = $errors;
     if (empty($errors)) {
         $this->setSuccess(true);
     } else {
         $this->setSuccess(false);
     }
     parent::setVariable('errors', $errors);
     return $this;
 }
Beispiel #5
0
 /**
  * Apresentar Configurações
  *
  * @return JsonModel Modelo de Visualização
  */
 public function jsAction()
 {
     // Capturar Configurações
     $configs = [];
     // Inicialização
     $view = new JsonModel($configs);
     // Requisição
     $request = $this->getRequest();
     // Tipagem Correta?
     if (!$request instanceof Http\PhpEnvironment\Request) {
         throw new Exception('Invalid Request');
     }
     // Configurar Caminho Base
     $view->setVariable('basePath', $this->getRequest()->getBaseUrl());
     // Configurar Linguagem de Localização
     $view->setVariable('locale', $this->getLocale());
     // Configurar Variável
     $view->setJsonpCallback('$.application.setConfigs');
     // Apresentação
     return $view;
 }
Beispiel #6
0
 public function deleteAction()
 {
     $jsonModel = new JsonModel();
     $id = (int) $this->params()->fromPost('id');
     if ($id > 0) {
         $result = $this->getNoteTable()->delete($id);
     } else {
         $result = false;
     }
     $jsonModel->setVariable("result", $result);
     return $jsonModel;
 }
Beispiel #7
0
 public function deleteAction()
 {
     $id = $this->params()->fromQuery('id');
     $em = $this->getEntityManager();
     $jsonModel = new JsonModel();
     /** @var  $res \Base\Entity\Competition */
     $res = $em->getRepository('Base\\Entity\\User')->find($id);
     $em->remove($res);
     $em->flush();
     $jsonModel->setVariable('success', true);
     return $jsonModel;
 }
 /**
  * @return JsonModel
  */
 public function indexAction()
 {
     $this->logger->clear();
     $data = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
     $this->config->setConfigData($data);
     $this->config->install();
     $this->setupFactory->setConfig($this->config->getConfigData());
     $moduleNames = array_keys($this->moduleList);
     foreach ($moduleNames as $moduleName) {
         $setup = $this->setupFactory->create($moduleName);
         $setup->applyUpdates();
         $this->logger->logSuccess($moduleName);
     }
     $this->logger->logSuccess('Artifact');
     // Set data to config
     $setup->addConfigData('web/seo/use_rewrites', isset($data['config']['rewrites']['allowed']) ? $data['config']['rewrites']['allowed'] : 0);
     $setup->addConfigData('web/unsecure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{unsecure_base_url}}');
     $setup->addConfigData('web/secure/use_in_frontend', isset($data['config']['https']['front']) ? $data['config']['https']['front'] : 0);
     $setup->addConfigData('web/secure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{secure_base_url}}');
     $setup->addConfigData('web/secure/use_in_adminhtml', isset($data['config']['https']['admin']) ? $data['config']['https']['admin'] : 0);
     $setup->addConfigData('general/locale/code', isset($data['store']['language']) ? $data['store']['language'] : 'en_US');
     $setup->addConfigData('general/locale/timezone', isset($data['store']['timezone']) ? $data['store']['timezone'] : 'America/Los_Angeles');
     $currencyCode = isset($data['store']['currency']) ? $data['store']['currency'] : 'USD';
     $setup->addConfigData('currency/options/base', $currencyCode);
     $setup->addConfigData('currency/options/default', $currencyCode);
     $setup->addConfigData('currency/options/allow', $currencyCode);
     // Create administrator account
     $this->adminAccountFactory->setConfig($this->config->getConfigData());
     $adminAccount = $this->adminAccountFactory->create($setup);
     $adminAccount->save();
     $this->logger->logSuccess('Admin User');
     if ($data['config']['encrypt']['type'] == 'magento') {
         $key = md5($this->random->getRandomString(10));
     } else {
         $key = $data['config']['encrypt']['key'];
     }
     $this->config->replaceTmpEncryptKey($key);
     $this->config->replaceTmpInstallDate(date('r'));
     $phpPath = $this->phpExecutablePath();
     exec($phpPath . 'php -f ' . escapeshellarg($this->systemConfig->create()->getMagentoBasePath() . '/dev/shell/run_data_fixtures.php'), $output, $exitCode);
     if ($exitCode !== 0) {
         $outputMsg = implode(PHP_EOL, $output);
         $this->logger->logError(new \Exception('Data Update Failed with Exit Code: ' . $exitCode . PHP_EOL . $outputMsg));
         $this->json->setVariable('success', false);
     } else {
         $this->logger->logSuccess('Data Updates');
         $this->json->setVariable('success', true);
     }
     $this->json->setVariable('key', $key);
     return $this->json;
 }
 /**
  * Translate
  *
  * @return JsonModel
  */
 public function translateAction()
 {
     $model = new JsonModel();
     $namespace = $this->getEvent()->getRouteMatch()->getParam('namespace', 'default');
     $locale = $this->getEvent()->getRouteMatch()->getParam('locale', null);
     if ($this->getRequest()->getMethod() === 'GET') {
         $params = $this->getRequest()->getQuery();
         if (array_key_exists('callback', $params)) {
             $model->setJsonpCallback($params['callback']);
         }
     } else {
         $params = $this->getRequest()->getPost();
     }
     if (!isset($params['key'])) {
         $model->setVariable('error', 'No key[] given');
     }
     if (!is_array($params['key'])) {
         $params['key'] = array($params['key']);
     }
     foreach ($params['key'] as $key) {
         $model->setVariable($key, $this->getTranslator()->translate($key, $namespace, $locale));
     }
     return $model;
 }
 public function validFormAction()
 {
     $jsonModel = new JsonModel();
     $formData = $this->params()->fromPost();
     $formManager = $this->getServiceLocator()->get('formElementManager');
     $form = $formManager->get('addressForm');
     $form->setData($formData);
     $result = $form->isValid();
     $messages = [];
     if (!$result) {
         $messages = $form->getMessages();
     }
     $jsonModel->setVariable('jsonData', ['isValid' => $result, 'messages' => $messages]);
     $this->getResponse()->getHeaders()->addHeaderLine('content-type', 'application/json');
     return $jsonModel;
 }
Beispiel #11
0
 /**
  * @return JsonModel
  */
 public function indexAction()
 {
     $this->logger->clear();
     $data = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
     $this->config->setConfigData($data);
     $this->config->install();
     $this->setupFactory->setConfig($this->config->getConfigData());
     $moduleNames = array_keys($this->moduleList);
     foreach ($moduleNames as $moduleName) {
         $setup = $this->setupFactory->create($moduleName);
         $setup->applyUpdates();
         $this->logger->logSuccess($moduleName);
     }
     $this->logger->logSuccess('Artifact');
     // Set data to config
     $setup->addConfigData('web/seo/use_rewrites', isset($data['config']['rewrites']['allowed']) ? $data['config']['rewrites']['allowed'] : 0);
     $setup->addConfigData('web/unsecure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{unsecure_base_url}}');
     $setup->addConfigData('web/secure/use_in_frontend', isset($data['config']['https']['front']) ? $data['config']['https']['front'] : 0);
     $setup->addConfigData('web/secure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{secure_base_url}}');
     $setup->addConfigData('web/secure/use_in_adminhtml', isset($data['config']['https']['admin']) ? $data['config']['https']['admin'] : 0);
     $setup->addConfigData('general/locale/code', isset($data['store']['language']) ? $data['store']['language'] : 'en_US');
     $setup->addConfigData('general/locale/timezone', isset($data['store']['timezone']) ? $data['store']['timezone'] : 'America/Los_Angeles');
     $currencyCode = isset($data['store']['currency']) ? $data['store']['currency'] : 'USD';
     $setup->addConfigData('currency/options/base', $currencyCode);
     $setup->addConfigData('currency/options/default', $currencyCode);
     $setup->addConfigData('currency/options/allow', $currencyCode);
     // Create administrator account
     $this->adminAccountFactory->setConfig($this->config->getConfigData());
     $adminAccount = $this->adminAccountFactory->create($setup);
     $adminAccount->save();
     $this->logger->logSuccess('Admin User');
     if ($data['config']['encrypt']['type'] == 'magento') {
         $key = md5($this->random->getRandomString(10));
     } else {
         $key = $data['config']['encrypt']['key'];
     }
     $this->config->replaceTmpEncryptKey($key);
     $this->config->replaceTmpInstallDate(date('r'));
     $this->json->setVariable('success', true);
     $this->json->setVariable('key', $key);
     return $this->json;
 }
Beispiel #12
0
 public function productSearchSerialAction()
 {
     $product = $this->params()->fromPost('product');
     $jsonModel = new JsonModel();
     $productList = array();
     if (isset($product) && !empty($product)) {
         $products = $this->getProductTable()->getBySerial($product);
         foreach ($products as $key => $productValue) {
             //if(stristr($productValue,$product)){
             $productList[$key] = $productValue;
             //}
         }
         $jsonModel->setVariable("products", $productList);
         return $jsonModel;
     }
 }
Beispiel #13
0
 public function updaterolefeatureAction()
 {
     $actionId = $this->getRequest()->getPost('actionId');
     $roleId = $this->getRequest()->getPost('roleId');
     $value = $this->getRequest()->getPost('value');
     $jsonModel = new JsonModel();
     if (in_array($roleId, array(\User\Model\User::ROLE_ADMIN, \User\Model\User::ROLE_SUPERADMIN, \User\Model\User::ROLE_MEMBER, \User\Model\User::ROLE_GUEST))) {
         $jsonModel->setVariables(array('code' => 0, 'messages' => ['Không thể điều chỉnh quyền này của nhóm người dùng này']));
         return $jsonModel;
     }
     $role = new \System\Model\Role();
     $role->setId($roleId);
     $roleMapper = $this->getServiceLocator()->get('\\System\\Model\\RoleMapper');
     if (!$roleMapper->get($role)) {
         $jsonModel->setVariables(array('code' => 0, 'messages' => ['Không tìm thấy quyền này']));
         return $jsonModel;
     }
     $action = new Action();
     $action->setId($actionId);
     $actionMapper = $this->getServiceLocator()->get('\\System\\Model\\ActionMapper');
     if (!$actionMapper->get($action)) {
         $jsonModel->setVariables(array('code' => 0, 'messages' => ['Không tìm thấy action này']));
         return $jsonModel;
     }
     $roleFeature = new \System\Model\Role\Feature();
     $roleFeature->setActionId($actionId);
     $roleFeature->setRoleId($roleId);
     $roleFeatureMapper = $this->getServiceLocator()->get('\\System\\Model\\Role\\FeatureMapper');
     if ($value) {
         if (!$roleFeatureMapper->isExisted($roleFeature)) {
             $roleFeature->setCreatedById($this->user()->getIdentity());
             $roleFeature->setCreatedDateTime(DateBase::getCurrentDateTime());
             $roleFeatureMapper->save($roleFeature);
         }
     } else {
         if ($roleFeatureMapper->isExisted($roleFeature)) {
             $roleFeatureMapper->delete($roleFeature);
         }
     }
     $jsonModel->setVariable('code', 1);
     return $jsonModel;
 }
Beispiel #14
0
 /**
  * Return group members in JSON
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function groupAction()
 {
     $jsonModel = new JsonModel(array('success' => false));
     $groupId = $this->getRequest()->getPost('group');
     if (empty($groupId) || !is_numeric($groupId)) {
         return $jsonModel;
     }
     $groupMembers = $this->groupService->fetchGroupMembers($groupId, $this->identity->getId());
     $jsonModel->setVariable('success', true);
     $jsonModel->setVariable('groupMembers', $groupMembers);
     return $jsonModel;
 }
Beispiel #15
0
 public function deleteFileAction()
 {
     $id = (int) $this->params()->fromQuery('id');
     $em = $this->getEntityManager();
     /** @var  $res \base\Entity\PageFile */
     $res = $em->getRepository('Base\\Entity\\PageFile')->find($id);
     $jsonModel = new JsonModel();
     if ($res) {
         $fileName = $res->getFileName();
         $filePath = $this->FileStorePath() . '/' . $fileName;
         if (is_file($filePath)) {
             unlink($filePath);
         }
         $em->remove($res);
         $em->flush();
         $jsonModel->setVariable('success', true);
     } else {
         $jsonModel->setVariable('success', false);
     }
     return $jsonModel;
 }
 /**
  * Helper action for userselect form element.
  * 
  * @return \Zend\View\Model\JsonModel
  */
 public function searchUsersAction()
 {
     if (!$this->getRequest()->isXmlHttpRequest()) {
         throw new \RuntimeException('This action must be called via ajax request');
     }
     $model = new JsonModel();
     $query = $this->params()->fromPost('query', false);
     if (false === $query) {
         $result = array();
     } else {
         $services = $this->getServiceLocator();
         $repositories = $services->get('repositories');
         $repository = $repositories->get('Auth/User');
         $users = $repository->findByQuery($query);
         $userFilter = $services->get('filtermanager')->get('Auth/Entity/UserToSearchResult');
         $filterFunc = function ($user) use($userFilter) {
             return $userFilter->filter($user);
         };
         $result = array_values(array_map($filterFunc, $users->toArray()));
     }
     $model->setVariable('users', $result);
     return $model;
 }
Beispiel #17
0
 /**
  * @return JsonModel
  */
 public function indexAction()
 {
     return $this->jsonModel->setVariable('nav', $this->navigation->getData());
 }
 public function searchSerialAction()
 {
     $serialValue = $this->params()->fromPost('serial');
     if (isset($serialValue) && !empty($serialValue)) {
         $serials = $this->getDetailsReceiveInventoryTable()->searchSerial($serialValue);
         $serialList = array();
         foreach ($serials as $serial) {
             $serialList[] = $serial->getSerials();
         }
         $jsonModel = new JsonModel();
         $jsonModel->setVariable("serials", $serialList);
         return $jsonModel;
     }
 }
Beispiel #19
0
 public function sendemailAction()
 {
     $data = $this->params()->fromQuery();
     if (!isset($data['email']) || !$data['email']) {
         return 'Dữ liệu không đúng';
     }
     if (!isset($data['activeKey']) || !$data['activeKey']) {
         return 'Dữ liệu không đúng';
     }
     $validator = new \Zend\Validator\EmailAddress();
     if ($validator->isValid($data['email'])) {
         $user = new User();
         $user->setEmail($data['email']);
         $user->setActiveKey($data['activeKey']);
         /* @var $userMapper \User\Model\UserMapper */
         $userMapper = $this->getServiceLocator()->get('User\\Model\\UserMapper');
         if ($userMapper->checkExistsUserActive($user)) {
             $renderer = $this->getServiceLocator()->get('Zend\\View\\Renderer\\RendererInterface');
             // Email content
             $viewContent = new \Zend\View\Model\ViewModel(array('activeLink' => Uri::buildAutoHttp('/user/user/activeaccount', ['u' => $user->getEmail(), 'c' => $user->getActiveKey()])));
             $viewContent->setTemplate('email/activeFill');
             // set in module.config.php
             $content = $renderer->render($viewContent);
             // Email layout
             $viewLayout = new \Zend\View\Model\ViewModel(array('content' => $content));
             $viewLayout->setTemplate('email/layout');
             // set in module.config.php
             $message = new Message();
             $message->addTo($data['email']);
             $message->addFrom('*****@*****.**', $_SERVER['HTTP_HOST']);
             $message->setSubject('Welcome to ' . $_SERVER['HTTP_HOST']);
             $html = new \Zend\Mime\Part($renderer->render($viewLayout));
             $html->type = 'text/html';
             $body = new \Zend\Mime\Message();
             $body->setParts(array($html));
             $message->setBody($body);
             $message->setEncoding("UTF-8");
             $smtp = new \Zend\Mail\Transport\Smtp();
             $config = $this->getServiceLocator()->get('Config');
             $options = new SmtpOptions($config['smtpOptions']);
             $smtp->setOptions($options);
             $smtp->send($message);
             $json = new JsonModel();
             return $json->setVariable('Status', 'Đã xong');
         } else {
             return 'Dữ liệu không phù hợp';
         }
     }
 }
 public function getDebugData(JsonModel $model)
 {
     $model->setVariable('debug', ['db_profile' => $this->getDbProfiles()]);
     return $model;
 }
Beispiel #21
0
 public function execute()
 {
     $request = $this->getRequest();
     if ($request->isXmlHttpRequest() === true && $request->isPost() === true && $request->getPost('nd') != '') {
         // AJAX Request...load only data...
         $viewModel = new JsonModel();
         $viewModel->setVariable('data', $this->getDataJqGrid());
     } else {
         $viewModel = $this->getViewModel();
         $viewModel->setTemplate($this->getTemplate());
         $viewModel->setVariable('data', $this->getDataJqGrid());
         $columnsRowClickDisabled = [];
         $columns = $viewModel->getVariable('columns');
         foreach ($columns as $column) {
             /* @var $column \ZfcDatagrid\Column\AbstractColumn */
             if ($column->isRowClickEnabled() !== true) {
                 $columnsRowClickDisabled[] = $column->getUniqueId();
             }
         }
         $viewModel->setVariable('columnsRowClickDisabled', $columnsRowClickDisabled);
     }
     return $viewModel;
 }
 /**
  * Detail view of an application
  *
  * @return array|JsonModel|ViewModel
  */
 public function detailAction()
 {
     if ('refresh-rating' == $this->params()->fromQuery('do')) {
         return $this->refreshRatingAction();
     }
     $nav = $this->serviceLocator->get('Core/Navigation');
     $page = $nav->findByRoute('lang/applications');
     $page->setActive();
     /* @var \Applications\Repository\Application$repository */
     $repository = $this->serviceLocator->get('repositories')->get('Applications/Application');
     /* @var Application $application */
     $application = $repository->find($this->params('id'));
     if (!$application) {
         $this->response->setStatusCode(410);
         $model = new ViewModel(array('content' => 'Invalid apply id'));
         $model->setTemplate('applications/error/not-found');
         return $model;
     }
     $this->acl($application, 'read');
     $applicationIsUnread = false;
     if ($application->isUnreadBy($this->auth('id')) && $application->getStatus()) {
         $application->addReadBy($this->auth('id'));
         $applicationIsUnread = true;
         $application->changeStatus($application->getStatus(), sprintf('Application was read by %s', $this->auth()->getUser()->getInfo()->getDisplayName()));
     }
     $format = $this->params()->fromQuery('format');
     if ($application->isDraft()) {
         $list = false;
     } else {
         $list = $this->paginationParams('Applications\\Index', $repository);
         $list->setCurrent($application->id);
     }
     $return = array('application' => $application, 'list' => $list, 'isUnread' => $applicationIsUnread, 'format' => 'html');
     switch ($format) {
         case 'json':
             /*@deprecated - must be refactored */
             $viewModel = new JsonModel();
             $viewModel->setVariables($this->serviceLocator->get('builders')->get('JsonApplication')->unbuild($application));
             $viewModel->setVariable('isUnread', $applicationIsUnread);
             $return = $viewModel;
             break;
         case 'pdf':
             $pdf = $this->serviceLocator->get('Core/html2pdf');
             $return['format'] = $format;
             break;
         default:
             $contentCollector = $this->getPluginManager()->get('Core/ContentCollector');
             $contentCollector->setTemplate('applications/manage/details/action-buttons');
             $actionButtons = $contentCollector->trigger('application.detail.actionbuttons', $application);
             $return = new ViewModel($return);
             $return->addChild($actionButtons, 'externActionButtons');
             $allowSubsequentAttachmentUpload = $this->serviceLocator->get('Applications/Options')->getAllowSubsequentAttachmentUpload();
             if ($allowSubsequentAttachmentUpload && $this->acl($application, Application::PERMISSION_SUBSEQUENT_ATTACHMENT_UPLOAD, 'test')) {
                 $attachmentsForm = $this->serviceLocator->get('forms')->get('Applications/Attachments');
                 $attachmentsForm->bind($application->getAttachments());
                 /* @var $request \Zend\Http\PhpEnvironment\Request */
                 $request = $this->getRequest();
                 if ($request->isPost() && $attachmentsForm->get('return')->getValue() === $request->getPost('return')) {
                     $data = array_merge($attachmentsForm->getOption('use_post_array') ? $request->getPost()->toArray() : [], $attachmentsForm->getOption('use_files_array') ? $request->getFiles()->toArray() : []);
                     $attachmentsForm->setData($data);
                     if (!$attachmentsForm->isValid()) {
                         return new JsonModel(['valid' => false, 'errors' => $attachmentsForm->getMessages()]);
                     }
                     $content = $attachmentsForm->getHydrator()->getLastUploadedFile()->getUri();
                     return new JsonModel(['valid' => $attachmentsForm->isValid(), 'content' => $content]);
                 }
                 $return->setVariable('attachmentsForm', $attachmentsForm);
             }
             break;
     }
     return $return;
 }
    /**
     * Get the tree data from a record
     */
    public function treeAction()
    {
        $data = array();
        $data[] = array('id' => 10, 'idParent' => '', 'hasChildren' => 'n', 'name' => 'blubb', 'tags' => array('Tag1', 'tag2...'), 'expandAction' => '', 'action' => '', 'idConcated' => 'blubb');
        $viewModel = new JsonModel();
        $viewModel->setVariable('data', $data);
        return $viewModel;
        return '
       [
            {"id":1,"parentId":"","hasChildren":"y","name":"Root","tags":["Tag1","Tag2"," Martin"," ZfcDatagrid"],"expandAction":"","action":"\\u003Ca class=\\u0022btn\\u0022 href=\\u0022#\\u0022 onclick=\\u0022alert(\\u0027clicked\\u0027);\\u0022\\u003Eblubb\\u003C\\/a\\u003E","idConcated":"1"}
            ,{"id":5,"parentId":"","hasChildren":"y","name":"Root2","tags":[""],"expandAction":"", action":"\\u003Ca class=\\u0022btn\\u0022 href=\\u0022#\\u0022 onclick=\\u0022alert(\\u0027clicked\\u0027);\\u0022\\u003Eblubb\\u003C\\/a\\u003E","idConcated":"5"}
            ,{"id":6,"parentId":5,"hasChildren":"n","name":"Second level of Root2","tags":[""],"expandAction":"","action":"","idConcated":"6"}
            ,{"id":2,"parentId":1,"hasChildren":"y","name":"Second level: entry 1","tags":["Tag1","Root"," Root2"],"expandAction":"","action":"\\u003Ca class=\\u0022btn\\u0022 href=\\u0022#\\u0022 onclick=\\u0022alert(\\u0027clicked\\u0027);\\u0022\\u003Eblubb\\u003C\\/a\\u003E","idConcated":"2"}
            ,{"id":3,"parentId":2,"hasChildren":"n","name":"Third level: entry 1","tags":["cool"," stuff"],"expandAction":"","action":"","idConcated":"3"}
        ];

        ';
        /*
        * var myData= [
        {"id":1,"parentId":"","hasChildren":"y","name":"&nbsp;&nbsp;&nbsp;&nbsp;<i class=\"icon-leaf\"></i> asdf <b>test</b>","action": "","idConcated":"10"}
        ,{"id":5,"parentId":"","hasChildren":"y","name":"&nbsp;&nbsp;&nbsp;&nbsp;asdf2","action":"","idConcated":"50"}
        ,{"id":6,"parentId":5,"hasChildren":"n","name":"&nbsp;&nbsp;&nbsp;&nbsp;asdf3 level of Root2","action":"","idConcated":"60"} ,{"id":2,"parentId":1,"hasChildren":"y","name":"&nbsp;&nbsp;&nbsp;&nbsp;asdf4 level: entry 1","action":"","idConcated":"20"} ,{"id":3,"parentId":2,"hasChildren":"n","name":"&nbsp;&nbsp;&nbsp;&nbsp;asdf5 level: entry 1","action":"","idConcated":"30"}
        ];
        
        $.each(myData, function (index, value) {
            $('#defaultGrid').jqGrid('addRowData', value.idConcated, value, 'after', 5);
        });
        
        //$('#defaultGrid').jqGrid('addRowData', 'idConcated', myData, 'first', 5);
        */
    }
Beispiel #24
0
 /**
  * Checks progress of installation
  *
  * @return JsonModel
  */
 public function progressAction()
 {
     $percent = 0;
     $success = false;
     $contents = [];
     $json = new JsonModel();
     // Depending upon the install environment and network latency, there is a possibility that
     // "progress" check request may arrive before the Install POST request. In that case
     // "install.log" file may not be created yet. Check the "install.log" is created before
     // trying to read from it.
     if (!$this->log->logfileExists()) {
         return $json->setVariables(['progress' => $percent, 'success' => true, 'console' => $contents]);
     }
     try {
         $progress = $this->progressFactory->createFromLog($this->log);
         $percent = sprintf('%d', $progress->getRatio() * 100);
         $success = true;
         $contents = $this->log->get();
         if ($this->sampleDataState->hasError()) {
             $json->setVariable('isSampleDataError', true);
         }
     } catch (\Exception $e) {
         $contents = [(string) $e];
     }
     return $json->setVariables(['progress' => $percent, 'success' => $success, 'console' => $contents]);
 }
Beispiel #25
0
 public function getParentIdOptionAction()
 {
     $jsonModel = new JsonModel();
     // 上層選單目錄
     $options = $this->getServiceLocator()->get('Menu\\Model\\Menu')->getOptions($this->menuItem->getMenuName());
     $options = array('0' => '首層') + $options;
     $jsonModel->setVariable('options', $options);
     return $jsonModel;
 }
 public function getMeasuresAction()
 {
     $specification = $this->params()->fromPost('specification');
     $jsonModel = new JsonModel();
     $measures = $this->getMeasureTable()->getBySpecification($specification);
     $jsonModel->setVariable("measures", $measures);
     return $jsonModel;
 }
Beispiel #27
0
 /**
  * Checks progress of installation
  *
  * @return JsonModel
  */
 public function progressAction()
 {
     $percent = 0;
     $success = false;
     $json = new JsonModel();
     try {
         $progress = $this->progressFactory->createFromLog($this->log);
         $percent = sprintf('%d', $progress->getRatio() * 100);
         $success = true;
         $contents = $this->log->get();
     } catch (\Exception $e) {
         $contents = [(string)$e];
         if ($e instanceof \Magento\Setup\SampleDataException) {
             $json->setVariable('isSampleDataError', true);
         }
     }
     return $json->setVariables(['progress' => $percent, 'success' => $success, 'console' => $contents]);
 }
Beispiel #28
0
 public function revokeSimulationAction()
 {
     $jsonModel = new JsonModel();
     $session = $this->getServiceLocator()->get('SchoolSession');
     $this->getAuthService()->getStorage()->write($session->simulationUser);
     $session->group = [];
     $session->user_anchor = [];
     $session->simulationTeacher = [];
     $session->simulationUser = [];
     $em = $this->getEntityManager();
     // 記錄回復時間
     if ($simulationLog = $em->getRepository('Base\\Entity\\UserSimulationLog')->find($session->simulation_log_id)) {
         $simulationLog->setEndTime(new \DateTime());
         $em->persist($simulationLog);
         $em->flush();
     }
     $jsonModel->setVariable('success', true);
     return $jsonModel;
 }
 /**
  * Detail view of an application
  * 
  * @return Ambigous <\Zend\View\Model\JsonModel, multitype:boolean unknown >
  */
 public function detailAction()
 {
     if ('refresh-rating' == $this->params()->fromQuery('do')) {
         return $this->refreshRatingAction();
     }
     $nav = $this->getServiceLocator()->get('main_navigation');
     $page = $nav->findByRoute('lang/applications');
     $page->setActive();
     $repository = $this->getServiceLocator()->get('repositories')->get('Applications/Application');
     $application = $repository->find($this->params('id'));
     if (!$application) {
         $this->response->setStatusCode(410);
         $model = new ViewModel(array('content' => 'Invalid apply id'));
         $model->setTemplate('applications/error/not-found');
         return $model;
     }
     $this->acl($application, 'read');
     $applicationIsUnread = false;
     if ($application->isUnreadBy($this->auth('id'))) {
         $application->addReadBy($this->auth('id'));
         $applicationIsUnread = true;
     }
     $format = $this->params()->fromQuery('format');
     if ($application->isDraft()) {
         $list = false;
     } else {
         $list = $this->paginationParams('Applications\\Index', $repository);
         $list->setCurrent($application->id);
     }
     $return = array('application' => $application, 'list' => $list, 'isUnread' => $applicationIsUnread);
     switch ($format) {
         case 'json':
             /*@deprecated - must be refactored */
             $viewModel = new JsonModel();
             $viewModel->setVariables($this->getServiceLocator()->get('builders')->get('JsonApplication')->unbuild($application));
             $viewModel->setVariable('isUnread', $applicationIsUnread);
             $return = $viewModel;
             break;
         case 'pdf':
             $pdf = $this->getServiceLocator()->get('Core/html2pdf');
             break;
         default:
             $contentCollector = $this->getPluginManager()->get('Core/ContentCollector');
             $contentCollector->setTemplate('applications/manage/details/action-buttons');
             $actionButtons = $contentCollector->trigger('application.detail.actionbuttons', $application);
             $return = new ViewModel($return);
             $return->addChild($actionButtons, 'externActionButtons');
             break;
     }
     return $return;
 }
Beispiel #30
0
 public function jsonAction()
 {
     /* @var $user Entity\User */
     /**
      * Accepted actions:
      *
      * -----StoryActions-----
      * postStory (create new)
      * deleteStory (delete)
      * putStory (edit)
      *
      * -----alertActions----
      * getNearbyStories
      *
      *
      */
     $em = $this->getEntityManager();
     if ($this->getServiceLocator()->get('zfcuser_auth_service')->hasIdentity()) {
         $user = $this->getServiceLocator()->get('zfcuser_auth_service')->getIdentity();
     } else {
         $user = $em->getRepository('GeoStory\\Entity\\User')->findOneByEmail("*****@*****.**");
     }
     $currentUser = array('id' => $user->getId(), 'email' => $user->getEmail(), 'dateCreated' => $user->getDateCreated()->format('m-d-y'));
     $data = $this->params()->fromJson();
     $result = new JsonModel(array('success' => true, 'user' => $currentUser));
     $errors = $this->JsonGeoStoryPlugin()->checkInputs($data, $user);
     $em = $this->getEntityManager();
     if (empty($errors)) {
         $result->setVariable("action", $data['action']);
         switch ($data['action']) {
             case ActionType::NEW_STORY:
                 //todo: errorcheck the base64 encode
                 //todo: check for existing md5 hash
                 $tmpfname = md5(uniqid(rand(), true)) . ".jpg";
                 $decoded = base64_decode($data['image']);
                 file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/img/si/" . $tmpfname, $decoded);
                 $newStory = new Entity\Story($user, $data['title'], $data['storyText'], $tmpfname);
                 $newGpsLocation = new Entity\GpsLocation(floatval($data['latitude']), floatval($data['longitude']), $newStory);
                 $newStory->setGpsLocation($newGpsLocation);
                 $em->persist($newGpsLocation);
                 $em->persist($newStory);
                 $em->flush();
                 $result->setVariable('image', $_SERVER['SERVER_NAME'] . "/img/si/" . $tmpfname);
                 $result->setVariable("newStory", $newStory->toArray());
                 break;
             case ActionType::GET_STORY_BY_ID:
                 $story = $em->getRepository('GeoStory\\Entity\\Story')->findOneById(intval($data['id']));
                 $view = $em->getRepository('GeoStory\\Entity\\View')->findOneBy(array('viewerAccount' => $user, 'story' => $story));
                 $result->setVariable("myRating", 0);
                 if (!$view) {
                     $view = new Entity\View($user, $story);
                 } else {
                     if ($view->hasRating()) {
                         $result->setVariable("myRating", $view->getRating());
                     }
                 }
                 if ($story) {
                     $result->setVariable("story", $story->toArray());
                     $result->setVariable("message", "Story '{$story->getTitle()}' Found");
                     $story->incrementViewCount();
                     $em->persist($story);
                     $em->persist($view);
                     $em->flush();
                 } else {
                     $result->setVariable('success', 'false');
                     $result->setVariable('errors', array("story with id '{$data['id']} does not exist' "));
                 }
             case ActionType::NEW_COMMENT:
                 break;
             case ActionType::EDIT_STORY:
                 break;
             case ActionType::DELETE_STORY:
                 $story = $em->getRepository('GeoStory\\Entity\\Story')->findOneById(intval($data['id']));
                 if ($story) {
                     //todo:check for permissions
                     $em->remove($story);
                     $em->flush();
                     $result->setVariable("message", "Story '{$story->getTitle()}' Deleted");
                 } else {
                     $result->setVariable('success', 'false');
                     $result->setVariable('errors', array("story with id '{$data['id']}' does not exist "));
                 }
                 break;
             case ActionType::GET_STORIES_BY_USERNAME:
                 $rp = $em->getRepository('GeoStory\\Entity\\Story');
                 $foundUser = $em->getRepository('GeoStory\\Entity\\User')->findOneBy(array('username' => $data['username']));
                 if ($foundUser) {
                     $result->setVariable('message', "userId : " . $foundUser->getId());
                     $stories = $rp->findBy(array('author' => $foundUser->getId()));
                     $storiesFormated = array();
                     foreach ($stories as $s) {
                         $storiesFormated[] = $s->toArray();
                     }
                     $result->setVariable('stories', $storiesFormated);
                 } else {
                     $result->setVariable('success', 'false');
                     $result->setVariable('errors', array("user '{$data['username']} does not exist' "));
                 }
                 break;
             case ActionType::GET_STORIES_BY_EMAIL:
                 $rp = $em->getRepository('GeoStory\\Entity\\Story');
                 $foundUser = $em->getRepository('GeoStory\\Entity\\User')->findOneBy(array('email' => $data['email']));
                 if ($foundUser) {
                     $result->setVariable('message', "userId : " . $foundUser->getId());
                     $stories = $rp->findBy(array('author' => $foundUser->getId()));
                     $storiesFormated = array();
                     foreach ($stories as $s) {
                         $storiesFormated[] = $s->toArray();
                     }
                     $result->setVariable('stories', $storiesFormated);
                 } else {
                     $result->setVariable('success', 'false');
                     $result->setVariable('errors', array("user with the email '{$data['email']} does not exist' "));
                 }
                 break;
             case ActionType::GET_STORIES_BY_DISTANCE:
                 $rp = $em->getRepository('GeoStory\\Entity\\Story');
                 $stories = $rp->getStoriesByDistance($data['latitude'], $data['longitude'], floatval($data['distance']));
                 $storiesFormated = array();
                 foreach ($stories as $s) {
                     $storiesFormated[] = array('id' => $s[0]['id'], 'user' => 'NA', 'title' => $s[0]['title'], 'storyText' => $s[0]['storyText'], 'rating' => $s[0]['cachedRating'], 'imageFile' => $s[0]['photoFile'], 'longitude' => $s[0]['gpsLocation']['longitude'], 'latitude' => $s[0]['gpsLocation']['latitude'], 'numOfView' => $s[0]['cachedNumberOfViews']);
                 }
                 $result->setVariable('stories', $storiesFormated);
                 break;
             case ActionType::GET_SESSION_INFO:
                 //just return default result.
                 break;
             case ActionType::SET_STORY_RATING:
                 $story = $em->getRepository('GeoStory\\Entity\\Story')->findOneById(intval($data['storyId']));
                 $view = $em->getRepository('GeoStory\\Entity\\View')->findOneBy(array('viewerAccount' => $user, 'story' => $story));
                 if (!$view) {
                     $view = new Entity\View($user, $story);
                 }
                 $view->setRating(intval($data['rating']));
                 $story->adjustRating();
                 //todo: update story rating
                 $em->persist($view);
                 $em->persist($story);
                 $em->flush();
                 break;
             default:
                 break;
                 //this should NEVER HAPPEN
         }
     } else {
         $result->setVariable('success', 'false');
         $result->setVariable('errors', $errors);
         $result->setVariable('requestDump', $this->getRequest()->toString());
     }
     return $result;
     //
     //        $failure = true;
     //        if (!empty($data)) {
     //            if(strcmp($data['action'],"newStory") == 0) {
     //
     //
     //                if (!is_string($data['title'])){
     //                    $result->setVariable('Error', "Missing Valid 'title' entry");
     //                } else if (!is_string($data['storyText'])) {
     //                    $result->setVariable('Error', "Missing Valid 'storyText' entry");
     //                } else if (is_null($data['longitude']) && is_null($data['latitude'])) {
     //                    $result->setVariable('Error', "Missing Valid 'longitude' or 'latitude' entry");
     //                } else {
     //                    $failure = false;
     //                    $newStory = new Entity\Story(null);
     //                    $newStory->setTitle($data['title']);
     //                    $newStory->setStoryText($data['storyText']);
     //                    $newGpsLocation = new Entity\GpsLocation(floatval($data['latitude']),floatval($data['longitude']),$newStory);
     //                    $newStory->setAuthor($user);
     //                    $newStory->setGpsLocation($newGpsLocation);
     //
     //                    if (is_string($data['image'])){
     //                        $tmpfname = md5(uniqid(rand(), true)) . ".jpg";
     //                        $decoded=base64_decode($data['image']);
     //                        file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/img/si/" . $tmpfname, $decoded);
     //                        $newStory->setPhotoFile($tmpfname);
     //                        $result->setVariable('image',$_SERVER['SERVER_NAME'] . "/img/si/" . $tmpfname);
     //                    }
     //
     //
     //
     //
     //                    $this->getEntityManager()->persist($newGpsLocation);
     //                    $this->getEntityManager()->persist($newStory);
     //                    $this->getEntityManager()->flush();
     //
     //                    $result->setVariable("newStory", true);
     //                }
     //
     //
     //
     //            } else if ((strcmp($data['action'],"getStoriesByDistance") == 0)) {
     //                if (is_null($data['longitude']) && is_null($data['latitude'])) {
     //                    $result->setVariable('Error', "Missing Valid 'longitude' or 'latitude' entry");
     //                } else if (!is_string($data['distance'])){
     //                    $result->setVariable('Error', "Missing Valid 'distance'");
     //                } else {
     //                    $failure = false;
     //                    /* @var $rp Entity\Repository\StoryRepository */
     //                    $rp = $this->getEntityManager()->getRepository('GeoStory\Entity\Story');
     //                    $result->setVariable('stories',$rp->getNearbyStories($data['latitude'],$data['longitude'],floatval($data['distance'])));
     //                }
     //
     //            } else {
     //                $result->setVariable('success', 'false');
     //                $result->setVariable('Error', "Unknown Action");
     //            }
     //
     //        } else {
     //            $result->setVariable('Error', "No JSON received; doing nothing");
     //
     //        }
 }