It allows developers to create word processing documents by combining user-defined Microsoft Word templates with data from disparate data sources, such as XML files and databases. It is typically used to create professional, print-ready word processing documents in DOCX, DOC, RTF and PDF. LiveDocx is a Web Service that can be easily integrated into any web application without installing or configuring any software on your server. Currently, the following programming languages are supported: * ASP.NET * PHP As LiveDocx is strictly based on open standards, it is simple to add support for more programming languages. As long as SOAP (Simple Object Access Protocol) is available on the client-side system, LiveDocx runs on all operating systems and in all programming languages.This looked to be the best solution for what I was attempting to do, and best of all, it was free. All I had to do was sign up for an account, and then I was free to begin coding my solution. I knew that I wanted the solution to be dynamic; I didn't want to hard-code the author into my code. Instead, I wanted to be able to export any author's blog posts. So, step 1 was to create a form that would allow site administrators to find the author they are looking for. The form consists of a textfield with autocomplete functionality, and a select box with export options. For the purpose of this example, the only option is to export to MS Word (doc). However, LiveDocX also supports docx, rtf, and pdf.
<?php
function MYMODULE_blog_export_form() {
$form = array();
$form['export'] = array(
'#type' => 'fieldset',
'#title' => t('Blog Export Options'),
'#collapsed' => false,
'#collapsible' => false,
);
$form['export']['method'] = array(
'#type' => 'select',
'#title' => t('Export output type'),
'#options' => array(
'msword' => t('Microsoft Word'),
),
);
$form['export']['author'] = array(
'#type' => 'textfield',
'#title' => t('Author name'),
'#autocomplete_path' => 'admin/autocomplete/bloggers',
'#description' => t('Enter the name of the user.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
?><?php
/**
* Menu callback function to provide autocomplete functionality for
* searching for users by username
*
* @param string $search_string
*/
function MYMODULE_autocomplete_bloggers($search_string) {
static $blogger_roles = array();
$result = db_query("SELECT r.rid FROM {role} r WHERE
r.name = '%s'", 'blogger');
while($role = db_fetch_object($result)) {
$blogger_roles[] = $role->rid;
}
$matches = array();
$result = db_query("SELECT u.uid, u.name FROM {users} u
LEFT JOIN {users_roles} ur ON ur.uid = u.uid
LEFT JOIN {role} r ON r.rid = ur.rid
WHERE u.name LIKE '%s%%' AND
r.rid IN (".join(',', $blogger_roles).")
LIMIT 50", $search_string);
while ($row = db_fetch_object($result)) {
$matches[$row->name] = $row->name;
}
print drupal_to_js($matches);
exit();
}
?><?php
function MYMODULE_blog_export_form_submit($form, $form_state) {
$uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $form_state['values']['author']));
if($uid) {
$start_func = 'MYMODULE_blog_export_'.$form_state['values']['method'];
$finished_func = 'MYMODULE_blog_export_'.$form_state['values']['method'].'_batch_process_finished';
// Add a batch set with simple operations taking an argument.
$batch = array(
'title' => t('Blog Export'), // Not displayed.
'operations' => array(
array($start_func, array($uid)),
),
'finished' => $finished_func,
);
batch_set($batch);
batch_process('admin/content/blogs/export');
}
else {
drupal_set_message('An error occurred while trying to process this action.');
}
}
?><?php
function MYMODULE_blog_export_msword($uid, &$context) {
$limit = 5;
$context['finished'] = 0;
if (!isset($context['sandbox']['progress'])) {
$max_nodes = db_result(db_query("SELECT count(n.nid) FROM {node} n WHERE n.uid = %d AND n.type = 'blog' ORDER BY nid ASC", $uid));
$context['sandbox']['progress'] = 0;
$context['sandbox']['current_node'] = 0;
$context['sandbox']['max'] = $max_nodes;
$context['sandbox']['results']['author'] = user_load(array('uid' => $uid));
$block_values = array();
$context['sandbox']['results']['block_values'] =& $block_values;
}
$nodes = array();
$result = db_query_range("SELECT n.nid, n.type FROM {node} n WHERE n.nid > %d AND n.uid = %d AND n.type = 'blog' ORDER BY nid ASC", $context['sandbox']['current_node'], $uid, 0, $limit);
while($row = db_fetch_object($result)) {
$nodes[$row->nid] = $row;
}
if(count($nodes) == 0) {
cache_set('famed:blog_export_results', 'cache', serialize($context['sandbox']['results']));
$context['finished'] = 1;
}
$context['message'] = t('Processing nodes authored by user %uid', array('%uid' => $uid));
foreach ($nodes as $node) {
// Process the node
$node = node_load($node->nid);
if($node) {
$content = node_view($node, false, true, false);
if($content) {
$context['sandbox']['results']['block_values'][] = array (
'post_title' => $node->title,
'content' => strip_tags($node->body),
'created' => date('Y-m-d h:m:s', $node->created),
'updated' => date('Y-m-d h:m:s', $node->changed),
'pub_status' => ($node->status == 1) ? 'Published' : 'Unpublished',
'tags' => $node->nodewords['keywords'],
);
}
}
// Update our progress information.
$context['message'] = t('Processing blog posts authored by user %uid', array('%uid' => $uid));
$context['results'][] = t('Processed node %node', array('%node' => $node->nid));
$context['sandbox']['progress']++;
$context['sandbox']['current_node'] = $node->nid;
}
// Inform the batch engine that we are not finished,
// and provide an estimation of the completion level we reached.
if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
}
}
?><?php
/**
* Batch finished handler.
*/
function MYMODULE_blog_export_msword_batch_process_finished($success, $results, $operations) {
// Load the data from Drupal's cache
$cache = cache_get('famed:blog_export_results', 'cache');
// Unserialize the cache data
$blog_data = unserialize($cache->data);
cache_clear_all('famed:blog_export_results', 'cache');
if ($blog_data) {
// Turn up error reporting
error_reporting (E_ALL|E_STRICT);
// Turn off WSDL caching
ini_set ('soap.wsdl_cache_enabled', 0);
// Define credentials for LD
$credentials = array(
'username' => 'my_user_name',
'password' => 'my_password',
);
// SOAP WSDL endpoint
$endpoint = 'https://api.livedocx.com/1.2/mailmerge.asmx?WSDL';
// Define timezone
date_default_timezone_set('Europe/Berlin');
// Create a new instance of the SoapClient object
$soap = new SoapClient($endpoint);
$soap->LogIn(
array(
'username' => $credentials['username'],
'password' => $credentials['password']
)
);
// Upload template
$path_to_template = './'.drupal_get_path('module', 'MYMODULE').'/template.doc';
$data = file_get_contents($path_to_template);
if(empty($data)) {
drupal_set_message('Failed to read the template', 'error');
watchdog('famed', 'Failed to read the template', WATCHDOG_ERROR);
return;
}
$soap->SetLocalTemplate(array(
'template' => base64_encode($data),
'format' => 'doc'
));
$fieldValues = array (
'author' => $blog_data['author']->name,
'email' => $blog_data['author']->mail,
'title' => 'Blog Posts by '.$blog_data['author']->name,
);
/**
* In the template, these field values are used on the title page of the document,
* and in the header/footer of the doucment.
*/
$soap->SetFieldValues(array (
'fieldValues' => assocArrayToArrayOfArrayOfString($fieldValues)
));
// Block values is the repeating data, in this case, the contents of each blog post
$soap->SetBlockFieldValues(array(
'blockName' => 'blogpost',
'blockFieldValues' => multiAssocArrayToArrayOfArrayOfString($blog_data['block_values'])
));
// Build the document
$soap->CreateDocument();
// Get document as DOC
$result = $soap->RetrieveDocument(array(
'format' => 'doc'
));
// Fetch the document
$data = $result->RetrieveDocumentResult;
$filename = './sites/default/files/blog.doc';
if(file_exists($filename)) {
unlink($filename);
}
// Write the document to the filesystem
file_put_contents($filename, base64_decode($data));
// Force the browser to download the document
if(file_exists($filename)) {
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename=blog.doc;");
header("Content-Length: ".filesize($filename));
readfile($filename);
exit;
}
else {
drupal_set_message('Failed to download the file', 'error');
}
}
else {
// An error occurred.
// $operations contains the operations that remained unprocessed.
$error_operation = reset($operations);
$message = t('An error occurred while processing %error_operation with arguments: @arguments', array('%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE)));
}
drupal_set_message($message);
}
?><?php
/**
* Convert a PHP assoc array to a SOAP array of array of string
*
* @param array $assoc
* @return array
*/
function assocArrayToArrayOfArrayOfString ($assoc) {
$arrayKeys = array_keys($assoc);
$arrayValues = array_values($assoc);
return array ($arrayKeys, $arrayValues);
}
/**
* Convert a PHP multi-depth assoc array to a SOAP array of array of array of string
*
* @param array $multi
* @return array
*/
function multiAssocArrayToArrayOfArrayOfString ($multi){
$arrayKeys = array_keys($multi[0]);
$arrayValues = array();
foreach ($multi as $v) {
$arrayValues[] = array_values($v);
}
$_arrayKeys = array();
$_arrayKeys[0] = $arrayKeys;
return array_merge($_arrayKeys, $arrayValues);
}
?>When discussing whether or not homosexuals ought to be able to marry, the argument invariably turns to the institution of marriage, if it can be said that such a thing exists in the United States. A lot of people feel that by allowing same-sex marriages, the institution of marriage will further weaken, and thus destroy the family. To counter some of those arguments and fears, marriage must first be defined, which serves as the purpose of this writing.
There is a point to marriage. Marriage has the social benefit of trying to prevent males from mating with many different females. Historically speaking, this has never worked correctly. The recognized union between a man and a woman most certainly does not prevent adultery, nor is it truly possible to do so. The desire to mate with as many females as possible is rampant throughout the animal kingdom, and man being part of that kingdom, attempts to control such behavior through the implementation of social rules. This argument is not intended to justify promiscuous sex (although humans are the only species to attach emotional guilt to the act of procreation), but merely to illustrate that marriage serves as an attempt to control one of the most basic and innate behaviors of the male gender.
Another point of marriage is to pledge to the person you want to marry that you will spend the rest of your life with them and love them until the day you die. It has an additional purpose of tying someone else to you for life to share this life with. Granted, you do not need marriage for any of these things, but the actual marriage is a way of making the decision legally binding. Again, this purpose seems to fall short in the United States, which is experiencing a divorce rate of 51%. If more than half of all marriages fail, what does that say about the value of such an institution?
Marriage has meaning that is based on tradition. However, that definition is no longer valid for this enlightened world. Definitions must change and adapt to serve the needs of the people using the thing that is being defined. As society and civilization evolves and changes, so must its definitions of right and wrong. A hundred years ago, society deemed it correct and natural for women to stay at home and to not have any rights. Should we continue with that historical interpretation of morality?
One interpretation of marriage is the traditional Christian viewpoint of one man and one woman swearing before God. That is not the viewpoint shared by everyone, and that does not mean that their viewpoints are wrong, or that their marriage isn't as special to them as another's is to them. If marriage only had meaning in the context of a religious ceremony, there wouldn't both civil ceremonies and religious ceremonies. A man and a woman can get married in a civil ceremony without any mention of God or religion. And yet, no one questions the fact that they are married. No one even thinks twice about it. Why should this be any different for homosexuals?
In this case, marriage in the civil sense should have no religious base. Civil ceremonies by default must be without religious base. If an atheist wanted to marry another atheist, they could not have gotten married in a church, had they wanted to. And no religious leader would have performed the ceremony either. Marriages performed via civil ceremony are for people who either don't want to get married in a church, or can't get married in a church for whatever reason. Some people say that non-religious marriages are not real marriages. This would appear to be a narrow-minded point of view, reeking of religious intolerance. What it says is that if a person does not subscribe to their way of thinking and belief system, then they are wrong.
All marriages are legally binding contracts. That is why spouses are worth 50% of each other's assets, which is and should be enforced by the government. In its most basic definition, marriage is an arrangement between two consenting adults, more like a private agreement. There should be no one else involved in a marriage besides the two married people. But how can you then limit marriage to two people? Since a contract can be made between more than two parties, there is no reason why this idea should not be extended into the definition of marriage. Because people cannot be discriminated against because of religious beliefs, religious arguments against bigamy cannot be used in this situation. Once those arguments have been removed, there is no reason why bigamy should not be allowed. However, many people would take this argument and extend it to inanimate objects, such as a house or car, or the argument for marrying children and animals will be presented. If marriage is to be considered as a contract, that contract must be made between consenting adults. In most states, the age of consent for an adult is 16. Therefore, the marriage of children would not be allowed. Objects cannot consent, nor can animals. Clearly, an object such as a house is therefore a silly and ridiculous argument, and should be given no serious consideration. Similarly, all arguments for the marriage to animals must be given the same lack of consideration.
Once the traditional religious core meaning and characteristics of marriage have been removed from the argument, the concept of marriage as a contract opens up to many interpretations. The definition of marriage ought to come from a non-religiously biased referendum, not from the Bible, or another other religious text. In a free society that is not ruled by its religion, the definitions of social morality must not come from the religious base. What if, by some pure chance, the religious majority in this country suddenly endorsed sacrificing women to the Sun god? Would that be moral and right too?
In a free society, the laws ought to reflect the will of the majority, not of the religious sector, the corporations, the rich, or the elite. We have a society based upon a Constitution, a document that outlines the basic rights that people in the country are entitled to. The Constitution does not exclude people, nor does it tell them that some people can do certain things while other cannot because they have different beliefs. Denying homosexuals the right to marry is no better than telling blacks that they cannot marry either. I would like to think that America has evolved beyond this petty, discriminatory behavior.
But then again, I am an optimist...
I don't understand what the fuss is all about. Wait, yes I do.
It's about prejudice, hatred, bigotry, all carried out under the guise of religious morality. In recent years, the issue of gay rights, especially the right to marry, has exploded in this country. Liberal states such as Hawaii and Vermont have considered trumping the government by allowing such marriages, but have fallen short of this goal. What we have instead in Vermont is the legalization of "civil unions", which are a mockery of the rights that the heterosexuals of this country are allowed.
These civil unions do not carry the rights and privileges of marriage because the government and most of the other states do not recognize the union. Vermont grants some limited benefits, but it is nothing like what married people enjoy. So the question remains, why doesn't the government recognize these unions, and what exactly is the difference between a union and a marriage?
Perhaps the best way to begin answering these questions is to define marriage. Christians believe that marriage is a sacred pact with God. As an atheist, I believe it is a solemn pact with the person you are marrying. It all boils down to a promise, or set of promises, made to another person. Some of the common promises are fidelity, a pledge to care for one another, and a pledge to remain with that person until death. Many people choose to define marriage as a pledge of sexual exclusivity, fidelity, family and permanence of commitment or moral reasons between one man and one woman, their God and community. By denying same sex marriages, the implication is that homosexuals are incapable of pledging sexual exclusivity, fidelity, and permanence of commitment. There is also the unspoken societal rule that when you get married, you have to have children, which by no means should be used to define what a marriage is. This would mean that childless couples should not be considered to be married.
By including God in the definition, atheists ought to also be banned from marriage, as they do not pledge anything to a deity. The inclusion of ambiguous "moral reasons" in this definition is also problematic and faulty, as there is no standard set of "morals" agreed upon by all members of society. The problem with morality is that it is often associated with religious participation and tends to be theocratical in nature. In the United States, laws cannot be based on theocratic values, as they amount to an endorsement of a specific religion by the government.
Religious bigotry is perhaps the biggest reason why same sex marriages are illegal in this country, because there is the claim that homosexuality is condemned in the New Testament. To address this issue, let's consider some points:
The Roman Catholic Church has preserved more than 8,000 copies of the Bible written in Latin and called the Vulgate which was originally translated from Greek and Hebrew to Latin by Saint Jerome. Jerome (347-420) was born in Stridon, near the modern-day Rijeka, Croatia to Christian parents and was given a fine classical education. He spent three years (379-382) in Constantinople (present-day Istanbul) where he studied Greek and the Bible under Eastern Church father, Saint Gregory of Nazianzus. Jerome was ordained a priest.
At the age of 37, he was appointed secretary to Pope Damasus I and became an influential figure. Damasus selected Jerome to create a new Latin Bible, which was badly needed by the Church. Jerome was close to a Roman widow named Paula and her daughter. He traveled to Bethlehem in 386 to study Hebrew under Jewish scholars and was accompanied by Paula (later Saint Paula) and her daughter. At first Jerome used the Greek Septuagint for his Old Testament translation. Later he consulted the original Hebrew texts. Jerome was a contemporary of Saint Augustine (354-430) who was the leading figure in the Church in North Africa, and they were known to have met or corresponded. It may have been through this contact that Jerome obtained his Alexandrian manuscripts common in North Africa from which he translated the New Testament portion of the Latin Vulgate.
The Vulgate shows that Jerome did not use Byzantine manuscripts from the Eastern Church. Through the next 12 centuries, the text of the Vulgate was transmitted with less and less accuracy, or was deliberately revised. The Council of Trent (1545-1563) recognized the need for an authentic Latin text and authorized a revision of the extant corrupt editions. This revision is the basic Latin text still used by the Roman Catholic Church and scholars. With all of these revisions, how can Christians possibly declare the New Testament as the "Word of God"? It is the word of humans and clergy, revised to fit their own needs, politics, and beliefs. Not to mention all the "additions" to the Bible that members of the Church felt were important topics. St. John maintained that Jesus did and taught very many other things not recorded in the Bible. How can we be sure that these teachings have not been modified over the many years? In other words, the Bible is an unreliable source for spreading the "Word of God", let alone using it to dictate social policy and law.
In its most simplistic definition, marriage is a choice, made every single day. When a person wakes up in the morning, he or she has the ability to choose whether to remain married or not. By denying homosexuals the right to marry each other, the government is saying the gay people are incapable of making this promise and this choice. To understand why the government takes this position, one must recall American history.
This country is a Christian country, based on Puritan values. Since the 1600's, theocracy has melded and merged with every facet of law in America, and has shaped our society into what it is today. From the Declaration of Independence to our currency, God is everywhere, and lawmakers have used this religious premise to influence the laws. Examples of this idea are found in the subject of blue laws, which is defined as legislation regulating public and private conduct, especially laws relating to Sabbath observance. The term was originally applied to the 17th-century laws of the theocratic New Haven colony; they were called "blue laws after the blue paper on which they were printed. New Haven and other Puritan colonies of New England had rigid laws prohibiting Sabbath breaking, breaches in family discipline, drunkenness, and excesses in dress. Although such legislation had its origins in European Sabbatarian and sumptuary laws, the term "blue laws is usually applied only to American legislation. With the dissolution of the Puritan theocracies after the American Revolution, blue laws declined; many of them lay forgotten in state statute books only to be revived much later. The growth of the prohibition movement in the 19th and early 20th centuries brought with it other laws regulating private conduct. Many states forbade the sale of cigarettes, and laws prohibited secular amusements as well as all unnecessary work on Sunday; provision was made for strict local censorship of books, plays, films and other means of instruction and entertainment. Although much of this legislation has been softened if not repealed, there are still many areas and communities in the United States, especially those where religious fundamentalism is strong, that retain blue laws. [1]
Because this fundamentalism exists in the United States, people are denied rights based on those religious beliefs. Homosexual rights are a prime example of this. Homosexuals should be allowed to marry in a church that supports gay marriages. If other churches don't want to, that is fine - they have the right to govern their own religion. However, the state cannot discriminate against homosexuals on the basis of the lawmakers' religious convictions, for this is in direct violation of the Constitution of the United States, specifically in violation of the separation of Church and State clause. By using religious biases to deny marriage rights to homosexuals, the government is, in effect, sponsoring a state religion.
There is a myth in this country that marriage is an institution, that it is one of our most basic "truths" developed slowly through thousands of years of civilization, and it is a founding pillar of our society. Marriage is not an institution. It is a choice made every single day to remain with one person under law. Religion removed, marriage is a legal arrangement. When discussing the legal aspects of marriage, religious arguments cannot be used because it is an unconstitutional argument. One cannot use the moral argument either, because morals are different for each and every person, and are also founded on religion. If marriage were truly a "pillar of society", there would not be a 51% divorce rate in this country. Heterosexual immorality, to apply the defunct "moral" argument to the question, and irresponsibility has severely harmed the institutions of marriage and the family much more so than any homosexual activism.
Once the religious and moral arguments have been removed from the debate, there is very little left to debate over. Every time people don't like something in this country, they try to get it banned. When people see programs on television that they find offensive, they try to censor it. No one thinks "Hey, maybe I ought to change the channel!" Instead, they complain to the "Moral Police Squad" out there trying to tell everyone else how to run their lives. This country was founded on the freedom of choice, but people would much rather try to control others than change themselves. It is all about power over others.
So what exactly is the difference then between a marriage and a civil union? It depends on whether you are gay or not. Marriage via religious ceremony has a moral construct from the past. Civil marriages do not. The reason for this is that one religion's morals are not the same as another's. The morals of the conservative Christian right should not dictate what everyone in this country should or should not do. The way I see it is that thousands of heterosexual couples get a Justice of the Peace and have a civil ceremony. It happens everyday. No one questions whether they are married or not. In this type of marriage, there is no religious aspect. Why does this have to be different for gay people? Why can't they get married in civil ceremonies and have all of the same marriage benefits as straight couples?
Civil unions do not have the rights and privileges of marriage. Homosexuals joined in a civil union cannot file joint tax returns, get health benefits, Social Security benefits, inherit real estate, be listed as next of kin, etc. It's not just about the recognition. It's also about the benefits awarded by the government. Here is an example:
Two men have been living together in a monogamous relationship for thirty years (better than a lot of heterosexual relationships!) and one of them dies. Unless they are married, the surviving partner is not entitled to the life insurance money (must be a family member), and other benefits which require a family member as the benefactor. This is the real tragedy - homosexual couples are not even allowed to provide for each other after death.
When I die, I want to know that my wife will be taken care of (i.e. insurance, etc.) - it should be no different for homosexuals.
Many people will argue that marriage ought to be only between a man and a woman. When the counter-argument that love should be a criteria for marriage is presented, the argument is skewed to include many other situations. They will argue that "I love my lab, or another person loves a child, or another loves a house or a cat or groups of people who love each other. Are you suggesting that they also be allowed to marry whatever they love?" However, marriage is first and foremost between people, not inanimate objects or animals; real people, with real jobs, who return the love that the other is giving. The same love that a heterosexual gives his or her spouse, and receives in return.
Since it is only between someone else and religion has been removed, then marriage can better be defined as a legally binding contract. If marriage is such a contract, why should married people have any special considerations in our society? Marriage should be a private contract because it is only an issue between private parties. Then if marriage had no special benefits for the parties involved, marriage can then be further defined as a relationship in a contract or under contract law.
If this were the case, one cannot make a contract with an inanimate object, because it cannot agree to anything. That is why you can't marry your house or television, and would thus render the argument about marrying your pet or television null and void. Additionally, a child is not mentally or emotionally capable of giving consent to anything until they reach the age of 16. This argument is not a morally based argument; it is founded on current laws. This is why you cannot marry a child - they must be able to consent to the contract that you propose.
Further, if marriage were to be considered a legally binding private contract between two parties, the definition of such a contract will deny that there are such moral reasons for the contract. Marriage would then become an "arrangement" that is purely a private matter designed solely to satisfy the desires of the "married" parties. But why else do people get married? People get married to satisfy the desire of the individuals to get married. And yes, it is a private arrangement. It is nobody else's business whom I chose to marry, as it is none of my business who you chose to marry. Gay people marrying each other does not affect me, or anyone else but the two people who are getting married. For everyone in this country who has something against gay people, get over it, because it has nothing to do with you, and is none of your business in the first place.
If that is the case, there is no real reason that marriage should require exclusivity, fidelity, permanence or even a limit of two people or even to people, unless otherwise specified by the contract. Like divorce in marriage, a contract can also be dissolved through legal means, the same way that a divorce proceeds. By denying homosexuals the right to form such contracts, the conclusion is that homosexuals are incapable of honoring the exclusivity, fidelity, and permanence aspects of such a contract that is mentioned above.
The fear that same sex marriages will damage the family and the institution of marriage by forcing same sex marriages onto an institution that is a main pillar of our society is ridiculous. Marriages between two people are private, and have nothing to do with society as a whole, much less the tradition of marriage. If marriage is a choice, then there is no force involved. There is no entity which forces parties to marry each other, except in certain cultures where arranged marriages are the tradition. In such case, a legal challenge by an unwilling party would most certainly win, if the challenge was presented in the United States.
The point of marriage is to pledge to the person you want to marry that you will spend the rest of your life with them and love them until the day you die, in a traditional wedding with traditional vows. It has an additional purpose of tying someone else to you for life to share this life with. Granted, one does not need marriage for any of these things, but the actual marriage is a way of making the decision legally binding.
By denying homosexuals the right to form legally binding contracts with one another in the form of marriage, the United States is discriminating against a large population of its citizens, based on sexual preference. The time has come for the United States to recognize its obligations to all of its citizens, and act in concert with the Constitution and the Bill of Rights. Until this happens, homosexuals will continue to be discriminated against and treated like second-class citizens.
[1] http://www.encyclopedia.com/articles/01594.html
I love going to the movie theater. Or, at least, I used to.
When I was growing up, my family did not have a lot of money, and so it was a rare treat to go to the theater to see a movie. As a young college student, I got hired as a projectionist at a small movie theater in New Hampshire, and I absolutely loved it. There were many late nights, after splicing all the movie reels of a newly-delivered film together, that I would sit with my brother and my closest friends to sneak preview the movie until the small hours of the morning.
To me, the experience of a larger-than-life movie on a larger-than-life screen is thrilling. I love the smell of popcorn and the auditory onslaught of music and explosions from the sound system. I love seeing all the movie posters for upcoming films.
I especially love the movie trailers. It seems to me that lots of other people do too; of some 10-billion videos watched annually on the internet, movie trailers rank third, after news and user-created video. To me, the experience of watching the trailers is an important part of the theater experience. It's like the appetizer before a great meal, or if the meal turns out to be bad, it can save the memories of the evening. The same can be said about movie trailers; how many times have you heard that the trailers were the best part of the movie?
I took my sons to the theater today to see "Despicable Me". This was only the second time my children have been to the theater, and I was probably more excited for them than they were about seeing the movie. However, I was dismayed to find out that my movie experience has been sold out. Before the trailers (but after the trivia and random bits of information), a number of commercials were run for everyday products, such as deodorant, and other health and beauty aids. I was horrified, even though my children didn't know any different.
To me, the practice of running product advertisements before the movies is like going to a nice restaurant and being served airline peanuts before the appetizers and meal. It cheapens the rest of the meal. What's worse is that in the movies, you're a captive audience so to speak. You can't change the channel, and most people aren't likely to get up and stand in the hallway while the ads are running. I can practically see the advertising executives greedily rubbing their hands together and laughing wickedly.
Sadly, I know this is just the start. I wouldn't be surprised if at some point in the next decade, films will take regular commercial breaks, or display ads in a running ticker along the bottom of the screen.
I sincerely hope I'm wrong about that.
In my last post, I showed a method for conditionally displaying facet blocks with Search Lucene, depending on the type of query being performed. This can also be adapted to work for Apache Solr, albeit with a different mechanism. The easiest way to do this with Apache Solr is to use the Context module to control which facet blocks are displayed, along with when and where they are displayed. In this example, I set up a context based on path, where that path was search/apachesolr/*. I then added all of my Apache Solr facet blocks in the context. With the context configured, I now have the ability to alter that context on the fly, based on whatever conditions I choose.
<?php
/**
* Implementation of hook_context_active_contexts_alter().
*
* <a href="http://twitter.com/param">@param</a> mixed $contexts
* Associative array of context objects
*/
function MYMODULE_context_active_contexts_alter(&$contexts) {
// If one of the active contexts is the apachesolr_search context, remove
// some unneccessary blocks
if(in_array('search-apachesolr-search', array_keys($contexts))) {
/**
* Look at the type of query that has been performed, and set a flag regarding whether or
* not to show the biblio facets if the type:biblio filter is in effect
*/
$show_biblio_facets = false;
$query = apachesolr_current_query();
if($query) {
if($query->has_filter('type', 'biblio')) {
$show_biblio_facets = true;
}
}
// Loop through the apachesolr-search blocks and remove the Biblio facet blocks if needed
foreach($contexts['search-apachesolr-search']->block as $bid => $block) {
if(preg_match('/^apachesolr_biblio_/', $bid)) {
if(!$show_biblio_facets) {
unset($contexts['search-apachesolr-search']->block[$bid]);
}
}
}
}
}
?>I am working on a Drupal project that implements Search Lucene API, along with the Biblio module. The client did not like the fact that when a generic search was executed, all enabled facet blocks were being displayed without context. For example, a search for the generic term "data" with no filters showed Biblio-specific facet blocks, which didn't make any sense to the client. He only wanted to display Biblio facet blocks if the current query was being filtered by content type where the content type was biblio.
After protesting mildly to the client, I realized that this request wasn't very difficult to achieve by implementing hook_luceneapi_facet_postrender_alter() in a custom module. This implementation of the hook first checks to see if a search was executed, and if so, we retrieve the Zend query object in order to get the terms. If the query is filtering by type where type is biblio, a flag is set to true to indicate that the Biblio facet blocks should be displayed. If this flag is not set, the code loops through all the facet blocks ($items) passed into the hook, and removes the Biblio facets.
<?php
function MYMODULE_luceneapi_facet_postrender_alter(&$items, $realm, $module, $type = NULL) {
// The example is only valid for "node" content.
if ($type != 'node') {
return;
}
if ($realm == 'block') {
/**
* Look at the type of query that has been performed, and set a flag regarding whether
* or not to show the biblio facets if the type:biblio filter is in effect
*/
$show_biblio_facets = false;
if($module = luceneapi_search_executed()) {
$query = Zend_Search_Lucene_Search_QueryParser::parse(search_get_keys());
if($query) {
module_invoke_all('luceneapi_query_alter', $query, $module, 'node');
$terms = $query->getQueryTerms();
if(!empty($terms)) {
foreach($terms as $term) {
if($term instanceof Zend_Search_Lucene_Index_Term) {
if($term->field == 'type' && $term->text == 'biblio') {
$show_biblio_facets = true;
break;
}
}
}
}
}
}
if(!$show_biblio_facets) {
// Loop through the items and remove the Biblio facet blocks if needed
if(!empty($items)) {
foreach($items as $name => $item) {
if(preg_match('/^biblio_/', $name)) {
unset($items[$name]);
}
}
}
}
}
}
?>I recently had a client with a Drupal site who wanted to be able to track whether or not his site members were watching videos on his site completely, and also wanted to know at what point site members were leaving the videos. The client currently uses SiteCatalyst for analytics, and is using the JW Media Player. After a lot of research, I came across this blog post, which gave some terrific insight regarding how to connect events in the JW Media Player to Omniture. However, the code samples did not apply to SiteCatalyst. The author of the blog post suggested using the s.tl() function in the SiteCatalyst code to track events. After a lot more research, I finally came up with a solution that tracks when users play a video, pause a video, watch a video until the end, and if the user navigates away from the video before it has completed. The current time of the video is also tracked for each of these events. Using this methodology, one could easily extend the tracking to include other events such as seek and playlist events. My code is below.
// Detect if the user navigates away from the video window.onbeforeunload = confirmExit; var currentPosition = 0; var currentVolume = 0; var currentMute = false; var currentState = "NONE"; var defaultState = "NONE"; var clipduration = 0; var player = null; var s = null; function playerReady() { player = document.getElementById('swfobject-1'); addListeners(player); } function addListeners(player) { if (player) { addAllModelListeners(player); } else { setTimeout("addListeners("+player+")",100); } } function addAllModelListeners(player) { if (typeof player.addModelListener == "function") { player.addModelListener("BUFFER", "doNothing"); player.addModelListener("ERROR", "doNothing"); player.addModelListener("LOADED", "doNothing"); player.addModelListener("META", "doNothing"); player.addModelListener("STATE", "stateListener"); player.addModelListener("TIME", "positionListener"); } } function doNothing(obj) { //nothing } function positionListener(obj) { currentPosition = obj.position; clipduration = obj.duration; } function stateListener(obj) { s = s_gi('sitecatalyst_id'); currentState = obj.newstate; switch(obj.newstate) { case 'PLAYING': s.linkTrackVars="prop1,eVar1,events"; s.linkTrackEvents="video_play"; s.prop1=secondsToMinutes(currentPosition); s.eVar1=secondsToMinutes(currentPosition); s.events="video_play"; s.tl(this,'o','Play Video'); break; case 'PAUSED': s.linkTrackVars="prop1,eVar1,events"; s.linkTrackEvents="video_pause"; s.prop1=secondsToMinutes(currentPosition); s.eVar1=secondsToMinutes(currentPosition); s.events="video_pause"; s.tl(this,'o','Pause Video'); break; case 'COMPLETED': s.linkTrackVars="prop1,eVar1,events"; s.linkTrackEvents="video_complete"; s.events="video_complete"; s.tl(this,'o','Video Complete'); break; } } function confirmExit() { if(currentState != 'COMPLETED') { s.linkTrackVars="prop1,eVar1,events"; s.linkTrackEvents="video_leave"; s.prop1=secondsToMinutes(currentPosition); s.eVar1=secondsToMinutes(currentPosition); s.events="video_leave"; s.tl(this,'o','Leave Video'); currentState = ''; } } // Helper function to convert seconds to mm:ss format function secondsToMinutes(seconds) { // Parse the minutes minVar = parseInt(Math.floor(seconds/60)); minVar = minVar <10 ? '0' + minVar : minVar; // Parse the seconds secVar = parseInt(seconds % 60); // The balance of seconds secVar = secVar <10 ? '0' + secVar : secVar; return minVar + ':' + secVar; }
Resources:
I have been a big fan of Candian musician Devin Townsend for a long time. If you're not familiar with his music, it's somewhat difficult to describe. First of all, it's definitely metal and mostly heavy. However, what makes Devin Townsend's music different is that he layers track upon track and ends up with a solid thick sonic wall that is so rich, you feel like you can reach out and grab it.
This morning, I went to check out his website and saw that a new video and song has been posted on the front page. My first thought was that Devin Townsend was channeling his inner Steve Wilson (Porcupine Tree, Blackfield). It certainly feels that way for most of the track, called "Coast". However, towards the end, the music turns decidedly in the direction of Townsend's previous DevLab work; strangely ambient, white noise, feedback, and general audio chaos. What makes this track different though is that the audio chaos is neatly and almost gently rendered on top of the more steady musical background. It's really quite something to listen to.
Even better than the song though is the accompanying video. It's simply incredible; aliens, monoliths, all shot in grainy black and white to mimic hand-held VHS camcorders. It's very reminiscent of parts of the X-Files, or something from the mind of M. Night Shyamalan.
Check out the video, or visit the Devin Townsend website.
Crayon Physics Deluxe trailer 2 from Petri Purho on Vimeo.This has got to be one of the coolest games I have ever seen.
I've always been a fan of puzzle games, but in this particular game, the puzzle of how to connect a ball to a star separated by distances and objects, is as dynamic as your imagination.
Players are presented with more than 70 different puzzles and its brilliance is found in the way it challenges you to use your imagination to envision and then implement your own unique solutions to each one.
In the PC version, players use the mouse to draw shapes and objects that react to the laws of physics. For example, if you draw a box in the air, it will fall because of gravity.
What's particularly clever about this game (as you'll see in the video below) is that you can be as creative as you want. Simple levers and inclined planes work, but then again, so will rockets, dragons, and trebuchets.
Watch the video to see what I'm talking about... Other really interesting demonstrations can be seen here and here.
[tags]crayon, game, petri+purho, physics[/tags]
Back in October, I released my first module for Drupal, the open-source content management system. These days, I seem to be developing exclusively for Drupal, and with a robust API and thriving community, I can only say how much fun it is to work with.
However, like any platforms, there are pieces missing. Fortunately, Drupal is one of those platforms that is very easily extended through modules. I came across one of those missing pieces while working on a project. I do all of my development in a sandbox, and when the work is complete, I QA the product in a staging environment before pushing the code and database changes to a production environment. I found that there was no way to manage user/role permissions in code; all management was a manual process via the web interface.
Having to repeat manual tasks like this across different environments increases the odds of errors. Steps can be omitted or performed improperly. In the case of permissions, I decided to correct that by writing a module called Permissions API. What this module allows you to do is to grant and revoke permissions to roles in code.
This is probably most useful in the context of programmatically creating CCK content types. The ability to import CCK content types through code is great until you decide that you want members of specific roles to be able to do something with this content type. Currently, the only way to grant the permissions is to navigate through the access control page in the admin interface, which is completely unusable if you have a lot of roles and a lot of modules. This module addresses that problem by providing two functions:
permissions_grant_permissions()
permissions_revoke_permissions()
Each function accepts a role id and an array of permissions. Sample usage would be:
<?php
function mymodule_update_1(){
// Handle roles and permissions
$rid = db_result(db_query('SELECT r.rid FROM {role} r WHERE r.name = \'some custom role\''));
if($rid > 0){
$permissions = array(
'create some_content_type content',
'edit some_content_type content',
'edit own some_content_type content',
);
permissions_grant_permissions($rid, $permissions);
}
}
?>
<?php
function mymodule_update_2(){
// Create a "super-admin" role by granting all permissions
$rid = db_result(db_query('SELECT r.rid FROM {role} r WHERE r.name = \'some custom role\''));
if($rid > 0){
permissions_grant_all_permissions($rid);
}
}
?>
<?php
function mymodule_update_3(){
// Grant all permissions defined by a module's hook_perm implementation
$rid = db_result(db_query('SELECT r.rid FROM {role} r WHERE r.name = \'some custom role\''));
if($rid > 0){
permissions_grant_all_permissions_by_module($rid, 'some module')
}
}
?>
Recent comments
3 weeks 5 days ago
8 weeks 1 day ago
8 weeks 1 day ago
2 years 6 days ago
2 years 1 week ago
2 years 22 weeks ago
2 years 22 weeks ago
2 years 29 weeks ago
2 years 39 weeks ago
2 years 11 weeks ago