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 "common.h"
00037 #include "pages.h"
00038 #include "storage.h"
00039 #include "cds_objects.h"
00040
00041 using namespace zmm;
00042 using namespace mxml;
00043
00044 web::containers::containers() : WebRequestHandler()
00045 {
00046 }
00047
00048 void web::containers::process()
00049 {
00050 log_debug(("containers.cc: containers::process()\n"));
00051 check_request();
00052
00053 int parentID = intParam(_("parent_id"), INVALID_OBJECT_ID);
00054 if (parentID == INVALID_OBJECT_ID)
00055 throw _Exception(_("web::containers: no parent_id given"));
00056
00057 Ref<Storage> storage = Storage::getInstance();
00058
00059
00060 Ref<Element> containers (new Element(_("containers")));
00061 containers->setArrayName(_("container"));
00062 containers->setAttribute(_("parent_id"), String::from(parentID), mxml_int_type);
00063 containers->setAttribute(_("type"), _("database"));
00064
00065 if (string_ok(param(_("select_it"))))
00066 containers->setAttribute(_("select_it"), param(_("select_it")));
00067 root->appendElementChild(containers);
00068
00069 Ref<BrowseParam> param(new BrowseParam(parentID, BROWSE_DIRECT_CHILDREN | BROWSE_CONTAINERS));
00070 Ref<Array<CdsObject> > arr;
00071 arr = storage->browse(param);
00072
00073 for (int i = 0; i < arr->size(); i++)
00074 {
00075 Ref<CdsObject> obj = arr->get(i);
00076
00077
00078 Ref<CdsContainer> cont = RefCast(obj, CdsContainer);
00079 Ref<Element> ce(new Element(_("container")));
00080 ce->setAttribute(_("id"), String::from(cont->getID()), mxml_int_type);
00081 int childCount = cont->getChildCount();
00082 ce->setAttribute(_("child_count"), String::from(childCount), mxml_int_type);
00083 int autoscanType = cont->getAutoscanType();
00084 ce->setAttribute(_("autoscan_type"), mapAutoscanType(autoscanType));
00085
00086 String autoscanMode = _("none");
00087 if (autoscanType > 0)
00088 {
00089 autoscanMode = _("timed");
00090 #ifdef HAVE_INOTIFY
00091 if (ConfigManager::getInstance()->getBoolOption(CFG_IMPORT_AUTOSCAN_USE_INOTIFY))
00092 {
00093 Ref<AutoscanDirectory> adir = storage->getAutoscanDirectory(cont->getID());
00094 if ((adir != nil) && (adir->getScanMode() == InotifyScanMode))
00095 autoscanMode = _("inotify");
00096 }
00097 #endif
00098 }
00099 ce->setAttribute(_("autoscan_mode"), autoscanMode);
00100 ce->setTextKey(_("title"));
00101 ce->setText(cont->getTitle());
00102 containers->appendElementChild(ce);
00103
00104 }
00105 }