tag:blogger.com,1999:blog-119897392024-03-08T04:54:16.441+05:30Brewing cup.. of thoughts, opinions & discoveriesAnonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.comBlogger131125tag:blogger.com,1999:blog-11989739.post-18817219513635246592014-03-11T20:46:00.004+05:302014-03-11T20:49:56.559+05:30How to send real time notifications to your Drupal site users<div dir="ltr" style="text-align: left;" trbidi="on">
Often you would want to notify logged in users of an urgent deployment that is going to take the site down. For these unavoidable deployments, real-time notifications to end users would be God-send as it would help editors save their work (if they are adding content) in adequate time.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOuhCfxuN9LmGv1q_189CydsDU25YE2eVlYh3d6RbyCfo-yOL47S3UPBj4IbhLhQ9Ge1dBtxqN-wgwlQLFJ-oK5w10NpMwTOVeUcwbrurc8bzr4v-N8cWrqhBz4P1TsGAB7pRc/s1600/Selection_143.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOuhCfxuN9LmGv1q_189CydsDU25YE2eVlYh3d6RbyCfo-yOL47S3UPBj4IbhLhQ9Ge1dBtxqN-wgwlQLFJ-oK5w10NpMwTOVeUcwbrurc8bzr4v-N8cWrqhBz4P1TsGAB7pRc/s1600/Selection_143.png" /></a></div>
<br />
<br />
Here is a simple attempt at building one such system. <a href="http://www.html5rocks.com/en/tutorials/eventsource/basics/">HTML5 Server Sent Events</a> is a one way communication technology which we can leverage for this. The caveat is that editors need to use HTML5 browsers or resort to XHR polling.<br />
<br />
In this example, we are using Jenkins for deployment and want to notify logged-in site editors when a deployment is about to happen. We'll build a separate notification server for this purpose (on node.js) that will register browser connections and will also listen for notifications from Jenkins. Once it receives a notification regarding a deployment, it will broadcast that to the registered browsers. We'd like this server to support different sites and their notifications (multi-site scenario in Drupal). Jenkins can send build info notifications via the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Notification+Plugin">Notifications plugin</a>. This server has been built and hosted on <a href="https://github.com/dennisinteractive/sse-jenkins">GitHub</a> along with usage instructions.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1Nr7aWK7TSIn0J4DL1G4HlZm2b0KExy0GooTggtdpBgtbJH9ZzXykC5AIyB0qyL9pfMnzmzj1FhYyVNj05EWMQgRejpjP1jcrUEG-jYx9_m-drDUZ5hF2Q3_I3JB9eWRlHgg1/s1600/HTML5+SSE-Jenkins.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1Nr7aWK7TSIn0J4DL1G4HlZm2b0KExy0GooTggtdpBgtbJH9ZzXykC5AIyB0qyL9pfMnzmzj1FhYyVNj05EWMQgRejpjP1jcrUEG-jYx9_m-drDUZ5hF2Q3_I3JB9eWRlHgg1/s1600/HTML5+SSE-Jenkins.png" height="381" width="570" /></a></div>
<br />
When each browser gets loaded, it fires off an EventSource() to the server, registering its connection. The server keeps a list of active connections per site. The Notifications plugin on Jenkins posts JSON build information to our server as it happens, with the site information as parameter. The server in turn broadcasts this to the registered browsers for that site, who then get a Growl/Ubuntu like notification. The <a href="https://github.com/dennisinteractive/sse-jenkins">GitHub</a> repo contains both the server side code (node.js) and client side javascript with the required polyfill, which can be used for any web application.<br />
<br />
To get the client-side working in Drupal, read on.<br />
<br />
<h3 style="text-align: left;">
Drupal</h3>
<div>
<br /></div>
Create a module that adds the client JS and CSS on all pages. It would help to create and use a permission to receive notifications for editors and other roles. Some of the crucial hooks are listed below. The JS assets are loaded on hook_init() based on 'receive sse notifications' permission. For the <a href="http://www.erichynds.com/blog/a-jquery-ui-growl-ubuntu-notification-widget">Growl-like notifications</a>, add in some required bit of html in hook_preprocess_page() which invokes a theme function so as to make it extensible/over-writeable.<br />
<br />
<span class="cfl" id="cl1" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">/**</span><span class="cfl" id="cl9" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>Implements<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>hook_init().
</span><span class="cfl" id="cl10" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*/
</span><span class="cfl" id="cl11" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">function<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>mymodule_init()<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>{
</span><span class="cfl" id="cl12" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>if<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>(user_access('receive<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>sse<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>notifications'))<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>{
</span><span class="cfl" id="cl13" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>drupal_add_js(SSECLIENTPOLYFILLPATH,<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'external');
</span><span class="cfl" id="cl14" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>drupal_add_js(variable_get('mymodule_eventsource_url',<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>SSECLIENTJSPATH),<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'external');
</span><span class="cfl" id="cl15" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">
</span><span class="cfl" id="cl16" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>//<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>Jquery<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>notify<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>additions
</span><span class="cfl" id="cl17" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>//<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>See<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>http://www.erichynds.com/blog/a-jquery-ui-growl-ubuntu-notification-widget
</span><span class="cfl" id="cl18" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>drupal_add_css(drupal_get_path('module',<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'mymodule')<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>.<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'/assets/css/ui.notify.css');
</span><span class="cfl" id="cl19" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>drupal_add_js(drupal_get_path('module',<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'mymodule')<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>.<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'/assets/js/jquery.notify.js');
</span><span class="cfl" id="cl20" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">
</span><span class="cfl" id="cl21" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>//<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>Add<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>the<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>notifications<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>server<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>URL<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>for<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>the<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>SSE<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>client<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>JS<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>to<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>use.
</span><span class="cfl" id="cl22" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>drupal_add_js(array(
</span><span class="cfl" id="cl23" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'mymodule'<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>=><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>array(
</span><span class="cfl" id="cl24" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'server'<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>=><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>variable_get('mymodule_server_address',<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>SSESERVERPATH)
</span><span class="cfl" id="cl25" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>)
</span><span class="cfl" id="cl26" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>),<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'setting');
</span><span class="cfl" id="cl27" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>}
</span><span class="cfl" id="cl28" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">}
</span><span class="cfl" id="cl29" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><br /></span><span class="cfl" id="cl46" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">/**
</span><span class="cfl" id="cl47" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>Implements<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>hook_permission.
</span><span class="cfl" id="cl48" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*/
</span><span class="cfl" id="cl49" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">function<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>mymodule_permission()<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>{
</span><span class="cfl" id="cl50" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>return<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>array(
</span><span class="cfl" id="cl51" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'receive<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>sse<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>notifications'<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>=><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>array(
</span><span class="cfl" id="cl52" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'title'<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>=><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>t('Receive<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>HTML5<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>SSE<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>notifications'),
</span><span class="cfl" id="cl53" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'description'<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>=><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>t('Receive<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>notifications<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>regarding<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>site<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>builds<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>in<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>real-time.'),
</span><span class="cfl" id="cl54" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>),
</span><span class="cfl" id="cl55" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>);
</span><span class="cfl" id="cl56" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">}
</span><span class="cfl" id="cl57" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">
</span><span class="cfl" id="cl58" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">/**</span><span class="cfl" id="cl95" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>Implements<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>hook_theme.
</span><span class="cfl" id="cl96" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*/
</span><span class="cfl" id="cl97" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">function<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>mymodule_theme()<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>{
</span><span class="cfl" id="cl98" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>return<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>array(
</span><span class="cfl" id="cl99" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'mymodule_jquery_notify'<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>=><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>array(
</span><span class="cfl" id="cl100" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'variables'<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>=><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>array(),
</span><span class="cfl" id="cl101" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'template'<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>=><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'jquery_notify',
</span><span class="cfl" id="cl102" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'path'<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>=><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>drupal_get_path('module',<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'mymodule')<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>.<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>'/templates',
</span><span class="cfl" id="cl103" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>)
</span><span class="cfl" id="cl104" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>);
</span><span class="cfl" id="cl105" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">}
</span><span class="cfl" id="cl106" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">
</span><span class="cfl" id="cl107" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">/**
</span><span class="cfl" id="cl108" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>Implements<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>hook_preprocess_page().
</span><span class="cfl" id="cl109" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*/
</span><span class="cfl" id="cl110" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">function<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>mymodule_preprocess_page(&$variables)<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>{
</span><span class="cfl" id="cl111" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>if<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>(!user_access('receive<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>sse<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>notifications'))<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>{
</span><span class="cfl" id="cl112" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>return;
</span><span class="cfl" id="cl113" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>}
</span><span class="cfl" id="cl114" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">
</span><span class="cfl" id="cl115" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>//<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>Append<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>notify<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>container<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>to<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>footer<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>or<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>content.
</span><span class="cfl" id="cl116" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>if<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>(!empty($variables['page']['footer']))<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>{
</span><span class="cfl" id="cl117" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>$variables['page']['footer']['jquery_notify']['#markup']<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>=<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>theme('mymodule_jquery_notify');
</span><span class="cfl" id="cl118" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>}
</span><span class="cfl" id="cl119" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>else<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>{
</span><span class="cfl" id="cl120" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>$variables['page']['content']['jquery_notify']['#markup']<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>=<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>theme('mymodule_jquery_notify');
</span><span class="cfl" id="cl121" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>}
</span><span class="cfl" id="cl122" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;">}</span><br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com3tag:blogger.com,1999:blog-11989739.post-80884960513768657232014-03-06T22:30:00.002+05:302014-03-06T23:33:27.795+05:30Improve performance: Organize your files into subfolders - Drupal 7<div dir="ltr" style="text-align: left;" trbidi="on">
Having too many files in a single folder can be detrimental to your site's performance. It is advisable to segregate files into multiple folders for various benefits. Your sysadmin would surely thank you later :-)<br />
<br />
<a href="https://docs.acquia.com/articles/optimizing-file-paths-organizing-files-subfolders" target="_blank">This Acquia post</a> introduces the problem of file organization and suggests two token based modules. Personally, having tried both, <a class="ext" href="https://drupal.org/project/fe_paths" target="_blank"><b>File Entity Paths</b></a> is my choice as it allows you to create folder structures based on properties of the file per-se and not the parent entity. This is useful if you would not like files from changing their location every time they get reused in another entity and need to be in folders based on that entity's properties. By ensuring a folder structure based on file id (fid) for example, you can also guarantee a more even spread and can limit the number of folders created.<br />
<span class="ext"></span><br />
For example, to store up to 1,000,000 files with not more than 1000 in a folder, it means we do not need more than 1000 folders. For an even distribution of files, this folder structure could be: <i>[0-9]/[00-99]</i> where the [0-9] is the third digit from the end of the fid, and the [00-99] digits are based on the last two digits of the fid (left pad fids with '0' for fids < 99). So a file 'image.jpg' having fid 123456 would be in <i>files/4/56/image.jpg</i>.<br />
<br />
To implement the above logic, we can modify the helpful <a href="https://gist.github.com/acquialibrary/7252438#file-9276_d7_migration_filepath-drush-inc" target="_blank">Drupal 7 drush script</a> to relocate files based on their fid, instead of the timestamp.<br />
<br />
Here's the script (Drupal 7):<br />
<script src="https://gist.github.com/girishmuraly/9393882.js"></script>
<br />
For new files uploaded via the UI, it's easy to create a file token based on the above logic, to be used in <a class="ext" href="https://drupal.org/project/fe_paths" target="_blank">File Entity Paths</a> settings.<br />
<br />
<span class="cfl" id="cl3" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="sd" style="color: #008800;">/**</span>
</span><span class="cfl" id="cl4" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="sd" style="color: #008800;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>Implements<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>hook_token_info().</span>
</span><span class="cfl" id="cl5" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="sd" style="color: #008800;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*/</span>
</span><span class="cfl" id="cl6" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="k" style="color: #000088;">function</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nf" style="color: #660066;">mymodule_token_info</span><span class="p" style="color: #666600;">()</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="p" style="color: #666600;">{</span>
</span><span class="cfl" id="cl7" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$info</span><span class="p" style="color: #666600;">[</span><span class="s1" style="color: #008800;">'tokens'</span><span class="p" style="color: #666600;">][</span><span class="s1" style="color: #008800;">'file'</span><span class="p" style="color: #666600;">][</span><span class="s1" style="color: #008800;">'fid_split'</span><span class="p" style="color: #666600;">]</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">=</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="k" style="color: #000088;">array</span><span class="p" style="color: #666600;">(</span></span><span class="cfl" id="cl21" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="s1" style="color: #008800;">'name'</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">=></span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nx" style="color: #660066;">t</span><span class="p" style="color: #666600;">(</span><span class="s1" style="color: #008800;">'Split<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>based<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>on<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>File<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>id'</span><span class="p" style="color: #666600;">),</span>
</span><span class="cfl" id="cl22" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="s1" style="color: #008800;">'description'</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">=></span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nx" style="color: #660066;">t</span><span class="p" style="color: #666600;">(</span><span class="s1" style="color: #008800;">'Creates<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>two<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>directories<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>based<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>on<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>fid'</span><span class="p" style="color: #666600;">),</span>
</span><span class="cfl" id="cl23" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="p" style="color: #666600;">);</span>
</span><span class="cfl" id="cl24" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="k" style="color: #000088;">return</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$info</span><span class="p" style="color: #666600;">;</span>
</span><span class="cfl" id="cl25" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="p" style="color: #666600;">}</span></span><span class="cfl" id="cl25" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="p" style="color: #666600;"><br /></span></span><span class="cfl" id="cl25" style="background-color: #f9f9f9; display: block; font-family: monospace; font-size: 12px; line-height: 17px; margin: 0px -9px; padding: 0px 9px; white-space: pre;"><span class="p" style="color: #666600;"><span class="cfl" id="cl27" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="sd" style="color: #008800;">/**</span>
</span><span class="cfl" id="cl28" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="sd" style="color: #008800;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>Implements<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>hook_tokens().</span>
</span><span class="cfl" id="cl29" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="sd" style="color: #008800;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>*/</span>
</span><span class="cfl" id="cl30" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="k" style="color: #000088;">function</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nf" style="color: #660066;">mymodule_tokens</span><span class="p" style="color: #666600;">(</span><span class="nv">$type</span><span class="p" style="color: #666600;">,</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$tokens</span><span class="p" style="color: #666600;">,</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$data</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">=</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="k" style="color: #000088;">array</span><span class="p" style="color: #666600;">(),</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$options</span><span class="o vs" style="color: #666600;"> </span><span class="o" style="color: #666600;">=</span><span class="o vs" style="color: #666600;"> </span><span class="k" style="color: #000088;">array</span><span class="p" style="color: #666600;">())</span><span class="o vs" style="color: #666600;"> </span><span class="p" style="color: #666600;">{</span></span><span class="cfl" id="cl31" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$replacements</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">=</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="k" style="color: #000088;">array</span><span class="p" style="color: #666600;">();</span></span><span class="cfl" id="cl40" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="k" style="color: #000088;">if</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="p" style="color: #666600;">((</span><span class="nv">$type</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">==</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="s1" style="color: #008800;">'file'</span><span class="p" style="color: #666600;">)</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">&&</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">!</span><span class="k" style="color: #000088;">empty</span><span class="p" style="color: #666600;">(</span><span class="nv">$data</span><span class="p" style="color: #666600;">[</span><span class="s1" style="color: #008800;">'file'</span><span class="p" style="color: #666600;">]))</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="p" style="color: #666600;">{</span>
</span><span class="cfl" id="cl41" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$fid</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">=</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nb" style="color: #660066;">str_pad</span><span class="p" style="color: #666600;">(</span><span class="nv">$data</span><span class="p" style="color: #666600;">[</span><span class="s1" style="color: #008800;">'file'</span><span class="p" style="color: #666600;">]</span><span class="o" style="color: #666600;">-></span><span class="na" style="color: #660066;">fid</span><span class="p" style="color: #666600;">,</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="mi" style="color: #006666;">10</span><span class="p" style="color: #666600;">,</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="s1" style="color: #008800;">'0'</span><span class="p" style="color: #666600;">,</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nx" style="color: #660066;">STR_PAD_LEFT</span><span class="p" style="color: #666600;">);</span>
</span><span class="cfl" id="cl42" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$len</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">=</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nb" style="color: #660066;">strlen</span><span class="p" style="color: #666600;">(</span><span class="nv">$fid</span><span class="p" style="color: #666600;">);</span>
</span><span class="cfl" id="cl43" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="c1" style="color: #880000;">//<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>Top<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>level<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>dir<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>to<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>be<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>0<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>-<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>9</span>
</span><span class="cfl" id="cl44" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$top_dir</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">=</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$fid</span><span class="p" style="color: #666600;">[</span><span class="nv">$len</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">-</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="mi" style="color: #006666;">3</span><span class="p" style="color: #666600;">];</span>
</span><span class="cfl" id="cl45" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="c1" style="color: #880000;">//<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>Sub<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>level<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>dir<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>to<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>be<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>00<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>-<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>99<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>(100<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>per<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>top<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>level<span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span>dir)</span>
</span><span class="cfl" id="cl46" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$sub_dir</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">=</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$fid</span><span class="p" style="color: #666600;">[</span><span class="nv">$len</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">-</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="mi" style="color: #006666;">2</span><span class="p" style="color: #666600;">]</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">.</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$fid</span><span class="p" style="color: #666600;">[</span><span class="nv">$len</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">-</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="mi" style="color: #006666;">1</span><span class="p" style="color: #666600;">];</span>
</span><span class="cfl" id="cl47" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$value</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">=</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$top_dir</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">.</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="s1" style="color: #008800;">'/'</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">.</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$sub_dir</span><span class="p" style="color: #666600;">;</span>
</span><span class="cfl" id="cl48" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$replacements</span><span class="p" style="color: #666600;">[</span><span class="nv">$tokens</span><span class="p" style="color: #666600;">[</span><span class="s1" style="color: #008800;">'fid_split'</span><span class="p" style="color: #666600;">]]</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o" style="color: #666600;">=</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$value</span><span class="p" style="color: #666600;">;</span></span><span class="cfl" id="cl50" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="p" style="color: #666600;">}</span>
</span><span class="cfl" id="cl51" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="k" style="color: #000088;">return</span><span class="o vs" style="background-image: url(data:image/png; background-position: 50% 50%; background-repeat: no-repeat no-repeat; color: #666600;"> </span><span class="nv">$replacements</span><span class="p" style="color: #666600;">;</span>
</span><span class="cfl" id="cl52" style="color: black; display: block; margin: 0px -9px; padding: 0px 9px;"><span class="p" style="color: #666600;">}</span></span></span></span><br />
<br />
At the time of this writing, you need to use the latest dev version of fe_paths module (commit dated 16 Oct 2012).</div>
Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com1tag:blogger.com,1999:blog-11989739.post-36096001674192791172014-01-13T23:19:00.000+05:302014-01-13T23:19:34.704+05:30Alter path alias programmatically for an existing taxonomy term<div dir="ltr" style="text-align: left;" trbidi="on">
Here's a method to alter the path alias (if you're using the <a href="http://drupal.org/project/pathauto" target="_blank">pathauto</a> module) of an existing taxonomy term programmatically. Here we shall be doing this in a hook_update_N(). It is quite un-intuitive given the lack of proper documentation as to how to alter the alias of an existing term. Here is my trial & error method:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">/**</span><br />
<span style="font-family: Courier New, Courier, monospace;"> * Re-alias 'Trailer' term & create a redirect from its old path to the new alias.</span><br />
<span style="font-family: Courier New, Courier, monospace;"> */</span><br />
<span style="font-family: Courier New, Courier, monospace;">function xxxxx_update_7007() {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> // 'Trailer' term.</span><br />
<span style="font-family: Courier New, Courier, monospace;"> $term = taxonomy_term_load(20);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> // Set 'Generate automatic URL alias' to FALSE to allow custom alias setting later.</span><br />
<span style="font-family: Courier New, Courier, monospace;"> $term->path['pathauto'] = FALSE;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> taxonomy_term_save($term);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"> // Create a new alias</span><br />
<span style="font-family: Courier New, Courier, monospace;"> $new_path = path_load('taxonomy/term/20');</span><br />
<span style="font-family: Courier New, Courier, monospace;"> $new_path['alias'] = 'trailers';</span><br />
<span style="font-family: Courier New, Courier, monospace;"> path_save($new_path);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"> // Setup redirect from the old url 'trailer' to 'trailers'</span><br />
<span style="font-family: Courier New, Courier, monospace;"> $redirect = new stdClass();</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"> module_invoke(</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'redirect',</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'object_prepare',</span><br />
<span style="font-family: Courier New, Courier, monospace;"> $redirect,</span><br />
<span style="font-family: Courier New, Courier, monospace;"> array(</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'source' => 'trailer',</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'source_options' => array(),</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'redirect' => 'trailers',</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'redirect_options' => array(),</span><br />
<span style="font-family: Courier New, Courier, monospace;"> 'language' => LANGUAGE_NONE,</span><br />
<span style="font-family: Courier New, Courier, monospace;"> )</span><br />
<span style="font-family: Courier New, Courier, monospace;"> );</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"> module_invoke('redirect', 'save', $redirect);</span><br />
<span style="font-family: Courier New, Courier, monospace;">}</span><br />
<br />
In the above example, we are changing the path of a term from '/trailer' to '/trailers' and setting up a redirect from the old path so that users don't get lost (plus it's better for SEO).<br />
<br />
We first have to unset the 'Generate automatic URL alias' option and save the term. Then create the new alias, followed by adding the redirect from the old alias.</div>
Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-44805190749537826822013-02-22T22:14:00.001+05:302013-04-02T16:06:09.507+05:30Intro to Drupal image token system (Drupal 7.20 onwards)<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: black; font-family: Tahoma;"><span dir="ltr">In Drupal 7.20, a new token system was introduced for image derivative urls to circumvent a <a href="http://drupal.org/SA-CORE-2013-002" target="_blank">security DOS issue</a>.</span></span><br />
<span style="color: black; font-family: Tahoma;"><span dir="ltr"><br /></span></span>
<span style="color: black; font-family: Tahoma;"><span dir="ltr">An image derivative would have
only one token. However, different image derivatives (image styles) of
the same main
image will have different tokens each.<br />
<br />
The image token is generated as a base-64 encoded sha-256 hmac based on the <u>drupal hash salt</u>, <u>image style name</u> & <u>uri</u> in <a href="https://webmail.dennis.co.uk/owa/redir.aspx?C=83d3d0724cda4aa3b885aa046cd228c9&URL=http%3a%2f%2fapi.drupal.org%2fapi%2fdrupal%2fmodules%2521image%2521image.module%2ffunction%2fimage_style_path_token%2f7" target="_blank">image_style_path_token()</a>.
So it remains constant for an image derivative but changes based on the image style name.<br />
<br />
The call stack for generating image style links is:<br />
</span></span><br />
<div style="margin: 14pt 30pt;">
<span style="color: black; font-family: Tahoma;"><a href="https://webmail.dennis.co.uk/owa/redir.aspx?C=83d3d0724cda4aa3b885aa046cd228c9&URL=http%3a%2f%2fapi.drupal.org%2fapi%2fdrupal%2fmodules%2521image%2521image.module%2ffunction%2fimage_style_url%2f7" target="_blank">image_style_url()</a> -> <a href="https://webmail.dennis.co.uk/owa/redir.aspx?C=83d3d0724cda4aa3b885aa046cd228c9&URL=http%3a%2f%2fapi.drupal.org%2fapi%2fdrupal%2fmodules%2521image%2521image.module%2ffunction%2fimage_style_path_token%2f7" target="_blank">image_style_path_token()</a>
-> <a href="https://webmail.dennis.co.uk/owa/redir.aspx?C=83d3d0724cda4aa3b885aa046cd228c9&URL=http%3a%2f%2fapi.drupal.org%2fapi%2fdrupal%2fincludes%2521bootstrap.inc%2ffunction%2fdrupal_hmac_base64%2f7" target="_blank">drupal_hmac_base64()</a><br />
</span></div>
<span style="color: black; font-family: Tahoma;">
The security check is conducted in image_style_deliver() where it is a valid url request iff;<br />
<br />
</span><br />
<pre style="background-color: #f6f6f2; border-width: 0px; font-size: 10pt; padding: 1px; text-align: left;"><span style="color: black; font-family: Tahoma;"><span style="color: #222222; font-family: courier new,courier,lucida console; font-size: xx-small;"><span style="font-size: 13px;"><span style="color: #333300; font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace; font-size: xx-small;"><span style="font-size: 12px;">$_GET</span></span><span style="font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace;"><span style="font-size: 0.92em;">[</span></span><a href="https://webmail.dennis.co.uk/owa/redir.aspx?C=83d3d0724cda4aa3b885aa046cd228c9&URL=http%3a%2f%2fapi.drupal.org%2fapi%2fdrupal%2fmodules%2521image%2521image.module%2fconstant%2fIMAGE_DERIVATIVE_TOKEN%2f7" target="_blank"><span style="color: #0000aa; font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace; font-size: xx-small;"><span style="font-size: 12px;"><b>IMAGE_DERIVATIVE_TOKEN</b></span></span></a><span style="font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace;"><span style="font-size: 0.92em;">] === </span></span><a href="https://webmail.dennis.co.uk/owa/redir.aspx?C=83d3d0724cda4aa3b885aa046cd228c9&URL=http%3a%2f%2fapi.drupal.org%2fapi%2fdrupal%2fmodules%2521image%2521image.module%2ffunction%2fimage_style_path_token%2f7" target="_blank"><span style="color: #0000aa; font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace; font-size: xx-small;"><span style="font-size: 12px;"><b>image_style_path_token</b></span></span></a><span style="font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace;"><span style="font-size: 0.92em;">(</span></span><span style="color: #333300; font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace; font-size: xx-small;"><span style="font-size: 12px;">$style</span></span><span style="font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace;"><span style="font-size: 0.92em;">[</span></span><span style="color: #aa0000; font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace; font-size: xx-small;"><span style="font-size: 12px;">'name'</span></span><span style="font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace;"><span style="font-size: 0.92em;">], </span></span><span style="color: #333300; font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace; font-size: xx-small;"><span style="font-size: 12px;">$scheme</span></span><span style="font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace;"><span style="font-size: 0.92em;"> . </span></span><span style="color: #aa0000; font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace; font-size: xx-small;"><span style="font-size: 12px;">'://'</span></span><span style="font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace;"><span style="font-size: 0.92em;"> . </span></span><span style="color: #333300; font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace; font-size: xx-small;"><span style="font-size: 12px;">$target</span></span><span style="font-family: Bitstream Vera Sans Mono,Monaco,lucida console,monospace;"><span style="font-size: 0.92em;">);</span></span></span></span></span></pre>
<span style="color: black; font-family: Tahoma;">
<br /><span style="font-size: x-small;">NB: IMAGE_DERIVATIVE_TOKEN is a constant for 'itok'.</span></span></div>
Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-27093392562646265352012-12-11T03:42:00.000+05:302012-12-11T03:43:08.324+05:30Thank You, from the bottom of our hearts.<div dir="ltr" style="text-align: left;" trbidi="on">
On the morning of Diwali 2012, a day before Teachers Day, my wife and I found ourselves on our way to India. It was not a joyride home though. My father had bid adieu to this world in a sudden respiratory attack. He was ambulatory, witty and independent to the very end. Also, he was very well loved and respected. Too many people have expressed grief over our loss and as many have been with us so long.<br />
<br />
I dedicate this post to everyone who have touched our lives. Right from the very beginning till now. Sometimes it was the most unexpected of people who've shown empathy. Countless times we've been blown away by the tireless compassion shown by you all. My father was blessed in every other way - we'd always say.<br />
<br />
My father has shown that Cancer is definitely not a disease. It is not to be frightened about. It is a door to a different world - perhaps painful to the body but enlightening to the soul. It is a world where the smallest of things can bring much happiness. And each peaceful morning is all that matters. Where a smiling face is like the radiating sun and a lending hand lets you cross an ocean.<br />
<br />
Truth be told, my father had conquered the disease ages ago. He was never tormented by the pain in as much as a bodily discomfort and helplessness to others, as he only gained in faith and respect as it progressed, thereby giving it only his body in the end but leaving with a very strong and reaffirmed soul than ever before.<br />
<br />
We thank each and everyone of you who have shown us this world. We have seen the kindness in your soul. Your empathy and compassion is unforgettable.<br />
<br />
We really thank all our doctors at <a href="http://www.aimshospital.org/" target="_blank">Amritha hospital, Cochin</a> and <a href="http://www.cancerinstitutewia.org/" target="_blank">Adayar Cancer Institute, Chennai</a> - you are all God in different forms, tirelessly working and striving to help others compassionately. Truly yours is a noble profession. I have to especially highlight the work done by Adayar Cancer Institute and <a href="http://www.cacharcancerhospital.org/" target="_blank">Cachar Cancer Center</a> because they are hospitals with world-class doctors freely treating the poor throughout the year. My respect for them goes through the roof. I was only able to contribute as little as I could monetarily but I will make it a point to lend my voluntary help as I can too.<br />
<br />
Now to the present and the future.<br />
<br />
In the present day, where one in three is affected with this disease, there is not a single neighborhood that is without an affected household. Economic and social conditions aside, this disease affects victims alike. And suffice to be told that a terminal disease afflicts not just the patient, but an entire family.<br />
<br />
Gauging from simple research, one can be quite satisfied with the level of cancer awareness spreading throughout the world now. The fight for it is also in good progress with countless agencies and pharmaceuticals in this pursuit. But what is lacking is the continued support, care and voluntary work shown by society - what you have given us and taught the invaluable benefit of. Ongoing cancer support is as much as a necessity as finding a cure. Society needs to mend itself to be more outward and supportive than inward and pleasure seeking nowadays. I now feel if I could spend some of those empty evenings from work at a needy house lending a helping hand, it could do wonders. Way better than procrastinating in front of the television or computer. This is my next journey.<br />
<br />
I thank you all from the bottom of my heart once again for being my guide, mentor, friend and strength in times of our deepest sorrow. God Bless.</div>
Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-19694002315229110752012-09-10T00:42:00.001+05:302012-09-10T00:43:58.048+05:30Keeping focus is necessary<div><p>A lot of us loose focus quickly. This is exactly what I don't want to be. Even after my dearest family member has either succeeded or succumbed to cancer, I want to keep fighting and supporting all means of eradicating this killer disease. Need to keep my focus. I pray to continue the good deeds that I involuntarily needed to  support.</p>
</div>Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-53310973612614962162012-07-23T16:34:00.002+05:302012-07-23T18:46:56.174+05:30Lighter version of loading fields on an entity<div dir="ltr" style="text-align: left;" trbidi="on">
Here is an alternative to <a href="http://api.drupal.org/api/drupal/includes%21entity.inc/function/DrupalDefaultEntityController%3A%3Aload/7" target="_blank">entity_load()</a> types (<a href="http://api.drupal.org/api/drupal/modules--node--node.module/function/node_load/7" target="_blank">node_load()</a>, <a href="http://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_term_load/7" target="_blank">taxonomy_term_load()</a> etc.) that is useful if you want to bypass all the calls to <a href="http://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_entity_load/7" target="_blank">hook_entity_load()</a><br />
<br />
If you know the entity id, type and 'bundle', then this could reduce load time:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">
</div>
<div style="background-color: #cccccc; color: #444444; font-family: "Courier New",Courier,monospace;">
<script class="brush:php" type="syntaxhighlighter">
<![CDATA[
/**
* Loads fields of an entity without invoking hook_entity_load() and hook_<entity_type>_load()
*
* @param $type Entity type. e.g. 'node', 'taxonomy_term'
* @param $id Entity id
* @param $properties Basic entity properties specific to the entity type that are needed in field_attach_load().
*
* Note: $type and $id have to be separately included in $properties
*/
function entity_field_load_lite($type, $id, $properties = array()) {
if (empty($properties)) {
return FALSE;
}
// A note on caching:
// When using field cache, the cache is set on call for field_attach_load itself
// When using entity cache however, it disabled field cache and sets cache only during entity load.
// We, on the other hand can store these 'lightly loaded' entities in our own cache system
$cid = md5((string)$type . (string)$id);
if ($data = cache_get($cid, 'cache')) {
return $data;
}
$object = new stdClass();
foreach ($properties as $property => $value) {
$object->$property = $value;
}
field_attach_load($type, array($id => $object));
cache_set($cid, $object, 'cache');
return $object;
}
]]>
</script>
</div>
<br />
How do you call this function?<br />
<br />
For nodes:<br />
<br />
<script class="brush:php" type="syntaxhighlighter">
<![CDATA[
$properties = array(
'nid' => '20481',
'type' => 'article',
);
$node = entity_field_load_lite('node', '20481', $properties);
]]>
</script>
<br />
For taxonomy terms:<br />
<br />
<script class="brush:php" type="syntaxhighlighter">
<![CDATA[
$properties = array(
'tid' => 626,
'vid' => 11,
'vocabulary_machine_name' => 'model',
);
$term = entity_field_load_lite('taxonomy_term', 626, $properties);
]]>
</script>
<br />
Caveats:<br />
<ul style="text-align: left;">
<li>Does not call hook_entity_load() hooks.</li>
<li>You can implement a caching strategy based on the modules used. For e.g. when entity cache is used, <a href="http://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/field_attach_load/7" target="_blank">field_attach_load()</a> does not cache data in 'cache_field'</li>
</ul>
</div>Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com1tag:blogger.com,1999:blog-11989739.post-91137696506782504592012-04-11T21:15:00.003+05:302012-04-11T21:15:46.377+05:30Fivestar float rating module - Drupal<div dir="ltr" style="text-align: left;" trbidi="on">
I have just created a <a href="http://drupal.org/sandbox/girishmuraly/1528000." target="_blank">sandbox module</a> that allows inputting of float values for Fivestar fields, so that it is easy to create ratings such as 2.7/5, 3.1/5 etc.<br />
<br />
This module adds a field widget to the Fivestar field, which is a textfield that will take a float value as rating input. The display is unaffected and uses the default Fivestar theme functions. Users can override the theme functions to make use of better floating point precision by affecting the <a href="http://www.php.net/manual/en/function.round.php" target="_blank">round()</a> function there. See more description in the <a href="http://drupal.org/sandbox/girishmuraly/1528000" target="_blank">project page</a>.<br />
<br />
Awaiting comments, thoughts and reviews before I decide on the further course of action.<br />
<br />
Do read <a href="http://drupal.org/node/1514826" target="_blank">this fivestar feature request</a> first, as to what is missing and why I created this module.</div>Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-66920124113290223942012-03-05T17:08:00.001+05:302012-03-05T17:08:08.984+05:30Cache expiration module Alpha1 version released<div dir="ltr" style="text-align: left;" trbidi="on">
What a pleasant surprise on a Monday morning to see the <a href="http://drupal.org/project/expire" target="_blank">Cache expiration</a> module release its alpha1 version, ready for basic use and testing.<br />
<br />
Varnish, arguable the most common reverse proxy caching mechanism used with Drupal sites has integration with the Cache expiration module. With this module, it was not possible to selectively expire (purge) urls from Varnish. But now we can (atleast for some most commonly used cases).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpGXf0VpyXGSDG80bxFXqUuvaHNqTIEUP7f0MXkwCeioILv0_tvpbCTpLr-sFq9rG4Md1xUWptTHsMTtBQmit9vl0ZJROhyNDnFrXY8U1vwWkMNLsKmX5f0M4EVgBeqdBzbqM5/s1600/cache-expire-config.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="107" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpGXf0VpyXGSDG80bxFXqUuvaHNqTIEUP7f0MXkwCeioILv0_tvpbCTpLr-sFq9rG4Md1xUWptTHsMTtBQmit9vl0ZJROhyNDnFrXY8U1vwWkMNLsKmX5f0M4EVgBeqdBzbqM5/s400/cache-expire-config.png" width="400" /></a></div>
<b>Basic testing</b><br />
Some basic testing gave very good expected results. First your Drupal setup to cache pages for anonymous users at admin/config/development/performance. Then by merely enabling the expire module, and using the default options enabled in its config page (snugged away in admin/config/development/performance/expire), you can see the benefits already:<br />
<br />
For e.g:<br />
Assume you have you home page cached by varnish (min cache liftime 5mins). Which means any edit to the homepage in that time will not show up to the anon user, who still sees the cached version. Unless you purge Varnish manually.
<br />
<br />
Not anymore, with the expire module enabled.<br />
<br />
Cache expiration will purge the url of the homepage immediately, because you edited your homepage. <br />
<br />
Good stuff already! That is not all. Here is a look at its optional features in the alpha1 release:<br />
<br />
<b>Optional features</b>
<br />
<ul style="text-align: left;">
<li>When a node is expired their nodereferences and parent nodes where it is referenced can be expired.</li>
<li>When a 'promoted to homepage' node has been expired, the homepage can be expired.</li>
<li>Expire the menu(tree) when a node expires</li>
<li>Expire the term pages of those terms tagged to an expired node.</li>
</ul>
Note: 'expired node' refers to a node (url) that is being purged from Varnish on the event of it being edited.<br />
<br />
Now, the wait for <a href="http://drupal.org/project/views_content_cache">http://drupal.org/project/views_content_cache</a> just got more exciting!
</div>Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-61512390384706457582011-11-24T17:06:00.001+05:302011-11-24T18:11:39.635+05:30JW Player module now supports plugins<div dir="ltr" style="text-align: left;" trbidi="on">
The <a href="http://drupal.org/project/jw_player" target="_blank">JW Player</a> module, which is currently in development for Drupal 7 <a href="http://drupal.org/node/1338964" target="_blank">has just got</a> the feature of being able to support plugins for presets. With this feature, it is possible to plug in all the add ons availabe from <a href="http://www.longtailvideo.com/addons/plugins">Longtail video</a>.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.longtailvideo.com/addons/plugins" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaa5Evun6IEFDWW6RjVcSnJfQFzLW4FlIdS6GBpOrb3BbibFpfyj0KaMaUbb-e8ljEUzzbW_Vw7dX4B4YU-Xvs0ayqQdj0vpmCb9jFpz0gDINgaMHIAC0oHsfj3cI6IEh5ihuO/s320/longtail_plugins.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">JW Player plugins</td></tr>
</tbody></table>
<br />
There is also a Drupal preset plugin created for <a href="http://www.longtailvideo.com/addons/plugins/107/Google-Analytics-Pro" target="_blank">Google Analytics Pro2 JW player</a> available in <a href="http://drupal.org/sandbox/girishmuraly/1344992" target="_blank">my sandbox</a>.
Custom modules can implement plugins by using the newly introduced hook_jw_player_plugin_info() in the <a href="http://drupal.org/project/jw_player" target="_blank">JW Player module</a>. The format to use this hook as described in jw_player.api.php is:<br />
<br />
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
/**<br />
* Implements hook_jw_player_plugin_info()<br />
*<br />
* @return array Associative array of plugins keyed by actual plugin id<br />
*/<br />
function hook_jw_player_plugin_info($preset) {<br />
// Create a plugin keyed by its actual plugin id<br />
$plugins['foo'] = array(</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'name' => t('Foobar'),</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'description' => t('A plugin to do foobar'),</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
// Note: Each option should be in a valid FAPI format, as it is directly referenced in the preset settings form,</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
// except the '#title' may be omitted for the name of the option to be taken as default</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'config options' => array(</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'accountid' => array(</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'#type' => 'textfield',</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'#required' => TRUE,</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'#size' => 15,</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'#default_value' => 'bar'</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
),</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'param2' => array(</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'#type' => 'select',</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'#options' => array('TRUE' => 'TRUE', 'FALSE' => 'FALSE'),</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'#default_value' => 'TRUE',</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
'#description' => t('Enables the controls on an item when playing')),</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
),</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
);</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
return $plugins;</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace; text-align: justify;">
}</div>
<div style="text-align: justify;">
</div>
<br />
As described above, the plugin is an associative array keyed by its actual plugin name as required by the player. The data basically consists of a friendly name and description, followed by configurable options that the site-administrator/editor can set per preset, which would look something like:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjuJaSslin554PDaVblYbgu-Mr97CJMHCyfX8-SCFKfiGMphHdwg6nfOL9a8FT8_lDYWzshZ2bMm1PmO0NZE0J62gEdTY0KMuqkG-kbNSH6PhTqe5baEnXfyUoVyS2we2ks25a/s1600/preset_plugin_configuration.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjuJaSslin554PDaVblYbgu-Mr97CJMHCyfX8-SCFKfiGMphHdwg6nfOL9a8FT8_lDYWzshZ2bMm1PmO0NZE0J62gEdTY0KMuqkG-kbNSH6PhTqe5baEnXfyUoVyS2we2ks25a/s640/preset_plugin_configuration.png" width="304" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">JW Player preset settings</td></tr>
</tbody></table>
If the preset plugin is enabled, when viewing the source code of your page that contains a JW Player video, you should be able to see the plugin added to the player code; something like: <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK9657FkCORGk_D6Yzy_m0CLXx-0lu22NGyQ-7G2icseaENhMsFuSQINInzdN8fmTd8Ajc99fGWBbEuYR-OnLAtPsS3w9xlTklDR2wGC7sJHRM1-9P8e-7YO0nMiA2124YbYMu/s1600/preset_player_javascript.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="162" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK9657FkCORGk_D6Yzy_m0CLXx-0lu22NGyQ-7G2icseaENhMsFuSQINInzdN8fmTd8Ajc99fGWBbEuYR-OnLAtPsS3w9xlTklDR2wGC7sJHRM1-9P8e-7YO0nMiA2124YbYMu/s400/preset_player_javascript.png" width="400" /></a></div>
<br /></div>Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-60550437410921103362011-11-09T04:01:00.001+05:302011-11-12T23:00:28.431+05:30How to use hook_query_alter() to alter Views in Drupal 7<div dir="ltr" style="text-align: left;" trbidi="on">
Sometimes you need to alter a Views query by using the regular <a href="http://api.drupal.org/api/drupal/includes--database--select.inc/interface/SelectQueryInterface/7" style="font-family: Georgia,"Times New Roman",serif;" target="_blank">SelectQueryInterface</a> methods without having to use the Views data structure in <a href="http://drupalcontrib.org/api/drupal/contributions--views--docs--views.api.php/function/hook_views_query_alter/7" style="font-family: Georgia,"Times New Roman",serif;" target="_blank">hook_views_query_alter()</a>. It may get tedious at times working out all the views relationships, and arguments separately and adding a simple 'groupby' may get tricky if you do not have aggregation set in the view. It could also be that your hook_views_query_alter() runs a little too early for the <span style="font-family: Georgia,"Times New Roman",serif;">$query</span> to be modified.<br />
<br />
Luckily, when the Views query is built in <a href="http://api.drupalecommerce.org/api/views/views--plugins--views_plugin_query_default.inc/function/views_plugin_query_default%3A%3Aquery/7.x" target="_blank"><code>views_plugin_query_default::query</code></a> a unique tag is added to each view of the form <span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">'<b><span style="font-family: Arial,Helvetica,sans-serif;">view_<view_name></span></b></span></span>':<br />
<br /> <span style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace;">// Go ahead and build the query. </span><br />
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace;">
// db_select doesn't support to specify the key, so use getConnection directly.</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace;">
$query = Database::getConnection($target, $key) </div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace;">
->select($this-><a href="http://api.drupalecommerce.org/api/views/views--plugins--views_wizard--views_ui_base_views_wizard.class.php/property/ViewsUiBaseViewsWizard%3A%3Abase_table/7.x">base_table</a>, $this-><a href="http://api.drupalecommerce.org/api/views/views--plugins--views_wizard--views_ui_base_views_wizard.class.php/property/ViewsUiBaseViewsWizard%3A%3Abase_table/7.x">base_table</a>, $options) </div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace;">
->addTag('views')</div>
<div style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace;">
->addTag('views_' . $this-><a href="http://api.drupalecommerce.org/api/views/views--includes--view.inc/class/view/7.x">view</a>->name);</div>
<br />
<div style="font-family: Times,"Times New Roman",serif;">
Note: <a href="http://api.drupalecommerce.org/api/views/views--plugins--views_plugin_query_default.inc/function/views_plugin_query_default%3A%3Aexecute/7.x" target="_blank">views_plugin_query_default::execute</a> adds access data to the query which should be used for building access rights to the query during execution.</div>
<br />
So, in your hook_query_alter(), you could identify the view based on its tag and modify the query like any other SelectQuery. I found this easier than using hook_views_query_alter() many times.<br />
<br />
Example to group by a specific field:<span style="background-color: #fff2cc; font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"> </span></span><br />
<br />
<span style="background-color: #fff2cc; font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">function </span><a href="http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_query_alter/7" style="font-family: "Courier New",Courier,monospace;">hook_query_alter</a><span style="font-family: "Courier New",Courier,monospace;">(</span><a href="http://api.drupal.org/api/drupal/includes--database--query.inc/interface/QueryAlterableInterface/7" style="font-family: "Courier New",Courier,monospace;">QueryAlterableInterface</a><span style="font-family: "Courier New",Courier,monospace;"> $query){</span></span><br />
<span style="background-color: #fff2cc; font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"> if ($query-></span><a href="http://api.drupal.org/api/drupal/includes--database--select.inc/function/SelectQuery%3A%3AhasTag/7" style="font-family: "Courier New",Courier,monospace;">hasTag</a><span style="font-family: "Courier New",Courier,monospace;">('view_my_custom_view')) {</span></span><br />
<span style="background-color: #fff2cc; font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"> $query-></span><a href="http://api.drupal.org/api/drupal/includes--database--select.inc/function/SelectQuery%3A%3AgroupBy/7" style="font-family: "Courier New",Courier,monospace;">groupBy</a><span style="font-family: "Courier New",Courier,monospace;">('n.type');</span></span><br />
<span style="background-color: #fff2cc; font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"> }</span></span><br />
<span style="background-color: #fff2cc; font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"> }</span></span><code>
</code></div>Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-14796016014099066792011-11-08T16:52:00.004+05:302011-11-08T17:04:18.290+05:30Themeing EVA views using custom templates [patch]<a href="http://drupal.org/project/eva">Entity Views Attachment</a> lets you attach a view to a Drupal 7 entity. This means when viewing a node, you could display for example, a list of other nodes by the same author. See http://www.theweek.co.uk/columnist/michael-bywater<br /><br />But due to the way the views plugin was written, it was not possible to use custom templates for EVA views. If you tried to, you would end up with a lot of 'underfined variable' notices for all the variables in your custom template.<br /><br />E.g.<br /><span style="color: rgb(102, 102, 102);font-family:courier new;" >Notice: Undefined variable: title in include() (line 31 of /../sites/all/themes/../templates/eva-display-entity-view--gallery--entity-view-1.tpl.php).</span><br /><br />There is a hard dependency on <span style="font-family:courier new;">eva.theme.inc</span> even when overriding <strong style="font-weight: normal; font-family: courier new;">eva-display-entity-view.tpl.php</strong> to a custom tpl. Due to this, <span style="font-family:courier new;">template_preprocess_views_view()</span> is not run.<br /><br />The patch in <a href="http://drupal.org/node/1205008#comment-5130160">http://drupal.org/node/1205008#comment-5130160</a> fixes the above limitation by removing the dependency from hook_views_plugins().Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-51562804224023722192011-11-06T23:54:00.006+05:302011-11-07T17:02:56.171+05:30Its all a dream they sayIn my dream I conjure up characters, including myself. I am very real in the duration of my dream. I do things, I see other people. I feel emotions. Sometimes I also see myself from above doing different things, often connected to me past interactions with people. And then I wake up. All the characters and myself disappear away and I am back to my present self. It was all a dream, they say.<br /><br />Where did all those characters go? The events in the dream seemed real, even though the colours were not as vibrant and vivid as the non-dream state. We have always pondered about what happens to the soul after death. Life is energy, so it has to transform from one form to another?<br /><br />I believe the answer to the question of where one 'goes' after death is also similar to what happens to the characters of a dream on waking up.<br /><br />Hinduism suggests the whole world is Maya (an illusion). Do illusions change form? What if we do not involve the perceptor?Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-75962450657336614272011-11-02T23:20:00.003+05:302011-11-06T23:54:15.336+05:30Varnish simple purge<p>So whats a Drupal 7 developer to do if he needs to launch a highly dynamic anonymous site and needs to plan caching strategies? Use <a href="https://www.varnish-cache.org/">Varnish cache</a> of course.</p><p>But if your site is as dynamic as mine, Varnish will display stale entries unless its TTL is set to something like <span style="font-family:courier new;">1 hour</span>. For a dynamic news site then, surely you need automatic rules to purge pages from Varnish on new or updated content? For e.g. the homepage is changing constantly! The index pages will also change often.<br /></p><p>There are currently two modules in the pipeline that should offer the ability to purge pages (cache ids) from Varnish, instead of the whole Varnish cache (oh God, no!):</p><ol><li><a href="http://drupal.org/project/expire" rel="nofollow">Cache Expiration</a>, and</li><li><a href="http://drupal.org/project/cache_actions" rel="nofollow">Cache actions</a></li></ol><p>While waiting for these more suited modules to have a stable, usable release on Drupal 7 production sites, I had to create a very simple module -<a href="http://drupal.org/sandbox/girishmuraly/1322416">Varnish Simple Purge</a> - that allows site admins/editors to purge individual urls from Varnish.</p><p>We don't want to give them too many options, cos by experience we know they will use all :) Finally Varnish will more often be empty - not a good state to be in.<br /></p> <p>Hence with a Varnish TTL of 1hour and a simple purge mechanism to purge pages immediately if needed, my news site is working way faster than its non Drupal predecessor. Oh did I forget to mention that this site is a port from a bespoke CMS to Drupal?</p><p>Other cache clearing mechanisms we use are time based views cache (in-built in views). What we would really love is this <a href="http://drupal.org/sandbox/jaydub/1286920">port of Views Content cache</a>.<br /></p>Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-72359005789217029632011-08-03T17:21:00.006+05:302011-11-02T23:04:42.256+05:30Managing optional features in a Drupal DistroSo you need to build a comprehensive distro using features to export data into code. Fair enough. What could be one of the most common problems in trying to create a common solution for all sites?<br /><br />Problems:<br /><ol><li>20% of the sites would want additional fields<br /><br />In your distro, say content type 'article' has 10 fields and needs 2 optional fields. All sites will use the 10 'core' fields and the 2 optional fields may or may not be used.<br /><br /></li><li>Some sites want to alter field labels and change display settings on content types</li></ol><br /><u>Solutions:</u><br /><br /><ol><li>Separate overridable feature for extra fields per content type<br /><br />Export the main content with 10 fields into one feature and the optional fields into another feature. Site builders can leave the main feature alone and modify the extra feature only (change field permissions, usage, labels etc.)<br /><br />Perhaps its not easy to export the content type with the extra fields left out. In that case, manually remove the field's references from the export files. Usually those will be in *.features.field.inc & *.info files.<br /><br />Then export the extra fields in a separate content type and manually add a dependency to the main feature.<br /><br /></li><li>template_preprocess hooks.<br /><br />Consider encouraging site-builders to place all field alterations in appropriate hooks such as hook_form_alter() and hook_template_preprocess_page()<br /><br /></li><li>Override field display settings<br /><br />This <a href="http://drupal.org/sandbox/mpotter/1280900">module</a> is still in its infancy but its possible to export field display settings separately into a feature. A comprehensive guide can be found here - <a href="http://www.agileapproach.com/blog-entry/new-paradigm-overriding-drupal-features">http://www.agileapproach.com/blog-entry/new-paradigm-overriding-drupal-features</a><br /></li></ol>Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-76660445850512929582011-07-11T19:30:00.002+05:302011-07-11T19:33:25.881+05:30Space shuttle cockpitA few years ago, I remember posting this <a href="http://lechronicles.blogspot.com/2008/01/must-see-airbus-a380-cockpit-incredible.html">interactive view</a> of the Airbus A380 cockpit.<br /><br />And now I am as thrilled to get this link for the <a href="http://360vr.com/2011/06/22-discovery-flight-deck-opf_6236/index.html">Space shuttle cockpit</a>Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-29669465553600921732011-04-01T15:47:00.002+05:302011-04-01T15:49:36.565+05:30Google's April fool 2011 - Google motionIts always a pleasure to blog about the April fool's joke played by Google each year. For 2011, its the <a href="http://mail.google.com/mail/help/motion.html">Google motion</a> way of communication.<br /><br />Wonder if anybody would really start doing the 'motion's! Good exercise anyway!Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-71263190678272775442010-11-05T14:23:00.002+05:302010-11-05T14:39:43.066+05:30The thing about documentationI love agile methodology and extreme programming. I used to work in a team that loved it and lived by its core philosophy. To top it of we had a strong technical manager who was a certified scrum master and new the approach inside out. Life was good.<br /><br />Then our manager left. We got a lot of new recruits, many who had never worked in a core agile environment. Our teams got shaken up. Ultimately, the loudest voices got heard. 6 months into it, we have sort of become a mess. To sort of patch up the mess, somebody suggested documenting processes, because to some people, agile meant chaos. Of course agile methodology minimises documentation. Its not that we hate documentation. But I hate certain kinds of documentation. Documentation of processes.<br /><br />How can you encapsulate all the nuances about human activities - interactive communicative and effective procedures - into words? Documenting processes is like making humans machines. Without creativity or without thought. Processes always are evolving and no two situations can be asked to follow the same text. People need to think on their feet each time. Agreed - some process documentation come with a disclaimer that these are just guidelines and to use proper judgement before following them. Now a poor new recruit new to the agile world would ask - where is that documented?<br /><br />I believe in mentor-ship and process mentor-ship that encourages and teaches the ideology behind thought. Perhaps putting this ideology into text would not be bad since it does just that - captures ideology. <br /><br />Anyway, I do like documentation on one important aspect - requirements. Although requirements may change in the real world, they still need to be documented. Because requirements need to be translated into code, which a machine needs to understand. Quite unlike process documentation which a human needs to understand, assimilate and generate an effective action out of.Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-64598651029141743662010-10-22T01:08:00.010+05:302010-10-25T01:08:06.308+05:30Are we doing enough, or are we sinners?In the colonial era, my countrymen, Indians, with our peaceful ideology and treating-guests-like-kings mentality eventually got overpowered by the mighty British forces who had been thinking of and investing in arms and destruction years before. <br /><br />In fact, the British powered over so many other peaceful regions and these innocent people paid the price for.. being innocent? The British in this case can of course be seen as barbarous and used their technological advantage to power over other (weaker) human beings. Nothing too different from Hitler and others who abused powers and got blinded by greed, possession and sense of omnipotence. <br /><br />Question is: why did the peace-loving, God loving people have to pay the price for not having destructive weapons? They did not waste time polluting their minds thinking about exploitation, murder, destruction and such evil thoughts. Was it their fault that they were abiding by God's teachings? <br /><br />I could not come up with a good answer to this easily. After pondering for quite a while, the most reasonable explanation I could come up was:<br /><br />'The good' & the 'innocent' did not do enough to take over the world and spread their goodness. Evil took over the world quite easily. Why? Because the good was dormant. They perhaps did not do enough and did not think for other people in other lands so as to spread the wealth of their knowledge and values to other cultures. It is the duty of every 'good' person to spread the message about their ideologies. If they think its not worth spreading, then they probably are vagabonds without a purpose in life and in doing so, are committing a sin.<br /><br />So it all boils down to each one of us. Are we doing enough to spread our message of our view of the world? Are we doing enough to share our thoughts and beliefs in the hope that it will help humanity? What are we doing for mankind? Are we doing enough?Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-87033144408149214072010-10-21T16:15:00.003+05:302010-10-21T16:25:48.792+05:30Autocomplete paths and themes in DrupalIt is very important that any AHAH callback menu item is of the same theme loading menu execution path as that of the parent. Otherwise you will have themes conflicting and overriding each other.<div><br /></div><div>Here's a case in point:</div><div><br /></div><div>Say you are using 'rubik' theme for admin pages (node edit & add pages). And lets assume you are using Garland as the front end theme for other users.</div><div><br /></div><div>If you happen to have an autocomplete or AHAH form element in the node edit page like so:</div><div><blockquote><div>$form['book']['submit_book'] = array(<br /> '#type' => 'submit',<br /> '#value' => t('Select book'),<br /> '#weight' => -4,<br /> '#attributes' => array('class' => 'book-title-select'),<br /> '#ahah' => array(<br /> 'path' => 'mybooks/js',<br /> 'wrapper' => 'edit-book-plid-wrapper',<br /> 'effect' => 'slide',<br /> ),<br /> );</div></blockquote><div></div></div><br />This will cause the Garland theme to be loaded to the current page when the AHAH callback 'mybooks/js' executes. If the callback happened to add new elements into the form, then they would be rendered in Garland. Not what you would really want! You could go around in circles with your UI team over this and waste a lot of time like I did!Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-45053414644186690802010-09-29T02:17:00.002+05:302010-09-29T02:26:23.351+05:30Eclipse crashing & workspace in use?I use <a href="http://www.eclipse.org/">Eclipse</a> with PDT at work. True it may be a memory hog but I love using it now. <div><br /></div><div>I usually edit the eclipse.ini file in the eclipse/ folder and increase the memory usage of it.</div><div><br /></div><div>For e.g. for 512MB RAM, I set: </div><div><br /></div><div>-Xms256m -Xmx256m -XX:PermSize=64m -XX:MaxPermSize=64m</div><div><br /></div><div><a href="http://wiki.eclipse.org/Eclipse.ini">Here</a> are some more configurations.</div><div><br /></div><div>Another common problem is eclipse <b>crashing</b>. When you restart it, it may say that your current <b>workspace is in use</b> and you need to <b>choose another workspace</b>. </div><div><br /></div><div>This is because there is a .lock file hidden in your .metadata/ folder in your eclipse/ directory. This file is created when eclipse starts and is deleted at every proper shutdown of eclipse. So if eclipse crashed, sometimes it would not have deleted .lock file and hence it thinks there is another eclipse program running. Delete the .lock file and you are on your way.</div><div></div>Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-26824915245281151652009-10-20T21:32:00.003+05:302009-10-20T21:37:34.090+05:30Google new home page (A/B testing I think)<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioGO6Iq1KLdZQbBmSvvN2UvZi29w1RLRUMBlaijJVmV9lFTwraEXzLeBqetHpADS4-KvgRqZxzJpZ-6Sm911jcUKpvhnSdJC1fBZrgFu7kjsoXdJv-CA12GjXYdsE8iYEZDAG8/s1600-h/google-new-homepage.JPG"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 170px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioGO6Iq1KLdZQbBmSvvN2UvZi29w1RLRUMBlaijJVmV9lFTwraEXzLeBqetHpADS4-KvgRqZxzJpZ-6Sm911jcUKpvhnSdJC1fBZrgFu7kjsoXdJv-CA12GjXYdsE8iYEZDAG8/s320/google-new-homepage.JPG" alt="" id="BLOGGER_PHOTO_ID_5394714116131337874" border="0" /></a><br />I happened to hit a Google A/B testing page from UK today.<br /><br />They seem to be loading just the Google logo and the search bar first. Then once you move your mouse onto the page, the top header and footers appear. Some javascript funkiness to a simple page. ~Why?<br /><br />Also if you notice, the "Search" and "I'm feeling lucky" buttons have disappeared.<br /><br />The live search suggestions work from the search bar still.<br /><br />I'm feeling this may be one of the new Google home pages we may be seeing in the near future.Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-43963886428724008672009-03-19T23:59:00.002+05:302009-03-20T00:09:19.224+05:30Changing the scenario of global development: The great economic crisis of modern timesWill the current economic crisis just be a short circuit for the current development trends of the world, and will the same technologies and advancements continue in hoping for a quick recovery? I don't think so.<br /><br />Economic trends of money generation and consumer satisfaction are based on unforeseen habits that can quickly catch up. Like in art and architecture, they are parts of the current age. They are born, live a span of life (based on various acceptance and factors of chance) and also face death. I am analysing the impending of the current Information Technology age advancements in niche areas. True, the Internet was a revolutionary invention. People are so dependent on it. But not all its seedlings are going to be properly nourished or going to have a market in the future. The economic crisis has forced us to look inwards on the basic needs of life and sustenance.<br /><br />Humanity is going to reinvent its business-space. Looking inwards, we are going to realize the basic necessities of sustenance in Food, agriculture, and its related areas. People will be less concerned about technology except for the most widely used areas (like e-commerce). The basis of business is going to be reshaped. Organic farming is going to be the most popular choice. Service based industries will pop up their heads but will be difficult to survive for long as customers are less cash-rich.Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0tag:blogger.com,1999:blog-11989739.post-62237151243328580802009-02-26T10:59:00.002+05:302009-02-26T11:04:59.344+05:30Non iodized salt in KeralaFor Thyroid Cancer patients undergoing a Low Iodine Diet (LID), finding non-iodized salt in some regions of India, especially Kerala can be a pain. The Kerala government has imposed a state-wide ban on selling non-iodized salt.<br /><br />Those who require non-iodized salt can buy "induppu" from any ration shop or place where you buy whole sale dals, grams, rice etc. If you do not get induppu, crystal salt can also be bought. This does not contain iodine as well.Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com1tag:blogger.com,1999:blog-11989739.post-7198841366038722892008-10-07T06:29:00.003+05:302008-10-07T06:46:13.881+05:30Osama has achieved total annihilationAl Qaeda -> 9/11 -> Billions spent on Iraq War -> Trillions in debt -> Wall St. crash -> World economies follow -> Worldwide crisis -> Osama still alive.<br /><br />And thats just the way it is.Anonymoushttp://www.blogger.com/profile/02455526965145376614noreply@blogger.com0