/** * @param string $word * @return mixed */ private function interpret($word) { switch ($word) { case "getName": if ($this->stack[count($this->stack) - 1] == "list") { if ($this->stack[count($this->stack) - 3] == "sample") { // [...] } } else { switch ($this->stack[count($this->stack) - 2]) { case "sample": if ($this->sample instanceof Sample) { $this->result = $this->sample->get_name(); } else { $this->sample = new Sample($this->stack[count($this->stack) - 1]); $this->result = $this->sample->get_name(); } return $this->result; break; } } break; case "item": $sample_item = new SampleItem($this->sample_id); $this->temp = $sample_item->get_sample_items(); array_push($this->stack, "item"); $item_value_var = new ItemValueVar(); $this->result = $item_value_var->get_content($this->string_array, $this->stack, $this->result, $this->temp); $this->stack = $item_value_var->get_stack(); $this->string_array = $item_value_var->get_string_array(); break; default: break; } if (count($this->string_array) == 0) { return $this->result; } else { return $this->get_content(null, null, null, null); } }
/** * @param string $role * @throws ItemParentIDMissingException * @throws ItemPositionIDMissingException * @throws BaseModuleDialogMethodNotFoundException * @throws BaseModuleDialogClassNotFoundException * @throws BaseModuleDialogFileNotFoundException * @throws BaseModuleDialogNotFoundException * @throws SampleSecurityAccessDeniedException * @throws BaseModuleDialogMissingException */ public static function item_add_edit_handler($role = "add") { if ($_GET['dialog']) { if (!is_numeric($_GET['parent_id'])) { throw new ItemParentIDMissingException(); } if (!is_numeric($_GET['key'])) { throw new ItemPositionIDMissingException(); } $sample = new Sample($_GET['parent_id']); $sample_security = new SampleSecurity($_GET['parent_id']); if ($sample_security->is_access(2, false) == true) { if ($role == "add") { $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_add", $_GET['dialog']); } elseif ($role == "edit") { $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_edit", $_GET['dialog']); } if (is_array($module_dialog) and $module_dialog['class_path']) { if (file_exists($module_dialog['class_path'])) { require_once $module_dialog['class_path']; if (class_exists($module_dialog['class'])) { if (method_exists($module_dialog['class'], $module_dialog['method'])) { $sample_item = new SampleItem($_GET['parent_id']); $sample_item->set_gid($_GET['key']); $current_requirements = $sample->get_requirements(); if ($role == "add") { $module_dialog['class']::$module_dialog['method']($current_requirements[$_GET['key']]['type_id'], $current_requirements[$_GET['key']]['category_id'], "Sample", $_GET['parent_id'], $_GET['key']); } elseif ($role == "edit") { $module_dialog['class']::$module_dialog['method']($current_requirements[$_GET['key']]['fulfilled'][0]['item_id']); } } else { throw new BaseModuleDialogMethodNotFoundException(); } } else { throw new BaseModuleDialogClassNotFoundException(); } } else { throw new BaseModuleDialogFileNotFoundException(); } } else { throw new BaseModuleDialogNotFoundException(); } } else { throw new SampleSecurityAccessDeniedException(); } } else { throw new BaseModuleDialogMissingException(); } }
/** * @see EventListenerInterface::listen_events() * @param object $event_object * @return bool */ public static function listen_events($event_object) { if ($event_object instanceof ItemDeleteEvent) { $sample_item = new SampleItem(null); $sample_item->set_item_id($event_object->get_item_id()); if ($sample_item->unlink_item_full() == false) { return false; } } return true; }
/** * @see ItemHolderInterface::list_item_holders_by_item_id() * @param $item_id $holder_id * @return array */ public static function list_item_holders_by_item_id($item_id) { return SampleItem::list_entries_by_item_id($item_id, false); }
/** * @see SampleItemFactoryInterface::create() * @param integer $sample_id * @param integer $item_id * @param integer $gid * @param string $keywords * @param string $description * @param bool $parent * @return bool */ public static function create($sample_id, $item_id, $gid, $keywords = null, $description = null, $parent_item_id = null, $parent_sample = false, $parent_is_parent_sample = false) { global $transaction; if ($transaction->is_in_transction() == true) { $sample = new Sample($sample_id); $sample_item = new SampleItem($sample_id); $sample_item->set_gid($gid); $sample_item->set_parent($parent_sample); // For parent sample only $sample_item->set_parent_item_id($parent_item_id); if ($sample_item->set_item_id($item_id) == false) { return false; } if ($sample_item->link_item() == false) { return false; } if (($class_name = $sample_item->is_classified()) == true) { if ($sample_item->set_class($class_name) == false) { return false; } } $description_required = $sample_item->is_description(); $keywords_required = $sample_item->is_keywords(); if ($description_required == true xor $keywords_required == true) { if ($description_required == false and $keywords_required == true) { $sample_item->set_information(null, $keywords); } else { $sample_item->set_information($description, null); } } else { if ($description_required == true and $keywords_required == true) { $sample_item->set_information($description, $keywords); } } $item_holder_type_array = Item::list_holders(); $item_holder_id_array = array(); if (is_array($item_holder_type_array) and count($item_holder_type_array) >= 1) { foreach ($item_holder_type_array as $key => $value) { $item_holder_id_array[$key] = $value::list_item_holders_by_item_id($sample->get_item_id()); if ($key == "sample" and $parent_is_parent_sample == true) { $item_holder_id_array[$key] = array_merge($item_holder_id_array[$key], Sample_Wrapper::get_sample_id_and_gid_by_parent_sample_id($sample_id)); } } } $item_holder_add_event = new ItemHolderAddEvent($item_holder_id_array, $sample->get_item_id(), $item_id, $gid); $event_handler = new EventHandler($item_holder_add_event); if ($event_handler->get_success() == false) { return false; } return true; } else { return false; } }