static function ajax_get_field($type, $field)
 {
     $field = sys_array_shift(self::_get_obj($type, "/table/field[@name='" . $field . "']"));
     if (empty($field)) {
         return array();
     }
     $result = array();
     foreach ($field->attributes() as $key => $value) {
         if ($key == "separator") {
             $key = "fseparator";
         }
         $result[$key] = (string) $value;
     }
     if (isset($field->KEY)) {
         $result["fkey"] = true;
     }
     if (isset($field->INDEX)) {
         $result["findex"] = true;
     }
     if (isset($field->INDEX_FULLTEXT)) {
         $result["findex_fulltext"] = true;
     }
     if (isset($field->notin)) {
         $result["notin"] = (string) $field->notin->attributes()->views;
     }
     if (isset($field->hiddenin)) {
         $result["hiddenin"] = (string) $field->hiddenin->attributes()->views;
     }
     if (isset($field->onlyin)) {
         $result["onlyin"] = (string) $field->onlyin->attributes()->views;
     }
     if (isset($field->readonlyin)) {
         $result["readonlyin"] = (string) $field->readonlyin->attributes()->views;
     }
     if (isset($field->description)) {
         $result["description_title"] = (string) $field->description->attributes()->title;
         $result["description_hint"] = (string) $field->description->attributes()->hint;
         $result["description_value"] = (string) $field->description->attributes()->value;
     }
     return $result;
 }
示例#2
0
 private static function _create_default_folder_xml_data($xml, $folder)
 {
     $assets = sys_array_shift(get_object_vars($xml));
     if (is_object($assets)) {
         $assets = array($assets);
     }
     if (!is_array($assets) or count($assets) == 0) {
         return;
     }
     @set_time_limit(60);
     $sgsml = new sgsml($folder, "new");
     $sgsml->notification = false;
     foreach ($assets as $asset) {
         $data = get_object_vars($asset);
         if (isset($data["@attributes"])) {
             unset($data["@attributes"]);
         }
         $result = $sgsml->insert($data);
         if (DEBUG and !is_int($result)) {
             print_r($result);
         }
         if (DEBUG) {
             echo " @" . memory_get_usage(true);
         }
         sys::$cache = array();
         sys::$db_queries = array();
     }
 }
示例#3
0
function folder_from_path($path)
{
    return sys_array_shift(folders_from_path($path));
}
示例#4
0
 function __construct($folder, $view, $items = array(), $writeable = true)
 {
     // Mountpoint
     $folders = array($folder);
     if (!is_numeric($folder)) {
         $url = sys_parse_folder($folder);
         $type = "sys_nodb_" . $url["handler"];
         $mfolder = $url["mfolder"];
         sys_credentials($mfolder);
     } else {
         $row = db_select_first("simple_sys_tree", array("ftype", "folders"), "id=@id@", "", array("id" => $folder));
         if (empty($row["ftype"])) {
             throw new Exception("{t}Folder not found.{/t}");
         }
         $type = $row["ftype"];
         if ($row["folders"] != "") {
             $folders = array();
             foreach (explode("|", trim($row["folders"], "|")) as $val) {
                 if (empty($val) or !db_get_right($val, $writeable ? "write" : "read", $view)) {
                     continue;
                 }
                 $folders[] = $val;
             }
         }
         $mfolder = "";
     }
     if (isset($_SESSION["disabled_modules"][$type])) {
         exit("{t}Module disabled.{/t}");
     }
     $this->schema = db_get_schema(sys_find_module($type), $folder, $view);
     $view = sys_array_shift(array_keys($this->schema["views"]));
     $this->current_view =& $this->schema["views"][$view];
     if (isset($this->current_view["SCHEMA"]) and $this->current_view["SCHEMA"] != "") {
         $this->schema = db_get_schema(sys_find_module($this->current_view["SCHEMA"]), "", $view);
         $view = sys_array_shift(array_keys($this->schema["views"]));
         $this->current_view =& $this->schema["views"][$view];
     }
     $this->folder = $folder;
     $this->view = $view;
     $this->fields =& $this->schema["fields"];
     $this->att =& $this->schema["att"];
     $this->tname = $this->att["NAME"];
     $this->where = $this->current_view["SQLWHERE"];
     $this->handler = $this->current_view["SQL_HANDLER"];
     $this->buttons = $this->current_view["buttons"];
     $this->rowvalidates = $this->current_view["rowvalidates"];
     $this->rowfilters = $this->current_view["rowfilters"];
     $this->current_fields =& $this->current_view["fields"];
     $this->notification = true;
     $this->vars = array("item" => $items, "folder" => $this->folder, "folders" => $folders, "mfolder" => $mfolder);
     $this->vars_noquote = array();
     if (!empty($this->att["ENABLE_ASSET_RIGHTS"])) {
         if ($writeable) {
             $this->where[] = "@permission_sql_write_nq@";
         }
         $this->vars_noquote["permission_sql_read_nq"] = $_SESSION["permission_sql_read"];
         $this->vars_noquote["permission_sql_write_nq"] = $_SESSION["permission_sql_write"];
     }
     if (is_array($this->where) and count($this->where) > 0) {
         foreach ($this->where as $key => $val) {
             $matches = array();
             if (!preg_match_all("|@(.*?)@|i", $val, $matches, PREG_SET_ORDER)) {
                 continue;
             }
             foreach ($matches as $match) {
                 if (count($match) != 2) {
                     continue;
                 }
                 $wkey = $match[1];
                 if (empty($this->vars[$wkey]) and empty($this->vars_noquote[$wkey])) {
                     $this->where[$key] = "1=1";
                 }
             }
         }
     }
 }