Developers, Developers, Developers! Maksim Sorokin IT Blog

5Feb/120

Drupal 7 Views — Collapsible Grouping Field

The idea for this solution was stolen somewhere from Drupal forums (cannot find the link now) and combined with this post.

1. Go to the edit page of the view
2. Click Advanced
3. Click Theme: Information
4. In the new window choose "Style output"
5. Copy the appeared code into new file "views-view-table.tpl.php".
6. Edit this new file. Add something like this (take a look onto highlighted lines):

<?php
/**
 * @file views-view-table.tpl.php
 * Template to display a view as a table.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $header: An array of header labels keyed by field id.
 * - $header_classes: An array of header classes keyed by field id.
 * - $fields: An array of CSS IDs to use for each field id.
 * - $classes: A class or classes to apply to the table, based on settings.
 * - $row_classes: An array of classes to apply to each row, indexed by row
 *   number. This matches the index in $rows.
 * - $rows: An array of row items. Each row is an array of content.
 *   $rows are keyed by row number, fields within rows are keyed by field ID.
 * - $field_classes: An array of classes to apply to each field, indexed by
 *   field id, then row number. This matches the index in $rows.
 * @ingroup views_templates
 */
?>

<?php drupal_add_js('misc/form.js'); ?>
<?php drupal_add_js('misc/collapse.js'); ?>

<fieldset class="collapsible collapsed">
  <legend><span class="fieldset-legend"><?php if (!empty($title)) : ?><?php print $title; ?><?php endif; ?></span></legend>
<div class="fieldset-wrapper">

<table <?php if ($classes) { print 'class="'. $classes . '" '; } ?><?php print $attributes; ?>>
  <thead>
    <tr>
      <?php foreach ($header as $field => $label): ?>
        <th <?php if ($header_classes[$field]) { print 'class="'. $header_classes[$field] . '" '; } ?>>
          <?php print $label; ?>
        </th>
      <?php endforeach; ?>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($rows as $row_count => $row): ?>
      <tr class="<?php print implode(' ', $row_classes[$row_count]); ?>">
        <?php foreach ($row as $field => $content): ?>
          <td <?php if ($field_classes[$field][$row_count]) { print 'class="'. $field_classes[$field][$row_count] . '" '; } ?><?php print drupal_attributes($field_attributes[$field][$row_count]); ?>>
            <?php print $content; ?>
          </td>
        <?php endforeach; ?>
      </tr>
    <?php endforeach; ?>
  </tbody>
</table>

</div>

</fieldset>

7. Save the file
8. Copy the file to the "templates" folder of the theme.

6Jan/120

[PACKT] JBoss AS 7 Configuration, Deployment and Administration

I have just been contacted from PACKT to review a book JBoss AS 7 Configuration, Deployment and Administration book. I agreed immediately, since PACKT releases quite good and qualitative stuff.

In two words, as the title says, the JBoss AS 7 book deals with administration topics, new and advanced features of the JBoss Application Server 7. It seems like it is a must-have book for everyone using or looking forward to migrate/update to JBoss AS 7.

16Dec/110

Some Resources on Social Engineering

I have recently been to social engineering lecture by some security specialist. The presentation was ok. There were no surprises as I was interested in social engineering some time ago. However, there were some useful resources and and tools mentioned, which I want to list here:

22Nov/110

Berlin — Google Developer Day 2011

Very well organized event. It was a good chance to talk to Google people and other developers that are interested in latest technologies from Google.

However, some talks were more like common-sense and did not gave much new insights. Some talks were in how-to fashion. Furthermore, some presenters were somewhat unprepared and boring. Talks about html5 were very tight to Google products and are not that well supported by other vendors. Several talks were done by Berlin universities people. Those were somewhat boring and abstract.

Anyhow, here are some photos:


4Oct/110

Java SE 7 Certificates Are Almost Out!

Check the Oracle certification page. Java SE 7 certificates are now in beta (programmer certificate is not available yet, however). The price is 50$, instead of ordinary 300$. However, it has twice more questions and is twice longer.

18Sep/110

Maven + Apache Felix + CXF + DOSGi: An Example of DOSGi Service

Link in series

Link to two Felix instances

Here is yet another post in Maven + Apache Felix + CXF + DOSGi series.

Here I will show how to use Apache CXF DOSGi for cosuming remote services. You may see the sources on my GitHub account.

We will have

11Aug/110

Apache Felix: Running Two Instances of Felix Launcher in The Eclipse

This is a next post in Maven + Apache Felix + CXF + DOSGi series.

As was shown in the first post, one my have a separate project for Apache Felix in conveniently launch it using Eclipse.

You need to have two instance of Apache Felix running in the same Eclipse, for example if you are testing DOSGi remote services between different OSGi instances.

First, you will need to have two Apache Felix configurations. The first one can be default: conf\config.properties:

felix.auto.deploy.action=install,start
felix.log.level=1

org.osgi.framework.storage.clean=onFirstInit

felix.auto.start.1 = ...

Then you need to have second one for the second instance. Let's create it here: conf\secondConfig.properties:

felix.auto.deploy.action=install,start
felix.log.level=1

org.osgi.framework.storage.clean=onFirstInit

org.osgi.service.http.port=8081
org.osgi.framework.storage=secondCache

felix.auto.start.1= ...

Note org.osgi.service.http.port and org.osgi.framework.storage. Former is needed to tell OSGi to use different http port. The latter one specifies different cache for OSGi bundle (by default it is felix-cache), which is used to contain all started bundles.

Then the start configuration is the same as was described in the first post. For the second configuration one has to provide a location of conf\secondConfig.properties. In "VM arguments" specify:

-Dfelix.config.properties=file:conf/secondConfig.properties
9Aug/110

Maven + Apache Felix: Strategy to Handle non-OSGi Dependencies

This is another post in Maven + Apache Felix + CXF + DOSGi series.

Sometimes in the project plain Maven dependencies has to be used. A simple strategy to use those in OSGi project handled by Maven is to have a separate module, containing all non-OSGi dependencies and converting those to OSGi bundles using Apache Felix Maven Bundle Plugin.
So one may have the following structure of the project:

project
    ...
    project.nonOsgiDependencies
        project.nonOsgiDependencies.base64
        project.nonOsgiDependencies.mysqlConnector
        project.nonOsgiDependencies.xercesImpl

This nonOsgiDependencies projects would contain

6Aug/110

Maven + Apache Felix + CXF: Securing a Service with HTTP Basic Authentication

This is another post in series Maven + Apache Felix + CXF + DOSGi Series. Here I will describe how to secure CXF published web services with HTTP basic authentication. You can find the sources on my GitHub account.

We will have three projects here. The first one defines an interface for a service. Another one provides implementation for it. And the third one will provide security.

dosgiSecurity
    dosgiSecurity-api
    dosgiSecurity-impl
    dosgiSecurity-security

dosgiSecurity will be just a holder project.

Our interface HelloService in bundle dosgiSecurity-api will be similar to the one we defined in

2Aug/110

Maven + Apache Felix + CXF: RESTful Webservice with CXF. Using POST.

It is another post in Maven + Apache Felix + CXF + DOSGi Series.

In this post I showed you how to create a RESTful webservice consuming and creating a String. However, the example was using @GET method. Here I will show, what changes need to be done in order to consume input from @POST. As usual, sources are available in the end of the post.

Simply change @GET to @POST and remove