private static function _build_data($html, $data_arr = array(), $xml = false, $rss = false, $hidden = false) { $t = $GLOBALS["t"]; $data = array(); $i = 0; if (count($data_arr) == 0) { $data_arr = $t["data"]; } else { $data_arr = array($data_arr); } foreach ($data_arr as $asset) { if (!isset($asset["_id"])) { continue; } if (!in_array("id", $t["hidden_fields"]) and is_numeric($asset["_id"])) { $data[$i]["id"] = array("name" => "Id", "displayname" => "{t}Id{/t}", "type" => "", "field" => "id", "filter" => $asset["_id"], "width" => ""); } foreach ($t["fields"] as $akey => $value) { if ((isset($value["HIDDENIN"][$t["view"]]) or isset($value["HIDDENIN"]["all"])) and !$hidden) { continue; } if ($value["SIMPLE_TYPE"] == "password") { continue; } $aval = $asset[$akey]; if (!is_array($aval)) { $aval_data = explode("|", trim($aval, "|")); $aval = array("name" => "", "type" => "", "data" => $aval_data, "filter" => $aval_data); } if ($value["SIMPLE_TYPE"] == "checkbox") { if ($aval["data"][0] == "1") { $aval["filter"][0] = "{t}yes{/t}"; } else { $aval["filter"][0] = ""; } } if ($value["SIMPLE_TYPE"] == "date") { $aval["filter"][0] = modify::dateformat($aval["data"][0], "{t}m/d/Y{/t}"); } if ($value["SIMPLE_TYPE"] == "datetime") { $aval["filter"][0] = modify::dateformat($aval["data"][0], "{t}m/d/Y g:i a{/t}"); } $filter = ""; if (isset($aval["filter"]) and is_array($aval["filter"]) and isset($aval["filter"][0])) { if ($xml and !$rss and sgsml::type_is_multiple($value["SIMPLE_TYPE"]) and (empty($value["SIMPLE_SIZE"]) or $value["SIMPLE_SIZE"] != "1")) { $filter = "|" . implode("|", $aval["data"]) . "|"; } else { if ($xml and !$rss) { $filter = implode("|", $aval["data"]); } else { $filter = implode(" ", $aval["filter"]); } } } else { if (!is_array($aval["filter"]) and $aval != "") { $filter = $aval; } else { if ($html) { $filter = " "; } } } if (!empty($value["DISPLAYNAME"])) { $name = $value["DISPLAYNAME"]; $displayname = $value["DISPLAYNAME"]; } else { $name = $value["NAME"]; $displayname = $value["NAME"]; } if (!isset($value["WIDTH"])) { $value["WIDTH"] = ""; } if (count($aval["data"]) < 2) { $aval["data"] = implode(" ", $aval["data"]); } $linktext = ""; if (!empty($value["LINKTEXT"][0]["VALUE"][1]) and strpos($value["LINKTEXT"][0]["VALUE"][1], "ext/norefer.php") !== false) { $linktext = modify::link($value["LINKTEXT"][0]["VALUE"][1], $asset, 0, "folder2=" . rawurlencode($t["folder"]) . "&view2=" . rawurlencode($t["view"])); $linktext = str_replace("&iframe=1", "", $linktext); } $link = ""; if (!empty($value["LINK"][0]["VALUE"][1]) and strpos($value["LINK"][0]["VALUE"][1], "ext/norefer.php") !== false) { $link = modify::link($value["LINK"][0]["VALUE"][1], $asset, 0, "folder2=" . rawurlencode($t["folder"]) . "&view2=" . rawurlencode($t["view"])); $link = str_replace("&iframe=1", "", $link); } $data[$i][$akey] = array("name" => $name, "displayname" => $displayname, "field" => $value["NAME"], "data" => $aval["data"], "filter" => $filter, "type" => $value["SIMPLE_TYPE"], "width" => $value["WIDTH"], "linktext" => $linktext, "link" => $link); } if (!isset($asset["created"])) { $asset["created"] = 0; } if (!isset($asset["lastmodified"])) { $asset["lastmodified"] = 0; } if (is_array($asset["created"])) { $asset["lastmodified"] = $asset["created"]["data"][0]; } if (is_array($asset["lastmodified"])) { $asset["lastmodified"] = $asset["lastmodified"]["data"][0]; } if (empty($data[$i]["created"])) { $data[$i]["created"] = array("name" => "", "type" => "", "data" => $asset["created"]); } if (empty($data[$i]["lastmodified"])) { $data[$i]["lastmodified"] = array("name" => "", "type" => "", "data" => $asset["lastmodified"]); } if (!empty($asset["lastmodifiedby"]) and !isset($data[$i]["lastmodifiedby"]) and $html) { if (!in_array("lastmodified", $t["hidden_fields"])) { $data[$i]["lastmodified"] = array("name" => "lastmodified", "displayname" => "{t}Modified{/t}", "type" => "", "field" => "lastmodified", "filter" => sys_date("{t}m/d/Y{/t}", $asset["lastmodified"]), "width" => ""); } if (!in_array("lastmodifiedby", $t["hidden_fields"])) { $data[$i]["lastmodifiedby"] = array("name" => "lastmodifiedby", "displayname" => "{t}Modified by{/t}", "type" => "", "field" => "lastmodifiedby", "filter" => $asset["lastmodifiedby"], "width" => ""); } } $data[$i]["_id"] = array("name" => "", "type" => "", "data" => $asset["_id"]); $i++; } return $data; }
function filter_field($field_name, $value, $row) { if ($field_name == "" or !isset($this->fields[$field_name])) { return $value; } $field = $this->current_fields[$field_name]; $type = $field["SIMPLE_TYPE"]; if (!empty($field["NO_CHECKS"])) { return $value; } $filters = array(); if (isset($this->current_view["filters"][$field_name])) { $filters = $this->current_view["filters"][$field_name]; } if (is_call_type($type)) { $filters[] = array("FUNCTION" => "modify::nl2br"); $filters[] = array("FUNCTION" => "quote"); /* TODO implement $filters[] = array("FUNCTION"=>"type_".$type."::render_page"); $filters[] = array("FUNCTION"=>"modify::htmlfield"); $filters[] = array("FUNCTION"=>"quote"); $filters[] = array("FUNCTION"=>"type_".$type."::render_value"); $values[$key] = call_user_func(array($class, $function), $val, $value, $params, self::_explode($row)); */ } else { if ($type == "textarea") { $filters[] = array("FUNCTION" => "modify::nl2br"); $filters[] = array("FUNCTION" => "quote"); } else { $filters[] = array("FUNCTION" => "modify::field"); $filters[] = array("FUNCTION" => "quote"); } } if (empty($filters)) { return $value; } if (sgsml::type_is_multiple($type)) { $values = explode("|", trim($value, "|")); } else { $values = (array) $value; } foreach ($filters as $filter) { list($class, $function, $params) = sys_find_callback("modify", $filter["FUNCTION"]); if (isset($filter["TYPE"])) { continue; } // TODO implement foreach ($values as $key => $value) { $values[$key] = call_user_func(array($class, $function), $value, $params, self::_explode($row)); } } return $values; }