<?php
/**
 * @file
 * Responsive panels layouts for Panopoly.
 */

/**
 * Implements hook_ctools_plugin_directory().
 */
function radix_layouts_ctools_plugin_directory($module, $plugin) {
  return 'plugins/' . $plugin;
}

/**
 * Implements hook_ctools_plugin_post_alter().
 *
 * @param $plugin
 * @param $info
 */
function radix_layouts_ctools_plugin_post_alter(&$plugin, &$info) {
  // Switch Panopoly Layouts to Radix Layouts.
  if ($info['type'] == 'layouts' && $plugin['module'] == 'panopoly_theme') {
    if (strpos($plugin['theme'], 'radix_') === FALSE) {
      $new_name = 'radix_' . $plugin['theme'];
      $path = drupal_get_path('module', 'radix_layouts') . '/plugins/layouts/' . $new_name;
      if (file_exists($path)) {
        $plugin['theme'] = $new_name;
        $plugin['file'] = 'radix_' . $plugin['file'];
        $plugin['path'] = $path;
        $plugin['icon'] = 'radix-' . $plugin['icon'];
        unset($plugin['css']);
      }
    }
  }
}