Exemplo n.º 1
0
	def onInit(self):
		osiris.IMainPage.onInit(self)		
		
		self.document = osiris.XMLDocument()
		self.document.create("mcp")
		
		template = osiris.HtmlXSLControl()
		template.stylesheet = self.loadStylesheet(os.path.join(os.path.dirname(__file__), "mcp.xsl"))
		template.document = self.document		
		self.getArea(osiris.pageAreaContent).controls.add(template)
		
		if(self.getMcpMode()):
			if(osiris.Options.instance().getWebMcpPassword() != ""):
				self.cmdLogout = osiris.IdeButton(self.getText("main.pages.mcp.action.logout"))
				self.cmdLogout.id = "logout"
				self.cmdLogout.isDefault = True
				osiris.events.connect(self.cmdLogout.eventClick, self.onLogout)
				template.addChildParam(self.cmdLogout)
		else:
			self.txtPassword = osiris.HtmlTextBox()
			self.txtPassword.id = "password"
			self.txtPassword.password = True
			template.addChildParam(self.txtPassword)
		
			self.cmdLogin = osiris.IdeButton(self.getText("main.pages.mcp.action.login"))
			self.cmdLogin.id = "login"
			self.cmdLogin.isDefault = True
			osiris.events.connect(self.cmdLogin.eventClick, self.onLogin)			
			template.addChildParam(self.cmdLogin)
Exemplo n.º 2
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        document = osiris.XMLDocument()
        root = document.create("skinpreview")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "skinpreview.xsl"))
        template.document = document

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)

        self.saveCommand = osiris.IdeButton(
            self.getText("common.actions.save"))
        self.saveCommand.id = "save"
        self.saveCommand.iconHref = self.skin.getImageUrl(
            "icons/16x16/save.png")
        template.addChildParam(self.saveCommand)

        self.chkBoolean = osiris.IdePickerBool()
        self.chkBoolean.id = "boolean"
        template.addChildParam(self.chkBoolean)

        self.txtText = osiris.HtmlTextBox()
        self.txtText.id = "text"
        self.txtText.size = 60
        self.txtText.value = "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
        template.addChildParam(self.txtText)
Exemplo n.º 3
0
    def onLoad(self):
        osiris.IPortalPage.onLoad(self)

        document = osiris.XMLDocument()
        self.root = document.create("page")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "importer.xsl"))
        template.document = document

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)

        self.act = self.request.getUrlParam("act")

        if (self.act == ""):
            document.root.setAttributeString("mode",
                                             self.request.getUrlParam("mode"))

            self.root.setAttributeString("subscribe_href",
                                         self.portal.generateInviteLink(False))
            self.root.setAttributeString("isis_subscribe_href",
                                         self.portal.generateInviteLink(True))
            self.root.setAttributeString("export_href",
                                         self.portal.generateExportLink())
        elif (self.act == "start"):
            self.portal.runJobImporter(
                "http://www.osiris-sps.org/utils/exporter/?act=export")
Exemplo n.º 4
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        document = osiris.XMLDocument()
        root = document.create("help")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "help.xsl"))
        template.document = document

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)

        document.root.setAttributeString("mode",
                                         self.request.getUrlParam("mode"))

        document.root.setAttributeString(
            "version",
            osiris.Engine.instance().getVersionName(True))

        document.root.setAttributeString(
            "href_about",
            osiris.PortalsSystem.instance().getMainLink("about"))
        document.root.setAttributeString(
            "href_home",
            osiris.IsisSystem.instance().resolveItemLink("home"))
        document.root.setAttributeString(
            "href_forum",
            osiris.IsisSystem.instance().resolveItemLink("forum"))
Exemplo n.º 5
0
    def onInit(self):
        osiris.IMainPage.onInit(self)

        document = osiris.XMLDocument()
        self.root = document.create("isis")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "isis.xsl"))
        template.document = document

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)

        self.act = self.session.request.getUrlParam("act")
        if (self.act == ""):
            self.act = "home"

        self.root.setAttributeString("action", self.act)

        if (self.act == "home"):

            #osiris.events.connect(self.events.get("onAdd"), self.onAdd)
            #osiris.events.connect(self.events.get("onEdit"), self.onEdit)
            osiris.events.connect(self.events.get("onRemove"), self.onRemove)
        elif ((self.act == "add") or (self.act == "edit")):

            self.saveCommand = osiris.IdeButton(
                self.getText("common.actions.save"))
            self.saveCommand.id = "save"
            self.saveCommand.iconHref = self.skin.getImageUrl(
                "icons/16x16/save.png")
            osiris.events.connect(self.saveCommand.eventClick, self.onSave)
            template.addChildParam(self.saveCommand)

            self.cboPortal = osiris.HtmlComboBox()
            self.cboPortal.id = "portal"
            self.cboPortal.size = 40
            template.addChildParam(self.cboPortal)

            self.txtName = osiris.HtmlTextBox()
            self.txtName.id = "name"
            self.txtName.size = 40
            template.addChildParam(self.txtName)

            self.txtUrl = osiris.HtmlTextBox()
            self.txtUrl.id = "url"
            self.txtUrl.size = 40
            template.addChildParam(self.txtUrl)

            self.txtPassword = osiris.HtmlTextBox()
            self.txtPassword.id = "password"
            self.txtPassword.size = 40
            template.addChildParam(self.txtPassword)

            self.chkEnabled = osiris.IdePickerBool()
            self.chkEnabled.id = "enabled"
            template.addChildParam(self.chkEnabled)
Exemplo n.º 6
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        document = osiris.XMLDocument()
        root = document.create("testsuite")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "testsuite.xsl"))
        template.document = document
        self.getArea(osiris.pageAreaContent).controls.add(template)
Exemplo n.º 7
0
    def onLoad(self):
        osiris.IPortalPage.onLoad(self)

        document = osiris.XMLDocument()
        self.root = document.create("assistant")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "assistant.xsl"))
        template.document = document

        self.controls.add(template)
Exemplo n.º 8
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        document = osiris.XMLDocument()
        root = document.create("page")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "page.xsl"))
        template.document = document
        self.controls.add(template)

        root.setAttributeString("session", self.session.state.getID())
Exemplo n.º 9
0
    def onLoad(self):
        osiris.IPortalPage.onLoad(self)

        self.act = self.session.request.getUrlParam("act")
        if (self.act == ""):
            self.act = "home"

        self.document = osiris.XMLDocument()
        self.root = self.document.create(self.act)
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "peers.xsl"))
        template.document = self.document

        self.document.root.setAttributeString("page_url", self.request.rawUrl)

        if (self.act == "home"):

            self.addPeerIP = osiris.HtmlTextBox()
            self.addPeerIP.id = "addPeerIP"
            self.addPeerIP.css = "os_input_full"
            template.addChildParam(self.addPeerIP)

            self.addPeerPort = osiris.HtmlTextBox()
            self.addPeerPort.id = "addPeerPort"
            self.addPeerPort.css = "os_input_full"
            template.addChildParam(self.addPeerPort)

            self.addPeerCommand = osiris.IdeButton(
                self.getText("common.actions.add"))
            self.addPeerCommand.id = "addPeerCommand"
            osiris.events.connect(self.addPeerCommand.eventClick,
                                  self.onAddPeer)
            template.addChildParam(self.addPeerCommand)

        #if(self.act == "your"):
        #
        #	client = osiris.Engine.instance().createHttpClient()
        #
        #	url = "check.php?port=" + str(osiris.Options.instance().getServerPort()) + "&output=xml";
        #	if(osiris.Options.instance().getOptionBool("p2p.enable") == False):
        #		url += "&notest";
        #	client.perform(osiris.HttpUrl(osiris.Options.instance().getIsisLink(url)))
        #	#osiris.LogManager.instance().log(osiris.Options.instance().getIsisLink(url))
        #	self.document.parseBuffer(client.response.content.content)
        #	self.document.root.setAttributeBool("p2p_enabled",osiris.Options.instance().getOptionBool("p2p.enable"))

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)
Exemplo n.º 10
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        self.showMessage("This is a message")
        self.showWarning("This is a warning")
        self.showError("This is an error")

        document = osiris.XMLDocument()
        root = document.create("folder")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "elements.xsl"))
        template.document = document
        self.getArea(osiris.pageAreaContent).controls.add(template)
Exemplo n.º 11
0
    def onLoad(self):
        osiris.IMainPage.onLoad(self)

        document = osiris.XMLDocument()
        self.root = document.create("login")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "login_main.xsl"))
        template.document = document
        self.getArea(osiris.pageAreaContent).controls.add(template)

        #template.addChildParam(self.username)
        template.addChildParam(self.password)
        template.addChildParam(self.savePassword)
        template.addChildParam(self.cmdLogin)
Exemplo n.º 12
0
	def onLoad(self):
		osiris.IPortalPage.onLoad(self)
		
		document = osiris.XMLDocument()
		self.root = document.create("register")
		template = osiris.HtmlXSLControl()
		template.stylesheet = self.loadStylesheet(os.path.join(os.path.dirname(__file__), "register.xsl"))
		template.document = document
		self.getArea(osiris.pageAreaContent).controls.add(template)		
		
		template.addChildParam(self.username)	
		template.addChildParam(self.password)	
		template.addChildParam(self.passwordChecker)	
		template.addChildParam(self.savePassword)	
		template.addChildParam(self.cmdRegister)	
		template.addChildParam(self.cmdCancel)	
Exemplo n.º 13
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        document = osiris.XMLDocument()
        root = document.create("folder")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "images.xsl"))
        template.document = document
        self.getArea(osiris.pageAreaContent).controls.add(template)

        self.listFiles(
            document.root,
            osiris.Options.instance().getDataPath() +
            "/extensions/138B613D055759C619D5F4EFD9FDB978387E97CB/htdocs",
            "images")
Exemplo n.º 14
0
    def onLoad(self):
        osiris.IPortalPage.onLoad(self)

        document = osiris.XMLDocument()
        self.root = document.create("stats")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "stats.xsl"))
        template.document = document

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)

        document.root.setAttributeString("mode",
                                         self.request.getUrlParam("mode"))

        document.root.setAttributeString(
            "machine_id",
            osiris.Engine.instance().getMachineID())

        document.root.setAttributeString("align_hash",
                                         self.portal.options.getAlignHash())

        document.root.setAttributeString(
            "acceptable_hash", self.portal.optionsShared.getAcceptableHash())

        self.query = osiris.IdeTableQuery()
        self.query.id = "stats_table"

        sql = "select "
        sql += "(select count(*) from os_entries) as objects_total, "
        sql += "(select count(*) from os_snapshot_objects) as entities_total, "
        sql += "(select count(*) from os_snapshot_objects where visible=0) as entities_invisible, "
        sql += "(select count(*) from os_entries where rank<0) as objects_trash, "
        sql += "(select min(stability_date) from os_snapshot_objects) as min_stab, "
        sql += "(select max(stability_date) from os_snapshot_objects) as max_stab "

        self.query.setSql(sql)
        self.query.setColumnType(0, osiris.IdeTableQuery.ctString)
        self.query.setColumnType(1, osiris.IdeTableQuery.ctString)
        self.query.setColumnType(2, osiris.IdeTableQuery.ctString)
        self.query.setColumnType(3, osiris.IdeTableQuery.ctString)
        self.query.setColumnType(4, osiris.IdeTableQuery.ctShortDateTime)
        self.query.setColumnType(5, osiris.IdeTableQuery.ctShortDateTime)
        template.addChildParam(self.query)
Exemplo n.º 15
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        document = osiris.XMLDocument()
        root = document.create("omlhelp")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "omlhelp.xsl"))
        template.document = document

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)

        document.root.setAttributeString("mode",
                                         self.request.getUrlParam("mode"))
Exemplo n.º 16
0
    def onLoad(self):
        osiris.IMainPage.onLoad(self)

        self.addCss(self.skin.getResourceUrl("css/main/external.css"))

        url = self.request.getUrlParam("url")
        if url != "":
            document = osiris.XMLDocument()
            root = document.create("page")
            root.attributes.set("url", url)
            root.attributes.set("confirm", self.request.getUrlParam("confirm"))

            template = osiris.HtmlXSLControl()
            template.stylesheet = self.loadStylesheet(
                os.path.join(os.path.dirname(__file__), "external.xsl"))
            template.document = document

            self.getArea(osiris.pageAreaContent).controls.add(template)
Exemplo n.º 17
0
    def onLoad(self):
        osiris.IMainPage.onLoad(self)

        url = self.request.getUrlParam("url")
        if url != "":
            redirectMetaTag = osiris.HtmlMetaTag()
            redirectMetaTag.httpEquiv = "refresh"
            redirectMetaTag.content = "2; url=" + url
            self.addMetaTag(redirectMetaTag)

            document = osiris.XMLDocument()
            root = document.create("page")
            root.attributes.set("url", url)

            template = osiris.HtmlXSLControl()
            template.stylesheet = self.loadStylesheet(
                os.path.join(os.path.dirname(__file__), "redirect.xsl"))
            template.document = document
            self.getArea(osiris.pageAreaContent).controls.add(template)
Exemplo n.º 18
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        self.page.addCss("/" + globalvars.extension.id.getString() +
                         "/css/pythoninfo.css")

        document = osiris.XMLDocument()
        root = document.create("modules")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "pythoninfo.xsl"))
        template.document = document
        self.getArea(osiris.pageAreaContent).controls.add(template)

        from pyinfo import pyinfo
        output = pyinfo()
        output = "<div class=\"pyinfo\">" + output + "</div>"
        self.getArea(osiris.pageAreaContent).controls.add(
            osiris.HtmlLiteral(output))
Exemplo n.º 19
0
	def onPreRender(self):
		osiris.IMainPage.onPreRender(self)	
		
		helpID = self.session.request.getUrlParam("id")	
		title = self.session.request.getUrlParam("title")	
		hide = self.session.request.getUrlParam("hide")	
				
		if(hide == "true"):			
			osiris.Options.instance().setHelpTipStatus(helpID, True)
		else:			
			hide = osiris.Options.instance().getHelpTipStatus(helpID)
			
			if(hide == False):
				document = osiris.XMLDocument()
				root = document.create("helptip")
				template = osiris.HtmlXSLControl()
				template.stylesheet = self.loadStylesheet(os.path.join(os.path.dirname(__file__), "helptip.xsl"))
				template.document = document
				self.controls.add(template)
				
				document.root.setAttributeString("id", helpID)
				document.root.setAttributeString("title", title)
Exemplo n.º 20
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        document = osiris.XMLDocument()
        root = document.create("page")

        self.renderPageActions(root)
        self.renderSubscribedPortals(root)

        if (osiris.ExtensionsSystem.instance().knownUpgradableCounter != -1):
            root.attributes.set(
                "upgradable_counter",
                osiris.ExtensionsSystem.instance().getKnownUpgradableCounter())

        if (osiris.IsisSystem.instance().getLatestOsirisVersion() != ""):
            if (osiris.Engine.instance().getVersionName(False) !=
                    osiris.IsisSystem.instance().getLatestOsirisVersion()):
                root.attributes.set(
                    "latest_osiris_notes",
                    osiris.IsisSystem.instance().getLatestOsirisNotes())

        #root.attributes.set("subscribe_self_portal_href",self.getEventCommand("onPortalSelfCreate"))
        root.attributes.set(
            "subscribe_self_portal_href",
            osiris.PortalsSystem.instance().getMainLink("subscribe?mode=self"))

        if (self.sessionAccount.isLogged() == True):
            root.attributes.set("session_user",
                                self.sessionAccount.getUserID().string)
        else:
            root.attributes.set("session_user", "")

        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "home.xsl"))
        template.document = document
        self.getArea(osiris.pageAreaContent).controls.add(template)
Exemplo n.º 21
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        act = self.session.request.getUrlParam("act")

        token = self.session.request.getUrlParam("token")
        snippetCode = self.session.request.getUrlParam("code")
        answer = self.session.request.getUrlParam("answer")
        remember = self.session.request.getUrlParam("remember")

        if (act == "play"):
            if ((self.session.state != None)
                    and (token == self.session.state.token)):

                if (remember == "yes"):
                    osiris.Options.instance().setOptionString(
                        "extensions.htmlsnippet." + snippetCode, answer)
                else:
                    if (answer == "yes"):
                        self.session.state.set(
                            "extensions.htmlsnippet." + snippetCode, "yes")

            else:
                osiris.LogManager.instance().log("invalid token")

        else:
            document = osiris.XMLDocument()
            root = document.create("htmlsnippet")
            template = osiris.HtmlXSLControl()
            template.stylesheet = self.loadStylesheet(
                os.path.join(os.path.dirname(__file__), "pagehtml.xsl"))
            template.document = document
            self.controls.add(template)

            document.root.attributes.set("extension_id",
                                         core.extension.id.getString())

            if (self.request.hasPostParam("action_global")):
                osiris.Options.instance().setOptionString(
                    "extensions.htmlsnippet.global",
                    self.request.getPostParam("action_global").getString())

            globalAction = osiris.Options.instance().getOptionString(
                "extensions.htmlsnippet.global")
            document.root.attributes.set("action_global", globalAction)

            for snippet in core.snippetsList:
                snippetNode = document.root.addChild("snippet")

                snippetNode.setAttributeString("code", snippet.code)
                snippetNode.setAttributeString("name", snippet.name)
                snippetNode.setAttributeString("category", snippet.category)
                snippetNode.attributes.set("url", snippet.url)
                snippetNode.attributes.set(
                    "href",
                    osiris.PortalsSystem.instance().getExternalLink(
                        snippet.url, True))
                snippetNode.setAttributeString("security", snippet.security)
                snippetNode.setAttributeBool("notes", snippet.notes)

                if (self.request.hasPostParam("action_" + snippet.code)):
                    newValue = self.request.getPostParam(
                        "action_" + snippet.code).getString()
                    oldValue = osiris.Options.instance().getOptionString(
                        "extensions.htmlsnippet." + snippet.code)
                    if (newValue != oldValue):
                        if (self.session.state != None):
                            self.session.state.set("extensions.htmlsnippet." +
                                                   snippet.code, "")  # Reset
                        osiris.Options.instance().setOptionString(
                            "extensions.htmlsnippet." + snippet.code, newValue)

                snippetAction = osiris.Options.instance().getOptionString(
                    "extensions.htmlsnippet." + snippet.code)
                snippetNode.attributes.set("action", snippetAction)

                snippetNode.setAttributeString("status",
                                               snippet.getCurrentAction(self))
Exemplo n.º 22
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        document = osiris.XMLDocument()
        root = document.create("help")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "network.xsl"))
        template.document = document

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)

        if (self.request.getUrlParam("force") == "true"):
            osiris.IsisSystem.instance().doTask(True)

        document.root.setAttributeString("mode",
                                         self.request.getUrlParam("mode"))

        document.root.setAttributeDateTime(
            "last_request",
            osiris.IsisSystem.instance().getLastRequest())
        document.root.setAttributeString(
            "last_error",
            osiris.IsisSystem.instance().getLastError())
        document.root.setAttributeString("ip",
                                         osiris.IsisSystem.instance().getIp())
        document.root.setAttributeInt32(
            "port",
            osiris.Options.instance().getServerPort())
        document.root.setAttributeString(
            "country_code",
            osiris.IsisSystem.instance().getCountryCode())
        document.root.setAttributeString(
            "country_name",
            osiris.IsisSystem.instance().getCountryName())
        document.root.setAttributeBool(
            "reachable",
            osiris.IsisSystem.instance().getReachable())
        document.root.setAttributeInt32("tor",
                                        osiris.IsisSystem.instance().getTor())

        if (osiris.IsisSystem.instance().getLastValidationDate().isNull() ==
                False):
            document.root.setAttributeDateTime(
                "last_validation_date",
                osiris.IsisSystem.instance().getLastValidationDate())

        document.root.setAttributeDateTime(
            "last_check_date",
            osiris.IsisSystem.instance().getLastCheckDate())

        document.root.setAttributeBool(
            "p2p_enabled",
            osiris.Options.instance().getOptionBool("p2p.enable"))

        dta = osiris.IsisSystem.instance().isInternetDateTimeAvailable()
        document.root.setAttributeBool("internet_datetime_available", dta)
        if (dta):
            dts = osiris.DateTime.now()
            dti = osiris.IsisSystem.instance().getInternetDateTime()
            delta = osiris.TimeDuration(dts, dti)
            document.root.setAttributeDateTime("internet_datetime", dti)
            document.root.setAttributeDateTime("system_datetime", dts)
            document.root.setAttributeInt32("internet_datetime_delta",
                                            delta.getTotalSeconds())
            document.root.setAttributeString(
                "internet_datetime_sync_method",
                osiris.IsisSystem.instance().getInternetDateTimeSyncMethod())
Exemplo n.º 23
0
    def onLoad(self):
        osiris.IPortalPage.onLoad(self)

        self.act = self.session.request.getUrlParam("act")
        if (self.act == ""):
            self.act = "home"

        self.document = osiris.XMLDocument()
        self.root = self.document.create(self.act)
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "acp.xsl"))
        template.document = self.document

        #self.document.root.setAttributeString("page_url",self.request.rawUrl);

        osiris.LogManager.instance().log(
            self.sessionAccount.userID.getString())
        osiris.LogManager.instance().log(self.portal.povID.getString())

        if (self.sessionAccount.userID.getString() ==
                self.portal.povID.getString()):
            osiris.LogManager.instance().log("kkk")

        isGuest = self.sessionAccount.isPortalGuest(self.database)
        self.root.setAttributeBool("isGuest", isGuest)

        self.root.setAttributeString(
            "stabilization_stats_href",
            self.portal.getLink("stabilization_stats"))
        self.root.setAttributeString("trash_href",
                                     self.portal.getLink("trash"))

        if (isGuest == False):
            # Hack, to fix: senza le getString le rileva diversi sempre...
            isUserOfPov = (self.sessionAccount.isPortalGuest(self.database)
                           == False and self.sessionAccount.userID.getString()
                           == self.portal.povID.getString())
            self.root.setAttributeBool("isUserOfPov", isUserOfPov)

            povOfUser = osiris.PortalsSystem.instance().getPortal(
                self.portal.portalID, self.sessionAccount.userID.getString())
            self.root.setAttributeBool("povOfUserExists", (povOfUser != None))

            povOfUserHref = ""
            if (povOfUser != None):
                povOfUserHref = povOfUser.getLink("acp")
            else:
                params = {}
                params["mode"] = "fork"
                params["name"] = self.portal.optionsShared.portalName
                params["id"] = self.portal.portalID.toWide()
                povOfUserHref = osiris.PortalsSystem.instance().getMainLink(
                    "subscribe", params)

            self.root.setAttributeString("povOfUserHref", povOfUserHref)

        if (self.act == "home"):

            self.saveCommand = osiris.IdeButton(
                self.getText("common.actions.save"))
            self.saveCommand.id = "saveCommand"
            self.saveCommand.iconHref = self.skin.getImageUrl(
                "icons/16x16/save.png")
            osiris.events.connect(self.saveCommand.eventClick, self.onSave)
            template.addChildParam(self.saveCommand)

            self.portalName = osiris.HtmlTextBox()
            self.portalName.id = "portalName"
            self.portalName.css = "os_input_full"
            self.portalName.getAttributes().set("data-os-otype", "string")
            self.portalName.getAttributes().set("data-os-minchars", "5")
            self.portalName.getAttributes().set("data-os-submit",
                                                "page-saveCommand")
            template.addChildParam(self.portalName)

            self.portalDescription = osiris.HtmlTextBox()
            self.portalDescription.id = "portalDescription"
            self.portalDescription.css = "os_input_full"
            template.addChildParam(self.portalDescription)

            self.authorsReputationThreshold = osiris.HtmlComboBox()
            self.authorsReputationThreshold.id = "authorsReputationThreshold"
            template.addChildParam(self.authorsReputationThreshold)
            self.authorsReputationThreshold.addOption(
                self.getText("reputation.threshold.all"), "0")
            self.authorsReputationThreshold.addOption(
                self.getText("reputation.threshold.negative"), "1")
            self.authorsReputationThreshold.addOption(
                self.getText("reputation.threshold.not_negative"), "2")
            self.authorsReputationThreshold.addOption(
                self.getText("reputation.threshold.positive"), "3")

            self.editorsReputationThreshold = osiris.HtmlComboBox()
            self.editorsReputationThreshold.id = "editorsReputationThreshold"
            template.addChildParam(self.editorsReputationThreshold)
            self.editorsReputationThreshold.addOption(
                self.getText("reputation.threshold.all"), "0")
            self.editorsReputationThreshold.addOption(
                self.getText("reputation.threshold.negative"), "1")
            self.editorsReputationThreshold.addOption(
                self.getText("reputation.threshold.not_negative"), "2")
            self.editorsReputationThreshold.addOption(
                self.getText("reputation.threshold.positive"), "3")

            self.txtPovWhiteList = osiris.HtmlTextBox()
            self.txtPovWhiteList.id = "povWhiteList"
            self.txtPovWhiteList.css = "os_input_full"
            template.addChildParam(self.txtPovWhiteList)

            self.txtPovBlackList = osiris.HtmlTextBox()
            self.txtPovBlackList.id = "povBlackList"
            self.txtPovBlackList.css = "os_input_full"
            template.addChildParam(self.txtPovBlackList)

            # Layout

            self.layoutComponent = osiris.IdePickerComponent()
            self.layoutComponent.id = "layoutComponent"
            self.layoutComponent.css = "os_input_full"
            template.addChildParam(self.layoutComponent)

            #self.registerTerms = osiris.IdeOMLEditor()
            #self.registerTerms.id = "registerTerms"
            #self.registerTerms.css = "os_input_full"
            #template.addChildParam(self.registerTerms)

            self.layoutTileImage = osiris.IdePickerObject()
            self.layoutTileImage.id = "layoutTileImage"
            template.addChildParam(self.layoutTileImage)

            self.layoutTileColorBackground = osiris.IdePickerColor()
            self.layoutTileColorBackground.id = "layoutTileColorBackground"
            template.addChildParam(self.layoutTileColorBackground)

            self.layoutTileColorForeground = osiris.IdePickerColor()
            self.layoutTileColorForeground.id = "layoutTileColorForeground"
            template.addChildParam(self.layoutTileColorForeground)

            self.layoutSkinParams = osiris.IdeOMLEditor()
            self.layoutSkinParams.id = "layoutSkinParams"
            self.layoutSkinParams.css = "os_input_full"
            template.addChildParam(self.layoutSkinParams)

            self.layoutCss = osiris.IdeOMLEditor()
            self.layoutCss.id = "layoutCss"
            self.layoutCss.css = "os_input_full"
            template.addChildParam(self.layoutCss)

            self.layoutHeader = osiris.IdePickerBool()
            self.layoutHeader.id = "layoutHeader"
            template.addChildParam(self.layoutHeader)

            # Rules

            self.objectsMaxSize = osiris.IdePickerNumber()
            self.objectsMaxSize.id = "objectsMaxSize"
            template.addChildParam(self.objectsMaxSize)

            self.badWords = osiris.HtmlTextBox()
            self.badWords.id = "badWords"
            self.badWords.css = "os_input_full"
            template.addChildParam(self.badWords)

            # Rules ex

            self.allowObjectInFuture = osiris.IdePickerBool()
            self.allowObjectInFuture.id = "allowObjectInFuture"
            template.addChildParam(self.allowObjectInFuture)

            self.allowObjectUnsigned = osiris.IdePickerBool()
            self.allowObjectUnsigned.id = "allowObjectUnsigned"
            template.addChildParam(self.allowObjectUnsigned)

            self.objectsPhysicalRemove = osiris.IdePickerBool()
            self.objectsPhysicalRemove.id = "objectsPhysicalRemove"
            template.addChildParam(self.objectsPhysicalRemove)

            self.objectsPhysicalRemoveDays = osiris.IdePickerNumber()
            self.objectsPhysicalRemoveDays.id = "objectsPhysicalRemoveDays"
            template.addChildParam(self.objectsPhysicalRemoveDays)

            if (self.postBack == False):

                # Main
                self.portalName.value = self.portal.name
                self.portalDescription.value = self.portal.optionsShared.portalDescription
                self.authorsReputationThreshold.value = self.portal.optionsShared.authorsReputationThreshold
                self.editorsReputationThreshold.value = self.portal.optionsShared.editorsReputationThreshold
                self.txtPovWhiteList.value = self.portal.optionsShared.povWhiteList
                self.txtPovBlackList.value = self.portal.optionsShared.povBlackList

                # Layout

                self.layoutComponent.value = self.portal.optionsShared.layoutComponent
                #self.registerTerms.value = self.portal.optionsShared.registerTerms
                self.layoutTileImage.value = self.portal.optionsShared.layoutTileImage
                self.layoutTileColorBackground.value = self.portal.optionsShared.layoutTileColorBackground
                self.layoutTileColorForeground.value = self.portal.optionsShared.layoutTileColorForeground
                self.layoutSkinParams.value = self.portal.optionsShared.layoutSkinParams
                self.layoutCss.value = self.portal.optionsShared.layoutCss
                self.layoutHeader.check = self.portal.optionsShared.layoutHeader

                # Rules

                self.objectsMaxSize.value = self.portal.optionsShared.objectsMaxSize
                self.badWords.value = self.portal.optionsShared.badWords

                # Rules Ex

                self.allowObjectInFuture.check = self.portal.optionsShared.allowObjectInFuture
                self.allowObjectUnsigned.check = self.portal.optionsShared.allowObjectUnsigned
                self.objectsPhysicalRemove.check = self.portal.optionsShared.objectsPhysicalRemove
                self.objectsPhysicalRemoveDays.value = self.portal.optionsShared.objectsPhysicalRemoveDays

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)
Exemplo n.º 24
0
	def onLoad(self):	
		osiris.IMainPage.onLoad(self)
		
		if(self.sessionAccount.isLogged() == False):
			self.redirect("home")
			return
		
		self.act = self.session.request.getUrlParam("act")
		if(self.act == ""):
			self.act = "home"		
				
		self.document = osiris.XMLDocument()
		self.root = self.document.create(self.act)
		template = osiris.HtmlXSLControl()
		template.stylesheet = self.loadStylesheet(os.path.join(os.path.dirname(__file__), "account.xsl"))
		template.document = self.document
				
		self.saveCommand = osiris.IdeButton(self.getText("common.actions.save"))
		self.saveCommand.id = "saveCommand"
		self.saveCommand.iconHref = self.skin.getImageUrl("icons/16x16/save.png")
		osiris.events.connect(self.saveCommand.eventClick, self.onSave)
		template.addChildParam(self.saveCommand)
		
		self.txtName = osiris.HtmlTextBox()
		self.txtName.id = "name"
		self.txtName.size = 40
		template.addChildParam(self.txtName)

		self.txtPassword = osiris.HtmlTextBox()
		self.txtPassword.id = "password"
		self.txtPassword.size = 40
		self.txtPassword.setPassword(True)
		template.addChildParam(self.txtPassword)
		
		self.skinPicker = osiris.IdePickerSkin()
		self.skinPicker.id = "skin"		
		self.skinPicker.setShowSystem(True)
		template.addChildParam(self.skinPicker)


		self.languagePicker = osiris.IdePickerCulture()
		self.languagePicker.id = "language"		
		self.languagePicker.setShowSystem(True)
		template.addChildParam(self.languagePicker)
				
		osiris.events.connect(self.events.get("onAccountExport"), self.onAccountExport)
		self.document.root.attributes.set("export_href",self.getEventCommand("onAccountExport"))		

		osiris.events.connect(self.events.get("onAccountRemove"), self.onAccountRemove)
		self.document.root.attributes.set("remove_href",self.getEventCommand("onAccountRemove"))		

		
		
		if(self.postBack == False):
			self.txtName.value = self.getSessionAccount().account.name
			self.txtPassword.value = self.getSessionAccount().account.getRealPassword()
			self.skinPicker.value = self.getSessionAccount().account.skinID.getString()
			self.languagePicker.value = self.getSessionAccount().language;
						
		if(self.ajax):
			self.controls.add(template)
		else:
			self.getArea(osiris.pageAreaContent).controls.add(template)		
Exemplo n.º 25
0
def load(page):
    document = osiris.XMLDocument()
    document.parseFile(os.path.join(os.path.dirname(__file__), "about.xml"))
    template = osiris.HtmlXSLControl()
    template.stylesheet = page.loadStylesheet(
        os.path.join(os.path.dirname(__file__), "about.xsl"))
    template.document = document

    mode = page.session.request.getUrlParam("mode")
    filter = page.session.request.getUrlParam("filter")

    document.root.attributes.set("mode", mode)
    document.root.attributes.set("filter", filter)
    document.root.attributes.set(
        "version",
        osiris.Engine.instance().getVersionName(False))
    document.root.attributes.set(
        "href_home",
        osiris.Options.instance().getIsisLink("link.php", "id=home"))

    if ((filter == "") or (filter == "changelog")):
        pathChangelog = os.path.join(osiris.Options.instance().getSharePath(),
                                     "changelog.txt")
        changelog = osiris.TextFile.readFile(pathChangelog)
        document.root.attributes.set("changelog", changelog)

    if ((filter == "") or (filter == "license")):
        culture = osiris.LanguageManager.instance().getCulture(
            page.getLanguage())
        while (culture != None):
            pathLicense = os.path.join(
                osiris.Options.instance().getSharePath(),
                "license/" + culture.getID() + ".txt")
            license = osiris.TextFile.readFile(pathLicense)
            if (license != ""):
                document.root.attributes.set("license", license)
                break

            culture = culture.parent

    if (page.getMcpMode()):
        if ((filter == "") or (filter == "sysinfo")):
            nodeInstaller = document.root.addChild("installer")
            nodeInstaller.attributes.set(
                "folders.share",
                osiris.Options.instance().getSharePath())
            nodeInstaller.attributes.set(
                "folders.data",
                osiris.Options.instance().getDataPath())
            nodeInstaller.attributes.set(
                "folders.temp",
                osiris.Options.instance().getTempPath())
            nodeInstaller.attributes.set(
                "folders.log",
                osiris.Options.instance().getLogPath())

    if ((filter == "") or (filter == "libraries")):
        nodeLibraries = document.root.addChild("libraries")

        libraries = osiris.ThirdPartyLibrariesReporter.instance().libraries
        for library in libraries:
            nodeLibrary = osiris.XMLNode()
            nodeLibrary.name = "library"

            nodeLibrary.attributes.set("name", library.name)
            if (library.version != ""):
                nodeLibrary.attributes.set("version", library.version)
            if (library.description != ""):
                nodeLibrary.attributes.set("description", library.description)
            if (library.url != ""):
                nodeLibrary.attributes.set("home", library.url)
                #nodeLibrary.attributes.set("href_home", osiris.PortalsSystem.instance().getExternalLink(library.url, True))
                nodeLibrary.attributes.set("href_home", library.url)
            if (library.license != ""):
                nodeLibrary.attributes.set("license", library.license)
            if (library.licenseUrl != ""):
                #nodeLibrary.attributes.set("href_license", osiris.PortalsSystem.instance().getExternalLink(library.licenseUrl, True))
                nodeLibrary.attributes.set("href_license", library.licenseUrl)

            nodeLibraries.addChild(nodeLibrary)

    if (filter == "general"):
        page.pathway.add(page.getText("main.pages.about.title.general"),
                         page.request.rawUrl)
    if (filter == "changelog"):
        page.pathway.add(page.getText("main.pages.about.title.changelogs"),
                         page.request.rawUrl)
    if (filter == "license"):
        page.pathway.add(page.getText("main.pages.about.title.license"),
                         page.request.rawUrl)
    if (filter == "libraries"):
        page.pathway.add(page.getText("main.pages.about.title.third_parties"),
                         page.request.rawUrl)
    if (filter == "sysinfo"):
        page.pathway.add(page.getText("main.pages.about.title.system_info"),
                         page.request.rawUrl)

    if (page.ajax):
        page.controls.add(template)
    else:
        page.getArea(osiris.pageAreaContent).controls.add(template)
Exemplo n.º 26
0
	def processHtml(self, item, context):
	
		output = ""
		
		if context.getMode() == osiris.omlRenderModeSearch:
			return "{HTML-Snippet}"
		
		#if(context.checkPortalPageAvailable(item) == False):
		#	return ""
		
		#if(context.getPortalPage() == None):
		#	context.addWarning("HTML Snippet: Must be used in portal pages.")
		#	return ""
		
		if(context.page == None): # Don't know why, but occur...
			return ""
			
		html = item.getSingleText()
		
		# Replaces
		html = html.replace("{os:ref_id}", context.getRefID());
		html = html.replace("{os:obj_id}", context.page.getRequest().getUrlParam("id"));
		html = html.replace("{os:url}", context.getFullUrl());
		html = html.replace("{os:lang}", context.page.getLanguage());		
				
		# Debugging box helper
		if( (item.getParam("mode") == "debug") and (context.getMode() == osiris.omlRenderModeOsiris) ):
			output += "<div class=\"os_htmlsnippet_debug1\">";
			output += osiris.OMLManager.instance().parse("[code=\"" + str(item.getParam("title")) + "\"]" + str(html) + "[/code]", context.page, True, True, False, osiris.omlRenderModeOsiris, "", "")				
			output += "<div class=\"os_htmlsnippet_debug2\">";
		
		# Start cleaning HTML, pre removing lines.
				
		html = re.sub(" // [^\n]*?\n","\n", html) # Remove JS // comments. TODO: Check if inside a <script> tag. Note: very ugly regex. I'm unable to use lookbehind or regex advanced syntax to accomplish that.
			
		# Start cleaning HTML, Removing lines.		
		html = html.replace("\n","")
		html = html.replace("\r","")
		
		# Start cleaning HTML, post removing lines.
		html = html.replace("\t","")
		html = re.sub("/\*(.*?)\*/","", html) # Remove JS comments. TODO: Check if inside a <script> tag.				
		html = re.sub("\<\!\-\-(.*?)\-\-\>","", html) # Remove HTML comments.
		
		# TODO: Remove <noscript>. Ininfluent in Osiris, that require it.
		html = re.sub("\<noscript\>([\s\S]*?)\</noscript\>","",html)
		
		ready = False
		while (ready == False):
			oldHtml = html			
			#html = html.replace("  "," ")
			# TODO: The following must be done only OUTSIDE <script> tag.
			#html = html.replace("> <","><")			
			#html = html.replace("> ",">")
			#html = html.replace(" <","<")			
			# TODO: The following must be done only INSIDE <script> tag.
			html = html.replace("; ",";")
			html = html.replace(" ;",";")
			html = html.replace("= ","=")
			html = html.replace(" =","=")
			html = html.replace(" {","{")
			html = html.replace("{ ","{")
			html = html.replace(" }","{")
			html = html.replace("} ","{")
			
			ready = (html == oldHtml)
			
		html = html.strip() # Trim
			
		# End cleaning HTML
				
		result = "unknown"		
				
		isIsis = (context.page.getRequestSource() != osiris.IPage.rsOsiris)
						
		for snippet in core.snippetsList:
		
			if( (hasattr(snippet,"debug")) and (snippet.debug) ):
				osiris.LogManager.instance().log(snippet.name + " : " + "Debug mode.")
				osiris.LogManager.instance().log(snippet.name + " : " + "HTML : " + html)
				
			if(hasattr(snippet,"matchRe")):		
				
				if( (hasattr(snippet,"debug")) and (snippet.debug) ):
					osiris.LogManager.instance().log(snippet.name + " : " + "Matching regular expressions")					
					
				for matchReSingle in snippet.matchRe:
					regex = "^" + matchReSingle + "$"
					
					regexWithMacro = regex
					
					for macroName in macros.regexMacros:
						macroValue = macros.regexMacros[macroName];
						regex = regex.replace("{@" + macroName + "}",macroValue);
					
					if( (hasattr(snippet,"debug")) and (snippet.debug) ):
						osiris.LogManager.instance().log(snippet.name + " : " + "Regex: " + regex)
					
					prog = re.compile(regex, re.M)
						
					# Test if be macro-optimized
					macroEdition = regex
					for macroName in macros.regexMacros:
						macroValue = macros.regexMacros[macroName];
						macroEdition = macroEdition.replace(macroValue, "{@" + macroName + "}");
					if(macroEdition != regexWithMacro):
						if macroEdition.endswith("$"): 
							macroEdition = macroEdition[:-1]
						if macroEdition.startswith("^"): 
							macroEdition = macroEdition[1:]
						macroEdition = macroEdition.replace("\\","\\\\")
						macroEdition = macroEdition.replace("\"","\\\"")
						macroEdition = "\"" + macroEdition + "\""

						if( (hasattr(snippet,"debug")) and (snippet.debug) ):
							osiris.LogManager.instance().log(snippet.name + " : " + "Warning: Suggested Macro edition python variable: " + macroEdition)
							
		
					if prog.match(html) is not None:
						if( (hasattr(snippet,"debug")) and (snippet.debug) ):
							osiris.LogManager.instance().log(snippet.name + " : " + "Match regex.")
						result = snippet.getCurrentAction(context.page)
			
			if(hasattr(snippet,"match")):
				if(snippet.match(html)):
					if( (hasattr(snippet,"debug")) and (snippet.debug) ):
						osiris.LogManager.instance().log(snippet.name + " : " + "Match method.")
					result = snippet.getCurrentAction(context.page)
						
			if(result == "session"):
				result = "yes"
				
			if( (result == "ask") and (isIsis) ):
				result = "no"
				
			if( (context.getMode() == osiris.omlRenderModeSearch) and (result == "ask") ):
				result = "no"
				
			if( (context.getMode() == osiris.omlRenderModeExternal) and (result == "ask") ):
				result = "no"
					
			if(result == "ask"):
				
				#context.page.addJavascript("/9A53510BB471C48AF9B7954466D123438C387368/js/htmlsnippet.js")
				#context.page.addCss("/9A53510BB471C48AF9B7954466D123438C387368/css/htmlsnippet.css")
				
				document = osiris.XMLDocument()
				root = document.create("html")
				
				root.attributes.set("extension_id", core.extension.id.getString())			
				
				root.attributes.set("code", snippet.code)		
				root.attributes.set("name", snippet.name)		
				root.attributes.set("url", snippet.url)						
				root.attributes.set("href", osiris.PortalsSystem.instance().getExternalLink(snippet.url, True))						
				root.attributes.set("security", snippet.security)
				root.attributes.set("notes", snippet.notes)
				root.attributes.set("reload", snippet.reload)
				root.attributes.set("token", context.page.getSession().state.token)				
				
				root.attributes.set("uid", context.getContextNextID())
				
				
				# Javascript encoding
				htmlEncoded = html
				htmlEncoded = htmlEncoded.replace("\n","\\n")
				htmlEncoded = htmlEncoded.replace("\r","\\r")
				htmlEncoded = htmlEncoded.replace("\"","\\\"")				
				htmlEncoded = htmlEncoded.replace("'","\\'")				
				root.attributes.set("html", htmlEncoded)		
				
				# Detect / suggest width & height
				width = 0
				height = 0
				
				# Detect Width
				progC = re.compile("^(.*?)width\s?\=\s?['\"]?([0-9]*)['\"]?(.*?)$", re.M)
				progM = progC.match(html)
				if progM is not None:
					width = int(progM.group(2))
					
				# Detect Height
				progC = re.compile("^(.*?)height\s?\=\s?['\"]?([0-9]*)['\"]?(.*?)$", re.M)
				progM = progC.match(html)
				if progM is not None:
					height = int(progM.group(2))

				
				# Ask width & height to snippet
				if( (width == 0) and (hasattr(snippet,"width")) ):
					width = snippet.width
				
				if( (height == 0) and (hasattr(snippet,"height")) ):
					height = snippet.height
					
				# Use default width & height
				if(width == 0):
					width = 160
				if(height == 0):
					height = 160
				
				root.attributes.set("width", width)		
				root.attributes.set("height", height)		
				
				stylesheet = context.page.loadStylesheet(os.path.join(os.path.dirname(__file__), "omlhtml.xsl"))				
				outputAsk = stylesheet.applyToString2(document)
								
				output += outputAsk;
				break
		
			elif(result == "yes"):				
				output += str(html)
				break
		
			elif(result == "no"):
				context.addWarning("HTML Snippet: '" + snippet.name + "' is detected, but output is disabled.")				
				break			
		
		if(result == "unknown"):
			context.addWarning("HTML Snippet: Unknown html code.")	
			
		if( (item.getParam("mode") == "debug") and (context.getMode() == osiris.omlRenderModeOsiris) ):
			output += "<div style=\"clear:both\"></div></div></div>";
			
		return output
		
		
Exemplo n.º 27
0
    def onPreRender(self):
        osiris.IMainPage.onPreRender(self)

        action = self.session.request.getUrlParam("act")
        if (action == ""):
            action = "home"

        document = osiris.XMLDocument()
        root = document.create(action)
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "addons.xsl"))

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)

        if ((action == "home") or (action == "upgradable")):
            client = osiris.Engine.instance().createHttpClient()
            mode = self.session.request.getUrlParam("mode")
            online = False

            document.root.addChild("lists")

            currents = ""
            extensions = osiris.ExtensionsSystem.instance().extensions
            for k in extensions.keys():
                extension = extensions[k]
                if (extension.internal == False):
                    #currents += extension.id.getString() + ":{0:.5f};".format(extension.versionCode);
                    currents += extension.id.getString() + ":" + str(
                        extension.versionCode) + ";"
            client.request.method = osiris.httpMethodPost
            client.request.setPostParamString("currents", currents)
            #osiris.LogManager.instance().log("currents:" + currents)
            if (client.perform(osiris.HttpUrl(self.getIsisUrl(action)))):
                remoteDocument = osiris.XMLDocument()
                online = remoteDocument.parseBuffer(
                    client.response.content.content)
                if (online):
                    document = remoteDocument

            if ((online) and (action == "upgradable") and (mode == "counter")):
                osiris.ExtensionsSystem.instance().setKnownUpgradableCounter(
                    document.root.getAttributeInt32("upgradable_counter"))

            document.root.setAttributeBool("online", online)

            if (action == "home"):
                lists = document.root.getNode("lists")

                self.processRemoteList(lists.getNode("recommended"), online)
                self.processRemoteList(lists.getNode("catalog"), online)
                self.processRemoteList(lists.getNode("upgradable"), online)

                nodeInstalled = document.root.getNode("lists").addChild(
                    "installed")
                extensions = osiris.ExtensionsSystem.instance().extensions
                for k in extensions.keys():
                    extension = extensions[k]
                    if (extension.internal == False):
                        nodeAddon = nodeInstalled.nodes.add("addon")
                        nodeAddon.setAttributeString("id",
                                                     extension.id.getString())
                        self.processExtension(nodeAddon, online, "local", True,
                                              False)

        if (action == "addon"):
            id = self.session.request.getUrlParam("id")
            online = False

            client = osiris.Engine.instance().createHttpClient()
            if (client.perform(
                    osiris.HttpUrl(self.getIsisUrl("single", "id=" + id)))):
                remoteDocument = osiris.XMLDocument()
                online = remoteDocument.parseBuffer(
                    client.response.content.content)
                if (online):
                    document = remoteDocument

            mode = self.session.request.getUrlParam("mode")
            showActions = (
                self.session.request.getUrlParam("actions") == "yes")
            showTrust = (self.session.request.getUrlParam("trust") == "yes")

            #osiris.LogManager.instance().log("show actions: " + self.session.request.getUrlParam("actions"))
            #osiris.LogManager.instance().log(self.session.request.getRawUrl())

            self.processExtension(document.root, online, mode, showActions,
                                  showTrust)

        if ((action == "upgrade") or (action == "uninstall")
                or (action == "activate") or (action == "deactivate")
                or (action == "install")):

            id = self.session.request.getUrlParam("id")
            href = "/main/addons?act=job&id=" + id + "&type=" + action

            document.root.setAttributeString("id", id)
            document.root.setAttributeString("token",
                                             self.session.state.createToken())

        if (action == "icon"):
            id = self.session.request.getUrlParam("id")
            extension = osiris.ExtensionsSystem.instance().getExtension(
                str(id))
            if (extension):
                self.session.transmitFile(extension.path + "/" +
                                          extension.icon)

        if (action == "logo"):
            id = self.session.request.getUrlParam("id")
            extension = osiris.ExtensionsSystem.instance().getExtension(
                str(id))
            if (extension):
                self.session.transmitFile(extension.path + "/" +
                                          extension.logo)

        if (action == "job"):
            id = self.session.request.getUrlParam("id")
            jobType = self.session.request.getUrlParam("type")
            token = self.session.request.getUrlParam("token")

            if (self.session.state.hasToken(str(token))):
                # osiris.LogManager.instance().log("jobs request: " + id + "," + jobType)

                #job = osiris.MainAddonsJob(osiris.Engine.instance().peekBackgroundJobID(), jobType)
                #job.extensionID = id

                #if( (jobType == "install") or (jobType == "upgrade") ):
                #	job.url = self.getIsisUrl("download","id=" + id)
                #osiris.Engine.instance().addBackgroundJob(job)

                url = ""
                if ((jobType == "install") or (jobType == "upgrade")):
                    url = self.getIsisUrl("download", "id=" + id)

                osiris.Engine.instance().startExtensionsJob(
                    jobType, str(id), url)

            else:
                osiris.LogManager.instance().log(
                    "Invalid token for requested addons action.")

        template.document = document
Exemplo n.º 28
0
    def onLoad(self):
        osiris.IPortalPage.onLoad(self)

        osiris.events.connect(self.events.get("onPortalRemove"),
                              self.onPortalRemove)

        document = osiris.XMLDocument()
        self.root = document.create("info")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "info.xsl"))
        template.document = document

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)

        node = self.root

        node.setAttributeString("mode", self.request.getUrlParam("mode"))

        if (self.act == "home"):

            if (self.sessionAccount.isLogged()):
                #self.showMessage("logged")
                self.isUserOfPov = (self.sessionAccount.userID.getString() ==
                                    self.portal.povID.getString())
                self.root.setAttributeBool("isUserOfPov", self.isUserOfPov)

                self.povOfUser = osiris.PortalsSystem.instance().getPortal(
                    self.portal.portalID,
                    self.sessionAccount.userID.getString())
                self.root.setAttributeBool("povOfUserExists",
                                           (self.povOfUser != None))

            nodeActions = node.nodes.add("actions")

            nodeAction = nodeActions.nodes.add("action")
            nodeAction.attributes.set("name", "home")
            nodeAction.attributes.set("href", self.portal.getLink("view"))

            if (self.sessionAccount.isLogged()):
                if (self.isUserOfPov):
                    nodeAction = nodeActions.nodes.add("action")
                    nodeAction.attributes.set("name", "acp")
                    nodeAction.attributes.set("href",
                                              self.portal.getLink("acp"))
                elif (self.povOfUser == None):
                    params = {}
                    params["mode"] = "fork"
                    params["name"] = self.portal.name
                    params["id"] = self.portal.portalID.toWide()
                    nodeAction = nodeActions.nodes.add("action")
                    nodeAction.attributes.set("name", "fork")
                    nodeAction.attributes.set("prefix", "main.pages.subscribe")
                    nodeAction.attributes.set(
                        "href",
                        osiris.PortalsSystem.instance().getMainLink(
                            "subscribe", params))

            #nodeAction = nodeActions.nodes.add("action")
            #nodeAction.attributes.set("name", "info")
            #nodeAction.attributes.set("href", self.portal.getLink("info"))

            #nodeAction = nodeActions.nodes.add("action")
            #nodeAction.attributes.set("name", "accounts")
            #nodeAction.attributes.set("href", osiris.PortalsSystem.instance().getMainLink("accounts?portal=" + self.portal.getFullPovID()))

            nodeAction = nodeActions.nodes.add("action")
            nodeAction.attributes.set("name", "settings")
            nodeAction.attributes.set(
                "href",
                osiris.PortalsSystem.instance().getMainLink(
                    "settings?portal=" + self.portal.getFullPovID()))

            #nodeAction = nodeActions.nodes.add("action")
            #nodeAction.attributes.set("name", "invite")
            #nodeAction.attributes.set("call", self.portal.getLink("invite?mode=dialog"))

            nodeAction = nodeActions.nodes.add("action")
            nodeAction.attributes.set("name", "remove")
            #nodeAction.attributes.set("href", osiris.PortalsSystem.instance().getMainLink("removeportal?portal=" + self.portal.getFullPovID()))
            nodeAction.attributes.set("prefix", "portal.pages.info")
            nodeAction.attributes.set(
                "href",
                self.getEventCommand("onPortalRemove",
                                     self.portal.getFullPovID()))
            nodeAction.attributes.set("confirm", "true")

            # Details

            node.attributes.set("id", self.portal.portalID.string)
            node.attributes.set("pov", self.portal.povID.string)
            node.attributes.set("name", self.portal.name)
            if self.portal.optionsShared.portalDescription != "":
                node.attributes.set(
                    "description", self.portal.optionsShared.portalDescription)

            #node.setAttributeString("machine_id", osiris.Engine.instance().getMachineID())
            #node.setAttributeString("align_hash", self.portal.options.getAlignHash().getString())
            #node.setAttributeString("acceptable_hash", self.portal.optionsShared.getAcceptableHash())

            nodeIsisEndpoints = node.nodes.add("isis")
            isisEndpoints = self.portal.options.isisEndpoints
            osiris.events.connect(self.events.get("onIsisRemove"),
                                  self.onIsisRemove)
            for isisEndpointID in isisEndpoints.keys():
                isisEndpoint = isisEndpoints[isisEndpointID]
                nodeIsis = nodeIsisEndpoints.nodes.add("isis")

                nodeIsis.attributes.set("name", isisEndpoint.getName())
                nodeIsis.attributes.set("url", isisEndpoint.url.toString())
                nodeIsis.attributes.set("enabled", isisEndpoint.enabled)
                nodeIsis.attributes.set("last_event",
                                        isisEndpoint.getLastEvent())

                nodeIsis.attributes.set(
                    "edit_href",
                    self.portal.getLink("info") + "?act=isis_edit&id=" +
                    str(isisEndpointID))
                nodeIsis.attributes.set(
                    "remove_href",
                    self.getEventCommand("onIsisRemove", str(isisEndpointID)))
            nodeIsisEndpoints.attributes.set(
                "add_href",
                self.portal.getLink("info") + "?act=isis_add")

            node.attributes.set(
                "exchangeEnabled",
                "true" if self.portal.options.exchangeEnabled else "false")

            if (osiris.Options.instance().getWebMcpPassword() != ""):
                node.attributes.set(
                    "publicEnabled",
                    "true" if self.portal.options.publicEnabled else "false")
                node.attributes.set(
                    "default", "true" if
                    (osiris.Options.instance().getWebDefaultPortal()
                     == self.portal.getFullPovID().toUTF16()) else "false")

            node.attributes.set("lastObjectDate",
                                self.portal.options.lastObjectDate.toXML())
            node.attributes.set("lastExchangeDate",
                                self.portal.options.lastExchangeDate.toXML())
            node.attributes.set(
                "lastDownloadedObjectDate",
                self.portal.options.lastDownloadedObjectDate.toXML())
            node.attributes.set(
                "lastUploadedObjectDate",
                self.portal.options.lastUploadedObjectDate.toXML())
            node.attributes.set(
                "lastOptimizationDate",
                self.portal.options.lastOptimizationDate.toXML())
            node.attributes.set("lastSyncDate",
                                self.portal.options.lastSyncDate.toXML())

            node.setAttributeUint32("nodesSameAlign",
                                    self.portal.nodesSameAlign)
            node.setAttributeUint32("nodesSamePortalPov",
                                    self.portal.nodesSamePortalPov)

            # Invite
            self.root.setAttributeString("subscribe_href",
                                         self.portal.generateInviteLink(False))
            self.root.setAttributeString("isis_subscribe_href",
                                         self.portal.generateInviteLink(True))
            self.root.setAttributeString("export_href",
                                         self.portal.generateExportLink())

            # Settings
            self.saveCommand = osiris.IdeButton(
                self.getText("common.actions.save"))
            self.saveCommand.id = "save"
            self.saveCommand.iconHref = self.skin.getImageUrl(
                "icons/16x16/save.png")
            osiris.events.connect(self.saveCommand.eventClick, self.onSave)
            template.addChildParam(self.saveCommand)

            self.chkExchange = osiris.IdePickerBool()
            self.chkExchange.id = "exchange"
            template.addChildParam(self.chkExchange)

            self.txtPassword = osiris.HtmlTextBox()
            self.txtPassword.id = "password"
            self.txtPassword.size = 20
            template.addChildParam(self.txtPassword)

            self.cboSync = osiris.HtmlComboBox()
            self.cboSync.id = "sync"
            template.addChildParam(self.cboSync)
            self.cboSync.addOption(
                self.getText("portal.pages.info.settings.sync.none"), "")
            subscribedPortals = osiris.PortalsSystem.instance().portals
            for portal2 in subscribedPortals:
                #osiris.LogManager.instance().log(portal2.getPovName() + "," + self.portal.getPortalID().getString() + "-" + portal2.getPortalID().getString())
                if (self.portal.getPortalID().getString() ==
                        portal2.getPortalID().getString()):
                    if (self.portal.getPovID().getString() !=
                            portal2.getPovID().getString()):
                        self.cboSync.addOption(portal2.getPovName(),
                                               portal2.getFullPovID())

            if (self.postBack == False):
                self.chkExchange.check = self.portal.options.getExchangeEnabled(
                )
                self.txtPassword.value = self.portal.options.getPassword()
                self.cboSync.value = self.portal.getSync()
        elif ((self.act == "isis_add") or (self.act == "isis_edit")):
            self.saveCommand = osiris.IdeButton(
                self.getText("common.actions.save"))
            self.saveCommand.id = "save"
            self.saveCommand.iconHref = self.skin.getImageUrl(
                "icons/16x16/save.png")
            osiris.events.connect(self.saveCommand.eventClick, self.onIsisSave)
            template.addChildParam(self.saveCommand)

            self.txtName = osiris.HtmlTextBox()
            self.txtName.id = "name"
            self.txtName.size = 40
            template.addChildParam(self.txtName)

            self.txtUrl = osiris.HtmlTextBox()
            self.txtUrl.id = "url"
            self.txtUrl.size = 40
            template.addChildParam(self.txtUrl)

            self.txtPassword = osiris.HtmlTextBox()
            self.txtPassword.id = "password"
            self.txtPassword.size = 40
            template.addChildParam(self.txtPassword)

            self.chkEnabled = osiris.IdePickerBool()
            self.chkEnabled.id = "enabled"
            template.addChildParam(self.chkEnabled)
Exemplo n.º 29
0
    def onInit(self):
        osiris.IMainPage.onInit(self)

        document = osiris.XMLDocument()
        self.root = document.create("accounts")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "accounts.xsl"))
        template.document = document

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)

        self.act = self.session.request.getUrlParam("act")
        if (self.act == ""):
            self.act = "home"

        self.root.setAttributeString("action", self.act)

        if (self.act == "home"):

            osiris.events.connect(self.events.get("onExport"), self.onExport)
            osiris.events.connect(self.events.get("onRemove"), self.onRemove)

            nodeActions = self.root.nodes.add("actions")

            actionRegisterParams = {}
            actionRegisterParams["act"] = "register"
            actionRegister = nodeActions.nodes.add("action")
            actionRegister.attributes.set("name", "register")
            actionRegister.attributes.set(
                "href",
                osiris.PortalsSystem.instance().getMainLink(
                    "accounts", actionRegisterParams))

            actionImportParams = {}
            actionImportParams["act"] = "import"
            actionImport = nodeActions.nodes.add("action")
            actionImport.attributes.set("name", "import")
            actionImport.attributes.set(
                "href",
                osiris.PortalsSystem.instance().getMainLink(
                    "accounts", actionImportParams))

        if (self.act == "login"):
            self.userid = self.session.request.getUrlParam("id")
            if ((self.userid == None) or (self.userid == "")):
                self.redirect("accounts")
                return

            account = osiris.IdeAccountsManager.instance().getByID(self.userid)
            if (account == None):
                return

            savedPassword = account.getRealPassword()
            if (savedPassword != ""):
                if (self.loginAccountWithID(self.userid, savedPassword)):
                    self.redirect("home")

            self.txtPassword = osiris.HtmlTextBox()
            self.txtPassword.id = "password"
            self.txtPassword.size = 20
            self.txtPassword.getAttributes().set("data-os-otype", "string")
            self.txtPassword.getAttributes().set("data-os-submit",
                                                 "page-login")
            self.txtPassword.password = True
            template.addChildParam(self.txtPassword)

            self.chkSavePassword = osiris.IdePickerBool()
            self.chkSavePassword.id = "savePassword"
            template.addChildParam(self.chkSavePassword)

            self.cmdLogin = osiris.IdeButton(
                self.getText("main.pages.accounts.enter"))
            self.cmdLogin.id = "login"
            self.cmdLogin.isDefault = True
            osiris.events.connect(self.cmdLogin.eventClick, self.onLogin)
            template.addChildParam(self.cmdLogin)

        if (self.act == "register"):
            self.txtName = osiris.HtmlTextBox()
            self.txtName.id = "name"
            self.txtName.size = 20
            template.addChildParam(self.txtName)

            self.txtPassword = osiris.HtmlTextBox()
            self.txtPassword.id = "password"
            self.txtPassword.size = 20
            self.txtPassword.attributes.set("data-os-otype", "password")
            self.txtPassword.attributes.set("data-os-login", "page_name")
            self.txtPassword.password = True
            template.addChildParam(self.txtPassword)

            self.txtPasswordChecker = osiris.HtmlTextBox()
            self.txtPasswordChecker.id = "passwordChecker"
            self.txtPasswordChecker.size = 20
            self.txtPasswordChecker.password = True
            template.addChildParam(self.txtPasswordChecker)

            #self.secretQuestion = osiris.HtmlTextBox()
            #self.secretQuestion.id = "secretQuestion"
            #self.secretQuestion.css = "os_input_full"

            #self.secretResponse = osiris.HtmlTextBox()
            #self.secretResponse.id = "secretResponse"
            #self.secretResponse.css = "os_input_full"
            #self.secretResponse.password = True

            #self.secretResponseChecker = osiris.HtmlTextBox()
            #self.secretResponseChecker.id = "secretResponseChecker"
            #self.secretResponseChecker.password = True

            self.chkSavePassword = osiris.IdePickerBool()
            self.chkSavePassword.id = "savePassword"
            template.addChildParam(self.chkSavePassword)

            self.cmdRegister = osiris.IdeButton(
                self.getText("common.actions.create"))
            self.cmdRegister.id = "register"
            self.cmdRegister.isDefault = True
            osiris.events.connect(self.cmdRegister.eventClick, self.onRegister)
            template.addChildParam(self.cmdRegister)

        if (self.act == "import"):

            self.txtFile = osiris.HtmlFileBrowser()
            self.txtFile.id = "file"
            self.txtFile.size = 20
            template.addChildParam(self.txtFile)

            self.cmdImport = osiris.IdeButton(
                self.getText("main.pages.accounts.import"))
            self.cmdImport.id = "import"
            self.cmdImport.isDefault = True
            osiris.events.connect(self.cmdImport.eventClick, self.onImport)
            template.addChildParam(self.cmdImport)
Exemplo n.º 30
0
    def onLoad(self):
        osiris.IPortalPage.onLoad(self)

        document = osiris.XMLDocument()
        self.root = document.create("stats")
        template = osiris.HtmlXSLControl()
        template.stylesheet = self.loadStylesheet(
            os.path.join(os.path.dirname(__file__), "stabilization_stats.xsl"))
        template.document = document

        if (self.ajax):
            self.controls.add(template)
        else:
            self.getArea(osiris.pageAreaContent).controls.add(template)

        document.root.setAttributeString("acp_href",
                                         self.portal.getLink("acp"))

        document.root.setAttributeString("trash_href",
                                         self.portal.getLink("trash"))

        document.root.setAttributeString("mode",
                                         self.request.getUrlParam("mode"))

        document.root.setAttributeString(
            "machine_id",
            osiris.Engine.instance().getMachineID())

        document.root.setAttributeString(
            "align_hash",
            self.portal.options.getAlignHash().getString())

        document.root.setAttributeString(
            "acceptable_hash", self.portal.optionsShared.getAcceptableHash())

        document.root.setAttributeString(
            "total_objects",
            self.database.getConnection().queryValue(
                "select count(*) from os_entries").getString())
        document.root.setAttributeString(
            "unchecked_objects",
            self.database.getConnection().queryValue(
                "select count(*) from os_entries where rank=-2").getString())
        document.root.setAttributeString(
            "trash_objects",
            self.database.getConnection().queryValue(
                "select count(*) from os_entries where rank=-1").getString())

        self.query = osiris.IdeTableQuery()
        self.query.id = "stats_table"

        sql = "select "
        sql += "(select count(*) from os_entries) as objects_total, "
        sql += "(select count(*) from os_snapshot_objects) as entities_total, "
        sql += "(select count(*) from os_snapshot_objects where visible=0) as entities_invisible, "
        sql += "(select count(*) from os_entries where rank<0) as objects_trash, "
        sql += "(select min(stability_date) from os_snapshot_objects) as min_stab, "
        sql += "(select max(stability_date) from os_snapshot_objects) as max_stab "

        #self.query.setSql(sql)
        self.query.setColumnType(0, osiris.IdeTableQuery.ctString)
        self.query.setColumnType(1, osiris.IdeTableQuery.ctString)
        self.query.setColumnType(2, osiris.IdeTableQuery.ctString)
        self.query.setColumnType(3, osiris.IdeTableQuery.ctString)
        self.query.setColumnType(4, osiris.IdeTableQuery.ctShortDateTime)
        self.query.setColumnType(5, osiris.IdeTableQuery.ctShortDateTime)
        #template.addChildParam(self.query)

        dataTrashReason = osiris.DataTable()
        sql = "select accept_msg, count(*) n from os_entries group by accept_msg"
        self.database.execute(sql, dataTrashReason)
        nodeTrashReason = document.root.nodes.add("trash_reasons")
        for r in range(dataTrashReason.rows()):
            nodeReason = nodeTrashReason.nodes.add("reason")
            nodeReason.setAttributeString(
                "id",
                dataTrashReason.get(r, "accept_msg").getString())
            nodeReason.setAttributeString(
                "n",
                dataTrashReason.get(r, "n").getString())

        nodeObjectsTypes = document.root.nodes.add("objects_types")

        self.queryObjectType("user", 1, nodeObjectsTypes)

        self.queryObjectType("section", 3, nodeObjectsTypes)
        self.queryObjectType("instance", 4, nodeObjectsTypes)
        self.queryObjectType("text", 5, nodeObjectsTypes)
        self.queryObjectType("file", 8, nodeObjectsTypes)
        self.queryObjectType("model", 15, nodeObjectsTypes)
        self.queryObjectType("poll", 12, nodeObjectsTypes)
        self.queryObjectType("poll_option", 13, nodeObjectsTypes)
        self.queryObjectType("calendar_event", 16, nodeObjectsTypes)
        #self.queryObjectType("attachment",18,nodeObjectsTypes)
        #self.queryObjectType("tag",9,nodeObjectsTypes)
        self.queryObjectType("post", 6, nodeObjectsTypes)

        self.queryObjectType("reputation", 2, nodeObjectsTypes)
        self.queryObjectType("avatar", 7, nodeObjectsTypes)

        #self.queryObjectType("attribute",10,nodeObjectsTypes)
        #self.queryObjectType("privatemessage",11,nodeObjectsTypes)

        self.queryObjectType("vote", 14, nodeObjectsTypes)
        self.queryObjectType("poll_vote", 17, nodeObjectsTypes)