Exemplo n.º 1
0
 def _process(self):
     if len(self._material.getResourceList()) == 1:
         res = self._material.getResourceList()[0]
         if isinstance(res, conference.Link):
             url = res.getURL()
             if url.find(".wmv") != -1:
                 urlwmv = urlHandlers.UHVideoWmvAccess().getURL(res)
                 self._redirect(urlwmv)
             elif url.find(".flv") != -1 or url.find("rtmp://") != -1:
                 urlflash = urlHandlers.UHVideoFlashAccess().getURL(res)
                 self._redirect(urlflash)
             else:
                 self._redirect(res.getURL())
         elif isinstance(res, conference.LocalFile):
             self._redirect(urlHandlers.UHFileAccess.getURL(res))
     else:
         #raise "%s"%self._material.getOwner()
         if self._material.getConference() != None:
             p = material.WPMaterialConfDisplayBase(self, self._material)
         else:
             p = material.WPMaterialCatDisplayBase(self, self._material)
         wf = self.getWebFactory()
         if wf is not None:
             p = wf.getMaterialDisplay(self, self._material)
         return p.display()
Exemplo n.º 2
0
    def _process(self):
        # material pages should not be cached, since protection can change
        self._disableCaching()

        if len(self._material.getResourceList()) == 1:
            res = self._material.getResourceList()[0]

            self._notify('materialDownloaded', res)

            if isinstance(res, conference.Link):
                url = res.getURL()
                if url.find(".wmv") != -1:
                    urlwmv = urlHandlers.UHVideoWmvAccess().getURL(res)
                    self._redirect(urlwmv)
                elif url.find(".flv") != -1 or url.find(
                        ".f4v") != -1 or url.find("rtmp://") != -1:
                    urlflash = urlHandlers.UHVideoFlashAccess().getURL(res)
                    self._redirect(urlflash, noCache=True)
                else:
                    self._redirect(res.getURL(), noCache=True)
            elif isinstance(res, conference.LocalFile):
                self._redirect(urlHandlers.UHFileAccess.getURL(res),
                               noCache=True)
        else:
            return self._processManyMaterials()
Exemplo n.º 3
0
 def _getURL(self, resource):
     url = resource.getURL()
     if url.find(".wmv") != -1:
         url = urlHandlers.UHVideoWmvAccess().getURL(resource)
     elif url.find(".flv") != -1 or url.find(".f4v") != -1 or url.find("rtmp://") != -1:
         url = urlHandlers.UHVideoFlashAccess().getURL(resource)
     return url
Exemplo n.º 4
0
    def getVars(self):
        vars = wcomponents.WTemplated.getVars(self)
        contrib = None
        mf = None
        if isinstance(self._material.getOwner(), conference.Conference):
            mf = ConfMFRegistry().get(self._material)
        elif isinstance(self._material.getOwner(), conference.Session):
            mf = SessionMFRegistry().get(self._material)
        elif isinstance(self._material.getOwner(), conference.Contribution):
            mf = ContribMFRegistry().get(self._material)
            contrib = self._material.getOwner()
        elif isinstance(self._material.getOwner(), conference.SubContribution):
            mf = ContribMFRegistry().get(self._material)
        if mf is None:
            vars["icon"] = quoteattr(
                str(Config.getInstance().getSystemIconURL("material")))
            vars["title"] = self.htmlText(self._material.getTitle())
        else:
            vars["icon"] = quoteattr(str(mf.getIconURL()))
            vars["title"] = self.htmlText(self._material.getTitle())
        vars["description"] = self.htmlText(self._material.getDescription())
        rl = []
        if self._material.getResourceList(
        ) == [] or not self._material.canView(self._aw):
            vars["resources"] = ""
        else:
            for res in self._material.getResourceList():
                if res.isProtected():
                    protection = """&nbsp;<img src=%s style="vertical-align: middle; border: 0;">""" % Config.getInstance(
                    ).getSystemIconURL("protected")
                else:
                    protection = ""
                if type(res) is conference.Link:
                    url = res.getURL()
                    if url.find(".wmv") != -1:
                        url = urlHandlers.UHVideoWmvAccess().getURL(res)
                    elif url.find(".flv") != -1 or url.find("rtmp://") != -1:
                        url = urlHandlers.UHVideoFlashAccess().getURL(res)
                    if res.getName() != "" and res.getName() != res.getURL():
                        title = """<b><a href="%s">%s</a></b>""" % (
                            url, res.getName())
                    else:
                        title = """<small><a href="%s">%s</a></small>""" % (
                            url, res.getURL())
                    rl.append(
                        """<tr><td align="right">[LINK]</td><td width="100%%" align="left">%s%s</td></tr>"""
                        % (title, protection))
                else:
                    iconURL = Config.getInstance().getFileTypeIconURL(
                        res.getFileType())
                    iconHTML = """<img src="%s" alt="">""" % Config.getInstance(
                    ).getSystemIconURL("bigfile")
                    if iconURL != "":
                        iconHTML = """<img src="%s" alt="">""" % iconURL
                    if res.getName() != res.getFileName():
                        rl.append(
                            """
                        <tr>
                            <td align="right"> %s</td>
                            <td align="left"><b>%s</b> <small>(<a href="%s">%s</a> %s - %s)</small>%s</td></tr>
                        """ %
                            (iconHTML, res.getName(),
                             vars["fileAccessURLGen"](res), res.getFileName(),
                             strfFileSize(res.getSize()), res.getCreationDate(
                             ).strftime("%d.%m.%Y %H:%M:%S"), protection))
                    else:
                        rl.append("""
                        <tr>
                            <td align="right"> %s</td>
                            <td align="left"><b><a href="%s">%s</a></b> <small>( %s - %s)</small>%s</td></tr>
                        """ % (iconHTML, vars["fileAccessURLGen"](res),
                               res.getFileName(), strfFileSize(res.getSize()),
                               res.getCreationDate().strftime(
                                   "%d.%m.%Y %H:%M:%S"), protection))

            vars["resources"] = _(
                """<td align="right" valign="top" class="displayField" nowrap><b> _("Resources"):</b></td>
                        <td>%s</td>""") % "".join(rl)
        vars["submitURL"] = quoteattr(
            str(
                urlHandlers.UHMaterialDisplaySubmitResource.getURL(
                    self._material)))
        vars["submitBtn"] = self._getSubmitButtonHTML()
        return vars