You are here

function joomla_block in Joomla to Drupal 7

Same name and namespace in other branches
  1. 6 joomla.module \joomla_block()

Implementation of hook_block().

File

./joomla.module, line 1093
The joomla module used for migrate Joomla to Drupal.

Code

function joomla_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $blocks = array(
        array(
          'info' => t('Joomla Backlinks'),
        ),
      );
      return $blocks;
      break;
    case 'view':

      // only show this block on node/* pages
      if ($node = menu_get_object()) {
        $joomla_live_url = variable_get('joomla_live_url', JOOMLA_LIVE_URL);

        // only show links if the base URL has been set
        if ($joomla_live_url) {
          $ids = db_query('SELECT nid, jcontentid FROM {joomla_content} WHERE nid = :nid', array(
            ':nid' => $node->nid,
          ))
            ->fetch();
          if (!$ids) {
            return;
          }
          $blocks['subject'] = t('Link Back to Joomla');
          $blocks['content'] = sprintf("<a href='http://%s/index.php?option=com_content&task=view&id=%d&Itemid=1'>View this node in Joomla</a>", $joomla_live_url, $ids->jcontentid);
          return $blocks;
        }
        else {
          $blocks['subject'] = t('Links Disabled');
          $blocks['content'] = t('You have not set your Joomla Live URL. ') . l("Settings", "admin/settings/joomla");
          return $blocks;
        }
      }
      return;
      break;
  }
}