Tag Archives: Script

CDS-Invenio: List DELETED RECORDS from collection name – python script

Some time ago I posted some cds invenio mysql useful queries. Some people wrote some days ago asking wether I could put this into a function. Here you are ;)

List all deleted records which belong(ed) to collection ‘colname’ (tested with Invenio 0.99.x)

def listDeletedFromCollname(colname, coltag='980__c'):
  from invenio.dbquery import run_sql
  query = """ SELECT distinct bibrec_bib98x.id_bibrec 
              FROM bib98x, bibrec_bib98x
              WHERE bib98x.tag='%s' AND bib98x.value = '%s' AND bib98x.id = bibrec_bib98x.id_bibxxx       
                    AND bibrec_bib98x.id_bibrec IN (SELECT DISTINCT bibrec_bib98x.id_bibrec 
                                      FROM bibrec_bib98x, bib98x 
                                      WHERE bibrec_bib98x.id_bibxxx=bib98x.id AND
                                            bib98x.tag = '980__c' AND
                                            bib98x.value = 'DELETED') """ %(coltag,colname)
  res = run_sql(query)
  deletedlist = []
  for i in res:
    deletedlist.append(i[0])
  return deletedlist

And it is used like:

# list deleted records from a collecion defined by the query '980__c:FH'
a = listDeletedFromCollname('FH')
print a
 
# if I have my collection defined in another way, for instance using this query: '980__a:TAZ'
a = listDeletedFromCollname('TAZ','980__a')
print a

In a similar fashion we can list the ones that have NOT been deleted, as in:

def listNotDeletedFromCollname(colname, coltag='980__c'):
  from invenio.dbquery import run_sql
  query = """ SELECT distinct bibrec_bib98x.id_bibrec 
              FROM bib98x, bibrec_bib98x
              WHERE bib98x.tag='%s' AND bib98x.value = '%s' AND bib98x.id = bibrec_bib98x.id_bibxxx       
                    AND bibrec_bib98x.id_bibrec NOT IN (SELECT DISTINCT bibrec_bib98x.id_bibrec 
                                      FROM bibrec_bib98x, bib98x 
                                      WHERE bibrec_bib98x.id_bibxxx=bib98x.id AND
                                            bib98x.tag = '980__c' AND
                                            bib98x.value = 'DELETED') """ %(coltag,colname)
  res = run_sql(query)
  notdeletedlist = []
  for i in res:
    notdeletedlist.append(i[0])
  return deletedlist

Hope it’s useful :)

vBulletin: adsense module for vBAdvanced [SOLVED]

vBulletin users usually purchase vBAdvanced to increase their forums potential. It is a great tool for doing things like:

Creating google adsense module

For my adsense ads in my right column I just created a simple template with the Adsense script inside of a <center> tag.

Follow this steps:

1 AdminCP > vBa CMPS > Add Module > Template Module
2I called mine adv_portal_publicidad but you can call yours anything you want after the “adv_portal_” part. Copy & past the code below into the template. Change the parts inside of the “script” tags to be your own code that the Google Adsense page generated for you. Save the template.

<center>
<script type="text/javascript"><!--
google_ad_client = "pub-8302299911530853";
google_ad_width = 120;
google_ad_height = 240;
google_ad_format = "120x240_as";
google_ad_channel ="6330441493";
google_color_border = "B4D0DC";
google_color_bg = "ECF8FF";
google_color_link = "0000CC";
google_color_url = "008000";
google_color_text = "6F6F6F";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</center>

3Edit your “homepage” page in vBa panel and include the adv_portal_publicidad module in the right column.

That’s all, folks!

W3C validator issues with ampersand (&) in javascript location.href

When I tried to validate the code for http://www.hyips.es (one of my freelance projects) the validator kept complaining:

cannot generate system identifier for general entity langpair.

This error is caused by the validator parsing the code inside of a <script> tag. Below are the lines which were producing the error (related to a function which translates the page from spanish to english using google translator):

<script type="text/javascript"> 
function es2eng(){
  location.href = "http://translate.google.com/translate?u=" + this.location.href + "&langpair=es|en&h1=es&ie=UTF-8"; 
}
</script>
<a href="#" onclick="es2eng();"><img style="border: medium none; margin:1px;" src="/images/banderas/england-flag.gif" alt="translate to english" height="20" width="30" /></a>

After reading a lot of confussing comments (like Try to change ‘&’ to ‘&amp;’ or to ‘%26′), and just when I was about to define the function in an external js file (not a big fan of this, because the function was only one line long…), I came to this revealing post in webmasterworld.com.

The problem can be solved as easy as this: change

<script type="text/javascript">
your script is here
</script>

To:

<script type="text/javascript">
// <![CDATA[
your script is here
// ]]>
</script>

The change stops W3C’s validator from parsing the code inside the script tags, therefore the error disappears! :-)