diff --git a/src/Form/Pagingform.php b/src/Form/Pagingform.php new file mode 100644 index 0000000..2bd3793 --- /dev/null +++ b/src/Form/Pagingform.php @@ -0,0 +1,286 @@ +getStorage('node_type')->loadMultiple(); + + + + // Set the id of the top-level form tag. + $form['#id'] = 'contentpager'; + + + + $form['paging_general'] = array( + '#type' => 'fieldset', + '#title' => t('General paging settings'), + '#collapsible' => FALSE, + ); + + // Paging separator string. + // @TODO will need an upgrade path. + $form['paging_general']['paging_separator'] = array( + '#type' => 'textfield', + '#title' => t('Page separator string'), + '#size' => 20, + '#maxlength' => 255, + + // '#default_value' => variable_get('paging_separator', ''), + '#description' => t('Use an HTML tag that will render reasonably when + paging is not enabled, such as %pagebreak or %hr.'), + ); + + + $form['paging_general']['paging_pager_count'] = array( + '#type' => 'radios', + '#title' => t('Number of Pagers on each page'), + '#options' => array( + 'one' => t('One'), + 'two' => t('Two'), + ), + + + // '#default_value' => variable_get('paging_pager_count', 'one'), + '#attributes' => array('class' => array('paging-pager')), + ); + + + $contentTypesList = []; + foreach ($contentTypes as $contentType) { + + $contentTypesList[$contentType->id()] = $contentType->label(); + $content_type= $contentType->label(); + $content_type = 'Article'; + + $form['Article'] = array( + '#type' => 'fieldset', + '#title' => $content_type, + ); + + $field_options = array('body'); + // Left column fieldset. + $form[$content_type]['paging_config']['paging_left'] = array( + '#type' => 'fieldset', + '#collapsible' => FALSE, + '#collapsed' => FALSE, + '#attributes' => array('class' => array('paging-left')), + ); + + + // Paging toggle checkbox. + $form[$content_type]['paging_config']['paging_left']['paging_enabled_' . $content_type] = array( + '#type' => 'checkbox', + '#title' => 'Enable paging', + // '#default_value' => variable_get('paging_enabled_' . $content_type, 0), + '#attributes' => array('class' => array('paging-enabled')), + ); + + // Paging toggle checkbox. + $form[$content_type]['paging_config']['paging_left']['paging_field_' . $content_type] = array( + '#type' => 'radios', + '#title' => 'Select field to use for page breaks', + '#options' => $field_options, + // '#default_value' => variable_get('paging_field_' . $type, 0), + '#attributes' => array('class' => array('paging-enabled')), + '#states' => array( + 'visible' => array(// action to take. + ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), + ), + ), + ); + + // Change "Read more" path when first page is greater than or equal to the teaser. + $form[$content_type]['paging_config']['paging_left']['paging_read_more_enabled_' . $content_type] = array( + '#type' => 'checkbox', + '#title' => t('Link "Read more" to second page'), + '#description' => t('When enabled, the "Read more" link for teasers will + link to the second page of the content if the teaser is larger than the + first page or if they are the same.'), + // '#default_value' => variable_get('paging_read_more_enabled_' . $type, 0), + '#states' => array( + 'visible' => array(// action to take. + ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), + ), + ), + ); + + // Set the browser's title to current page's name. + $form[$content_type]['paging_config']['paging_left']['paging_name_title_' . $content_type] = array( + '#type' => 'checkbox', + '#title' => t('Change page title to name of current page'), + '#description' => t("Change the node's and browser window's title into + name of the current page."), + // '#default_value' => variable_get('paging_name_title_' . $type, 0), + '#states' => array( + 'visible' => array(// action to take. + ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), + ), + ), + ); + + // Right column fieldset. + $form[$content_type]['paging_config']['paging_right'] = array( + '#type' => 'fieldset', + '#collapsible' => FALSE, + '#collapsed' => FALSE, + '#attributes' => array('class' => array('paging-right')), + '#states' => array( + 'visible' => array(// action to take. + ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), + ), + ), + ); + + + $form[$content_type]['paging_config']['paging_right']['paging_automatic_method_' . $content_type] = array( + '#type' => 'radios', + '#title' => t('Automatic paging method'), + '#options' => array( + 'disabled' => t('Disabled'), + 'chars' => t('Limit by characters (recommended)'), + 'words' => t('Limit by words')), + + '#description' => t('Method for automatic paging (ignored where paging + separator string is used).'), + + '#attributes' => array('class' => array('paging-method')), + '#states' => array( + 'visible' => array(// action to take. + ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), + ), + ), + ); + + + + // Get the length options. + // @TODO: Do we really need 750? + $char_len_options = array(-1 => 750) + range(500, 7500, 500); + $word_len = range(100, 1000, 50); + asort($char_len_options); + + // Automatic paging method. Select list to choose the number of characters per page. + $form[$content_type]['paging_config']['paging_right']['paging_automatic_chars_' . $content_type] = array( + '#type' => 'select', + '#title' => t('Length of each page'), + '#options' => $char_len_options, + '#field_suffix' => t('characters'), + + '#description' => '
' . t('Number of characters to display per page.'), + //'#default_value' => variable_get('paging_automatic_chars_' . $content_type, 4000), + '#prefix' => '
', + '#suffix' => '
', + '#states' => array( + 'visible' => array(// action to take. + ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), + ':input[name="paging_automatic_method_' . $content_type . '"]' => array('value' => 'chars'), + ), + ), + ); + + // Automatic paging method. Text box to choose orphan size. + $form[$content_type]['paging_config']['paging_right']['paging_automatic_chars_orphan_' . $content_type] = array( + '#type' => 'textfield', + '#title' => t('Length of orphans'), + '#size' => 6, + '#field_suffix' => t('characters'), + + '#description' => '
' . t('Number of characters to consider as an orphan.'), + // '#default_value' => variable_get('paging_automatic_chars_orphan_' . $content_type, 100), + '#prefix' => '
', + '#suffix' => '
', + '#states' => array( + 'visible' => array(// action to take. + ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), + ':input[name="paging_automatic_method_' . $content_type . '"]' => array('value' => 'chars'), + ), + ), + ); + + // Automatic paging method. Select list to choose the number of words per page. + $form[$content_type]['paging_config']['paging_right']['paging_automatic_words_' . $content_type] = array( + '#type' => 'select', + '#title' => t('Length of each page'), + '#options' => $word_len, + '#field_suffix' => t('words'), + + '#description' => '
' . t('Number of words to display per page.'), + // '#default_value' => variable_get('paging_automatic_words_' . $content_type, 400), + '#prefix' => '
', + '#suffix' => '
', + '#states' => array( + 'visible' => array(// action to take. + ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), + ':input[name="paging_automatic_method_' . $content_type . '"]' => array('value' => 'words'), + ), + ), + ); + + // Automatic paging method. Text box to set orphan page size. + $form[$content_type]['paging_config']['paging_right']['paging_automatic_words_orphan_' . $content_type] = array( + '#type' => 'textfield', + '#title' => t('Length of orphans'), + '#size' => 6, + '#field_suffix' => t('words'), + + '#description' => '
' . t('Number of wordss to consider as an orphan.'), + // '#default_value' => variable_get('paging_automatic_words_orphan_' . $content_type, 200), + '#prefix' => '
', + '#suffix' => '
', + '#states' => array( + 'visible' => array(// action to take. + ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), + ':input[name="paging_automatic_method_' . $content_type . '"]' => array('value' => 'words'), + ), + ), + ); + + + + + + } + + $form['submit'] = array( + '#type' => 'submit', + '#value' => $this->t('Save Configuration'), + + ); + + + + return $form; + } + + /** + * Form submission handler. + * + * @param array $form + * An associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + + + } +} \ No newline at end of file