44 * Provides custom blocks for Backdropcms.org
55 */
66
7+ /**
8+  * Modules included in core.
9+  */
10+ define('MODULES_CORE', 75);
11+ 
12+ /**
13+  * Percent of top Drupal Modules ready.
14+  */
15+ define('MODULES_TOP', 97);
16+ 
17+ /**
18+  * Projects available.
19+  */
20+ define('MODULES_AVAILABLE', 1300);
21+ 
22+ 
723/**
824 * Implements hook_block_info().
925 */
1026function borg_blocks_block_info() {
11-   // New home page blocks
12-   $blocks['resources'] = array(
13-     'info' => t('Get Started with Backdrop'),
14-     'description' => t('Home page: Resources section'),
15-   );
27+   // New home page block.
1628  $blocks['community'] = array(
1729    'info' => t('Join the community'),
1830    'description' => t('Home page: Community section'),
@@ -57,90 +69,17 @@ function borg_blocks_block_view($delta = '', $settings = array(), $contexts = ar
5769  $block = array();
5870
5971  switch ($delta) {
60-     case 'resources':
61-       $block_title = '<div class="visual-tag">Resources</div>';
62-       $block_title .= '<div class="b-resources__title">Get Started with Backdrop</div>';
63- 
64-       $copy = t('Our documentation is written and maintained for people, by people, just like our code.');
65- 
66-       $resource_links = array(
67-         'api' => array(
68-           'url' => 'https://api.backdropcms.org',
69-           'name' => t('Documentation & API'),
70-           'more' => t('Find complete documentation for people who are using Backdrop CMS.'),
71-         ),
72-         'forum' => array(
73-           'url' => 'https://forum.backdropcms.org',
74-           'name' => t('Visit the Backdrop Forum'),
75-           'more' => t('Visit our forum with questions. All answers will be provided with dignity and respect.'),
76-         ),
77-         'hours' => array(
78-           'url' => '/support/meetings',
79-           'name' => t('Join Office Hours'),
80-           'more' => t('Visit our virtual office hours every Wednesday from 12-2 pm EST'),
81-         ),
82-       );
83-       $items = array();
84-       foreach ($resource_links as $resource) {
85-         $link_content = '<div class="b-resources__resource-name">' . $resource['name'] . '</div>';
86-         $link_content .= $resource['more'];
87-         $items[] = l($link_content, $resource['url'], array('html' => TRUE));
88-       }
89-       $attributes = array('class' => array('b-resources__links'));
90-       $resources = theme('item_list', array('items' => $items, 'attributes' => $attributes));
91- 
92-       $block['subject'] = $block_title;
93-       $block['content'] = array(
94-         'copy' => $copy,
95-         'resources' => $resources,
96-       );
97-       break;
9872
9973    case 'community':
10074      $block_title = '<div class="visual-tag">Get Involved</div>';
10175      $block_title .= '<div class="b-community__title">Join the community</div>';
102- 
103-       $copy = t('Whether you’re a developer, designer, or enthusiast, your contributions make Backdrop better for everyone. Join a vibrant open source community.');
104- 
105-       $button_attributes = array(
106-         'class' => array('borg__button', 'borg__button--primary', 'borg__button--right-arrow'));
107-       $options = array('attributes' => $button_attributes);
108-       $button = l(t('Join the conversation'), 'https://forum.backdropcms.org', $options);
109- 
110-       $image_path = backdrop_get_path('module', 'borg_blocks') . '/images/';
111-       $photo_files = array(
112-         'Backdrop-BDay-Nantes.jpg',
113-         'Backdrop-BDay-Oakland.jpg',
114-         'Justin-Laryn.jpg',
115-         'migrating-backdrop-on-pantheon.jpg',
116-         'tcbackdrop.jpg',
117-       );
118-       $items = array();
119-       foreach ($photo_files as $filename) {
120-         $items[] = theme('image', array('path' => $image_path . $filename));
121-       }
122-       $attributes = array('class' => array('b-community__photos'));
123-       $photos = theme('item_list', array('items' => $items, 'attributes' => $attributes));
124- 
12576      $block['subject'] = $block_title;
126-       $block['content'] = array(
127-         'copy' => $copy,
128-         'photos' => $photos,
129-         'button' => $button,
130-       );
77+       $block['content'] = borg_blocks_community($settings);
13178      break;
13279
13380    case 'branding':
134-       $options = array('attributes' => array('class' => array('site-name')));
135-       $output = l(t('backdrop'), '', $options);
136- 
137-       $uri = backdrop_get_path('module', 'borg_blocks') . '/images/logo.png';
138-       $image = theme('image', array('uri' => $uri, 'alt' => t('Backdrop CMS Logo')));
139-       $options = array('html' => TRUE, 'attributes' => array('class' => array('logo'), 'title' => t('Backdrop CMS Home')));
140-       $output .= l($image, '', $options);
141- 
14281      $block['subject'] = NULL;
143-       $block['content'] = $output ;
82+       $block['content'] = borg_blocks_branding($settings) ;
14483      break;
14584
14685    case 'tagline':
@@ -150,7 +89,6 @@ function borg_blocks_block_view($delta = '', $settings = array(), $contexts = ar
15089
15190    case 'greeting':
15291      global $user;
153- 
15492      $block['subject'] = NULL;
15593      if ($user->uid) {
15694        $block['content'] = t('Hi !name!', array('!name'  => theme('username', array('account' => $user))));
@@ -163,7 +101,6 @@ function borg_blocks_block_view($delta = '', $settings = array(), $contexts = ar
163101      break;
164102
165103    case 'upgrade':
166- 
167104      $block['subject'] = t('Upgrade from Drupal 7');
168105      $block['content'] = borg_blocks_upgrade($settings);
169106      break;
@@ -184,6 +121,56 @@ function borg_blocks_block_view($delta = '', $settings = array(), $contexts = ar
184121  return $block;
185122}
186123
124+ /**
125+  * Block callback.
126+  */
127+ function borg_blocks_community($settings) {
128+   $copy = t('Whether you’re a developer, designer, or enthusiast, your contributions make Backdrop better for everyone. Join a vibrant open source community.');
129+ 
130+   $button_attributes = array(
131+     'class' => array('borg__button', 'borg__button--primary', 'borg__button--right-arrow'));
132+   $options = array('attributes' => $button_attributes);
133+   $button = l(t('Join the conversation'), 'https://forum.backdropcms.org', $options);
134+ 
135+   $image_path = backdrop_get_path('module', 'borg_blocks') . '/images/';
136+   $photo_files = array(
137+     'Backdrop-BDay-Nantes.jpg',
138+     'Backdrop-BDay-Oakland.jpg',
139+     'Justin-Laryn.jpg',
140+     'migrating-backdrop-on-pantheon.jpg',
141+     'tcbackdrop.jpg',
142+   );
143+   $items = array();
144+   foreach ($photo_files as $filename) {
145+     $items[] = theme('image', array('path' => $image_path . $filename));
146+   }
147+   $attributes = array('class' => array('b-community__photos'));
148+   $photos = theme('item_list', array('items' => $items, 'attributes' => $attributes));
149+ 
150+   return array(
151+     'copy' => $copy,
152+     'photos' => $photos,
153+     'button' => $button,
154+   );
155+ }
156+ 
157+ /**
158+  * Block callback.
159+  */
160+ function borg_blocks_branding($settings) {
161+   $options = array('attributes' => array('class' => array('site-name')));
162+   $output = l(t('backdrop'), '', $options);
163+ 
164+   $uri = backdrop_get_path('module', 'borg_blocks') . '/images/logo.png';
165+   $image = theme('image', array('uri' => $uri, 'alt' => t('Backdrop CMS Logo')));
166+   $options = array('html' => TRUE, 'attributes' => array('class' => array('logo'), 'title' => t('Backdrop CMS Home')));
167+   $output .= l($image, '', $options);
168+   return $output;
169+ }
170+ 
171+ /**
172+  * Block callback.
173+  */
187174function borg_blocks_tagline($settings) {
188175  $version = check_plain($settings['version']);
189176
@@ -250,6 +237,9 @@ function borg_blocks_tagline($settings) {
250237  return $output;
251238}
252239
240+ /**
241+  * Block callback.
242+  */
253243function borg_blocks_audiences($settings) {
254244  $button_class_name = 'borg__button';
255245
@@ -304,26 +294,22 @@ function borg_blocks_audiences($settings) {
304294  return $output;
305295}
306296
297+ /**
298+  * Block callback.
299+  */
307300function borg_blocks_upgrade($settings) {
308-   // Included in core
309-   $modules_core = 75;
310-   // Percent ready
311-   $modules_top = 97;
312-   // Number of modules
313-   $projects_available = 1100;
314- 
315301  $path = backdrop_get_path('module', 'borg_blocks');
316302  $button = l(t('Upgrade from Drupal'), 'node/4967', array('attributes' => array('class' => array('button'))));
317303
318-   $included_modules = l(t("$modules_core + included modules"), 'https://docs.backdropcms.org/documentation/features-added-to-core');
304+   $included_modules = l(t("MODULES_CORE + included modules"), 'https://docs.backdropcms.org/documentation/features-added-to-core');
319305  $included_modules_icon = '<img src="/' . $path . '/images/gift--white--256.png" />';
320306  $included_modules_icon_link = l($included_modules_icon, 'https://docs.backdropcms.org/documentation/features-added-to-core', array('html' => TRUE, 'attributes' => array('class' => array('icon'))));
321307
322-   $top_modules = l(t("$modules_top % of top modules"), 'https://docs.backdropcms.org/documentation/top-100-drupal-7-modules');
308+   $top_modules = l(t("MODULES_TOP % of top modules"), 'https://docs.backdropcms.org/documentation/top-100-drupal-7-modules');
323309  $top_modules_icon = '<img src="/' . $path . '/images/check-circle--white--256.png" />';
324310  $top_modules_icon_link = l($top_modules_icon, 'https://docs.backdropcms.org/documentation/top-100-drupal-7-modules', array('html' => TRUE, 'attributes' => array('class' => array('icon'))));
325311
326-   $total_addons = l(t("$projects_available + total add-ons"), 'node/1686');
312+   $total_addons = l(t("MODULES_AVAILABLE + total add-ons"), 'node/1686');
327313  $total_addons_icon = '<img src="/' . $path . '/images/puzzle-piece--white--256.png" />';
328314  $total_addons_icon_link = l($total_addons_icon, 'node/1686', array('html' => TRUE, 'attributes' => array('class' => array('icon'))));
329315
@@ -332,17 +318,17 @@ function borg_blocks_upgrade($settings) {
332318  $output .= '    <div class="col-md-4 column">';
333319  $output .=        $included_modules_icon_link;
334320  $output .= '      <h3>' . $included_modules . '</h3>';
335-   $output .= '      <p>' . t("More than $modules_core  Drupal modules have been merged into Backdrop core.") . '</p>';
321+   $output .= '      <p>' . t("More than MODULES_CORE  Drupal modules have been merged into Backdrop core.") . '</p>';
336322  $output .= '    </div>';
337323  $output .= '    <div class="col-md-4 column">';
338324  $output .=        $top_modules_icon_link;
339325  $output .= '      <h3>' . $top_modules . '</h3>';
340-   $output .= '      <p>' . t("Of the top 100 Drupal 7 modules, $modules_top  of them are ready for Backdrop CMS.") . '</p>';
326+   $output .= '      <p>' . t("Of the top 100 Drupal 7 modules, MODULES_TOP  of them are ready for Backdrop CMS.") . '</p>';
341327  $output .= '    </div>';
342328  $output .= '    <div class="col-md-4 column">';
343329  $output .=        $total_addons_icon_link;
344330  $output .= '      <h3>' . $total_addons . '</h3>';
345-   $output .= '      <p>' . t("More than $projects_available  modules, themes, and layouts are available for use today.") . '</p>';
331+   $output .= '      <p>' . t("More than MODULES_AVAILABLE  modules, themes, and layouts are available for use today.") . '</p>';
346332  $output .= '    </div>';
347333  $output .= '  </div>';
348334  $output .= '</div>';
@@ -398,7 +384,6 @@ function borg_blocks_form_supporter_node_form_alter(&$form, &$form_state, $form_
398384/**
399385 * Prepare variables for Block templates.
400386 *
401-  * @see block--borg-blocks--resources.tpl.php
402387 * @see block--borg-blocks--community.tpl.php
403388 */
404389function borg_blocks_preprocess_block(&$variables){
@@ -408,9 +393,5 @@ function borg_blocks_preprocess_block(&$variables){
408393      $variables['photos'] = $variables['content']['photos'];
409394      $variables['button'] = $variables['content']['button'];
410395    }
411-     elseif ($variables['block']->delta == 'resources') {
412-       $variables['copy'] = $variables['content']['copy'];
413-       $variables['resources'] = $variables['content']['resources'];
414-     }
415396  }
416397}
0 commit comments