00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00031
00032 #ifdef HAVE_CONFIG_H
00033 #include "autoconfig.h"
00034 #endif
00035
00036 #include "pages.h"
00037
00038 #include <stdio.h>
00039 #include "common.h"
00040 #include "cds_objects.h"
00041 #include "tools.h"
00042 #include "storage.h"
00043
00044
00045
00046
00047
00048 using namespace zmm;
00049 using namespace mxml;
00050
00051 web::edit_load::edit_load() : WebRequestHandler()
00052 {}
00053
00054 void web::edit_load::process()
00055 {
00056 check_request();
00057
00058 Ref<Storage> storage;
00059
00060 String objID = param(_("object_id"));
00061 int objectID;
00062 if (objID == nil)
00063 throw _Exception(_("invalid object id"));
00064 else
00065 objectID = objID.toInt();
00066
00067 storage = Storage::getInstance();
00068 Ref<CdsObject> obj = storage->loadObject(objectID);
00069
00070 Ref<Element> item (new Element(_("item")));
00071
00072 item->setAttribute(_("object_id"), objID, mxml_int_type);
00073
00074 Ref<Element> title (new Element(_("title")));
00075 title->setTextKey(_("value"));
00076 title->setText(obj->getTitle());
00077 title->setAttribute(_("editable"), obj->isVirtual() || objectID == CDS_ID_FS_ROOT ? _("1") : _("0"), mxml_bool_type);
00078 item->appendElementChild(title);
00079
00080 Ref<Element> classEl (new Element(_("class")));
00081 classEl->setTextKey(_("value"));
00082 classEl->setText(obj->getClass());
00083 classEl->setAttribute(_("editable"), _("1"), mxml_bool_type);
00084 item->appendElementChild(classEl);
00085
00086 int objectType = obj->getObjectType();
00087 item->appendTextChild(_("obj_type"), CdsObject::mapObjectType(objectType));
00088
00089 if (IS_CDS_ITEM(objectType))
00090 {
00091 Ref<CdsItem> objItem = RefCast(obj, CdsItem);
00092
00093 Ref<Element> description (new Element(_("description")));
00094 description->setTextKey(_("value"));
00095 description->setText(objItem->getMetadata(_("dc:description")));
00096 description->setAttribute(_("editable"), _("1"), mxml_bool_type);
00097 item->appendElementChild(description);
00098
00099 Ref<Element> location (new Element(_("location")));
00100 location->setTextKey(_("value"));
00101 location->setText(objItem->getLocation());
00102 if (IS_CDS_PURE_ITEM(objectType) || ! objItem->isVirtual())
00103 location->setAttribute(_("editable"),_("0"), mxml_bool_type);
00104 else
00105 location->setAttribute(_("editable"),_("1"), mxml_bool_type);
00106 item->appendElementChild(location);
00107
00108 Ref<Element> mimeType (new Element(_("mime-type")));
00109 mimeType->setTextKey(_("value"));
00110 mimeType->setText(objItem->getMimeType());
00111 mimeType->setAttribute(_("editable"), _("1"), mxml_bool_type);
00112 item->appendElementChild(mimeType);
00113
00114 if (IS_CDS_ITEM_EXTERNAL_URL(objectType))
00115 {
00116 Ref<Element> protocol (new Element(_("protocol")));
00117 protocol->setTextKey(_("value"));
00118 protocol->setText(getProtocol(objItem->getResource(0)->getAttribute(_("protocolInfo"))));
00119 protocol->setAttribute(_("editable"), _("1"), mxml_bool_type);
00120 item->appendElementChild(protocol);
00121 }
00122 else if (IS_CDS_ACTIVE_ITEM(objectType))
00123 {
00124 Ref<CdsActiveItem> objActiveItem = RefCast(objItem, CdsActiveItem);
00125
00126 Ref<Element> action (new Element(_("action")));
00127 action->setTextKey(_("value"));
00128 action->setText(objActiveItem->getAction());
00129 action->setAttribute(_("editable"), _("1"), mxml_bool_type);
00130 item->appendElementChild(action);
00131
00132 Ref<Element> state (new Element(_("state")));
00133 state->setTextKey(_("value"));
00134 state->setText(objActiveItem->getState());
00135 state->setAttribute(_("editable"), _("1"), mxml_bool_type);
00136 item->appendElementChild(state);
00137 }
00138 }
00139
00140 root->appendElementChild(item);
00141
00142 }