$listAttr = $this->config['addOns']['glm-member-db']['shortcodes']['glm-members-list']['attributes'];
$detailAttr = $this->config['addOns']['glm-member-db']['shortcodes']['glm-member-detail']['attributes'];
- $glmcat = new GlmDataCategories($this->wpdb, $this->wpconfig);
+ $glmcat = new GlmDataCategories($this->wpdb, $this->config);
$list = $glmcat->getListSortedParentChild();
// get the each addOn slugs to pass to the config array later
$addOns = $this->config['addOns'];
foreach($addOnSlugs as $addOn){
$shortCodeList[] = $this->config['addOns'][$addOn]['shortcodes'];
}
+
// loop through the shortcodes to pull out the shortcode names
foreach($shortCodeList as $addonInfo) {
foreach($addonInfo as $shortCode=>$value){
+// echo "<pre>".print_r($value, true)."</pre>";
if(!is_array($shortCode)){
$shortCodes[] = $shortCode;
}
}
}
-
//dropdown for shortcode names
echo '<div id="categoryContainer" style="overflow: auto">';
echo '<div id="shortcodeBuilder">';
}
editor_shortcodes = get_tinymce_content();
-
+ if(editor_shortcodes){
+ var number_of_categories = (editor_shortcodes.match(/category="(.*?)"/g) || []).length;
+ }
+ console.debug(number_of_categories);
if(editor_shortcodes){
if(editor_shortcodes.match(/category="(.*?)"/) !== null){
category_id = editor_shortcodes.match(/category="(.*?)"/)[1];
* Category Selection
*/
//////////////////////////////////////////////////////////////////////////////////////////////
- var content = $("#content"), editor_category_index, ids, id_string, new_ids = new Array(), editor_content, empty_space;
+ var content = $("#content"), editor_category_index, ids, id_string, new_ids = new Array(), editor_content, empty_space, count;
$('#category-scDropdown').change( function() {
editor_shortcodes = get_tinymce_content();
- console.debug(editor_shortcodes);
+
if(editor_shortcodes){
if(editor_shortcodes.match(/category="(.*?)"/) !== null){
category_id = editor_shortcodes.match(/category="(.*?)"/)[1];
- console.debug(category_id + "1");
+
if(category_id !== ""){
category_id = category_id.split(',');
- console.debug(category_id + "2");
+
ids = category_id.join(',');
empty_space = false;
} else {
- console.debug(category_id + "3");
+
ids = 'category=""';
empty_space = true;
}
-
+ function insert_tag(text){
+ if(tinyMCE && tinyMCE.activeEditor)
+ {
+ tinyMCE.activeEditor.selection.setContent(text);
+ }
+ return false;
+ }
/////////////////////////////////////////////////////////////////////////////////////////////////
// INSERT SHORTCODE FUNCTION
/////////////////////////////////////////////////////////////////////////////////////////////////
// generate the shortcode into a string and insert into the content upon clicking
$("#generate").on("click", function () {
+ count = 0;
+ if(number_of_categories){
+ count = number_of_categories;
+ count++;
+ } else {
+ count++;
+ }
// enforce the selection of a shortcode
if(shortcodeDropdown){
// set up properties for shortcode lists
}
}
// start the shortcode string that will be added to the tinymce editor
- shortcodeString = '<div class="previewCodes" id="' + shortcodeDropdown + '"> [' + shortcodeDropdown;
+ shortcodeString = '<div class="previewCodes" id="' + shortcodeDropdown + '_'+ count + '"> [' + shortcodeDropdown;
// populate the shortcode object
for (var key in shortcodeValues) {
$('#content').val( textBefore + shortcodeString + textAfter );
} else if($("#content").css("display") === "none") {
- function insert_tag(text){
- if(tinyMCE && tinyMCE.activeEditor)
- {
- tinyMCE.activeEditor.selection.setContent(text);
- }
- return false;
- }
+
insert_tag(shortcodeString);
}
} else {
});
id_string = new_ids.join(',');
- if(id_string === ""){
- id_string = "";
-// ids = 'category=""';
- }
if($("#content").css("display") !== "none"){
+
editor_content = content.val();
- if(ids === ""){
- console.debug("test1");
- }
editor_content = editor_content.replace(ids, id_string);
content.val(editor_content);
+
} else if(tinyMCE.activeEditor !== null){
+
editor_content = tinyMCE.get('content').getContent({format: 'raw'});
- if(ids === ""){
- console.debug("test");
- }
editor_content = editor_content.replace(ids, id_string);
tinyMCE.activeEditor.setContent(editor_content);
+
}
- console.debug(id_string);
});
window.onload = document.getElementById('view-scDropdown').options[0].selected = 'selected';
}
window.onload = uncheckAll();
-
-
});