Pārlūkot izejas kodu

simplenews prepopulation improvement

Bachir Soussi Chiadmi 11 gadi atpakaļ
vecāks
revīzija
9d2fee4ddd

+ 53 - 17
materio_admin.module

@@ -1,4 +1,4 @@
-<?php 
+<?php
 
 
 /**
@@ -17,6 +17,43 @@ function materio_admin_permission() {
   );
 }
 
+/**
+ * Implements hook_menu().
+ */
+function materio_admin_menu() {
+
+  if(module_exists('simplenews')){
+    $cats = simplenews_category_list();
+    dsm($cats, 'cats');
+    foreach ($cats as $tid => $name) {
+      // $items['node/%node/simplenews'] = array(
+      //   'title' => 'Newsletter',
+      //   'type' => MENU_LOCAL_TASK,
+      //   'access callback' => 'simplenews_node_tab_access',
+      //   'access arguments' => array(1),
+      //   'page callback' => 'simplenews_node_tab_page',
+      //   'page arguments' => array(1),
+      //   'context' => MENU_LOCAL_TASK,
+      //   'file' => 'includes/simplenews.admin.inc',
+      //   'weight' => 2,
+      // );
+      $items['node/add/simplenews/'.$tid] = array(
+        'title' => $name,
+        'title callback' => 'check_plain',
+        'page callback' => 'node_add',
+        'page arguments' => array('simplenews'),
+        'access callback' => 'node_access',
+        'access arguments' => array('create', 'simplenews'),
+        // 'description' => $type->description,
+        'file path' => drupal_get_path('module', 'node'),
+        'file' => 'node.pages.inc',
+        'options' => array('query'=>array('cat'=>$tid))
+      );
+    }
+  }
+  return $items;
+}
+
 /**
  * Implements hook_menu_alter().
  */
@@ -27,17 +64,25 @@ function materio_admin_menu_alter(&$items){
     $items['admin/people']['access arguments'] = array('access default users list');
     // dsm($items['admin/people']);
   }
-    
+
   if(isset($items['admin/people/expiration'])){
     $items['admin/people/expiration']['access arguments'] = array('access default UC roles expiration list');
     // dsm($items['admin/people/expiration']);
   }
-    
+
   # deactivate default home page
   $items['node']['access callback'] = FALSE;
-}
 
+  // if(isset($items['admin/content/add/simplenews'])){
+    // delete($items['admin/content/add/simplenews']);
+  //   $cats = simplenews_category_list();
+  //   dsm($cats, 'cats');
+  //   foreach ($cats as $tid => $name) {
+  //     $items['admin/content/add/simplenews/'.$tid]
+  //   }
+  // }
 
+}
 
 /**
   * Implements hook_form_alter().
@@ -51,29 +96,20 @@ function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $fo
   if(!$form['nid']['#value']){
     if(isset($_GET['cat'])){
       $cat = $_GET['cat'];
-      switch($cat){
-        case 6374:
-          $template = 'daily';
-          break;
-        case 6274:
-          $template = 'news';
-          break;
-      } 
 
       // prepopulate type of news
       $form['field_simplenews_term']['und']['#default_value'] = $cat;
       $form['field_simplenews_term']['und']['#disabled'] = true;
 
       // change default template regarding type of news
-      $form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodeBodyTemplate($template);
-      $form['body']['und'][0]['#rows'] = 50;  
+      $form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodeBodyTemplate($cat);
+      $form['body']['und'][0]['#rows'] = 50;
     }
   }else{
     $form['field_simplenews_term']['und']['#disabled'] = true;
   }
-
 }
 
-function materio_admin_getSimplenewsNodeBodyTemplate($template){
-  return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_'.$template.'_node_template.html');
+function materio_admin_getSimplenewsNodeBodyTemplate($cat){
+  return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_'.$cat.'_node.html');
 }

+ 0 - 0
templates/simplenews_news_node_template.html → templates/simplenews_6274_node.html


+ 0 - 0
templates/simplenews_daily_node_template.html → templates/simplenews_6374_node.html


+ 143 - 0
templates/simplenews_6585_node.html

@@ -0,0 +1,143 @@
+<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
+  <tbody>
+    <tr>
+      <td style="padding: 37px 0; background-color: #eeeeee;" align="center" bgcolor="#eeeeee">
+        <!-- #nl_container -->
+        <table style="margin: 0; border: 1px solid #dddddd; color: #444444; font-family: arial; font-size: 12px; border-color: #dddddd; background-color: #ffffff;" width="600" border="0" cellspacing="0" cellpadding="0">
+          <tbody>
+            <tr>
+              <td>
+                <img src="/sites/default/files/uploaderuneimage.png" width="600" height="400">
+                <br>
+                <!-- #nl_content -->
+                <table style="margin: 0; border-collapse: collapse;" width="100%" border="0" cellspacing="0" cellpadding="0">
+                  <tbody>
+                    <tr>
+                      <td style="color: #444444; font-family: arial; font-size: 12px; border-color: #dddddd; background-color: #ffffff; padding: 5px 0;" align="left">
+                        <table style="margin: 0 0 0 10px; border-collapse: collapse; color: #444444; font-family: arial; font-size: 12px; border-color: #dddddd; background-color: #ffffff;">
+                          <tbody>
+                            <tr>
+                              <td style="vertical-align: top; padding: 5px 0;" width="580">
+                                <table style="border-collapse: collapse; width: 565px; color: #444444; font-family: arial; font-size: 12px; border-color: #dddddd; background-color: #ffffff;" width="565" cellspacing="0" cellpadding="0">
+                                  <tbody>
+                                    <tr>
+                                      <td style="padding: 5px 0 5px 5px; line-height: normal; color: #444444; font-family: arial; font-size: 12px; border-color: #dddddd; background-color: #ffffff;">
+                                        <p style="color: #444444; text-align: left; ;margin: 0 0 10px; line-height: 1.3em;">
+                                          <span style="color: #444444; font-family: arial, helvetica, sans-serif;">
+                                            <strong>
+                                              ZE DAILY MATERIO'
+                                            </strong>
+                                          </span>
+                                        </p>
+                                        <p style="color: #444444; ;margin: 0 0 10px; line-height: 1.3em;">
+                                          <strong>
+                                            le titre en fr
+                                          </strong>
+                                          <br>
+                                          Toute une série de matières recyclées sous vos pieds, car ces tapis sont tissés avec des chambres à air usagées, des papiers de bonbons minutieusement filés, de vieux journaux et magazines tressés ou d'autres matières recyclées surprenantes. Certains tapis de cette gamme peuvent même aller à l'extérieur.
+                                        </p>
+                                        <div>
+                                          &nbsp;
+                                        </div>
+                                        <p style="color: #444444; ;margin: 0 0 10px; line-height: 1.3em;">
+                                          <span style="color: #696969;">
+                                            <em>
+                                              <strong>
+                                                The english title&nbsp;
+                                              </strong>
+                                            </em>
+                                          </span>
+                                          <br>
+                                          <span style="color: #808080;">
+                                            <em>
+                                              A wide range of beautiful carpets made out of surprising recycled materials: recycled candy wrappers, recycled tires and bike tubes, different recycled fibers and recycled newspaper! Some of them can even be used outside.
+                                            </em>
+                                          </span>
+                                        </p>
+                                      </td>
+                                    </tr>
+                                  </tbody>
+                                </table>
+                              </td>
+                            </tr>
+                          </tbody>
+                        </table>
+                        <table style="margin: 0 0 0 10px; border-collapse: collapse; color: #444444; font-family: arial; font-size: 12px; border-color: #dddddd; background-color: #ffffff;">
+                          <tbody>
+                            <tr>
+                              <td style="vertical-align: top; padding: 5px 0;" width="580">
+                                <table style="border-collapse: collapse; width: 565px; color: #444444; font-family: arial; font-size: 12px; border-color: #dddddd; background-color: #ffffff;" width="565" cellspacing="0" cellpadding="0">
+                                  <tbody>
+                                    <tr>
+                                      <td style="padding: 5px 0 5px 5px; line-height: normal;">
+                                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
+                                          <tbody>
+                                            <tr>
+                                              <td>
+                                                <table border="0" cellspacing="0" cellpadding="0" align="left">
+                                                  <tbody>
+                                                    <tr>
+                                                      <td>
+                                                        <table style="border-collapse: collapse; align: left;" cellspacing="0" cellpadding="0" align="left">
+                                                          <tbody>
+                                                            <tr>
+                                                              <td style="padding: 2px; margin: 0; vertical-align: top;">
+                                                                <a href="http://www.facebook.com/sharer.php?u=http://70u.r.mailjet.com/nl/98y/xzkv1.html" target="_blank" style="display: block; border: none; text-decoration: none;">
+                                                                  <img src="http://www.mailjet.com/images/theme/v1/icons/ico_social_facebook.png" alt="Facebook" style="vertical-align: top; border: none;">
+                                                                </a>
+                                                              </td>
+                                                              <td style="padding: 2px; margin: 0; vertical-align: top;">
+                                                                <a href="http://twitter.com/share?url=http://70u.r.mailjet.com/nl/98y/xzkv1.html" target="_blank" style="display: block; border: none; text-decoration: none;">
+                                                                  <img src="http://www.mailjet.com/images/theme/v1/icons/ico_social_twitter.png" alt="Twitter" style="vertical-align: top; border: none;">
+                                                                </a>
+                                                              </td>
+                                                              <td style="padding: 2px; margin: 0; vertical-align: top;">
+                                                                <a href="http://www.linkedin.com/shareArticle?url=http://70u.r.mailjet.com/nl/98y/xzkv1.html" target="_blank" style="display: block; border: none; text-decoration: none;">
+                                                                  <img src="http://www.mailjet.com/images/theme/v1/icons/ico_social_linkedin.png" alt="Linkedin" style="vertical-align: top; border: none;">
+                                                                </a>
+                                                              </td>
+                                                              <td style="padding: 2px; margin: 0; vertical-align: top;">
+                                                                <a href="http://pinterest.com/hello0691/ze-daily-mat%C3%A9rio/" target="_blank" style="display: block; border: none; text-decoration: none;">
+                                                                  <img src="http://www.mailjet.com/images/theme/v1/icons/ico_social_pinterest.png" alt="Pinterest" style="vertical-align: top; border: none;">
+                                                                </a>
+                                                              </td>
+                                                            </tr>
+                                                          </tbody>
+                                                        </table>
+                                                      </td>
+                                                    </tr>
+                                                  </tbody>
+                                                </table>
+                                              </td>
+                                            </tr>
+                                          </tbody>
+                                        </table>
+                                      </td>
+                                    </tr>
+                                  </tbody>
+                                </table>
+                              </td>
+                            </tr>
+                          </tbody>
+                        </table>
+                      </td>
+                    </tr>
+                  </tbody>
+                </table>
+              </td>
+            </tr>
+          </tbody>
+        </table>
+        <table style="height: 10px; border-collapse: collapse; font-size: 1px;" border="0" cellspacing="0" cellpadding="0">
+          <tbody>
+            <tr>
+              <td style="height: 10px; border-spacing: 0; font-size: 1px;" height="10">
+                &nbsp;
+              </td>
+            </tr>
+          </tbody>
+        </table>
+      </td>
+    </tr>
+  </tbody>
+</table>