protected function call_plugin_impl($call_ctx)
 {
     static $plugin;
     if (is_null($plugin)) {
         try {
             hd_print('Instantiating plugin...');
             $plugin = $this->create_plugin();
             hd_print('Plugin instance created.');
         } catch (Exception $e) {
             hd_print('Error: can not instantiate plugin (' . $e->getMessage() . ')');
             return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => ActionFactory::show_error(true, T::t('title_application_error'), array(T::t('msg_plugin_init_failed'))));
         }
     }
     $out_data = null;
     try {
         $out_data = $this->invoke_operation($plugin, $call_ctx);
     } catch (DuneException $e) {
         hd_print("Error: DuneException caught: " . $e->getMessage());
         return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => $e->get_error_action());
     } catch (Exception $e) {
         hd_print("Error: Exception caught: " . $e->getMessage());
         return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => ActionFactory::show_error(true, T::t('title_application_error'), array(T::t('msg_unhandled_plugin_error'))));
     }
     $plugin_output_data = array(PluginOutputData::has_data => !is_null($out_data), PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => false, PluginOutputData::error_action => null);
     if ($plugin_output_data[PluginOutputData::has_data]) {
         $plugin_output_data[PluginOutputData::data_type] = $this->get_out_type_code($call_ctx->op_type_code);
         $plugin_output_data[PluginOutputData::data] = $out_data;
     }
     return $plugin_output_data;
 }
예제 #2
0
 /**
  * setup search function for filtering and sorting
  * based on fullName field
  */
 public function search($params, Query $query)
 {
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     /**
      * Setup your sorting attributes
      * Note: This is setup before the $this->load($params)
      * statement below
      */
     $dataProvider->setSort(['attributes' => ['action' => ['label' => T::t('Action'), 'asc' => ['action' => SORT_ASC], 'desc' => ['action' => SORT_DESC], 'default' => SORT_ASC], 'created' => ['label' => T::t('Date'), 'asc' => ['created' => SORT_ASC, 'action' => SORT_ASC], 'desc' => ['created' => SORT_DESC, 'action' => SORT_ASC], 'default' => SORT_DESC], 'task_price' => ['label' => T::t('Reward'), 'asc' => ['task_price' => SORT_ASC, 'action' => SORT_ASC], 'desc' => ['task_price' => SORT_DESC, 'action' => SORT_ASC], 'default' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if (isset($params[$this->formName()])) {
         foreach ($params[$this->formName()] as $prop => $propValue) {
             if ("" != $propValue && property_exists($this, $prop)) {
                 /* map objet_id to type */
                 if (in_array($prop, ['object_id', 'task_price'])) {
                     $query->andWhere(sprintf('%s=%d', $prop, $this->{$prop}));
                 } else {
                     $query->andWhere(sprintf('%s LIKE "%%%s%%"', $prop, $this->{$prop}));
                 }
             }
         }
     }
     return $dataProvider;
 }
예제 #3
0
 /**
  * @inheritdoc
  */
 public function getSchemaByResourceType($resourceType)
 {
     // Schema is not found among instantiated schemas for resource type $resourceType
     $isOk = is_string($resourceType) === true && isset($this->resourceType2Type[$resourceType]) === true;
     // Schema might not be found if it hasn't been searched by type (not resource type) before.
     // We instantiate all schemas and then find one.
     if ($isOk === false) {
         //// todo make this better and less yolo
         //// inject standard schema
         //$this->providerMapping[$resourceType] = function (SchemaFactoryInterface $factory, ContainerInterface $container) use ($resourceType) {
         //    return new ResourceSchema($factory, $container, $resourceType);
         //};
         foreach ($this->providerMapping as $type => $schema) {
             if (isset($this->createdProviders[$type]) === false) {
                 // it will instantiate the schema
                 $this->getSchemaByType($type);
             }
         }
     }
     // search one more time
     $isOk = is_string($resourceType) === true && isset($this->resourceType2Type[$resourceType]) === true;
     if ($isOk === false) {
         throw new InvalidArgumentException(T::t('Schema is not registered for resource type \'%s\'.', [$resourceType]));
     }
     return $this->getSchemaByType($this->resourceType2Type[$resourceType]);
 }
예제 #4
0
 /**
  * Yes / No radio boxes
  */
 public function yesno($title, $name, $opts = array(), $value = '')
 {
     $opts['class'] = array_key_exists('class', $opts) ? $opts['class'] : '';
     $h = '<div class="radio"><label><input type="radio" name="' . $name . '" value="1"';
     $h .= $this->get_opts($opts, $name);
     $h .= $value ? ' checked="checked"' : '';
     $h .= '/>' . T::t('Yes', 'Oui') . '</label></div>';
     $h .= '<div class="radio"><label><input type="radio" name="' . $name . '" value="0"';
     $h .= $this->get_opts($opts, $name);
     $h .= !$value ? ' checked="checked"' : '';
     $h .= '/>' . T::t('No', 'Non') . '</label></div>';
     return $this->wrap($title, $h);
 }