本文整理汇总了PHP中Parameter::get_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Parameter::get_instance方法的具体用法?PHP Parameter::get_instance怎么用?PHP Parameter::get_instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameter
的用法示例。
在下文中一共展示了Parameter::get_instance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @see DataPermissionInterface::__construct()
* @param string type
* @param integer $id
*/
function __construct($type, $id)
{
if (is_numeric($id) and $type) {
$this->type = $type;
switch ($type) {
case "file":
$this->id = $id;
$this->object = File::get_instance($id);
break;
case "value":
$this->id = $id;
$this->object = Value::get_instance($id);
break;
case "parameter":
$this->id = $id;
$this->object = Parameter::get_instance($id);
break;
case "folder":
$this->id = $id;
$this->object = Folder::get_instance($id);
break;
}
$this->automatic = $this->object->get_automatic();
$this->permission = $this->object->get_permission();
$this->owner_id = $this->object->get_owner_id();
$this->owner_group_id = $this->object->get_owner_group_id();
} else {
$this->id = null;
$this->object = null;
}
}
示例2: history
public static function history()
{
if ($_GET['parameter_id']) {
$parameter = Parameter::get_instance($_GET['parameter_id']);
if ($parameter->is_read_access()) {
$argument_array = array();
$argument_array[0] = "parameter_id";
$argument_array[1] = $_GET['parameter_id'];
$list = new List_IO("DataParameterVersionHistory", "ajax.php?nav=data", "parameter_list_versions", "parameter_count_versions", $argument_array, "DataParameterVersionHistory");
$list->add_column("", "symbol", false, "16px");
$list->add_column(Language::get_message("DataGeneralListColumnName", "general"), "name", true, null);
$list->add_column(Language::get_message("DataGeneralListColumnVersion", "general"), "version", false, null);
$list->add_column(Language::get_message("DataGeneralListColumnDateTime", "general"), "datetime", true, null);
$list->add_column(Language::get_message("DataGeneralListColumnUser", "general"), "user", true, null);
$list->add_column("", "delete", false, "16px");
$template = new HTMLTemplate("data/parameter_history.html");
$template->set_var("title", $parameter->get_name());
$template->set_var("list", $list->get_list());
$template->output();
} else {
throw new DataSecurityAccessDeniedException();
}
} else {
throw new ParameterIDMissingException();
}
}
示例3: change_permission
/**
* @param string $permission_array
* @param string $type
* @return string
* @throws DataSecurityAccessDeniedException
*/
public static function change_permission($permission_array, $type)
{
global $user;
$permissions = (array) $permission_array;
switch ($type) {
case "File":
$id = $_POST['file_id'];
$object = File::get_instance($id);
break;
case "Folder":
$id = $_POST['folder_id'];
$object = Folder::get_instance($id);
break;
case "Value":
$id = $_POST['value_id'];
$object = Value::get_instance($id);
break;
case "Parameter":
$id = $_POST['parameter_id'];
$object = Parameter::get_instance($id);
break;
}
if ($object->is_control_access() == true) {
$full_access = true;
} else {
$full_access = false;
}
if ($object->get_owner_id() == $user->get_user_id()) {
$user_access = true;
} else {
$user_access = false;
}
if ($full_access == true or $user_access == true) {
$type = strtolower($type);
$id = intval($id);
echo $id;
$data_permission = new DataPermission($type, $id);
$paramquery = $_GET;
unset($paramquery['action']);
unset($paramquery['nextpage']);
$params = http_build_query($paramquery, '', '&');
if ($data_permission->set_permission_array($permissions) == true) {
return "1";
} else {
return "0";
}
} else {
throw new DataSecurityAccessDeniedException();
}
}
示例4: get_data_item_report
/**
* @param string $sql
* @param integer $item_id
* @param object $pdf
* @return object
*/
public static function get_data_item_report($sql, $item_id, $pdf)
{
global $regional;
if ($sql and is_object($pdf)) {
// Values
$value_array = Data_Wrapper::list_item_values($sql);
if (is_array($value_array) and count($value_array) >= 1) {
foreach ($value_array as $key => $value) {
$value_object = Value::get_instance($value['id']);
$value_object_value_array = $value_object->get_value_content(false);
$pdf->addPage();
$pdf->SetFont('dejavusans', 'B', 14, '', true);
$pdf->Write(0, 'Value - ' . $value_object->get_name() . '', '', 0, 'C', true, 0, false, false, 0);
$pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
$pdf->SetFont('dejavusans', '', 12, '', true);
if (is_array($value_object_value_array) and count($value_object_value_array) >= 1) {
foreach ($value_object_value_array as $sub_key => $sub_value) {
$sub_value['content'][0] = str_replace("\n", "<br />", $sub_value['content'][0]);
if ($sub_value['type'] == "textarea") {
$pdf->SetFont('dejavusans', 'B', 12, '', true);
$pdf->MultiCell(190, 9, $sub_value['title'], 1, 'L', 1, 1, '', '', true, 0, true, true, 0, "T");
$pdf->SetFont('dejavusans', '', 12, '', true);
$string_height = $pdf->getStringHeight(110, $sub_value['content'][0], true, true, '', 1);
$pdf->MultiCell(190, $string_height, $sub_value['content'][0], 1, 'L', 1, 1, '', '', true, 0, true, true, 0, "T");
} else {
$pdf->SetFont('dejavusans', 'B', 12, '', true);
$string_height1 = $pdf->getStringHeight(80, $sub_value['title'], true, true, '', 1);
$pdf->SetFont('dejavusans', '', 12, '', true);
$string_height2 = $pdf->getStringHeight(110, $sub_value['content'][0], true, true, '', 1);
if ($string_height1 > $string_height2) {
$height = $string_height1;
} else {
$height = $string_height2;
}
$pdf->SetFont('dejavusans', 'B', 12, '', true);
$pdf->MultiCell(80, $height, $sub_value['title'], 1, 'L', 1, 0, '', '', true, 0, true, true, 0, "T");
$pdf->SetFont('dejavusans', '', 12, '', true);
$pdf->MultiCell(110, $height, $sub_value['content'][0], 1, 'L', 1, 1, '', '', true, 0, true, true, 0, "T");
}
}
}
$value_object_version_array = $value_object->get_value_internal_revisions();
if (is_array($value_object_version_array) and count($value_object_version_array) >= 1) {
$pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
$header_array = array(array("name" => "name", "title" => "Name", "width" => 60), array("name" => "version", "title" => "Version", "width" => 25), array("name" => "datetime", "title" => "Date/Time", "width" => 55), array("name" => "user", "title" => "User", "width" => 50));
$report_table = new ReportTable_IO($pdf, '', '12');
$report_table->add_header($header_array);
foreach ($value_object_version_array as $sub_key => $sub_value) {
$value_version = clone $value_object;
$value_version->open_internal_revision($sub_value);
$datetime_handler = new DatetimeHandler($value_version->get_datetime());
$owner = new User($value_version->get_version_owner_id());
$line_array = array(array("name" => "name", "content" => $value_version->get_name()), array("name" => "version", "content" => $value_version->get_version()), array("name" => "datetime", "content" => $datetime_handler->get_datetime(false)), array("name" => "user", "content" => $owner->get_full_name(true)));
$report_table->add_line($line_array);
}
}
$pdf = $report_table->get_pdf();
}
}
// Files
$file_array = Data_Wrapper::list_item_files($sql, null, null, null, null);
if (is_array($file_array) and count($file_array) >= 1) {
$pdf->addPage();
$pdf->SetFont('dejavusans', 'B', 14, '', true);
$pdf->Write(0, 'Files', '', 0, 'C', true, 0, false, false, 0);
$pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
$pdf->SetFont('dejavusans', '', 14, '', true);
$header_array = array(array("name" => "name", "title" => "Name", "width" => 62), array("name" => "version", "title" => "Version", "width" => 25), array("name" => "datetime", "title" => "Date/Time", "width" => 55), array("name" => "user", "title" => "User", "width" => 48));
$report_table = new ReportTable_IO($pdf, '', '12');
$report_table->add_header($header_array);
foreach ($file_array as $key => $value) {
$file = File::get_instance($value['id']);
$owner = new User($value['owner_id']);
$datetime_handler = new DatetimeHandler($value['datetime']);
$line_array = array(array("name" => "name", "content" => $value['name']), array("name" => "version", "content" => $file->get_version()), array("name" => "datetime", "content" => $datetime_handler->get_datetime(false)), array("name" => "user", "content" => $owner->get_full_name(true)));
$report_table->add_line($line_array);
}
$pdf = $report_table->get_pdf();
}
// Parameters
$parameter_array = Data_Wrapper::list_item_parameters($sql);
if (is_array($parameter_array) and count($parameter_array) >= 1) {
foreach ($parameter_array as $key => $value) {
$parameter_object = Parameter::get_instance($value['id']);
$parameter_template = new ParameterTemplate($parameter_object->get_template_id());
$parameter_template_field_array = $parameter_template->get_fields();
$parameter_template_limit_array = $parameter_template->get_limits();
$parameter_value_array = $parameter_object->get_values();
$parameter_method_array = $parameter_object->get_methods();
$parameter_status_array = $parameter_object->get_status();
$parameter_limit_array = $parameter_object->geT_limits();
$pdf->addPage();
$pdf->SetFont('dejavusans', 'B', 14, '', true);
$pdf->Write(0, '' . $parameter_object->get_name() . '', '', 0, 'L', true, 0, false, false, 0);
//.........这里部分代码省略.........
示例5: get_context_sensitive_parameter_menu
/**
* @param integer $parameter_id
* @return string
*/
public static function get_context_sensitive_parameter_menu($parameter_id)
{
global $user;
$parameter = Parameter::get_instance($parameter_id);
$html = "";
if ($parameter->is_read_access()) {
$history_link = "index.php?username=" . $_GET['username'] . "&session_id=" . $_GET['session_id'] . "&nav=data¶meter_id=" . $parameter_id . "&action=parameter_history";
$html .= "<img src='images/icons/history.png' alt='' /><a href='" . $history_link . "' class='DataBrowserDialogLinkFollowDirectly'>History</a><br/>";
}
if ($parameter->is_control_access() == true or $parameter->get_owner_id() == $user->get_user_id()) {
$change_permission_link = "run=parameter_permission¶meter_id=" . $parameter_id;
$html .= "<img src='images/icons/permissions.png' alt='' /><a href='" . $change_permission_link . "' class='DataBrowserDialogLinkChangePermission'>Change permission</a><br/>";
}
if ($parameter->is_delete_access()) {
$delete_link = "run=parameter_delete¶meter_id=" . $parameter_id;
$html .= "<img src='images/icons/delete.png' alt='' /><a href='" . $delete_link . "' class='DataBrowserDialogLinkDelete'>Delete</a><br/>";
}
if ($parameter->is_read_access()) {
$open_link = "index.php?username=" . $_GET['username'] . "&session_id=" . $_GET['session_id'] . "&nav=data¶meter_id=" . $parameter_id . "&action=parameter_detail";
$html .= "<img src='images/icons/file_open.png' alt='' /><a href='" . $open_link . "' class='DataBrowserDialogLinkFollowDirectly'>Open / Edit</a><br/>";
}
return $html;
}
示例6: change_group
/**
* @throws FolderIDMissingException
*/
public static function change_group()
{
if ($_GET['file_id'] or $_GET['value_id'] or $_GET['parameter_id'] or $_GET['folder_id']) {
if ($_GET['file_id']) {
$id = $_GET['file_id'];
$object = File::get_instance($id);
$type = "file";
$title = $object->get_name();
}
if ($_GET['value_id']) {
$id = $_GET['value_id'];
$object = Value::get_instance($id);
$type = "value";
$title = $object->get_type_name();
}
if ($_GET['parameter_id']) {
$id = $_GET['parameter_id'];
$object = Parameter::get_instance($id);
$type = "parameter";
$title = $object->get_name();
}
if ($_GET['folder_id']) {
$id = $_GET['folder_id'];
$object = Folder::get_instance($id);
$type = "folder";
$title = $object->get_name();
}
} else {
throw new FolderIDMissingException();
}
if ($object->is_control_access() == true) {
$data_permission = new DataPermission($type, $id);
if (!$_GET['nextpage']) {
$template = new HTMLTemplate("data/data_change_group.html");
$paramquery = $_GET;
$paramquery['nextpage'] = "1";
$params = http_build_query($paramquery, '', '&');
$template->set_var("params", $params);
$template->set_var("title", $title);
$template->set_var("error", "");
$group_array = Group::list_groups();
$result = array();
$counter = 0;
foreach ($group_array as $key => $value) {
$group = new Group($value);
$result[$counter]['value'] = $value;
$result[$counter]['content'] = $group->get_name();
$counter++;
}
$template->set_var("option", $result);
$paramquery = $_GET;
$paramquery['action'] = "permission";
unset($paramquery['nextpage']);
$params = http_build_query($paramquery, '', '&');
$template->set_var("back_link", $params);
$template->output();
} else {
$paramquery = $_GET;
$paramquery['action'] = "permission";
unset($paramquery['nextpage']);
$params = http_build_query($paramquery, '', '&');
if ($data_permission->set_owner_group_id($_POST['group']) == true) {
Common_IO::step_proceed($params, "Permission: " . $title . "", "Changes saved succesful", null);
} else {
Common_IO::step_proceed($params, "Permission: " . $title . "", "Operation failed", null);
}
}
} else {
throw new DataSecuriyAccessDeniedException();
}
}
示例7: listen_events
/**
* @see EventListenerInterface::listen_events()
* @param object $event_object
* @return bool
*/
public static function listen_events($event_object)
{
if ($event_object instanceof ItemUnlinkEvent) {
if (($data_entity_id = DataEntityIsItem_Access::get_entry_by_item_id($event_object->get_item_id())) != null) {
if (($file_id = File::get_file_id_by_data_entity_id($data_entity_id)) != null) {
$file = File::get_instance($file_id);
if ($file->delete() == false) {
return false;
}
}
if (($value_id = Value::get_value_id_by_data_entity_id($data_entity_id)) != null) {
$value = Value::get_instance($value_id);
if ($value->delete() == false) {
return false;
}
}
if (($parameter_id = Parameter::get_parameter_id_by_data_entity_id($data_entity_id)) != null) {
$parameter = Parameter::get_instance($parameter_id);
if ($parameter->delete() == false) {
return false;
}
}
}
}
if ($event_object instanceof UserDeleteEvent) {
if (DataEntity_Access::set_owner_id_on_null($event_object->get_user_id()) == false) {
return true;
}
}
if ($event_object instanceof GroupDeleteEvent) {
if (DataEntity_Access::set_owner_group_id_on_null($event_object->get_group_id()) == false) {
return true;
}
}
return true;
}
示例8: delete
/**
* @param integer $parameter_id
* @return string
* @throws DataSecurityAccessDeniedException
*/
private static function delete($parameter_id)
{
$parameter = Parameter::get_instance($parameter_id);
if ($parameter->is_delete_access()) {
$parameter->delete();
return "1";
} else {
throw new DataSecurityAccessDeniedException();
}
}