|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.mgaip.Replacer
public final class Replacer
Class that replaces the already existent reports.
Control Version
Field Summary | |
---|---|
private static int |
HORIZONTAL_AD
Internal id for horizontal ad. |
private static int |
LOGO_AD
Internal id for logo ad. |
private AdInserterMojo |
report
Mojo that calls the replacer. |
private static int |
UNIQUE_AD
Internal id for unique ad. |
private static int |
VERTICAL_AD
Internal id for vertical ad. |
Constructor Summary | |
---|---|
Replacer(AdInserterMojo caller)
Instantiates the mojo. |
Method Summary | |
---|---|
private boolean |
changeHTMLTag(org.jdom.Element single,
String content)
Replaces an HTML tag with the given type of ad. |
private String |
getAdContent(int type)
Returns the Google ad according to the requested type. |
private org.jdom.Element |
getCommon()
|
private boolean |
getCustomPoweredBy(org.jdom.Element single)
Replaces the customPoweredBy tag with the given code. |
private boolean |
getFacebookILike(org.jdom.Element single)
Returns the I like Facebook script. |
private boolean |
getGooglePlusOne(org.jdom.Element single)
Adds the google plus one script in the page. |
private boolean |
htmlReplacement(org.jdom.Element elem)
Searches the tags to modify the HTML file and call the respective method to insert an ad. |
protected void |
replace(String directory,
String filename)
Open the file, parses the HTML and the searches the defined tags to replace with other content. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int HORIZONTAL_AD
private static final int LOGO_AD
private static final int UNIQUE_AD
private static final int VERTICAL_AD
private AdInserterMojo report
Constructor Detail |
---|
Replacer(AdInserterMojo caller)
caller
- Mojo containing all parameters.Method Detail |
---|
private boolean changeHTMLTag(org.jdom.Element single, String content)
single
- XML component that contains the location of the tag to
replace.content
- Content to insert.
private String getAdContent(int type)
type
- Type of ad.
private org.jdom.Element getCommon()
private boolean getCustomPoweredBy(org.jdom.Element single)
TODO this should call an external javascript file that will contain the code and stuff to show here.
single
- Element where the custom code has to be inserted.
private boolean getFacebookILike(org.jdom.Element single)
<iframe src=
"http://www.facebook.com/plugins/like.php?
href=https%3A%2F%2Fwww.facebook.com%2Fpages%2FZemucan%2F138284808329
&send=false&layout=box_count&width=150&show_faces=false
&action=like&colorscheme=light&font&height=90"
scrolling="no" frameborder="0"
style="border:none; overflow:hidden; width:150px; height:90px;"
allowTransparency="true"></iframe>
The example is for Zemucan, but it is defined in the variable facebookLink. There are two types of links:
However the link has to be transformed from
https://www.facebook.com/pages/Zemucan/138284808329
to
https%3A%2F%2Fwww.facebook.com%2Fpages%2FZemucan%2F138284808329
single
- Element where the code has to be inserted.
private boolean getGooglePlusOne(org.jdom.Element single)
Element
- where the code has to be inserted.
private boolean htmlReplacement(org.jdom.Element elem) throws org.jdom.JDOMException
Vertical (xpath: html/body/div id="leftColumn"/div id="navcolumn" title="googleAds"):
<a href="" title="googleAds" class="poweredBy">
<logo name="googleAds" img="googleAds"/>
</a>
Horizontal (xpath: html/body/div id="bodyColumn"/div id="contextBox"/div class="section"):
<img src="googleAds" alt="googleAds" />
Unique (xpath: html/body/div id="bodyColumn"/div id="contextBox"/div class="section"/p):
<a href="#googleAds">googleAds</a>
Logo (xpath: html/body/div id="banner"/span id="bannerLeft" | id="bannerRight"):
<img src="googleAds" alt="googleAds" />
And then put the publicity:
<script type="text/javascript"><!--
google_ad_client = "XXXXX";
google_ad_slot = "YYYYY";
google_ad_width = 120;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Where XXXXX the google user id, and YYYYY is the ad identifier.
Also, it replaces the powered by for facebook (xpath: html/body/div id="leftColumn"/div id="navcolumn" title="facebookILike").
<a href="" title="facebookILike" class="poweredBy">
<logo name="facebookILike" img="facebookILike"/>
</a>
And a custom code as powered by (xpath: html/body/div id="leftColumn"/div id="navcolumn" title="customPoweredBy").
<a href="" title="customPoweredBy" class="poweredBy">
<logo name="customPoweredBy" img="customPoweredBy"/>
</a>
elem
- Root element.
org.jdom.JDOMException
- If there is a problemprotected void replace(String directory, String filename)
directory
- Directory of the file.filename
- Name of the file to modify.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |