OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Brazilian Government Bar Plugin

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

Brazilian Government Bar Plugin

Postby ramon » Fri Jan 25, 2008 10:33 am

Hello All,

I've been bothering Alec for a while with this, and since he's very busy, I was hoping to get more help out here, as well as discuss the implementation more openly, as many people would like to learn how to get started on a Plugin (so we don't bother PKP so much...).
The Brazilian Government Bar is a visual standard needed in every website from any government institution. It must be at the top, and run across the whole page, being visible in every page.
Anyway, I plan to create a plugin that, according to Alec's analysis, needs to:
  1. Add the extra frame to templates/article/view.tpl
  2. Add the extra content to templates/common/header.tpl
  3. Add the extra content to templates/issue/header.tpl
  4. Implement a new UI function (currently in IndexHandler.inc.php, called setGovHeader)
  5. Add extra style info

I've managed to display the bar without the variables in the right position, but haven't a clue as to how to change the Frameset when viewing the article.
For now, I want to know how to get the URL for the images correctly, without having to do it manually. Also, this plugin must be displayed at Portal level, which means, it must display the bar even if the user is not accessing a specific journal.

This is the output generated
Code: Select all
<script language="javascript" type="text/javascript">
function openNewWindow(url){
   newwindow=window.open(url,'name','height=400,width=200');
   if (window.focus) newwindow.focus() ;
}
</script>
<div class="govbar">
   <form name="govbar">
      <div class="federal">
      <a href="http://www.brasil.gov.br"target="_blank"><img src="/brasil2.gif"width="74" height="21" align="top" alt="Acesse o Portal do Governo Brasileiro"border="0"></a>
   </div><div class="ministry">
      <a href="http://www.mct.gov.br"target="_blank">
         <img src="/plugins/generic/brazilGovBar/images/logo_def2.gif"alt="Acesse o Portal do Ministério da Ciência e Tecnologia"width="430" height="21" border="0">
      </a>

   </div><div class="govselect">
   <select name="govOptions" onChange="if(options[selectedIndex].value) openNewWindow(options[selectedIndex].value)" class="pr"><option value="">Destaques do Governo</option><option value="http://www.brasil.gov.br">Portal do Governo Federal</option><option value="http://www.e.gov.br">Portal de Serviços do Governo</option><option value="http://www.radiobras.gov.br">Portla da Agência Nacional de Notícias</option><option value="http://www.brasil.gov.br/emquestao">Em Questão</option><option value="http://www.fomezero.gov.br">Programa Fome Zero</option></select>
</div>
   </form>
</div


I've manged to use a foreach loop to get the select options dynamically, getting the text and values from a locale xml.
The URL for the images, though, are off, since I can't get the Journal URL, and even if I did, when viewing the portal I'm not sure it would be visible.
The URL should be something like, the following but all my attempts so far have accounted for nothing:
Code: Select all
<img src="'.$baseUrl.'/plugins/generic/brazilGovBar/images/'.$ministryImage.'"alt="'.$ministryImageAlt.'"width="430" height="21" border="0">


Anyone??

I've tried everything, even creating specific functions to return the correct path, but $baseUrl returns something that I don't need or can't use (like the server's main URL - http://cajueiro.ibict.br, or http://cajueiro.ibict.br/seer/ojs2.2/oj ... p/inclusao), when I just need http://cajueiro.ibict.br/seer/ojs2.2/ojs2.2.new/, which should be the $baseUrl.

Is there a way to get this in a plugin without being changed when changing from journal to journal, or journal to Portal view?
ramon
 
Posts: 940
Joined: Wed Oct 15, 2003 6:15 am
Location: Brasí­lia/DF - Brasil

Re: Brazilian Government Bar Plugin

Postby ramon » Thu Jan 31, 2008 6:18 am

Hello All,

Thanks to Alec's huge support off-line, I've managed to change the frameset structure, using strpos and substr_replace functions.
Thanks again.

I've managed to replace the frameset structure correctly, but the URL for the new frame source is not working.

I can't get a variable to return the setGovBar function. If I add just the template, it's displayed as plain text.

Changing the source code manually, I had in templates/article/view.tpl the following code:
Code: Select all
<frameset rows="23,*" frameborder="0" framespacing="0" border="0">
   <frame noresize="noresize" frameborder="0" scrolling="no" src="{url page="index" op="setGovHeader"}" />


Now, I need in my BrazilGovBarPlugin.inc.php to return the result of {url page="index" op="setGovHeader"}.

How do I do this?
ramon
 
Posts: 940
Joined: Wed Oct 15, 2003 6:15 am
Location: Brasí­lia/DF - Brasil

Re: Brazilian Government Bar Plugin

Postby asmecher » Thu Jan 31, 2008 10:01 am

Hi Ramón,

Glad to hear it's progressing!

The {url ...} function is a Smarty operation, and since you're putting together the HTML in PHP, it's never run through the Smarty engine. Instead of:
Code: Select all
{url page="index" op="setGovHeader"}
...use the following in your PHP...
Code: Select all
Request::url(null, "index", "setGovHeader");
This function will return the URL.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9212
Joined: Wed Aug 10, 2005 12:56 pm

Re: Brazilian Government Bar Plugin

Postby ramon » Thu Jan 31, 2008 11:05 am

Alec,

I can't get the template to be displayed.
Again I've tried many ways (obviously not the correct one!) to implement the User Interface function.
The frame source output seems to be ok now:
Code: Select all
<frameset rows="23,*" style="border:0; padding:0; margin:0;">
   <frame noresize="noresize" frameborder="0" scrolling="no" src="http://cajueiro.ibict.br/seer/ojs2.2/ojs2.2.new/index.php/inclusao/index/setGovHeader" />

This is what I have:
Code: Select all
function setGovHeader() {
   $templateMgr = &TemplateManager::getManager();
   $templateMgr->display('plugins/generic/brazilGovBar/brazilGovBar.tpl');
}

Current frameset function (still missing the header when not viewing the article
function commonHeaderFilter($output, &$smarty) {
      $template = Request::url(null, "index", "setGovHeader");
      $newOutput = $output;      
      $frameset = array('<frameset', '</frameset>');
      $framesetReplacer = array(
'<frameset rows="23,*" style="border:0; padding:0; margin:0;">
   <frame noresize="noresize" frameborder="0" scrolling="no" src="'.$template.'" />
   ',
   '</frameset>
'
      );
      
      $div = '<div id="container">';
      
      $divReplacer = '';
      $divMatches = strpos($newOutput, $div);
      $frameMatches = strpos($newOutput, $frameset[0]);   
      if(-1<$frameMatches){
         $newOutput = substr_replace($newOutput, $framesetReplacer[0], $frameMatches, 0);
         $framesetEnd = strpos($newOutput, $frameset[1]);
         if(-1<$framesetEnd) {
            $newOutput = substr_replace($newOutput, $framesetReplacer[1],$framesetEnd, 0);         
         }
      
      }
      return $newOutput;
   }
ramon
 
Posts: 940
Joined: Wed Oct 15, 2003 6:15 am
Location: Brasí­lia/DF - Brasil

Re: Brazilian Government Bar Plugin

Postby asmecher » Thu Jan 31, 2008 12:53 pm

Hi Ramón,

Have you registered a hook to intercept the incoming request? A good example is in the thesis plugin (plugins/generic/thesis), which registers against the LoadHandler hook. (Instead of defining HANDLER_CLASS etc., as the thesis plugin does, you can simply handle the request once you've checked that the value of $page is what you're looking for.)

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9212
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron