diff --git a/g2.legacy.php b/g2.legacy.php index 16331525b7caa9a5874139ebd0e3bebe659071c7..bda1d867c425ea81cbf18e8bae6825ce3a2d23f4 100644 --- a/g2.legacy.php +++ b/g2.legacy.php @@ -5,6 +5,8 @@ * This is unported code for the module. */ +use Drupal\g2\G2; + /** * Implements hook_block_configure(). */ @@ -23,7 +25,7 @@ function zg2_block_configure($delta) { ]; switch ($delta) { - case G2::DELTARANDOM: + case G2::DELTA_RANDOM: $form[G2::VARRANDOMSTORE] = [ '#type' => 'checkbox', '#title' => t('Store latest random entry'), @@ -49,7 +51,7 @@ function zg2_block_configure($delta) { ]; break; - case G2::DELTATOP: + case G2::DELTA_TOP: $form[G2::VARTOPITEMCOUNT] = [ '#type' => 'select', '#title' => t('Number of items'), @@ -59,7 +61,7 @@ function zg2_block_configure($delta) { ]; break; - case G2::DELTAWOTD: + case G2::DELTA_WOTD: // Convert nid to "title [<nid>]" even if missing. // @see autocomplete() $nid = variable_get(G2::VARWOTDENTRY, G2::DEFWOTDENTRY); @@ -75,7 +77,7 @@ function zg2_block_configure($delta) { '#type' => 'textfield', '#title' => t('Entry for the day'), '#maxlength' => 60, - '#autocomplete_path' => G2::PATHAUTOCOMPLETE, + '#autocomplete_path' => G2::PATH_AUTOCOMPLETE, '#required' => TRUE, // !title: we don't filter since this is input, not output, // and can contain normally escaped characters, to accommodate @@ -190,18 +192,18 @@ function zg2_block_configure($delta) { */ function zg2_block_info() { $blocks = []; - $blocks[G2::DELTARANDOM]['info'] = variable_get('g2_random_info', + $blocks[G2::DELTA_RANDOM]['info'] = variable_get('g2_random_info', t('G2 Random')); - $blocks[G2::DELTATOP]['info'] = variable_get('g2_top_info', t('G2 Top')); - $blocks[G2::DELTAWOTD]['info'] = variable_get('g2_wotd_info', + $blocks[G2::DELTA_TOP]['info'] = variable_get('g2_top_info', t('G2 Top')); + $blocks[G2::DELTA_WOTD]['info'] = variable_get('g2_wotd_info', t('G2 Word of the day')); // Else it couldn't be random. - $blocks[G2::DELTARANDOM]['cache'] = DRUPAL_NO_CACHE; + $blocks[G2::DELTA_RANDOM]['cache'] = DRUPAL_NO_CACHE; // Can contain unpublished nodes. - $blocks[G2::DELTATOP]['cache'] = DRUPAL_CACHE_PER_ROLE; + $blocks[G2::DELTA_TOP]['cache'] = DRUPAL_CACHE_PER_ROLE; // Not all roles have g2 view permission. - $blocks[G2::DELTAWOTD]['cache'] = DRUPAL_CACHE_PER_ROLE; + $blocks[G2::DELTA_WOTD]['cache'] = DRUPAL_CACHE_PER_ROLE; return $blocks; } @@ -210,16 +212,16 @@ function zg2_block_info() { */ function zg2_block_save($delta, $edit) { switch ($delta) { - case G2::DELTARANDOM: + case G2::DELTA_RANDOM: variable_set(G2::VARRANDOMSTORE, $edit[G2::VARRANDOMSTORE]); variable_set(G2::VARRANDOMTERMS, $edit[G2::VARRANDOMTERMS]); break; - case G2::DELTATOP: + case G2::DELTA_TOP: variable_set(G2::VARTOPITEMCOUNT, $edit[G2::VARTOPITEMCOUNT]); break; - case G2::DELTAWOTD: + case G2::DELTA_WOTD: // Convert "some title [<nid>, sticky]" to nid. $entry = $edit[G2::VARWOTDENTRY]; $matches = []; @@ -248,12 +250,12 @@ function zg2_block_save($delta, $edit) { */ function zg2_block_view($delta) { switch ($delta) { - case G2::DELTARANDOM: + case G2::DELTA_RANDOM: $block['subject'] = t('Random G2 glossary entry'); $block['content'] = theme('g2_random', ['node' => G2::random()]); break; - case G2::DELTATOP: + case G2::DELTA_TOP: $max = variable_get(G2::VARTOPITEMCOUNT, G2::DEFTOPITEMCOUNT); $block['subject'] = t( '@count most popular G2 glossary entries', @@ -263,7 +265,7 @@ function zg2_block_view($delta) { ['nodes' => G2::top($max, FALSE, TRUE)]); break; - case G2::DELTAWOTD: + case G2::DELTA_WOTD: $block['subject'] = variable_get(G2::VARWOTDTITLE, t('Word of the day in the G2 glossary')); $block['content'] = theme('g2_wotd', [ @@ -369,7 +371,7 @@ function zg2_field_extra_fields() { 'weight' => 99, ]; - $extra['node'][G2::NODETYPE] = [ + $extra['node'][G2::NODE_TYPE] = [ 'form' => [ 'expansion' => $expansion, 'period' => $period, @@ -430,7 +432,7 @@ function zg2_form(&$node, $form_state) { $node->title = check_plain( drupal_substr( \Drupal::requestStack()->getCurrentRequest()->query->get('q'), - drupal_strlen(G2::PATHNODEADD) + 1 + drupal_strlen(G2::PATH_NODE_ADD) + 1 ) ); } @@ -542,7 +544,7 @@ function zg2_load($nodes) { function zg2_menu() { $items = []; - $items[G2::PATHSETTINGS] = [ + $items[G2::PATH_SETTINGS] = [ 'title' => 'G2 glossary', 'description' => 'Define the various parameters used by the G2 module', 'page callback' => 'drupal_get_form', @@ -551,16 +553,16 @@ function zg2_menu() { ]; // AJAX autocomplete callback, so no menu entry. - $items[G2::PATHAUTOCOMPLETE] = [ + $items[G2::PATH_AUTOCOMPLETE] = [ 'page callback' => 'G2::autocomplete', - 'access arguments' => [G2::PERMVIEW], + 'access arguments' => [G2::PERM_VIEW], 'type' => MENU_CALLBACK, ]; - $items[G2::PATHWOTDFEED] = [ - 'title' => G2::TITLEWOTDFEED, + $items[G2::PATH_WOTD_FEED] = [ + 'title' => G2::TITLE_WOTD_FEED, 'page callback' => 'G2::wotd_feed', - 'access arguments' => [G2::PERMVIEW], + 'access arguments' => [G2::PERM_VIEW], 'type' => MENU_CALLBACK, ]; @@ -568,7 +570,7 @@ function zg2_menu() { $items['g2/wipe'] = [ 'page callback' => 'drupal_get_form', 'page arguments' => ['G2::referer_wipe_confirm_form'], - 'access arguments' => [G2::PERMADMIN], + 'access arguments' => [G2::PERM_ADMIN], 'type' => MENU_CALLBACK, ]; @@ -576,7 +578,7 @@ function zg2_menu() { $items['g2/wipe/%g2_nid'] = [ 'page callback' => 'drupal_get_form', 'page arguments' => ['G2::referer_wipe_confirm_form', 2], - 'access arguments' => [G2::PERMADMIN], + 'access arguments' => [G2::PERM_ADMIN], 'type' => MENU_CALLBACK, ]; @@ -584,7 +586,7 @@ function zg2_menu() { 'title' => 'Referers', 'page callback' => 'drupal_get_form', 'page arguments' => ['G2::referer_links', 1], - 'access arguments' => [G2::PERMADMIN], + 'access arguments' => [G2::PERM_ADMIN], 'type' => MENU_LOCAL_TASK, 'weight' => 2, ]; @@ -607,7 +609,7 @@ function zg2_nid_load($us_nid = 0) { $node = \Drupal::service('entity_type.manager') ->getStorage('node') ->load($us_nid); - if ($node->type != G2::NODETYPE) { + if ($node->type != G2::NODE_TYPE) { $node = NULL; } return $node; @@ -621,11 +623,11 @@ function zg2_node_access($node, $op, $account) { case 'create': case 'delete': case 'update': - $ret = user_access(G2::PERMADMIN, $account); + $ret = user_access(G2::PERM_ADMIN, $account); break; case 'view': - $ret = user_access(G2::PERMVIEW, $account); + $ret = user_access(G2::PERM_VIEW, $account); break; default: @@ -648,7 +650,7 @@ function zg2_node_access($node, $op, $account) { */ function zg2_node_info() { $ret = [ - G2::NODETYPE => [ + G2::NODE_TYPE => [ 'name' => t('G2 entry'), 'base' => 'g2', 'description' => t( @@ -676,7 +678,7 @@ function zg2_node_info() { */ function zg2_node_view($node, $view_mode, $langcode) { $q = \Drupal::requestStack()->getCurrentRequest()->query->get('q'); - if ($view_mode == 'rss' && $node->type == G2::NODETYPE && ($q == G2::PATHWOTDFEED)) { + if ($view_mode == 'rss' && $node->type == G2::NODE_TYPE && ($q == G2::PATH_WOTD_FEED)) { $node->created = variable_get(G2::VARWOTDDATE, \Drupal::time()->getRequestTime()); $node->name = filter_xss_admin( @@ -693,14 +695,14 @@ function zg2_node_view($node, $view_mode, $langcode) { */ function zg2_permission() { $ret = [ - G2::PERMADMIN => [ + G2::PERM_ADMIN => [ 'title' => t('Administer G2 entries'), 'description' => t( 'Access administrative information on G2 entries. This permission does not grant access to the module settings, which are controlled by the "administer site configuration" permission.' ), 'restrict access' => TRUE, ], - G2::PERMVIEW => [ + G2::PERM_VIEW => [ 'title' => t('View G2 entries'), 'description' => t('This permission allows viewing G2 entries, subject to additional node access control.'), ], @@ -732,7 +734,7 @@ function zg2_update($node) { function zg2_user_load($users) { $q = \Drupal::database()->select('node', 'n'); $result = $q->fields('n', ['nid', 'title', 'uid', 'type']) - ->condition('n.type', G2::NODETYPE) + ->condition('n.type', G2::NODE_TYPE) ->condition('n.status', 1) ->condition('n.uid', array_keys($users), 'IN') ->orderBy('n.changed', 'DESC') @@ -774,7 +776,7 @@ function zg2_view($node, $view_mode) { if (node_is_page($node)) { $bc = drupal_get_breadcrumb(); - $bc[] = l(G2::TITLEMAIN, + $bc[] = l(G2::TITLE_MAIN, $g2_home = variable_get(G2::VARPATHMAIN, G2::DEFPATHMAIN)); $initial = drupal_substr($title, 0, 1); $bc[] = l($title[0], $g2_home . '/initial/' . $initial); @@ -984,7 +986,7 @@ function ztheme_g2_wotd($variables) { $ret .= theme( 'feed_icon', [ - 'url' => url(G2::PATHWOTDFEED, ['absolute' => TRUE]), + 'url' => url(G2::PATH_WOTD_FEED, ['absolute' => TRUE]), // @todo Find a better title. 'title' => t('Glossary feed'), ] diff --git a/g2.module b/g2.module index 5039b40d483ee0b01dc4a721d452f828acb3b142..48532bb464000cab22c7662fac6eee911ebca49c 100644 --- a/g2.module +++ b/g2.module @@ -248,7 +248,7 @@ WHERE LOWER(n.title) LIKE '%s%%' ORDER BY n.sticky DESC, LOWER(n.title) ASC; SQL; $sq = db_rewrite_sql($sq); - $q = db_query_range($sq, $us_string, G2NODETYPE, 0, 10); + $q = db_query_range($sq, $us_string, G2::NODE_TYPE, 0, 10); while (is_object($o = db_fetch_object($q))) { $title = $o->sticky ? t('@title [@nid, sticky]', ['@title' => $o->title, '@nid' => $o->nid]) @@ -272,7 +272,7 @@ SQL; function _g2_comb_taxonomy($taxonomy = []) { // Filter tag vocabularies for non-G2 admins if this is requested. if (variable_get(G2::VARNOFREETAGGING, - G2::DEFNOFREETAGGING) && !user_access(G2::PERMADMIN)) { + G2::DEFNOFREETAGGING) && !user_access(G2::PERM_ADMIN)) { // No static cache here: there is already one in taxonomy_vocabulary_load(). $vocabs = []; @@ -345,7 +345,7 @@ function _g2_filter_process($entry) { // If we are not using a remote glossary. if ($target == G2::DEFREMOTENO) { - $target = G2PATHENTRIES; + $target = G2::PATH_ENTRIES; // No tooltips on remote glossaries: too slow. if (variable_get(G2::VARTOOLTIPS, G2::DEFTOOLTIPS)) { @@ -438,7 +438,7 @@ WHERE n.type = '%s' AND (n.status = 1) AND NOT (n.title = '%s' OR n.nid = %d); SQL; $sq = db_rewrite_sql($sq); - $q = \Drupal::database()->query($sq, G2NODETYPE, $random, $wotd_nid); + $q = \Drupal::database()->query($sq, G2::NODE_TYPE, $random, $wotd_nid); $n = db_result($q); // No need to mt_srand() since PHP 4.2. @@ -454,7 +454,7 @@ WHERE n.type = '%s' AND (n.status = 1) AND NOT (n.title = '%s' OR n.nid = %d); SQL; $sq = db_rewrite_sql($sq); - $q = db_query_range($sq, G2::NODETYPE, $random, $wotd_nid, $rand, 1); + $q = db_query_range($sq, G2::NODE_TYPE, $random, $wotd_nid, $rand, 1); $nid = db_result($q); $node = \Drupal::service('entity_type.manager') ->getStorage('node') @@ -674,11 +674,11 @@ function g2_access($op /* , $node, $account */) { case 'create': case 'delete': case 'update': - $ret = user_access(G2PERMADMIN); + $ret = user_access(G2::PERM_ADMIN); break; case 'view': - $ret = user_access(G2PERMVIEW); + $ret = user_access(G2::PERM_VIEW); break; } @@ -743,7 +743,7 @@ function g2_block($op = 'list', $delta = 0, $edit = []) { '#type' => 'textfield', '#title' => t('Entry for the day'), '#maxlength' => 60, - '#autocomplete_path' => G2PATHAUTOCOMPLETE, + '#autocomplete_path' => G2::PATH_AUTOCOMPLETE, '#required' => TRUE, // !title: we don't filter since this is input, not output, // and can contain normally escaped characters, to accommodate @@ -953,9 +953,9 @@ SQL; $sq = db_rewrite_sql($sq); $min_status = user_access('administer nodes') - ? NODE_NOT_PUBLISHED - : NODE_PUBLISHED; - $q = \Drupal::database()->query($sq, G2NODETYPE, $min_status, $title); + ? Node::NOT_PUBLISHED + : Node::PUBLISHED; + $q = \Drupal::database()->query($sq, G2::NODE_TYPE, $min_status, $title); $nodes = []; while (is_object($node = db_fetch_object($q))) { $nodes[$node->nid] = \Drupal::service('entity_type.manager') @@ -1013,12 +1013,12 @@ function g2_form(&$node, $form_state) { $node->title = check_plain( drupal_substr( $q, - drupal_strlen(G2PATHNODEADD) + 1 + drupal_strlen(G2::PATH_NODE_ADD) + 1 ) ); } - $type = node_get_types('type', G2NODETYPE); + $type = node_get_types('type', G2::NODE_TYPE); $form = []; $form['content'] = [ '#type' => 'fieldset', @@ -1123,7 +1123,7 @@ function g2_load($node) { function g2_menu() { $items = []; - $items[G2PATHSETTINGS] = [ + $items[G2::PATH_SETTINGS] = [ 'title' => 'G2 glossary', 'description' => 'Define the various parameters used by the G2 module', 'file' => 'g2.admin.inc', @@ -1133,16 +1133,16 @@ function g2_menu() { ]; // AJAX autocomplete callback, so no menu entry. - $items[G2PATHAUTOCOMPLETE] = [ + $items[G2::PATH_AUTOCOMPLETE] = [ 'page callback' => '_g2_autocomplete', - 'access arguments' => [G2PERMVIEW], + 'access arguments' => [G2::PERM_VIEW], 'type' => MENU_CALLBACK, ]; - $items[G2PATHWOTDFEED] = [ - 'title' => G2TITLEWOTDFEED, + $items[G2::PATH_WOTD_FEED] = [ + 'title' => G2::TITLE_WOTD_FEED, 'page callback' => '_g2_wotd_feed', - 'access arguments' => [G2PERMVIEW], + 'access arguments' => [G2::PERM_VIEW], 'type' => MENU_CALLBACK, ]; @@ -1150,7 +1150,7 @@ function g2_menu() { $items['g2/wipe'] = [ 'page callback' => 'drupal_get_form', 'page arguments' => ['g2_referer_wipe_confirm_form'], - 'access arguments' => [G2PERMADMIN], + 'access arguments' => [G2::PERM_ADMIN], 'type' => MENU_CALLBACK, ]; @@ -1158,7 +1158,7 @@ function g2_menu() { $items['g2/wipe/%g2_node'] = [ 'page callback' => 'drupal_get_form', 'page arguments' => ['g2_referer_wipe_confirm_form', 2], - 'access arguments' => [G2PERMADMIN], + 'access arguments' => [G2::PERM_ADMIN], 'type' => MENU_CALLBACK, ]; @@ -1166,7 +1166,7 @@ function g2_menu() { 'title' => 'Referers', 'page callback' => 'drupal_get_form', 'page arguments' => ['_g2_referer_links', 1], - 'access arguments' => [G2PERMADMIN], + 'access arguments' => [G2::PERM_ADMIN], 'type' => MENU_LOCAL_TASK, 'weight' => 2, ]; @@ -1179,7 +1179,7 @@ function g2_menu() { */ function g2_node_info() { $ret = [ - G2NODETYPE => [ + G2::NODE_TYPE => [ 'name' => t('G2 entry'), 'module' => 'g2', 'description' => t( @@ -1207,7 +1207,7 @@ function g2_node_load($us_nid = 0) { else { $node = reset($us_nid); } - if ($node->type != G2::NODE_TYPE) { + if ($node->getEntityTypeId() != G2::NODE_TYPE) { $node = NULL; } @@ -1228,8 +1228,8 @@ function g2_node_load($us_nid = 0) { */ function g2_nodeapi(&$node, $op) { $q = \Drupal::requestStack()->getCurrentRequest()->query->get('q'); - if (($op == 'rss item') && ($node->type == G2NODETYPE) - && ($q == G2PATHWOTDFEED) + if (($op == 'rss item') && ($node->type == G2::NODE_TYPE) + && ($q == G2::PATH_WOTD_FEED) ) { $node->created = variable_get(G2::VARWOTDDATE, time()); $node->name = filter_xss_admin( @@ -1249,13 +1249,13 @@ function g2_nodeapi(&$node, $op) { function g2_perm() { $ret = array_keys( [ - G2PERMADMIN => [ + G2::PERM_ADMIN => [ 'title' => t('Administer G2 entries'), 'description' => t( 'Access administrative information on G2 entries. This permission does not grant access to the module settings, which are controlled by the "administer site configuration" permission.' ), ], - G2PERMVIEW => [ + G2::PERM_VIEW => [ 'title' => t('View G2 entries'), 'description' => t('This permission allows viewing G2 entries, subject to additional node access control.'), ], @@ -1327,7 +1327,7 @@ function g2_referer_wipe_confirm_form( } else { $question = t('Are you sure to want to erase the referer information on all G2 entries ?'); - $cancel = G2PATHSETTINGS; + $cancel = G2::PATH_SETTINGS; } $ret = confirm_form( @@ -1353,7 +1353,7 @@ function g2_referer_wipe_confirm_form_submit($form, &$form_state) { _g2_referer_wipe(); \Drupal::messenger() ->addStatus(t('Referer information has been erased on all G2 entries')); - $form_state['redirect'] = G2PATHSETTINGS; + $form_state['redirect'] = G2::PATH_SETTINGS; } /** @@ -1379,7 +1379,7 @@ WHERE n.type = '%s' AND n.status = 1 AND n.uid = %d ORDER BY n.changed DESC, n.created DESC; SQL; $sq = db_rewrite_sql($sq); - $q = db_query_range($sq, G2NODETYPE, $account->uid, 0, 10); + $q = db_query_range($sq, G2::NODE_TYPE, $account->uid, 0, 10); $account->nodes = []; while (is_object($o = db_fetch_object($q))) { $account->nodes[] = [ @@ -1420,10 +1420,10 @@ function g2_view(&$node, $teaser = FALSE, $page = FALSE) { if ($page) { $bc = drupal_get_breadcrumb(); - $bc[] = l(G2TITLEMAIN, + $bc[] = l(G2::TITLE_MAIN, $g2_home = variable_get(G2::VARPATHMAIN, G2::DEFPATHMAIN)); $initial = drupal_substr($title, 0, 1); - $bc[] = l($title[0], G2PATHINITIAL . '/' . $initial); + $bc[] = l($title[0], G2::PATH_INITIAL . '/' . $initial); unset($initial); drupal_set_breadcrumb($bc); _g2_override_site_name(); @@ -1673,7 +1673,7 @@ function theme_g2_wotd(Node $node = NULL) { if (variable_get(G2::VARWOTDFEEDLINK, G2::DEFWOTDFEEDLINK)) { $ret .= theme( 'feed_icon', - url(G2PATHWOTDFEED, ['absolute' => TRUE]), + url(G2::PATH_WOTD_FEED, ['absolute' => TRUE]), t('A word a day in your RSS reader') ); } diff --git a/src/Controller/Main.php b/src/Controller/Main.php index fc0a8af135063da0dfb694ae2a63807920008c85..37e8a7044e7d2311930190825f765ba25f121e42 100644 --- a/src/Controller/Main.php +++ b/src/Controller/Main.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\g2\Alphabar; use Drupal\g2\G2; +use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -87,7 +88,7 @@ class Main implements ContainerInjectionInterface { if (!$node->body->isEmpty()) { // Simulate publishing. - $node->setPublished(NODE_PUBLISHED); + $node->setPublished(Node::PUBLISHED); // Remove the title : we used it for the page title. $node->setTitle(NULL); $builder = $this->etm->getViewBuilder($node->getEntityTypeId()); diff --git a/src/G2.php b/src/G2.php index 81afa287724ecfe6920bf02200b954dee7716a75..9b7c2f58a03f9d4d060aa1fbf73697f13792286a 100644 --- a/src/G2.php +++ b/src/G2.php @@ -59,6 +59,65 @@ class G2 { */ const DELTA_WOTD = 'wotd'; + // Constants in this group are only listed to remove WSODs, but they still + // need the associated logic to be converted from variables to config. + const VARNOFREETAGGING = 'g2-no-freetagging'; + const DEFNOFREETAGGING = FALSE; + const VARREMOTEG2 = 'g2-remote'; + const DEFREMOTEG2 = FALSE; + const DEFREMOTENO = ''; + const VARTOOLTIPS = 'g2-tooltips'; + const DEFTOOLTIPS = FALSE; + const VARPAGETITLE = 'g2-page-title'; + const DEFPAGETITLE = TRUE; + const VARWOTDENTRY = 'g2-wotd-entry'; + const DEFWOTDENTRY = ''; + const VARRANDOMSTORE = 'g2-random-store'; + const DEFRANDOMSTORE = TRUE; + const VARRANDOMENTRY = 'g2-random-entry'; + const DEFRANDOMENTRY = ''; + const VARRANDOMTERMS = 'g2-random-terms'; + const DEFRANDOMTERMS = []; + const VARWOTDTERMS = 'g2-wotd-terms'; + const DEFWOTDTERMS = FALSE; + // Default is DEFWOTDTITLE. + const VARWOTDFEEDTITLE = 'g2-wotd-feed-title'; + const VARWOTDTITLE = 'g2-wotd-title'; + const DEFWOTDTITLE = ''; + const VARWOTDFEEDDESCR = 'g2-wotd-feed-description'; + const DEFWOTDFEEDDESCR = ''; + const VARWOTDBODYSIZE = 'g2-wotd-body-size'; + const DEFWOTDBODYSIZE = 100; + const VARWOTDAUTOCHANGE = 'g2-wotd-auto-change'; + const DEFWOTDAUTOCHANGE = TRUE; + const VARWOTDFEEDLINK = 'g2-wotd-feed-link'; + const DEFWOTDFEEDLINK = TRUE; + const VARWOTDFEEDAUTHOR = 'g2-wotd-feed-author'; + const DEFWOTDFEEDAUTHOR = ''; + // Uses mktime() for default. + const VARWOTDDATE = 'g2-wotd-date'; + const VARPATHMAIN = 'g2-path-main'; + const DEFPATHMAIN = 'g2.main'; + const VARHIDDENTITLE = 'g2-hidden-title'; + const DEFHIDDENTITLE = FALSE; + const VARLOGREFERRERS = 'g2-log-referrers'; + const DEFLOGREFERRERS = TRUE; + const VARTOPITEMCOUNT = 'g2-top-item-count'; + const DEFTOPITEMCOUNT = 5; + + // Constants in this group are only listed to remove WSODs, but they still + // need to be converting from hook_menu to Symfony routing. + const PATH_AUTOCOMPLETE = 'g2/autocomplete'; + const PATH_ENTRIES = 'g2/entries'; + const PATH_INITIAL = 'g2/initial'; + const PATH_NODE_ADD = 'node/add/g2'; + const PATH_SETTINGS = 'g2/admin/settings'; + const PATH_WOTD_FEED = 'g2/wotd/feed'; + + + const TITLE_MAIN = 'Glossary'; + const TITLE_WOTD_FEED = 'Word of the day'; + /** * Encodes terminal path portions for G2. * diff --git a/src/Tests/access.test b/src/Tests/access.test index fececcf4e2f1f49291d594e769a3d959886627e3..b061b0dac855c2ae0152c63e6730bd8281b194be 100644 --- a/src/Tests/access.test +++ b/src/Tests/access.test @@ -3,6 +3,7 @@ namespace Drupal\g2\Tests; use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\g2\G2; /** * Class G2AccessTest contains the G2 access tests. @@ -25,19 +26,19 @@ class G2AccessTest extends DrupalWebTestCase { public function testAdminSettingsAccess() { $account = $this->drupalCreateUser(['access content']); $this->drupalLogin($account); - $this->drupalGet(G2PATHSETTINGS); + $this->drupalGet(G2::PATH_SETTINGS); $this->assertResponse(403, $this->t('Access to settings denied to normal users')); $this->drupalLogout(); - $account = $this->drupalCreateUser([G2PERMVIEW]); + $account = $this->drupalCreateUser([G2::PERM_VIEW]); $this->drupalLogin($account); - $this->drupalGet(G2PATHSETTINGS); + $this->drupalGet(G2::PATH_SETTINGS); $this->assertResponse(403, $this->t('Access to settings denied to users with G2 limited perms')); $this->drupalLogout(); $account = $this->drupalCreateUser(['administer site configuration']); $this->drupalLogin($account); - $this->drupalGet(G2PATHSETTINGS); + $this->drupalGet(G2::PATH_SETTINGS); $this->assertResponse(200, $this->t('Access to settings granted to G2 admins')); $this->drupalLogout(); } diff --git a/src/Tests/issues.test b/src/Tests/issues.test index 92c3f7505f2311c0a8ba17789deb6e1e245a1153..ef45b0b8ec2d6cd54b3570d4aa5d1d61d51a67cc 100644 --- a/src/Tests/issues.test +++ b/src/Tests/issues.test @@ -2,6 +2,8 @@ namespace Drupal\g2\Tests; +use Drupal\g2\G2; + /** * Class G2IssuesTest contains G2 non-regression tests. * @@ -35,7 +37,7 @@ class G2IssuesTest extends DrupalWebTestCase { */ public function setUp() { parent::setUp('taxonomy', 'g2'); - $this->admin = $this->drupalCreateUser([G2PERMVIEW, G2PERMADMIN]); + $this->admin = $this->drupalCreateUser([G2::PERM_VIEW, G2::PERM_ADMIN]); $this->root = $this->drupalCreateUser(module_invoke_all('perm')); } @@ -100,7 +102,7 @@ class G2IssuesTest extends DrupalWebTestCase { $fid = $this->createG2Format($format_name, $filter_name); $settings = [ - 'type' => G2NODETYPE, + 'type' => G2::NODE_TYPE, 'title' => 'CSS', 'body' => 'A style language for <dfn>HTML</dfn>', 'format' => $fid,