View source
<?php
include_once 'panopoly_core.features.inc';
function panopoly_core_menu_alter(&$items) {
foreach (node_type_get_types() as $type) {
$type_url_str = str_replace('_', '-', $type->type);
$menu_item_key = 'node/add/' . $type_url_str;
if (isset($items[$menu_item_key]['title callback']) && $items[$menu_item_key]['title callback'] == 'check_plain') {
unset($items[$menu_item_key]['title callback']);
}
}
}
function panopoly_core_apps_app_info() {
return array(
'configure form' => 'panopoly_core_configure_form',
);
}
function panopoly_core_configure_form($form, &$form_state) {
$form = array();
$form['panopoly_core_breadcrumb_title'] = array(
'#title' => t('Append Page Title to Site Breadcrumb'),
'#type' => 'select',
'#required' => TRUE,
'#options' => array(
'1' => 'Enabled',
'0' => 'Disabled',
),
'#default_value' => variable_get('panopoly_core_breadcrumb_title', 1),
'#description' => t('Do you want Panopoly to append the page title to the site breadcrumb?'),
);
$form['panopoly_core_override_jquery_ui_theme'] = array(
'#title' => t('Override jQuery UI theme provided by any theme'),
'#type' => 'select',
'#required' => TRUE,
'#options' => array(
'1' => 'Enabled',
'0' => 'Disabled',
),
'#default_value' => variable_get('panopoly_core_override_jquery_ui_theme', 1),
'#description' => t('Panopoly provides a custom jQuery UI theme. If this option is disabled, it will only be used by themes that don\'t provide one of their own. However, if enabled, we\'ll override all themes.'),
);
return system_settings_form($form);
}
function panopoly_core_theme_registry_alter(&$registry) {
if (($index = array_search('panopoly_core_preprocess_page', $registry['page']['preprocess functions'])) !== FALSE) {
array_splice($registry['page']['preprocess functions'], $index, 1);
}
$registry['page']['preprocess functions'][] = 'panopoly_core_preprocess_page';
}
function panopoly_core_preprocess_html(&$variables) {
$variables['classes_array'][] = 'region-content';
}
function panopoly_core_preprocess_page(&$variables) {
if (variable_get('panopoly_core_breadcrumb_title', TRUE)) {
$breadcrumb = drupal_get_breadcrumb();
if (drupal_is_front_page()) {
$breadcrumb = array();
}
elseif (is_array($breadcrumb) && count($breadcrumb) > 0 && drupal_get_title()) {
$breadcrumb[] = drupal_get_title();
}
drupal_set_breadcrumb($breadcrumb);
}
}
function panopoly_core_apps_servers_info() {
$info = drupal_parse_info_file(drupal_get_path('module', 'panopoly_core') . '/panopoly_core.info');
return array(
'panopoly' => array(
'title' => 'Panopoly',
'description' => 'Apps for Panopoly',
'manifest' => empty($info['version']) || $info['version'] == '7.x-1.x-dev' || strpos($info['version'], '-dev') ? 'http://apps.getpantheon.com/panopoly-dev' : 'http://apps.getpantheon.com/panopoly',
),
);
}
function panopoly_core_module_implements_alter(&$implementations, $hook) {
if ($hook == 'css_alter' || $hook == 'modules_enabled') {
$group = $implementations['panopoly_core'];
unset($implementations['panopoly_core']);
$implementations['panopoly_core'] = $group;
}
}
function panopoly_core_element_info_alter(&$type) {
if (isset($type['styles']['#pre_render'])) {
array_unshift($type['styles']['#pre_render'], 'panopoly_core_pre_render_styles');
}
}
function panopoly_core_modules_enabled($modules) {
if (drupal_installation_attempted() && in_array('panopoly_core', $modules)) {
taxonomy_features_rebuild('panopoly_core');
drupal_static_reset('panelizer_entity_plugin_get_handler');
if ($editor = user_role_load_by_name('editor')) {
user_role_grant_permissions($editor->rid, array(
'administer panelizer taxonomy_term panopoly_categories breadcrumbs',
));
user_role_grant_permissions($editor->rid, array(
'administer panelizer taxonomy_term panopoly_categories content',
));
user_role_grant_permissions($editor->rid, array(
'administer panelizer taxonomy_term panopoly_categories context',
));
user_role_grant_permissions($editor->rid, array(
'administer panelizer taxonomy_term panopoly_categories defaults',
));
user_role_grant_permissions($editor->rid, array(
'administer panelizer taxonomy_term panopoly_categories layout',
));
user_role_grant_permissions($editor->rid, array(
'administer panelizer taxonomy_term panopoly_categories overview',
));
user_role_grant_permissions($editor->rid, array(
'administer panelizer taxonomy_term panopoly_categories settings',
));
}
if ($administrator = user_role_load_by_name('administrator')) {
user_role_grant_permissions($administrator->rid, array(
'administer panelizer taxonomy_term panopoly_categories breadcrumbs',
));
user_role_grant_permissions($administrator->rid, array(
'administer panelizer taxonomy_term panopoly_categories content',
));
user_role_grant_permissions($administrator->rid, array(
'administer panelizer taxonomy_term panopoly_categories context',
));
user_role_grant_permissions($administrator->rid, array(
'administer panelizer taxonomy_term panopoly_categories defaults',
));
user_role_grant_permissions($administrator->rid, array(
'administer panelizer taxonomy_term panopoly_categories layout',
));
user_role_grant_permissions($administrator->rid, array(
'administer panelizer taxonomy_term panopoly_categories overview',
));
user_role_grant_permissions($administrator->rid, array(
'administer panelizer taxonomy_term panopoly_categories settings',
));
}
}
}
function panopoly_core_css_alter() {
}
function panopoly_core_library_alter(&$libraries, $module) {
if ($module == 'system') {
if (isset($libraries['ui'])) {
if (isset($libraries['ui']['css']['misc/ui/jquery.ui.theme.css'])) {
$libraries['ui']['css']['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('module', 'panopoly_core') . '/css/panopoly-jquery-ui-theme.css';
}
if (isset($libraries['ui']['css']['misc/ui/jquery.ui.core.css'])) {
unset($libraries['ui']['css']['misc/ui/jquery.ui.core.css']);
}
}
$jquery_ui_unnecessary_css = array(
'ui.button',
'ui.resizable',
'ui.selectable',
'ui.dialog',
'ui.tabs',
);
foreach ($jquery_ui_unnecessary_css as $name) {
if (isset($libraries[$name])) {
if (isset($libraries[$name]['css'])) {
unset($libraries[$name]['css']);
}
}
}
}
}
function panopoly_core_pre_render_styles($elements) {
$css =& $elements['#items'];
if (!isset($css['misc/ui/jquery.ui.theme.css'])) {
return $elements;
}
$seven_theme = drupal_get_path('theme', 'seven') . '/jquery.ui.theme.css';
if ($css['misc/ui/jquery.ui.theme.css']['data'] === $seven_theme || variable_get('panopoly_core_override_jquery_ui_theme', 1)) {
$css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('module', 'panopoly_core') . '/css/panopoly-jquery-ui-theme.css';
}
return $elements;
}
function panopoly_core_date_format_types() {
return array(
'panopoly_time' => t('Time'),
'panopoly_day' => t('Day'),
);
}
function panopoly_core_date_formats() {
$formats = array();
$formats[] = array(
'type' => 'panopoly_time',
'format' => 'g:ia',
'locales' => array(),
);
$formats[] = array(
'type' => 'panopoly_day',
'format' => 'F j, Y',
'locales' => array(),
);
return $formats;
}
function panopoly_core_view_mode_options() {
$entity_info = entity_get_info('node');
$options = array();
if (!empty($entity_info['view modes'])) {
foreach ($entity_info['view modes'] as $mode => $settings) {
if (!in_array($mode, array(
'rss',
'search_index',
'search_result',
'token',
))) {
$options[$mode] = $settings['label'];
}
}
}
return $options;
}
function _panopoly_core_import_demo_content($classes = array()) {
migrate_get_module_apis(TRUE);
foreach ($classes as $class) {
Migration::registerMigration($class);
$migration = Migration::getInstance($class);
Migration::setDisplayFunction('_panopoly_core_null_message');
$migration
->processImport();
}
}
function _panopoly_core_rollback_demo_content($classes = array()) {
foreach ($classes as $class) {
$migration = Migration::getInstance($class);
Migration::setDisplayFunction('_panopoly_core_null_message');
$migration
->processRollback();
Migration::deregisterMigration($class);
}
}
function _panopoly_core_null_message($message, $level) {
return;
}