/** * 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_hideSections * @version 1.2.1 (2014-05-25) * * @desc A widget for ManagerManager plugin that allows one or a few sections to be hidden on the document edit page. * * @uses ManagerManager plugin 0.6.2. * * @param $sections {comma separated string} - The id(s) of the sections 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: ''. * * @link http://code.divandesign.biz/modx/mm_hidesections/1.2.1 * * @copyright 2014 */ function mm_hideSections($sections, $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)) { // if we've been supplied with a string, convert it into an array $sections = makeArray($sections); $output = "//---------- mm_hideSections :: Begin -----\n"; foreach ($sections as $section) { switch ($section) { case 'access': // These have moved to tabs in 1.0.1 $output .= '$j("#sectionAccessHeader, #sectionAccessBody").hide();' . "\n"; break; default: $section = prepareSectionId($section); $output .= '$j("#' . $section . '_header, #' . $section . '_body").hide();' . "\n"; break; } } $output .= "//---------- mm_hideSections :: End -----\n"; $e->output($output); } }
/** * mm_renameSection * @version 1.2 (2013-05-31) * * Rename a section. * * @uses ManagerManager plugin 0.5. * * @param $section {string} - The id of the section this should apply to. * @param $newname {string} - The new text for the label. * @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} - 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_renamesection/1.2 * * @copyright 2013 */ function mm_renameSection($section, $newname, $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_renameSection :: Begin ------------- \n"; switch ($section) { case 'content': $output .= '$j("div#content_header").empty().prepend("' . jsSafe($newname) . '");' . "\n"; break; case 'tvs': $output .= ' $j("div#tv_header").empty().prepend("' . jsSafe($newname) . '"); '; break; case 'access': // These have moved to tabs in 1.0.1 $output .= '$j("div#sectionAccessHeader").empty().prepend("' . jsSafe($newname) . '");' . "\n"; break; default: $output .= '$j("#' . prepareSectionId($section) . '_header").empty().prepend("' . jsSafe($newname) . '");' . "\n"; break; } $output .= "// -------------- mm_renameSection :: End ------------- \n"; $e->output($output . "\n"); } }
/** * mm_ddMoveFieldsToSection * @version 1.0.2 (2013-12-10) * * @description Widget allows document fields & TVs to be moved in an another section. However you can’t move the following fields: keywords, metatags, which_editor, show_in_menu, menuindex. * * @uses ManagerManager 0.6. * * @param $fields {string} - The name(s) of the document fields (or TVs) this should apply to. @required * @param $sectionId {string} - The ID of the section which the fields should be moved 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: ''. * * @link http://code.divandesign.biz/modx/mm_movefieldstosection/1.0.2 * * @copyright 2013, DivanDesign * http://www.DivanDesign.ru */ function mm_ddMoveFieldsToSection($fields, $sectionId, $roles = '', $templates = '') { global $modx; $e =& $modx->Event; if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) { $output = "//---------- mm_ddMoveFieldsToSection :: Begin -----\n"; $output .= '$j.ddMM.moveFields("' . $fields . '", "' . prepareSectionId($sectionId) . '_body");' . "\n"; $output .= "//---------- mm_ddMoveFieldsToSection :: End -----\n"; $e->output($output); } }
/** * mm_minimizablesections * @version 0.2 (2015-05-30) * * @desc A widget for ManagerManager plugin that allows one, few or all sections to be minimizable on the document edit page. * * @uses ManagerManager plugin 0.6.2. * * @param $sections {comma separated string} - The id(s) of the sections this should apply to. Use '*' for apply to all. @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: ''. * @param $minimized {comma separated string} - The id(s) of the sections this should be minimized by default. * * @author Sergey Davydov <*****@*****.**> * * @copyright 2015 */ function prepareSection($section) { switch ($section) { case 'access': return "#sectionAccessHeader"; break; case '*': return ".sectionHeader"; break; default: $section = prepareSectionId($section); return "#{$section}_header"; break; } }