Пример #1
1
/**
 * Provide expansion arguments for dynamic menu items, i.e. menu paths
 * containing one or more %placeholders.
 *
 * The map items must be keyed by the dynamic path to expand. Each map item may
 * have the following properties:
 *
 * - parent: The parent menu path to link the expanded items to.
 * - arguments: An array of argument sets that will be used in the
 *   expansion. Each set consists of an array of one or more placeholders with
 *   an array of possible expansions as value. Upon expansion, each argument
 *   is combined with every other argument from the set (ie., the cartesian
 *   product of all arguments is created). The expansion values may be empty,
 *   that is, you don't need to insert logic to skip map items for which no
 *   values exist, since admin menu will take care of that.
 * - hide: (optional) Used to hide another menu item, usually a superfluous
 *   "List" item.
 *
 * @see admin_menu.map.inc
 */
function hook_admin_menu_map()
{
    // Expand content types in Structure >> Content types.
    // The key denotes the dynamic path to expand to multiple menu items.
    $map['admin/structure/types/manage/%node_type'] = array('parent' => 'admin/structure/types', 'hide' => 'admin/structure/types/list', 'arguments' => array(array('%node_type' => array_keys(node_type_get_types()))));
    return $map;
}
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $results = $_POST;
     $form['method'] = array('#type' => 'hidden', '#value' => $results['method']);
     if (!isset($results['reset'])) {
         $results['reset'] = 0;
     }
     $form['all'] = array('#type' => 'hidden', '#value' => $results['all']);
     if (isset($results['all'])) {
         // Only carry reset value through if delete all nodes is set
         $form['reset'] = array('#type' => 'hidden', '#value' => $results['reset']);
         $form['all_warning'] = array('#markup' => '<p>' . $this->t('All content in all content types will be deleted. Be sure to have a backup of any important data!') . '</p>');
         if (!empty($results['reset'])) {
             if ($results['all']) {
                 $form['all_reset'] = array('#markup' => '<p>' . $this->t('Node, revision and comment counts will be reset.') . '</p>');
             }
         }
     } elseif (isset($results['types'])) {
         if (is_array($results['types'])) {
             foreach ($results['types'] as $key_type => $type) {
                 /**
                  * @TODO, if we use the form array the value doesn't exist in the submit
                  */
                 $_SESSION['nodes_type'][$key_type] = $type;
                 $info = node_type_get_types('type', $type);
                 $info = $info[$type];
                 $form[$type . '_warning'] = array('#markup' => '<p>' . $this->t('All content in the %type content type will be deleted. Be sure to have a backup of any important data!', array('%type' => $info->get('name'))) . '</p>');
             }
         }
         if ($results['reset']) {
             $form['all_reset'] = array('#markup' => '<p>' . $this->t('Sorry, we can\'t reset the counters because you are not deleting all nodes.') . '</p>');
         }
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * Generate a settings form for this handler.
  */
 public function settingsForm($field, $instance)
 {
     #    echo '<pre>';
     #    print_r($instance);
     #    echo '</pre>';
     #    die;
     $options = array();
     if (!empty($field['settings']['handler_settings']['target_bundles'])) {
         $target_bundles = $field['settings']['handler_settings']['target_bundles'];
     } else {
         // By default, entity reference assumes that all bundles are enabled.
         $target_bundles = array_keys(node_type_get_types());
     }
     foreach ($target_bundles as $content_type) {
         $options[$content_type] = t(node_type_get_name($content_type));
     }
     $default_options = array();
     if (isset($instance['settings']['behaviors']['node_links'])) {
         foreach ($instance['settings']['behaviors']['node_links']['content_types'] as $content_type) {
             if ($content_type) {
                 $default_options[] = $content_type;
             }
         }
     }
     $form['content_types'] = array('#type' => 'checkboxes', '#title' => t('Content Types'), '#options' => $options, '#default_value' => $default_options, '#description' => t('Select the content types that will have create links for this type.'));
     return $form;
 }
 /**
  * Override Migration::prepare().
  *
  * Set the term parent for heirarchical terms
  *
  * @param $term
  * @param $row
  */
 public function prepare($term, $row)
 {
     // Handle og_vocab
     $vocab_name = $this->bundle;
     if (!($vocabulary = taxonomy_vocabulary_machine_name_load($vocab_name))) {
         // Create a new vocabulary
         $vocabulary = (object) array('name' => 'Meter categories for ' . $row->account_id, 'description' => 'Meter categories for ' . $row->account_id, 'machine_name' => $vocab_name);
         taxonomy_vocabulary_save($vocabulary);
     }
     // Create an OG-vocab and relate new vocabulary with OG.
     $account_id = $term->account_id['destid1'];
     $settings = array('cardinality' => 1, 'required' => TRUE);
     // Loop for all meter content-types and create og-vocabulary.
     $node_types = node_type_get_types();
     foreach ($node_types as $content_type) {
         if (strpos($content_type->type, '_meter') === FALSE) {
             // Not a meter type, skip.
             continue;
         }
         $og_vocab = og_vocab_create_og_vocab($vocabulary->vid, 'node', $content_type->type, OG_VOCAB_FIELD, $settings);
         $og_vocab->save();
     }
     og_vocab_relation_save($vocabulary->vid, 'node', $account_id);
     // Save vocabulary id.
     $term->vid = $vocabulary->vid;
     // Handle parent.
     $term->name = ucwords(trim($term->name));
     $parent = ucwords(trim($row->parent));
     $parent_term = taxonomy_get_term_by_name($parent, $vocab_name);
     $parent_term = reset($parent_term);
     if ($parent_term) {
         $term->parent = $parent_term->tid;
     }
 }
Пример #5
0
/**
 *  Получаем список NODE_TYPE
 * modules/node/node.module
 * @link https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_info/7 description param
 * @link https://www.drupal.org/node/1027630 info
 */
function dxray_get_node_type()
{
    $GML = new GraphML();
    $optN1 = $GML->setOptionsNode()->Fill_setColor('#ccffff')->Label_setFontSize('22')->getOptions();
    $aNtypes = node_type_get_types();
    foreach ($aNtypes as $oType) {
        // 1. Сначала создаем узел NODE_TYPE
        $data['attributes'] = array('Base: ' . $oType->base, 'Type: ' . $oType->type, 'Help: ' . PHP_EOL . $oType->help . PHP_EOL, 'Custom: ' . $oType->custom, 'Modified: ' . $oType->modified, 'Locked: ' . $oType->locked, 'Disabled: ' . $oType->disabled, 'Is new: ' . $oType->is_new, 'Has title: ' . $oType->has_title, 'Title label: ' . $oType->title_label, 'Module: ' . $oType->module);
        $options['NodeFill']['color'] = '#ccffff';
        $ID_bundle = $GML->addNode($oType->name, 'UMLClassNode', $optN1, $data);
        dxray_debug_stdout('Добавили bundle номер: ' . $ID_bundle);
        // 2. Получаем поля данного контента и строем зависимости
        $fields = field_info_instances('node', $oType->type);
        foreach ($fields as $field) {
            $finfo = field_info_field($field['field_name']);
            $data['attributes'] = array('Label: ' . $field['label'], 'Required: ' . $field['required'], 'Module: ' . $finfo['module'], 'Locked: ' . $finfo['locked'], 'Cardinality: ' . $finfo['cardinality'], 'Description: ' . $field['description']);
            $dataHTML['attributes'] = array('<html>', 'Label: ' . $field['label'] . '<br>', 'Required: ' . $field['required'] . '<br>', '<b>Module:</b> ' . $finfo['module'] . '<br>', 'Locked: ' . $finfo['locked'] . '<br>', 'Cardinality: ' . $finfo['cardinality'] . '<br>', 'Description: ' . $field['description'] . '<br>', '</html>');
            $ID_field = $GML->addNode($field['field_name'], 'UMLClassNode', null, $dataHTML);
            dxray_debug_stdout('Добавили field номер: ' . $ID_field);
            dxray_debug_stdout("{EDGE} SRC: {$ID_bundle} TARGET: {$ID_field} " . $ID_field);
            $GML->addEdge($ID_bundle, $ID_field);
        }
    }
    $file = DXRAY_OUTPATH . '/NodeType-' . date('d-m-Y_H-i-s') . '.graphml';
    $GML->createFullGraphML($file);
    $dbg = 0;
}
Пример #6
0
 /**
  * {@inheritdoc}
  */
 function describe($api)
 {
     // We will have a separate rule per node type on Admin > Structure > Crumbs.
     foreach (node_type_get_types() as $type_name => $type) {
         $api->addRule($type_name, $type->name);
     }
 }
Пример #7
0
/**
 * Alter "pseudo-field" components on fieldable entities.
 *
 * @param $info
 *   The associative array of 'pseudo-field' components.
 *
 * @see hook_field_extra_fields()
 */
function hook_field_extra_fields_alter(&$info) {
  // Force node title to always be at the top of the list by default.
  foreach (node_type_get_types() as $bundle) {
    if (isset($info['node'][$bundle]['title'])) {
      $info['node'][$bundle]['title']['weight'] = -20;
    }
  }
}
 /**
  * Add the types to the form. If there are no eligible types to delete,
  * we don't need to render the form.
  */
 protected function getContentTypes()
 {
     foreach (node_type_get_types() as $type => $info) {
         if (array_key_exists($type, $this->count)) {
             $this->types[$type] = $info->get('name') . ' (' . $this->count[$type] . ')';
         }
     }
 }
Пример #9
0
/**
 * Declare this module's structured permissions.
 *
 * A set of structured permissions is defined as a list of objects and a list
 * of verbs. The permissions are created by combining these. For example, the
 * list of node types and the verbs (create, edit, delete) form a grid of
 * permissions for operations on all the node types.
 *
 * This hook may be placed in the file MODULE.permissions.inc.
 *
 * @return
 *  An array of data for object types that have multiple permissions associated
 *  with them. The array keys are object machine names, eg, 'node' (though note
 *  these need not be entities).
 *  Values are arrays with the following properties:
 *    - 'label': The human-readable label of the object type.
 *    - 'objects': An array of the different objects of this type that have
 *      their own permissions, for example, node types, which each provide
 *      permissions such as 'create foo node types'. These will form the rows 
 *      of the permissions grid. The keys are the substrings of the permission
 *      strings, and the values are human-readable labels.
 *    - 'verb_groups': An array of one or more verb groups. Each verb group
 *      defines a list of verbs and a pattern for the permissions using those
 *      verbs. The verb groups keys are arbitrary (but using the name of the
 *      providing module is a good idea for ease of alterability), and each
 *      array has the following properties:
 *      - 'verbs': An array of verbs. The keys are the 'machine names', that is,
 *        the strings that are replaced into the pattern. The values may be
 *        human-readable labels. Note that verb machine names must be unique
 *        across all the verb groups for the object type.
 *      - 'pattern': The pattern of the permissions machine name, with the
 *        following replacements:
 *        - '%verb': The verb of the permission. This takes all the keys in the
 *          verbs array in this verb group.
 *        - '%object': The object of the permission. This takes all the keys in
 *          the objects array.
 *      - 'object_process_callback' (optional) A function to process the object
 *        name before replacing it into the pattern. (This is just a hack for
 *        taxonomy to work.) 
 */
function hook_permission_grid_info()
{
    $return = array('node' => array('label' => t('Content type'), 'objects' => array(), 'verb_groups' => array('node' => array('pattern' => '%verb %object content', 'verbs' => array('create' => t('Create'), 'edit own' => t('Edit own'), 'edit any' => t('Edit any'), 'delete own' => t('Delete own'), 'delete any' => t('Delete any'))))));
    $node_types = node_type_get_types();
    $configured_types = node_permissions_get_configured_types();
    foreach ($configured_types as $type) {
        $return['node']['objects'][$type] = $node_types[$type]->name;
    }
    return $return;
}
Пример #10
0
 function getContentTypes()
 {
     $types = array();
     $node = node_type_get_types();
     $node_types = new NodeTypes();
     foreach ($node as $key => $value) {
         $node_types->loadNode($value);
         $types[$key] = $node_types->getName();
     }
     return $types;
 }
Пример #11
0
/**
 * Preprocessor for theme_node().
 */
function eldir_preprocess_node(&$variables, $hook)
{
    if (!empty($variables['node'])) {
        // Add a node type label on node pages to help users.
        $types = node_type_get_types();
        $type = $variables['node']->type;
        if (!empty($types[$type])) {
            $variables['title'] = "<span class='label'>{$types[$type]->name}</span>" . $variables['title'];
        }
    }
}
 /**
  * @Given /^"([^"]*)" Content Type exists$/
  */
 public function ContentTypeExists($type)
 {
     $types = node_type_get_types();
     foreach ($types as $contentType) {
         if ($contentType->name == $type) {
             $this->contentType = $contentType;
             break;
         }
     }
     assertNotEmpty($this->contentType);
 }
 /** 
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('questions.settings');
     //echo "<pre>";
     // print_r(node_type_get_types());
     // exit;
     foreach (node_type_get_types() as $key => $value) {
         $options[$key] = $value->label();
     }
     $form['qus_content_type'] = array('#type' => 'select', '#default_value' => array($config->get('content_type')), '#options' => $options, '#title' => $this->t('Select content type'));
     return parent::buildForm($form, $form_state);
 }
Пример #14
0
 /**
  * @param string $title
  *   Inaccurate title of a node.
  * @param string $contentType
  *   Content type. Could be a title of content type.
  *
  * @return int
  *
  * @throws \InvalidArgumentException
  */
 public function getIdByArguments($title, $contentType = '')
 {
     $nid = new FetchField('node', 'nid');
     $nid->condition('title', "{$title}%", 'like');
     // Try to recognize node type by its title if content type specified and does not exist.
     if ('' !== $contentType && !isset(node_type_get_types()[$contentType])) {
         $contentType = (new FetchField('node_type', 'type'))->condition('name', $contentType)->execute();
         if ('' === $contentType) {
             throw new \InvalidArgumentException('Content type with such name does not exist!');
         }
         $nid->condition('type', $contentType);
     }
     return $nid->execute();
 }
 protected function setUp()
 {
     parent::setUp();
     // Create an article content type only if it does not yet exist, so that
     // child classes may specify the standard profile.
     $types = node_type_get_types();
     if (empty($types['article'])) {
         $this->drupalCreateContentType(array('type' => 'article', 'name' => t('Article')));
     }
     // Create two test users.
     $this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer comment types', 'administer comment fields', 'administer comment display', 'skip comment approval', 'post comments', 'access comments', 'access content'));
     $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content', 'edit own comments', 'skip comment approval', 'access content'));
     // Create comment field on article.
     $this->container->get('comment.manager')->addDefaultField('node', 'article');
     // Create a test node authored by the web user.
     $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->id()));
 }
Пример #16
0
function action_list()
{
    $header = array(t('Content Type'), t('Paths'), t('Operations'));
    $rows = array();
    $content_types = node_type_get_types();
    foreach (publisher_purge_get_all_content_type_paths() as $content_type => $paths) {
        $content_type_info = $content_types[$content_type];
        $row = array();
        $row[] = $content_type_info->name;
        if (empty($paths)) {
            $row[] = '<em>No Paths</em>';
        } else {
            $row[] = theme('item_list', array('items' => array_map('check_plain', $paths)));
        }
        $row[] = theme('links', array('links' => array(array('title' => 'Edit Paths', 'href' => 'admin/config/publisher/purge/' . $content_type)), 'attributes' => array('class' => array('links', 'inline'))));
        $rows[] = $row;
    }
    return theme('table', array('rows' => $rows, 'header' => $header));
}
Пример #17
0
 /**
  * {@inheritdoc}
  *
  * @todo, displays last backup timestamp
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $options = array();
     // Get list of content type.
     $types = node_type_get_types();
     ksort($types);
     foreach ($types as $key => $values) {
         $query = \Drupal::entityQuery('node')->condition('type', $key)->count();
         $count = $query->execute();
         if ($count > 0) {
             $options[$key] = $values->get('name') . " ({$count})";
         }
     }
     if (empty($options)) {
         $form['default_msg'] = array('#type' => 'item', '#markup' => t('Node not available.'));
     } else {
         $form['types'] = array('#type' => 'checkboxes', '#title' => $this->t('Content types for deletion'), '#options' => $options, '#description' => t('All nodes of these types will be deleted using the batch API.'));
         $form['actions']['#type'] = 'actions';
         $form['submit'] = array('#type' => 'submit', '#value' => $this->t('Delete'), '#button_type' => 'primary');
     }
     return $form;
 }
Пример #18
0
/**
 * Implements hook_form_system_theme_settings_alter().
 */
function sociale_platforme_form_system_theme_settings_alter(&$form, $form_state)
{
    // Hide advanced theme settings
    // $form["theme_settings"]['#access'] = FALSE;
    // $form["alpha_settings"]['#access'] = FALSE;.
    // The following CT should always be active.
    $types_default = array("group", "post", "notice");
    // Content Types.
    $types = node_type_get_types();
    $types_list = array();
    foreach ($types as $key => $val) {
        if (!in_array($key, $types_default)) {
            $types_list[$key] = $val->name;
        }
    }
    // Settings Form.
    $form['general'] = array('#title' => t('Site information'), '#type' => 'fieldset', '#collapsible' => TRUE);
    $form['general']['site_name'] = array('#type' => 'textfield', '#title' => t('Site name'), '#required' => TRUE, '#default_value' => variable_get('site_name'));
    $form['general']['site_mail'] = array('#type' => 'textfield', '#title' => t('Email address'), '#description' => 'Fra-adressen i automatiske beskeder som sendes ved oprettelse af brugere samt udsendelse af nye adgangskoder og andre beskeder. (Brug en adresse på sitets domæne for at undgå at beskeder fra adressen bliver markeret som spam.)', '#required' => TRUE, '#default_value' => variable_get('site_mail'));
    $form['types'] = array('#title' => 'Indholdstyper', '#type' => 'fieldset');
    $form['types']['sp_content_types'] = array('#type' => 'checkboxes', '#title' => t('Content types'), '#options' => $types_list, '#default_value' => theme_get_setting('sp_content_types'), '#description' => 'Vælg hvilke indholdstyper der skal være aktive på websitet.');
    $form['#process'][] = 'sociale_platforme_make_collapsible';
    $form['#submit'][] = 'sociale_platforme_settings_form_submit';
}
Пример #19
0
/**
 * Implements hook_form_alter().
 */
function ec_resp_form_alter(&$form, &$form_state, $form_id)
{
    switch ($form_id) {
        case 'nexteuropa_europa_search_search_form':
            if (theme_get_setting('enable_interinstitutional_theme')) {
                $form['search_input_group']['europa_search_submit']['#type'] = 'image_button';
                $form['search_input_group']['europa_search_submit']['#src'] = drupal_get_path('theme', 'ec_resp') . '/images/search-button.gif';
                $form['search_input_group']['europa_search_submit']['#attributes']['class'] = array_merge($form['search_input_group']['europa_search_submit']['#attributes']['class'], array('btn', 'btn-default'));
                $form['search_input_group']['europa_search_submit']['#attributes']['alt'] = t('Search');
            }
            break;
        case 'search_block_form':
            $form['search_block_form']['#attributes']['placeholder'][] = t('Search');
            $form['actions']['submit']['#type'] = 'image_button';
            if (theme_get_setting('enable_interinstitutional_theme')) {
                $form['actions']['submit']['#src'] = drupal_get_path('theme', 'ec_resp') . '/images/search-button.gif';
            } else {
                $form['actions']['submit']['#src'] = drupal_get_path('theme', 'ec_resp') . '/images/search-button.png';
            }
            $form['actions']['submit']['#attributes']['class'][] = 'btn btn-default btn-small';
            $form['actions']['submit']['#attributes']['alt'] = t('Search');
            break;
        case 'apachesolr_search_custom_page_search_form':
        case 'search_form':
            $form['basic']['#attributes']['class'][] = 'input-group';
            $form['basic']['keys']['#title'] = '';
            $form['basic']['keys']['#attributes']['placeholder'][] = t('Search');
            $form['basic']['submit']['#type'] = 'image_button';
            $form['basic']['submit']['#src'] = drupal_get_path('theme', 'ec_resp') . '/images/search-button.png';
            $form['basic']['submit']['#attributes']['class'][] = 'btn btn-default btn-small';
            break;
        case 'add_media_form':
            $form['submit']['#attributes']['class'][] = 'btn btn-default';
            break;
        case 'comment_admin_overview':
            $form['options']['submit']['#attributes']['class'][] = 'btn-small';
            $form['comments']['#prefix'] = '<div class="table-responsive">';
            $form['comments']['#suffix'] = '</div>';
            break;
        case 'views_exposed_form':
            if (isset($form['submit'])) {
                $form['submit']['#attributes']['class'][] = 'btn-small';
            }
            break;
        case 'feature_set_admin_form':
            if (isset($form['submit']) && $form['submit']['#type'] == "submit") {
                $form['submit']['#value'] = t('Validate');
                $form['submit']['#attributes']['class'][] = 'btn';
                $form['submit']['#attributes']['class'][] = 'btn-lg';
                $form['submit']['#attributes']['class'][] = 'btn-success';
            }
            break;
        default:
            break;
    }
    $content_types = node_type_get_types();
    foreach ($content_types as $content_type) {
        if ($form_id === $content_type->type . "_node_form") {
            $form['actions']['submit']['#attributes']['class'][] = 'btn btn-default';
            $form['actions']['preview']['#attributes']['class'][] = 'btn btn-default';
        }
    }
    // Hide format field.
    if (!user_access('administer nodes')) {
        $form['#after_build'][] = 'ec_resp_after_build';
    }
}
Пример #20
0
 /**
  * Given an entity object, expand any property fields to the expected structure.
  */
 protected function expandEntityProperties(\stdClass $entity)
 {
     // The created field may come in as a readable date, rather than a timestamp.
     if (isset($entity->created) && !is_numeric($entity->created)) {
         $entity->created = strtotime($entity->created);
     }
     // Map human-readable node types to machine node types.
     $types = \node_type_get_types();
     foreach ($types as $type) {
         if ($entity->type == $type->name) {
             $entity->type = $type->type;
             continue;
         }
     }
 }
function brafton_admin_form($form, &$form_state)
{
    $module_list = system_list('module_enabled');
    //debug($module_list);
    //Check if the importer should have run and it didn't
    $cron_time = variable_get('cron_safe_threshold');
    $cron_last = variable_get('cron_last');
    $current_time = time();
    $diff = $current_time - $cron_last;
    //if more time has passed than should have
    if ($diff > $cron_time) {
        drupal_set_message(t('It appears that your importer may have failed to run when is was scheduled.  A report has been sent to your CMS to ensure Delivery of content.'), 'warning');
        //$errors = new BraftonErrorReport(variable_get('brafton_api_key'), variable_get( 'brafton_api_root' ), (bool)variable_get('brafton_debug_mode') );
    }
    if (isset($_GET['b_error']) && $_GET['b_error'] == 'vital') {
        drupal_set_message(t('There was a fatal error when running the importer.  Please contact Tech support'), 'error');
    }
    $name = basename('brafton.module', '.module');
    /* This would be section to add new css rules for our admin page */
    drupal_add_css(drupal_get_path('module', $name) . '/brafton-admin.css', array('group' => CSS_THEME, 'type' => 'file'));
    $form = array();
    $types = node_type_get_types();
    $type_list = array();
    foreach ($types as $obj) {
        $type_list[] = array('name' => $obj->name, 'type' => $obj->type);
    }
    //Gets the users as an array for the author dropdown
    $results = db_query("SELECT uid, name FROM {users} WHERE status=1");
    $user_array = $results->fetchAllKeyed();
    //Add option for getting dynamic author.
    //0 is also the id for anonymous author as a fall back if no author is set in the feed
    $user_array[0] = 'Get Author from Article';
    //Renders the admin form using the Drupal forms API.
    /*
     *************************************************************************************
     * General Options
     *************************************************************************************
     */
    global $base_url;
    $form['brafton_general_options'] = array('#type' => 'fieldset', '#title' => 'General Options', '#collapsible' => true, '#collapsed' => true, '#description' => 'If you need help setting up your importer view our pdf Instructions <a href="' . $base_url . '/' . drupal_get_path('module', $name) . '/README.MD" target="_blank">Here</a>');
    $form['brafton_general_options']['brafton_feed_type'] = array('#type' => 'select', '#title' => t('Type of Content'), '#description' => t('The type(s) of content you are importing.'), '#options' => array('articles' => 'Articles', 'videos' => 'Videos', 'both' => 'Both'), '#default_value' => variable_get('brafton_feed_type', 'articles'), '#prefix' => '<h2>Choose Content Types</h2>');
    $form['brafton_general_options']['brafton_api_root'] = array('#type' => 'select', '#title' => t('API Root'), '#description' => t('The root domain of your Api key (i.e, api.brafton.com).'), '#options' => array('api.brafton.com' => 'Brafton', 'api.contentlead.com' => 'ContentLEAD', 'api.castleford.com.au' => 'Castleford'), '#default_value' => variable_get('brafton_api_root', 'api.brafton.com'));
    $form['brafton_general_options']['brafton_author'] = array('#type' => 'select', '#title' => t('Content Author'), '#description' => t('The author of the content.'), '#options' => $user_array, '#default_value' => variable_get('brafton_author', 1), '#prefix' => '<h2>Import Options</h2>');
    $form['brafton_general_options']['brafton_import_date'] = array('#type' => 'select', '#title' => t('Import Date'), '#description' => t('The date that the content is marked as having been published.'), '#options' => array('published' => 'Published Date', 'created' => 'Created Date', 'lastmodified' => 'Last Modified Date'), '#default_value' => variable_get('brafton_import_date', 'published'));
    $form['brafton_general_options']['brafton_comments'] = array('#type' => 'select', '#title' => t('Enable Comments?'), '#description' => t('Enable, Hide, or Disable Comments'), '#options' => array(0 => 'Disabled', 1 => 'Hidden', 2 => 'Enabled'), '#default_value' => variable_get('brafton_comments', 0));
    $form['brafton_general_options']['brafton_overwrite'] = array('#type' => 'checkbox', '#title' => t('Overwrite any changes made to existing content.'), '#default_value' => variable_get('brafton_overwrite', 0));
    $form['brafton_general_options']['brafton_published'] = array('#type' => 'checkbox', '#title' => t('Import Content as unpublished.'), '#default_value' => variable_get('brafton_published', 0));
    /*
     *************************************************************************************
     * Article Options
     *************************************************************************************
     */
    $form['brafton_article_options'] = array('#type' => 'fieldset', '#title' => 'Article Options', '#collapsible' => true, '#collapsed' => true);
    $form['brafton_article_options']['brafton_api_key'] = array('#type' => 'textfield', '#title' => t('Api Key'), '#description' => t('Your API key (of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'), '#default_value' => variable_get('brafton_api_key'), '#size' => 36, '#maxlength' => 36, '#prefix' => 'Options in this section apply to Articles ONLY.  Videos have seperate options');
    $form['brafton_article_options']['brafton_blog_page'] = array('#type' => 'checkbox', '#title' => t('Create a News Page at "mydomain.com/news".'), '#default_value' => variable_get('brafton_blog_page', 0), '#prefix' => '<h2>Integration Options for Articles</h2>');
    $form['brafton_article_options']['brafton_blog_archives'] = array('#type' => 'checkbox', '#title' => t('Create archives pages at "mydomain.com/news/archive/year/month" and an archives block.'), '#default_value' => variable_get('brafton_blog_archives', 0));
    $form['brafton_article_options']['brafton_blog_categories'] = array('#type' => 'checkbox', '#title' => t('Create a categories block.'), '#default_value' => variable_get('brafton_blog_categories', 0));
    $form['brafton_article_options']['brafton_blog_headlines'] = array('#type' => 'checkbox', '#title' => t('Create a headlines block.'), '#default_value' => variable_get('brafton_blog_headlines', 0));
    $form['brafton_article_options']['brafton_related_articles'] = array('#type' => 'checkbox', '#title' => t('Add related articles to Brafton posts.'), '#default_value' => variable_get('brafton_related_articles', 0));
    $form['brafton_article_options']['brafton_existing_type'] = array('#type' => 'select', '#title' => 'Content Type', '#options' => build_type_list($type_list), '#default_value' => variable_get('brafton_existing_type', 'b_news'), '#description' => 'Import Articles under the content type of your choice.<span class="disclaimer">ADVANCED OPTION.  Only change if you know what you are doing. Defaults to our News Article Content Type</span>', '#ajax' => array('callback' => 'ajax_brafton_test', 'wrapper' => 'brafton_type_info_block', 'replace' => 'replace', 'effect' => 'fade'));
    $form['brafton_article_options']['brafton_type_info'] = array('#title' => '', '#prefix' => '<div id="brafton_type_info_block">', '#suffix' => '</div>', '#type' => 'fieldset');
    //displays the form with values for existing post type on initial page load
    if (empty($form_state['values']['brafton_existing_type']) && variable_get('brafton_existing_type', 'b_news') != 'b_news') {
        $form['brafton_article_options']['brafton_type_info']['brafton_custom_body'] = array('#type' => 'select', '#prefix' => '<p>Map your content fields to the appropriate content parts.<span class="disclaimer">Caution the following are advanced options and should only be used if you know what your are doing</span></p>', '#title' => 'Content of the Article', '#options' => build_type_field_list(variable_get('brafton_existing_type')), '#default_value' => variable_get('brafton_custom_body', ''));
        $form['brafton_article_options']['brafton_type_info']['brafton_custom_image'] = array('#type' => 'select', '#title' => 'Image for Article', '#options' => build_type_field_list(variable_get('brafton_existing_type')), '#default_value' => variable_get('brafton_custom_image', ''));
        $form['brafton_article_options']['brafton_type_info']['brafton_custom_taxonomy'] = array('#type' => 'select', '#title' => 'Taxonomy for Article', '#options' => build_type_field_list(variable_get('brafton_existing_type')), '#default_value' => variable_get('brafton_custom_taxonomy', ''));
    }
    //used for displaying the ajax load of content type to display the fields available for mapping
    if (!empty($form_state['values']['brafton_existing_type']) && $form_state['values']['brafton_existing_type'] != 'b_news') {
        $current = $form_state['values']['brafton_existing_type'];
        $form['brafton_article_options']['brafton_type_info']['brafton_custom_body'] = array('#type' => 'select', '#prefix' => '<p>Map your content fields to the appropriate content parts.<span class="disclaimer">Caution the following are advanced options and should only be used if you know what your are doing</span></p>', '#title' => 'Content of the Article', '#options' => build_type_field_list($current), '#default_value' => '');
        $form['brafton_article_options']['brafton_type_info']['brafton_custom_image'] = array('#type' => 'select', '#title' => 'Image for Article', '#options' => build_type_field_list($current), '#default_value' => '');
        $form['brafton_article_options']['brafton_type_info']['brafton_custom_taxonomy'] = array('#type' => 'select', '#title' => 'Taxonomy for Article', '#options' => build_type_field_list($current), '#default_value' => '');
    }
    /*
     *************************************************************************************
     * Video Options
     *************************************************************************************
     */
    $form['brafton_video_options'] = array('#type' => 'fieldset', '#title' => 'Video Options', '#collapsible' => true, '#collapsed' => true);
    $form['brafton_video_options']['brafton_video_public_key'] = array('#type' => 'textfield', '#title' => t('Video Public Key'), '#description' => t('Your video Public Key.'), '#default_value' => variable_get('brafton_video_public_key'), '#size' => 8, '#maxlength' => 8, '#prefix' => '<h2>For Videos</h2>');
    $form['brafton_video_options']['brafton_video_secret_key'] = array('#type' => 'textfield', '#title' => t('Video Secret Key'), '#description' => t('Your video Secret Key.'), '#default_value' => variable_get('brafton_video_secret_key'), '#size' => 36, '#maxlength' => 36);
    $form['brafton_video_options']['brafton_video_feednum'] = array('#type' => 'textfield', '#title' => t('Video Feed Number'), '#description' => t('Your video feed number.'), '#default_value' => variable_get('brafton_video_feednum', 0), '#size' => 10, '#maxlength' => 10);
    $form['brafton_video_options']['brafton_video_page'] = array('#type' => 'checkbox', '#title' => t('Create a Video Page at "mydomain.com/video".'), '#default_value' => variable_get('brafton_video_page', 0), '#prefix' => '<h2>Integration Options for Videos</h2>');
    $form['brafton_video_options']['brafton_video_archives'] = array('#type' => 'checkbox', '#title' => t('Create video archives pages at "mydomain.com/video/archive/year/month" and a video archives block.'), '#default_value' => variable_get('brafton_video_archives', 0));
    $form['brafton_video_options']['brafton_video_categories'] = array('#type' => 'checkbox', '#title' => t('Create a video categories block.'), '#default_value' => variable_get('brafton_video_categories', 0));
    $form['brafton_video_options']['brafton_video_headlines'] = array('#type' => 'checkbox', '#title' => t('Create a video headlines block.'), '#default_value' => variable_get('brafton_video_headlines', 0));
    $form['brafton_video_options']['brafton_related_videos'] = array('#type' => 'checkbox', '#title' => t('Add related videos to Brafton videos.'), '#default_value' => variable_get('brafton_related_videos', ""));
    $form['b_cta'] = array('#type' => 'fieldset', '#title' => 'Brafton Video CTA\'s', '#collapsible' => true, '#collapsed' => true);
    $form['b_cta']['brafton_video_ctas'] = array('#type' => 'checkbox', '#title' => t('Use Video CTA\'s'), '#default_value' => variable_get('brafton_video_ctas'));
    $form['b_cta']['brafton_video_pause_cta_text'] = array('#type' => 'textfield', '#title' => t('Atlantis Pause CTA Text'), '#description' => t('Default video pause cta text every article imports'), '#default_value' => variable_get('brafton_video_pause_cta_text', ""), '#size' => 20, '#prefix' => variable_get('testingName'));
    $form['b_cta']['brafton_video_pause_cta_link'] = array('#type' => 'textfield', '#title' => t('Atlantis Pause Link'), '#description' => t('Default video pause cta link'), '#default_value' => variable_get('brafton_video_pause_cta_link'), '#size' => 20);
    $form['b_cta']['brafton_video_pause_cta_asset_gateway_id'] = array('#type' => 'textfield', '#title' => t('Pause Asset Gateway ID'), '#description' => t('Asset Gateay Form ID. disables pause link url'), '#default_value' => variable_get('brafton_video_pause_cta_asset_gateway_id'), '#size' => 20);
    $form['b_cta']['brafton_video_end_cta_title'] = array('#type' => 'textfield', '#title' => t('Atlantis End CTA Title'), '#description' => t('Default video end cta title every article imports'), '#default_value' => variable_get('brafton_video_end_cta_title', ""), '#size' => 20, '#maxlength' => 140);
    $form['b_cta']['brafton_video_end_cta_subtitle'] = array('#type' => 'textfield', '#title' => t('Atlantis End CTA Subtitle'), '#description' => t('Default video end cta subtitle every article imports'), '#default_value' => variable_get('brafton_video_end_cta_subtitle', ""), '#size' => 20, '#maxlength' => 140);
    $form['b_cta']['brafton_video_end_cta_link'] = array('#type' => 'textfield', '#title' => t('Atlantis End CTA Link'), '#description' => t('Default video end cta link every article imports. Requires http://'), '#default_value' => variable_get('brafton_video_end_cta_link', ""), '#size' => 20, '#maxlength' => 500);
    $form['b_cta']['brafton_video_end_cta_asset_gateway_id'] = array('#type' => 'textfield', '#title' => t('End Asset Gateway ID'), '#description' => t('Asset Gateay Form ID. disables end link url'), '#default_value' => variable_get('brafton_video_end_cta_asset_gateway_id'), '#size' => 20);
    $form['b_cta']['brafton_video_end_cta_text'] = array('#type' => 'textfield', '#title' => t('Atlantis End CTA Text'), '#description' => t('Default video end cta text every article imports'), '#default_value' => variable_get('brafton_video_end_cta_text', ""), '#size' => 20, '#maxlength' => 20);
    $form['b_cta']['brafton_video_end_cta_button_image'] = array('#type' => 'managed_file', '#title' => t('Ending CTA Button Image'), '#description' => '<span class="actual_description">This is Optional and wil override the end cta text </span>' . spit_image('brafton_video_end_cta_button_image'), '#upload_location' => 'public://', '#default_value' => variable_get('brafton_video_end_cta_button_image'));
    $form['b_cta']['brafton_video_end_cta_button_placement'] = array('#type' => 'select', '#title' => t(' Ending button image Placement'), '#description' => t('Choose the position of button image.  You can further affect the position via css rules'), '#options' => array(0 => 'Choose Position', 'tl' => 'Top Left', 'tr' => 'Top Right', 'bl' => 'Bottom Left', 'br' => 'Bottom Right'), '#default_value' => variable_get('brafton_video_end_cta_button_placement'));
    $form['b_cta']['brafton_video_end_cta_background'] = array('#type' => 'managed_file', '#title' => t('Ending Background Image'), '#description' => '<span class="actual_description">This is Optional</span>' . spit_image('brafton_video_end_cta_background'), '#upload_location' => 'public://', '#default_value' => variable_get('brafton_video_end_cta_background'));
    $form['b_error'] = array('#type' => 'fieldset', '#title' => 'Brafton Error Reporting', '#description' => 'Errors resulting in failed attempts to import content will turn on Debug mode and capture all errors for debugging.  These errors are reporting to your CMS so we can better resolve any issues in a timely manner.', '#collapsible' => true, '#collapsed' => true);
    $form['b_error']['brafton_error_logs'] = array('#type' => 'radio', '#title' => t('Report Log'), '#description' => get_errs(), '#format' => 'full_html', '#default_value' => variable_get('brafton_error_logs', 0), '#prefix' => '<h3>Error Report</h3>');
    $form['b_error']['brafton_debug_mode'] = array('#type' => 'checkbox', '#title' => 'Debug Mode', '#description' => 'Turns on debug mode to report all errors that occur during the importer operatin', '#default_value' => variable_get('brafton_debug_mode', 0));
    $form['b_error']['brafton_clear_report'] = array('#type' => 'checkbox', '#title' => t('Clear the Error Report Log'), '#default_value' => variable_get('brafton_clear_report', 0));
    $form['b_manual'] = array('#type' => 'fieldset', '#title' => 'Manual Control & Archive Uploads', '#collapsible' => true, '#collapsed' => true);
    /*
    $form['b_manual']['brafton_article'] = array(
        '#type' => 'fieldset',
    
    );
    */
    /*
    $form['b_manual']['brafton_article']['brafton_enable_article_import'] = array(
        '#type' => 'checkbox',
    		'#title' => t( 'Run Article Importer' ),
    		'#default_value' => variable_get( 'brafton_enable_article_import',0 ),
        '#prefix'   => '<h2>Run Article Importer</h2>'
    );
    */
    $form['b_manual']['brafton_run_importer'] = array('#type' => 'submit', '#title' => 'Run Article Importer', '#value' => 'Run Article Importer', '#submit' => array('brafton_run_manaul_article'));
    $form['b_manual']['brafton_run_video_importer'] = array('#type' => 'submit', '#title' => 'Run Video Importer', '#value' => 'Run Video Importer', '#submit' => array('brafton_run_video_importer'));
    if (variable_get('brafton_archive_file')) {
        $form['b_manual']['brafton_run_archive_importer'] = array('#type' => 'submit', '#title' => 'Run Archive Importer', '#value' => 'Run Archive Importer', '#submit' => array('brafton_run_manaul_article'));
    }
    $form['b_manual']['brafton_archive_file'] = array('#type' => 'managed_file', '#title' => t('Article Archive File'), '#description' => t('When using the Archive import feature you must click upload and than Save configuration.  Once you Save your configuration you may run the Archive Importer which will use the uploaded xml file.'), '#default_value' => variable_get('brafton_archive_file'), '#upload_validators' => array('file_validate_extensions' => array(0 => 'xml')));
    $form['#submit'][] = 'brafton_admin_form_submit';
    return system_settings_form($form);
}
 public function hook_page_alter(&$page)
 {
     // Add an extra "Panelizer" action on the content types admin page.
     if ($_GET['q'] == 'admin/structure/types') {
         // This only works with some themes.
         if (!empty($page['content']['system_main']['node_table'])) {
             // Shortcut.
             $table =& $page['content']['system_main']['node_table'];
             // Operations column should always be the last column in header.
             // Increase its colspan by one to include possible panelizer link.
             $operationsCol = end($table['#header']);
             if (!empty($operationsCol['colspan'])) {
                 $operationsColKey = key($table['#header']);
                 $table['#header'][$operationsColKey]['colspan']++;
             }
             // Since we can't tell what row a type is for, but we know that they
             // were generated in this order, go through the original types list.
             $types = node_type_get_types();
             $names = node_type_get_names();
             $row_index = 0;
             foreach ($names as $bundle => $name) {
                 $type = $types[$bundle];
                 if (node_hook($type->type, 'form')) {
                     $type_url_str = str_replace('_', '-', $type->type);
                     if ($this->is_panelized($bundle) && panelizer_administer_entity_bundle($this, $bundle)) {
                         $table['#rows'][$row_index][] = array('data' => l(t('panelizer'), 'admin/structure/types/manage/' . $type_url_str . '/panelizer'));
                     } else {
                         $table['#rows'][$row_index][] = array('data' => '');
                     }
                     // Update row index for next pass.
                     $row_index++;
                 }
             }
         }
     }
 }
Пример #23
0
 public static function getTypes()
 {
     return node_type_get_types();
 }
Пример #24
0
/**
 * Allows modules to alter user privileges.
 *
 * Standard drupal_alter() hook to allow modules to modify the sections
 * that a user is allowed to edit. This hook is largely present to allow for
 * complex handling of content type permissions.
 *
 * @param &$access
 *   An array of access data, keyed by the access id. Passed by reference.
 * @param $account
 *   The active user account object. Note that this object may also be altered,
 *   since objects are implicitly passed by reference. Normally, you should not
 *   alter the $account object with this hook.
 */
function hook_workbench_access_user_alter(&$access, $account)
{
    // Make content editing specific to assigned node types.
    if (empty($account->workbench_access)) {
        return;
    }
    $types = node_type_get_types();
    foreach ($access as $id => $data) {
        $access[$id]['update'] = array();
        foreach ($types as $type => $value) {
            if (user_access("edit any {$type} content", $account)) {
                $access[$id]['update'][] = $type;
            }
        }
    }
}
 public function hook_page_alter(&$page)
 {
     if ($_GET['q'] == 'admin/structure/types' && !empty($page['content']['system_main']['node_table'])) {
         // shortcut
         $table =& $page['content']['system_main']['node_table'];
         // Modify the header.
         $table['#header'][1]['colspan'] = 5;
         // Since we can't tell what row a type is for, but we know that they
         // were generated in this order, go through the original types
         // list:
         $types = node_type_get_types();
         $names = node_type_get_names();
         $row_index = 0;
         foreach ($names as $bundle => $name) {
             $type = $types[$bundle];
             if (node_hook($type->type, 'form')) {
                 $type_url_str = str_replace('_', '-', $type->type);
                 if ($this->is_panelized($bundle) && panelizer_administer_entity_bundle($this, $bundle)) {
                     $table['#rows'][$row_index][] = array('data' => l(t('panelizer'), 'admin/structure/types/manage/' . $type_url_str . '/panelizer'));
                 } else {
                     $table['#rows'][$row_index][] = array('data' => '');
                 }
                 // Update row index for next pass:
                 $row_index++;
             }
         }
     }
 }
Пример #26
0
// #states flag to indicate that Omega.gs has been enabled
$omegaGSon = array('invisible' => array(':input[name="enable_omegags_layout"]' => array('checked' => FALSE)));
// #states flag to indicate that Omega.gs has been disabled
$omegaGSoff = array('invisible' => array(':input[name="enable_omegags_layout"]' => array('checked' => TRUE)));
$enable_omegags_layout = theme_get_setting('enable_omegags_layout', $theme);
$form['enable_omegags_layout'] = array('#type' => 'checkbox', '#title' => t('Enable Omega.gs Layout Management'), '#description' => t('Turning on the Omega.gs layout management system will allow you to configure your site region layout in each breakpoint via a visual interface. <strong>#easybutton</strong>'), '#default_value' => isset($enable_omegags_layout) ? $enable_omegags_layout : TRUE, '#group' => 'layout-config', '#weight' => -999);
$form['layout-config']['non_omegags_info'] = array('#type' => 'item', '#prefix' => '', '#markup' => '<div class="messages messages--warning omega-styles-info"><p>Since you have "<strong><em>disabled the Awesome</em></strong>" above, now the Omega.gs layout is not being used in your theme/subtheme. This means that you will need to provide your own layout system. Easy huh?!? Although, I would really just use the awesome...</p></div>', '#suffix' => '', '#weight' => -99, '#states' => $omegaGSoff);
$availableLayouts = _omega_layout_select_options($layouts);
$form['layout-config']['default-layouts'] = array('#type' => 'details', '#attributes' => array('class' => array('layout-selection')), '#title' => 'Default Layouts', '#group' => 'layout-config', '#states' => $omegaGSon);
$form['layout-config']['default-layouts']['default_layout'] = array('#prefix' => '<div class="default-layout-select">', '#suffix' => '</div>', '#description' => '<p class="description">The Default Layout is used on any/every page rendered by the <strong>' . $theme . '</strong> theme. Additional layouts can be used for other pages/sections as defined in the additional select options below.</p>', '#type' => 'select', '#attributes' => array('class' => array('layout-select', 'clearfix')), '#title' => 'Default: Select Layout', '#options' => $availableLayouts, '#default_value' => isset($defaultLayout) ? $defaultLayout : theme_get_setting('default_layout', $theme), '#tree' => FALSE, '#states' => $omegaGSon);
$homeLayout = isset($form_state->values['home_layout']) ? $form_state->values['home_layout'] : theme_get_setting('home_layout', $theme);
$form['layout-config']['default-layouts']['home_layout'] = array('#prefix' => '<div class="home-layout-select">', '#suffix' => '</div>', '#description' => '<p class="description">The Homepage Layout is used only on the home page rendered by the <strong>' . $theme . '</strong> theme.</p>', '#type' => 'select', '#attributes' => array('class' => array('layout-select', 'clearfix')), '#title' => 'Homepage: Select Layout', '#options' => $availableLayouts, '#default_value' => isset($homeLayout) ? $homeLayout : theme_get_setting('default_layout', $theme), '#tree' => FALSE, '#states' => $omegaGSon);
// Show a select menu for each node type, allowing the selection
// of an alternate layout per node type.
$form['layout-config']['node-layouts'] = array('#type' => 'details', '#attributes' => array('class' => array('layout-selection')), '#title' => 'Node Type Layouts', '#group' => 'layout-config', '#states' => $omegaGSon);
$types = node_type_get_types();
foreach ($types as $ctype => $ctypeData) {
    $layout_name = 'node_type_' . $ctype . '_layout';
    $ctypeLayout = theme_get_setting($layout_name, $theme);
    $form['layout-config']['node-layouts'][$layout_name] = array('#prefix' => '<div class="' . $ctype . '-layout-select">', '#suffix' => '</div>', '#type' => 'select', '#attributes' => array('class' => array('layout-select', 'clearfix')), '#title' => $ctypeData->label() . ': Select Layout', '#description' => '<p class="description">The <strong>' . $ctypeData->label() . '</strong> Layout is used only on pages rendering a full node page of the type "<strong>' . $ctypeData->id() . '</strong>" using the <strong>' . $theme . '</strong> theme.</p>', '#options' => $availableLayouts, '#default_value' => isset($ctypeLayout) ? $ctypeLayout : theme_get_setting('default_layout', $theme), '#tree' => FALSE, '#states' => $omegaGSon);
}
// create layout switching options for taxonomy term pages
$form['layout-config']['taxonomy-layouts'] = array('#type' => 'details', '#attributes' => array('class' => array('layout-selection')), '#title' => 'Taxonomy Term Page Layouts', '#group' => 'layout-config', '#states' => $omegaGSon);
$vocabs = taxonomy_vocabulary_get_names();
foreach ($vocabs as $vocab_id) {
    $vocab = taxonomy_vocabulary_load($vocab_id);
    //dsm($vocab->get('name'));
    $layout_name = 'taxonomy_' . $vocab_id . '_layout';
    $ttypeLayout = theme_get_setting($layout_name, $theme);
    $form['layout-config']['taxonomy-layouts'][$layout_name] = array('#prefix' => '<div class="' . $ttype . '-layout-select">', '#suffix' => '</div>', '#type' => 'select', '#attributes' => array('class' => array('layout-select', 'clearfix')), '#title' => $vocab->get('name') . ' Vocabulary: Select Layout', '#description' => '<p class="description">The <strong>' . $vocab->get('name') . '</strong> Layout is used only on pages rendering a full taxonomy term listing page of the type "<strong>' . $vocab_id . '</strong>" using the <strong>' . $theme . '</strong> theme.</p>', '#options' => $availableLayouts, '#default_value' => isset($ttypeLayout) ? $ttypeLayout : theme_get_setting('default_layout', $theme), '#tree' => FALSE, '#states' => $omegaGSon);
}
Пример #27
0
 /**
  * Get all the available page types
  * Insert the teaser mode as a page type
  *
  * @return Array list of page types
  */
 public static function page_types()
 {
     $page_types = node_type_get_types();
     $teaser = new stdClass();
     $teaser->name = 'Teaser';
     $teaser->type = 'teaser';
     $page_types['shareaholic_custom_type'] = $teaser;
     return $page_types;
 }
 /**
  * Tests that node types correctly handles their locking.
  */
 function testNodeTypeStatus()
 {
     // Enable all core node modules, and all types should be active.
     $this->container->get('module_handler')->install(array('book'), FALSE);
     $types = node_type_get_types();
     foreach (array('book', 'article', 'page') as $type) {
         $this->assertTrue(isset($types[$type]), format_string('%type is found in node types.', array('%type' => $type)));
         $this->assertFalse($types[$type]->isLocked(), format_string('%type type is not locked.', array('%type' => $type)));
     }
     // Disable book module and the respective type should still be active, since
     // it is not provided by shipped configuration entity.
     $this->container->get('module_handler')->uninstall(array('book'), FALSE);
     $types = node_type_get_types();
     $this->assertFalse($types['book']->isLocked(), "Book module's node type still active.");
     $this->assertFalse($types['article']->isLocked(), 'Article node type still active.');
     $this->assertFalse($types['page']->isLocked(), 'Basic page node type still active.');
     // Re-install the modules and verify that the types are active again.
     $this->container->get('module_handler')->install(array('book'), FALSE);
     $types = node_type_get_types();
     foreach (array('book', 'article', 'page') as $type) {
         $this->assertTrue(isset($types[$type]), format_string('%type is found in node types.', array('%type' => $type)));
         $this->assertFalse($types[$type]->isLocked(), format_string('%type type is not locked.', array('%type' => $type)));
     }
 }
 /**
  * Constructor to load default values.
  */
 public function __construct()
 {
     $this->nodeTypes = array_keys(node_type_get_types());
     $this->allowedTypes = array('event');
     $this->loginMessageLink = array('#theme' => 'link', '#path' => 'culturefeed/oauth/connect', '#text' => t("logged in"), '#options' => array('html' => TRUE, 'attributes' => array('class' => array('culturefeedconnect'), 'rel' => 'nofollow'), 'query' => array('destination' => current_path())));
 }
Пример #30
0
/**
 * Implimentation of hook_form_system_theme_settings_alter()
 *
 * @param $form
 *   Nested array of form elements that comprise the form.
 *
 * @param $form_state
 *   A keyed array containing the current state of the form.
 */
function at_core_form_system_theme_settings_alter(&$form, &$form_state) {

  // Set the theme name.
  $build_info = $form_state->getBuildInfo();
  $theme = $build_info['args'][0];

  // Instantiate our Theme info object.
  $themeInfo = new ThemeInfo($theme);
  $getThemeInfo = $themeInfo->getThemeInfo('info');

  // Get this themes config settings
  $config = \Drupal::config($theme . '.settings')->get('settings');

  // Common paths.
  $at_core_path  = drupal_get_path('theme', 'at_core');
  $subtheme_path = drupal_get_path('theme', $theme);

  // Path to save generated CSS files. We don't want this happening for at_core or the generator.
  if (isset($getThemeInfo['subtheme type']) && $getThemeInfo['subtheme type'] === 'adaptive_subtheme') {
    $directoryOperations = new DirectoryOperations();
    $generated_files_path = $directoryOperations->directoryPrepare($backup_file_path = array($subtheme_path, 'styles/css/generated'));
  }

  // Get the active themes regions so we can use this in
  // various other places.
  $theme_regions = system_region_list($theme, $show = REGIONS_VISIBLE);

  // Active themes active blocks
  $theme_blocks = entity_load_multiple_by_properties('block', ['theme' => $theme]);

  // Check for breakpoints module and set a warning and a flag to disable much of the theme settings if its not available
  $breakpoints_module = \Drupal::moduleHandler()->moduleExists('breakpoint');

  if ($breakpoints_module == TRUE) {
    $breakpoint_groups = \Drupal::service('breakpoint.manager')->getGroups();

    // Unset core breakpoint groups due to notices and other issues, until this is resolved:
    // SEE: https://www.drupal.org/node/2379283
    unset($breakpoint_groups['toolbar']);
    unset($breakpoint_groups['seven']);
    unset($breakpoint_groups['bartik']);

    // Set breakpoint options, we use these in layout and other extensions like Responsive menus.
    foreach ($breakpoint_groups as $group_key => $group_values) {
      $breakpoints[$group_key] = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup($group_key);
    }

    foreach($breakpoints as $group => $breakpoint_values)  {
      if ($breakpoint_values !== array()) {
        $breakpoint_options[$group] = $group;
      }
    }
  }
  else {
    drupal_set_message(t('Adaptivetheme requires the <b>Breakpoint module</b>. Open the <a href="!extendpage" target="_blank">Extend</a> page and enable Breakpoint.', array('!extendpage' => base_path() . 'admin/modules')), 'warning');
  }

  // Get node types (bundles).
  $node_types = node_type_get_types();

  // View or "Display modes", the search display mode is still problematic so we will exclude it for now,
  // please see: https://drupal.org/node/1166114
  //$node_view_modes = \Drupal::entityManager()->getViewModeOptions('node', TRUE);
  $node_view_modes = \Drupal::entityManager()->getViewModes('node');

  // Unset unwanted view modes
  unset($node_view_modes['rss']);
  unset($node_view_modes['search_index']);
  unset($node_view_modes['search_result']);

  // Set a class on the form for the current admin theme, note if this is set to "Default theme"
  // the result is always 0.
  $system_theme_config = \Drupal::config('system.theme');
  $admin_theme = $system_theme_config->get('admin');
  if (!empty($admin_theme)) {
    $admin_theme_class = 'admin-theme--' . Html::getClass($admin_theme);
    $form['#attributes'] = array('class' => array($admin_theme_class));
  }

  // Attached required CSS and JS.
  $form['#attached']['library'][] = 'at_core/at.appearance_settings';

  // AT Core
  if ($theme == 'at_core') {
    $form['at_core']['message'] = array(
      '#type' => 'container',
      '#markup' => t('AT Core has no configuration and cannot be used as a front end theme - it is a base them only. Use the <b>AT Theme Generator</b> to generate or clone a theme to get started.'),
    );

    // Hide form items.
    $form['theme_settings']['#attributes']['class'] = array('visually-hidden');
    $form['logo']['#attributes']['class'] = array('visually-hidden');
    $form['favicon']['#attributes']['class'] = array('visually-hidden');
    $form['actions']['#attributes']['class'] = array('visually-hidden');
  }

  // AT Subtheme
  if (isset($getThemeInfo['subtheme type'])) {

    if ($getThemeInfo['subtheme type'] !== 'adaptive_generator') {

      // Pass in the generated files path to values and settings.
      $form['at']['settings_generated_files_path'] = array(
        '#type' => 'hidden',
        '#value' => $generated_files_path,
      );

      // Extension settings.
      require_once($at_core_path . '/forms/ext/extension_settings.php');

      // Layouts.
      require_once($at_core_path . '/forms/layout/layouts.php');

      // Basic settings - move into details wrapper and collapse.
      $form['basic_settings'] = array(
        '#type' => 'details',
        '#title' => t('Basic Settings'),
        '#open' => FALSE,
      );

      $form['theme_settings']['#open'] = FALSE;
      $form['theme_settings']['#group'] = 'basic_settings';
      $form['logo']['#open'] = FALSE;
      $form['logo']['#group'] = 'basic_settings';
      $form['favicon']['#open'] = FALSE;
      $form['favicon']['#group'] = 'basic_settings';

      // buttons don't work with #group, move it the hard way.
      $form['actions']['#type'] = $form['basic_settings']['actions']['#type'] = 'actions';
      $form['actions']['submit']['#type'] = $form['basic_settings']['actions']['submit']['#type'] = 'submit';
      $form['actions']['submit']['#value'] = $form['basic_settings']['actions']['submit']['#value'] = t('Save basic settings');
      $form['actions']['submit']['#button_type'] = $form['basic_settings']['actions']['submit']['#button_type'] = 'primary';
      unset($form['actions']);
    }
  }

  // Modify the color scheme form.
  if (\Drupal::moduleHandler()->moduleExists('color')) {
    //include_once($at_core_path . '/forms/color/color_submit.php');
    if (isset($build_info['args'][0]) && ($theme = $build_info['args'][0]) && color_get_info($theme) && function_exists('gd_info')) {
      $form['#process'][] = 'at_core_make_collapsible';
    }
  }
}