/** * Get CMSLinker for TinyMCE * * @since 1.0 * @return string */ public static function GetCMSLinker() { $mod = cms_utils::get_module('MicroTiny'); $result = ""; $config = cms_utils::get_config(); $result .= "\n\t\t//Creates a new plugin class and a custom listbox\n\t\ttinymce.create('tinymce.plugins.CMSLinkerPlugin', {\n\t\tcreateControl: function(n, cm) {\n\t\t\tswitch (n) {\n\t\t\t\tcase 'cmslinker':\n\t\t\t\t\tvar c = cm.createMenuButton('cmslinker', {\n\t\t\t\t\t\ttitle : '" . $mod->Lang("cmsmslinker") . "',\n\t\t\t\t\t\timage : '" . $config->smart_root_url() . "/modules/MicroTiny/images/cmsmslink.gif',\n\t\t\t\t\t\ticons : false\n\t\t\t\t\t});\n\n\t\t\t\t\tc.onRenderMenu.add(function(c, m) {\n\t\t"; $content_ops = cmsms()->GetContentOperations(); $content_array = $content_ops->GetAllContent(); $level = 0; $menu = "m"; foreach ($content_array as $one) { if ($one->Active() != 1) { continue; } if ($one->FriendlyName() == 'Separator') { continue; } //print_r($one); $thislevel = substr_count($one->Hierarchy(), "."); //echo $thislevel.":".$level; if ($thislevel < $level) { $menu = substr($menu, $level - $thislevel); $level -= $level - $thislevel; } //if ($thislevel==$level) { if ($one->ChildCount() > 0) { $menu = self::AddSub($menu, $one, $result); $level++; } else { $result .= self::AddEntry($menu, $one); } } $result .= "\n\t\t\t\t\t});\n\n\t\t\t\t\t// Return the new menu button instance\n\t\t\t\t\treturn c;\n\t\t\t}\n\n\t\t\treturn null;\n\t\t}\n\t\t});\n\n\t\t// Register plugin with a short name\n\t\ttinymce.PluginManager.add('cmslinker', tinymce.plugins.CMSLinkerPlugin);\n\n\t\t"; return $result; }