/** * mm_ddCreateSection * @version 1.0 (2013-05-22) * * @description * * @uses ManagerManager 0.5. * * @param $title {string} - The display name of the new section. @required * @param $id {string} - A unique ID for this section. @required * @param $tabId {string} - The ID of the tab which the section should be inserted to. Can be one of the default tab IDs or a new custom tab created with mm_createTab. Default: 'general'. * @param $roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). Default: ''. * @param $templates {comma separated string} - Id of the templates to which this widget is applied (when this parameter is empty then widget is applied to the all templates). Default: ''. * * @link http://code.divandesign.biz/modx/mm_ddcreatesection/1.0 * * @copyright 2013, DivanDesign * http://www.DivanDesign.ru */ function mm_ddCreateSection($title, $id, $tabId = 'general', $roles = '', $templates = '') { global $modx; $e =& $modx->Event; if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates) && !empty($id)) { // We always put a JS comment, which makes debugging much easier $output = "\n// -------------- mm_ddCreateSection :: Begin ------------- \n"; if ($title == '') { $title = $id; } $id = prepareSectionId($id); $tabId = prepareTabId($tabId); $section = ' <div class="sectionHeader" id="' . $id . '_header">' . $title . '</div> <div class="sectionBody" id="' . $id . '_body"><table style="position:relative;" border="0" cellspacing="0" cellpadding="3" width="100%"></table></div> '; //tabGeneral // Clean up for js output $section = str_replace(array("\n", "\t", "\r"), '', $section); $output .= '$j("#' . $tabId . '").append(\'' . $section . '\');'; //JS comment for end of widget $output .= "\n// -------------- mm_ddCreateSection :: End ------------- \n"; // Send the output to the browser $e->output($output . "\n"); } }
/** * mm_createTab * @version 1.1.1 (2014-12-01) * * @desc A widget for ManagerManager plugin that allows create a new custom tab within the document editing page. * * @uses ManagerManager plugin 0.6.2. * * @param $name {string} - The display name of the new tab. @required * @param $id {string} - A unique ID for this tab, so you can reference it later on, if you need to. @required * @param $roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). Default: ''. * @param $templates {comma separated string} - Templates IDs for which the widget is applying (empty value means the widget is applying to all templates). Default: ''. * @param $intro {string} - HTML text which appears at the top of the new tab. Default: ''. * @param $width {string} - New width for the content within the tab. If no units are included, they will be assumed to be pixels e.g. '100%' or '450px'. Default: '680'. * * @event OnDocFormRender * @event OnPluginFormRender * * @link http://code.divandesign.biz/modx/mm_createtab/1.1.1 * * @copyright 2014 */ function mm_createTab($name, $id, $roles = '', $templates = '', $intro = '', $width = '') { global $modx; $e =& $modx->Event; // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates if (($e->name == 'OnDocFormRender' || $e->name == 'OnPluginFormRender') && useThisRule($roles, $templates)) { // Plugin page tabs use a differen name for the tab object $js_tab_object = $e->name == 'OnPluginFormRender' ? 'tpSnippet' : 'tpSettings'; $output = "//---------- mm_createTab :: Begin -----\n"; $tabId = prepareTabId($id); $empty_tab = ' <div class="tab-page" id="' . $tabId . '"> <h2 class="tab">' . $name . '</h2> <div class="tabIntro" id="tab-intro-' . $id . '">' . $intro . '</div> <table width="' . $width . '" border="0" cellspacing="0" cellpadding="0" id="table-' . $id . '"> </table> </div> '; // Clean up for js output $empty_tab = str_replace(array("\n", "\t", "\r"), '', $empty_tab); $output .= '$j'; $output .= "('div#' + mm_lastTab).after('" . $empty_tab . "');\n"; $output .= "mm_lastTab = '" . $tabId . "';\n"; $output .= $js_tab_object . '.addTabPage(document.getElementById("' . $tabId . '"));' . "\n"; $output .= "//---------- mm_createTab :: End -----\n"; $e->output($output); } }
/** * mm_moveFieldsToTab * @version 1.2.2 (2013-12-10) * * @desc A widget for ManagerManager plugin that allows document fields & TVs to be moved in an another tab. * * @uses ManagerManager plugin 0.6. * * @param $fields {comma separated string} - The name(s) of the document fields (or TVs) this should apply to. @required * @param $tabId {string} - The ID of the tab which the fields should be moved to. Can be one of the default tab IDs or a new custom tab created with mm_createTab. @required * @param $roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). * @param $templates {comma separated string} - The Id of the templates to which this widget is applied (when this parameter is empty then widget is applied to the all templates). * * @link http://code.divandesign.biz/modx/mm_movefieldstotab/1.2.2 * * @copyright 2013 */ function mm_moveFieldsToTab($fields, $tabId, $roles = '', $templates = '') { global $modx; $e =& $modx->Event; if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) { $output = "//---------- mm_moveFieldsToTab :: Begin -----\n"; $output .= '$j.ddMM.moveFields("' . $fields . '", "' . prepareTabId($tabId) . '");' . "\n"; $output .= "//---------- mm_moveFieldsToTab :: End -----\n"; $e->output($output); } }
/** * mm_moveFieldsToTab * @version 1.2.2 (2013-12-10) * * @desc A widget for ManagerManager plugin that allows document fields & TVs to be moved in an another tab. * * @uses ManagerManager plugin 0.6. * * @param $fields {comma separated string} - The name(s) of the document fields (or TVs) this should apply to. @required * @param $tabId {string} - The ID of the tab which the fields should be moved to. Can be one of the default tab IDs or a new custom tab created with mm_createTab. @required * @param $roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). * @param $templates {comma separated string} - The Id of the templates to which this widget is applied (when this parameter is empty then widget is applied to the all templates). * * @link http://code.divandesign.biz/modx/mm_movefieldstotab/1.2.2 * * @copyright 2013 */ function mm_moveCategoryToTab($categoryId, $tabId, $roles = '', $templates = '') { global $modx; $e =& $modx->Event; $res = $modx->db->select("name", $modx->getFullTableName('site_tmplvars'), "category='" . $categoryId . "'"); $fieldsArr = array(); while ($row = $modx->db->getRow($res)) { $fieldsArr[] = $row['name']; } $fields = implode(",", $fieldsArr); if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) { $output = "//---------- mm_moveFieldsToTab :: Begin -----\n"; $output .= '$j.ddMM.moveFields("' . $fields . '", "' . prepareTabId($tabId) . '");' . "\n"; $output .= "//---------- mm_moveFieldsToTab :: End -----\n"; $e->output($output); } }
/** * mm_hideTabs * @version 1.2 (2014-12-01) * * @desc A widget for ManagerManager plugin that allows one or a few default tabs to be hidden on the document edit page. * * @uses ManagerManager plugin 0.6.2. * * @param $tabs {'general'; 'settings'; 'access'} - The id(s) of the tab(s) this should apply to. @required * @param $roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). Default: ''. * @param $templates {comma separated string} - Id of the templates to which this widget is applied (when this parameter is empty then widget is applied to the all templates). Default: ''. * * @event OnDocFormRender * * @link http://code.divandesign.biz/modx/mm_hidetabs/1.2 * * @copyright 2014, DivanDesign * http://www.DivanDesign.biz */ function mm_hideTabs($tabs, $roles = '', $templates = '') { global $modx; $e =& $modx->Event; // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) { $output = "//---------- mm_hideTabs :: Begin -----\n"; // if we've been supplied with a string, convert it into an array $tabs = makeArray($tabs); foreach ($tabs as $tab) { //meta for =< v1.0.0 only if ($tab != 'meta' || $modx->hasPermission('edit_doc_metatags') && $modx->config['show_meta'] != '0') { $output .= ' var $mm_hideTabs_tabElement = $j("#' . prepareTabId($tab) . '"); //If the element exists if ($mm_hideTabs_tabElement.length > 0){ //Hide the tab element $mm_hideTabs_tabElement.hide(); //Hide the tab link $j($mm_hideTabs_tabElement.get(0).tabPage.tab).hide(); } '; } } $output .= ' //All tabs var $mm_hideTabs_allTabs = $j(); for (var i = 0; i < tpSettings.pages.length - 1; i++){ $mm_hideTabs_allTabs = $mm_hideTabs_allTabs.add(tpSettings.pages[i].tab); } //If the active tab is hidden if ($j(tpSettings.pages[tpSettings.getSelectedIndex()].tab).is(":hidden")){ //Activate the first visible tab $mm_hideTabs_allTabs.filter(":visible").eq(0).trigger("click"); } '; $output .= "//---------- mm_hideTabs :: End -----\n"; $e->output($output); } }