コード例 #1
0
         // Create a new array for each new index (at the 3rd element of the split
         // string.
         if (!isset($mappings[$info[3]])) {
             $mappings[$info[3]] = array();
         }
         // Push this item into the array.
         array_push($mappings[$info[3]], $field['option_value']);
     }
 }
 // Now loop through the constructed array and generate a new row for each
 // mapping found.  Save off the highest mapping.  If there is no existing
 // mapping.  The -1 will be changed to a 0 index in the call to
 // AC_GenerateNewRowScript().  The javascript will use that index.
 $highestMapping = -1;
 foreach ($mappings as $index => $mapping) {
     $newRow = AC_GenerateCategoryMappingRow($index, WP88_CATEGORY_MAPPING_PREFIX, $categories, $mapping[0], $listHash, $mapping[2], $javaScript, $groupHash, $mapping[1], $templatesHash, $mapping[3]);
     // "template" is fourth
     if ($index > $highestMapping) {
         $highestMapping = $index;
     }
     print $newRow;
 }
 // Close out the table.
 print '</table>' . PHP_EOL;
 // Generate the javascript that lets users create new mapping rows.
 $nrScript = AC_GenerateNewRowScript($highestMapping + 1, "'" . WP88_CATEGORY_MAPPING_PREFIX . "'", "'#wp_category_mappings_table'", $categories, WP88_ANY, $listHash, WP88_NONE, $groupHash, WP88_ANY, $templatesHash, WP88_NONE);
 // Add in the "new row" script.  Clicking on this executes the javascript to
 // create a new row to map categories, lists, groups, and templates.
 print '<p><a href="#" id="addNewCategoyMappingRow" onclick="' . $nrScript . '">Add new post category mapping</a></p>' . PHP_EOL;
 print '</p>';
 //
コード例 #2
0
 public function GenerateMappingsUI($lists, $groups, $templates, $javaScript)
 {
     print '<p><strong>Since you are using Events Manager</strong>, you can create campaigns based on Event categories as well.  <em>If you use a \'user template\', be sure that the template\'s content section is called \'main\' so that your post\'s content can be substituted in the template.</em></p><p>' . PHP_EOL;
     print '<table id="event_manager_table">' . PHP_EOL;
     print '<tr><th>Category</th><th></th><th>Mailing List</th><th></th><th>Interest Group</th><th></th><th>User Template</th><th></th></tr>';
     // Will need a list of the EM categories (terms) that the user has created.
     $categories = get_terms(EM_TAXONOMY_CATEGORY, 'orderby=count&hide_empty=0');
     $categories = AC_AssembleTermsArray($categories);
     // Building array that contains the mappings.  Each entry is a row in the UI.
     $mappings = array();
     // Global DB object
     global $wpdb;
     // Pull all of the mappings from the DB.  Each row will have three items.  The
     // category is encoded in the option_name of each of the three along with an
     // index.
     $options_table_name = $wpdb->prefix . 'options';
     $sql = "SELECT option_name,option_value FROM {$options_table_name} WHERE option_name like '" . EVENTS_MANAGER_MAPPING_PREFIX . "%' ORDER BY option_name";
     $fields = $wpdb->get_results($sql, ARRAY_A);
     if ($fields) {
         foreach ($fields as $field) {
             // Split the results into an array which contains info about this mapping
             $info = explode('_', $field['option_name']);
             // Create a new array for each new index (at the 3rd element of the split
             // string.
             if (!isset($mappings[$info[3]])) {
                 $mappings[$info[3]] = array();
             }
             // Push this item into the array.
             array_push($mappings[$info[3]], $field['option_value']);
         }
     }
     // Now loop through the constructed array and generate a new row for each
     // mapping found.
     $highestMapping = -1;
     foreach ($mappings as $index => $mapping) {
         // The category is contained in the 1st element of the returned array.
         // The index is in the 0th.
         $newRow = AC_GenerateCategoryMappingRow($index, EVENTS_MANAGER_MAPPING_PREFIX, $categories, $mapping[0], $lists, $mapping[2], $javaScript, $groups, $mapping[1], $templates, $mapping[3]);
         // "template" is fourth
         if ($index > $highestMapping) {
             $highestMapping = $index;
         }
         print $newRow;
     }
     // Close out the table.
     print '</table>' . PHP_EOL;
     // Generate the javascript that lets users create new mapping rows.
     $nrScript = AC_GenerateNewRowScript($highestMapping + 1, "'" . EVENTS_MANAGER_MAPPING_PREFIX . "'", "'#event_manager_table'", $categories, WP88_ANY, $lists, WP88_NONE, $groups, WP88_ANY, $templates, WP88_NONE);
     // Add in the "new row" script.  Clicking on this executes the javascript to
     // create a new row to map categories, lists, groups, and templates.
     print '<p><a href="#" id="addNewEMRow" onclick="' . $nrScript . '">Add new Events Manager post category mapping</a></p>' . PHP_EOL;
     print '</p>';
 }