예제 #1
0
 /**
  * @throws FolderIDMissingException
  */
 public static function add_value_item($type_array, $category_array, $holder_class, $holder_id, $position_id)
 {
     global $user, $regional;
     if (class_exists($holder_class)) {
         $item_holder = new $holder_class($holder_id);
         if ($item_holder instanceof ItemHolderInterface) {
             $folder_id = $item_holder->get_item_holder_value("folder_id", $position_id);
         }
     }
     if (is_numeric($folder_id)) {
         if (count($type_array) != 1 and !$_POST['type_id']) {
             $result = array();
             $counter = 0;
             if (count($type_array) == 0) {
                 $value_obj = Value::get_instance(null);
                 $value_type_array = ValueType::list_entries();
                 foreach ($value_type_array as $key => $value) {
                     $value_type = new ValueType($value);
                     $result[$counter]['value'] = $value;
                     $result[$counter]['content'] = $value_type->get_name();
                     $counter++;
                 }
             } else {
                 foreach ($type_array as $key => $value) {
                     $value_type = new ValueType($value);
                     $result[$counter]['value'] = $value;
                     $result[$counter]['content'] = $value_type->get_name();
                     $counter++;
                 }
             }
         } elseif (count($type_array) != 1 and $_POST['type_id']) {
             $type_id = $_POST['type_id'];
         } else {
             $type_id = $type_array[0];
         }
         if (!$type_id) {
             $template = new HTMLTemplate("data/value_select_list.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&');
             $template->set_var("params", $params);
             $template->set_var("select", $result);
             if ($_POST['keywords']) {
                 $template->set_var("keywords", $_POST['keywords']);
             } else {
                 $template->set_var("keywords", "");
             }
             if ($_POST['description']) {
                 $template->set_var("description", $_POST['description']);
             } else {
                 $template->set_var("description", "");
             }
             $template->output();
         } else {
             $value_type = new ValueType($type_id);
             $template = new HTMLTemplate("data/value_add.html");
             $template->set_var("decimal_separator", $regional->get_decimal_separator());
             $template->set_var("thousand_separator", $regional->get_thousand_separator());
             $template->set_var("session_id", $_GET['session_id']);
             $template->set_var("folder_id", $folder_id);
             $template->set_var("type_id", $type_id);
             $template->set_var("get_array", serialize($_GET));
             if ($_GET['retrace']) {
                 $template->set_var("retrace", "index.php?" . http_build_query(Retrace::resolve_retrace_string($_GET['retrace'])));
             } else {
                 $template->set_var("retrace", "index.php?username="******"&session_id=" . $_GET['session_id']);
             }
             $template->set_var("title", $value_type->get_name());
             require_once "value_form.io.php";
             $value_form_io = new ValueFormIO(null, $type_id, $folder_id);
             $value_form_io->set_field_class("DataValueAddValues");
             $template->set_var("value", $value_form_io->get_content());
             if ($_POST['keywords']) {
                 $template->set_var("keywords", $_POST['keywords']);
             } else {
                 $template->set_var("keywords", "");
             }
             if ($_POST['description']) {
                 $template->set_var("description", $_POST['description']);
             } else {
                 $template->set_var("description", "");
             }
             $template->output();
         }
     } else {
         throw new FolderIDMissingException();
     }
 }
예제 #2
0
 /**
  * @see ValueInterface::get_type_name()
  * @return string
  */
 public function get_type_name()
 {
     if ($this->value) {
         $value_type = new ValueType($this->value->get_type_id());
         return $value_type->get_name();
     } else {
         return null;
     }
 }
예제 #3
0
 /**
  * @param string $action
  * @return string
  */
 public static function get_data_browser_link_html_and_button_handler($action)
 {
     global $regional;
     $html;
     $html_caption;
     $button_handler;
     $button_handler_caption;
     $template;
     $paramquery = $_GET;
     unset($paramquery['run']);
     switch ($action) {
         case "value_add":
             if (!isset($_POST['folder_id']) && !isset($_POST['value_array'])) {
                 //second call (from additional script; loads template)
                 require_once "core/modules/data/io/value_form.io.php";
                 $value_form_io = new ValueFormIO(null, $_POST['type_id'], $_POST['folder_id']);
                 $value_form_io->set_field_class("DataValueAddValues");
                 return $value_form_io->get_content();
             }
             if (isset($_POST['value_array'])) {
                 //third call (from add button; creates value)
                 return self::add_value($_POST['folder_id'], $_POST['type_id'], $_POST['value_array']);
             }
             require_once "core/include/data/value/access/value_type.access.php";
             $types = ValueType_Access::list_entries();
             $options = array();
             $counter = 0;
             foreach ($types as $key => $value) {
                 if ($value == 2) {
                     continue;
                 }
                 $value_type = new ValueType($value);
                 $options[$counter]['value'] = $value;
                 $options[$counter]['content'] = $value_type->get_name();
                 $options[$counter]['selected'] = "";
                 $options[$counter]['disabled'] = "";
                 $counter++;
             }
             $template = new HTMLTemplate("data/value_add_window.html");
             $template->set_var("option", $options);
             $html = $template->get_string();
             $html_caption = "Add Value";
             $button_handler_template = new JSTemplate("data/js/value_add_window.js");
             $button_handler_template->set_var("session_id", $_GET['session_id']);
             $button_handler_template->set_var("folder_id", $_POST['folder_id']);
             $button_handler = $button_handler_template->get_string();
             $button_handler_caption = "Add";
             $additional_script_template = new JSTemplate("data/js/value_add_window_additional.js");
             $additional_script_template->set_var("decimal_separator", $regional->get_decimal_separator());
             $additional_script_template->set_var("thousand_separator", $regional->get_thousand_separator());
             $additional_script_template->set_var("session_id", $_GET['session_id']);
             $additional_script = $additional_script_template->get_string();
             $array = array("content" => $html, "content_caption" => $html_caption, "handler" => $button_handler, "handler_caption" => $button_handler_caption, "additional_script" => $additional_script);
             return json_encode($array);
             break;
         case "value_delete":
             if (isset($_POST['sure'])) {
                 self::delete_value($_POST['value_id']);
             } else {
                 $template = new HTMLTemplate("data/value_delete_window.html");
                 $button_handler_template = new JSTemplate("data/js/value_delete_window.js");
                 $button_handler_template->set_var("session_id", $_GET['session_id']);
                 $button_handler_template->set_var("value_id", $_POST['value_id']);
                 $button_handler = $button_handler_template->get_string();
                 $button_handler_caption = "Delete";
                 $html_caption = "Delete Value";
                 $html = $template->get_string();
             }
             break;
         case "permission":
             require_once "data.ajax.php";
             if (isset($_POST['permissions'])) {
                 $success = DataAjax::change_permission(json_decode($_POST['permissions']), "Value");
                 return $success;
             } else {
                 $permission = DataAjax::permission_window();
                 $button_handler_template = new JSTemplate("data/js/value_permission_window.js");
                 $button_handler_template->set_var("session_id", $_GET['session_id']);
                 $button_handler_template->set_var("value_id", $_POST['value_id']);
                 $button_handler = $button_handler_template->get_string();
                 $button_handler_caption = "Change";
                 $html_caption = "Change permission";
                 $html = $permission;
             }
             break;
     }
     $array = array("content" => $html, "content_caption" => $html_caption, "handler" => $button_handler, "handler_caption" => $button_handler_caption);
     return json_encode($array);
 }
예제 #4
0
 /**
  * @see ItemListenerInterface::get_generic_name()
  * @param string $type
  * @param array $type_array
  * @return string
  */
 public static function get_generic_name($type, $type_array)
 {
     if ($type == "file") {
         return "File";
     } elseif ($type == "parameter") {
         if (is_array($type_array) and count($type_array) == 1) {
             $parameter_template_id = ParameterTemplate::get_id_by_internal_name($type_array[0]);
             if (is_numeric($parameter_template_id)) {
                 $parameter_template = new ParameterTemplate($parameter_template_id);
                 if (($parameter_name = $parameter_template->get_name()) != null) {
                     return "" . $parameter_name;
                 } else {
                     return "Parameter";
                 }
             } else {
                 return "Parameter";
             }
         } else {
             return "Parameter";
         }
     } else {
         if (is_array($type_array) and count($type_array) == 1) {
             $value_type = new ValueType($type_array[0]);
             if (($value_name = $value_type->get_name()) != null) {
                 return "" . $value_name;
             } else {
                 return "Value";
             }
         } else {
             return "Value";
         }
     }
 }