function mm_minimizablesections($sections, $roles = '', $templates = '', $minimized = '') { if (!useThisRule($roles, $templates)) { return; } global $modx; $e =& $modx->Event; $site = $modx->config['site_url']; $widgetDir = $site . 'assets/plugins/managermanager/widgets/mm_minimizablesections/'; $output = ''; if ($e->name == 'OnDocFormPrerender') { $output .= includeJsCss($widgetDir . 'minimizablesections.css', 'html'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { $sections = makeArray($sections); $minimized = makeArray($minimized); $sections = array_map("prepareSection", $sections); $minimized = array_map("prepareSection", $minimized); $output .= "//---------- mm_minimizablesections :: Begin -----\n"; $output .= '$j("' . implode(",", $sections) . '","#documentPane").addClass("minimizable").on("click",function(){ var _t = $j(this); _t.next().slideToggle(400,function(){_t.toggleClass("minimized");}) }); $j(".minimizable").filter("' . implode(",", $minimized) . '").addClass("minimized").next().hide(); '; $output .= "//---------- mm_minimizablesections :: End -----\n"; $e->output($output); } } }
/** * mm_widget_colors * @version 1.2 (2013-12-11) * * A widget for ManagerManager plugin that allows text field to be turned into a color picker storing a chosen hex value in the field on the document editing page. * * @uses ManagerManager plugin 0.6. * * @param $fields {comma separated string} - The name(s) of the template variables this should apply to. @required * @param $default {string} - Which color in hex format should be selected by default in new documents. This is only used in situations where the TV does not have a default value specified in the TV definition. Default: '#ffffff'. * @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 OnDocFormPrerender * @event OnDocFormRender * * @link http://code.divandesign.biz/modx/mm_widget_colors/1.2 * * @copyright 2013 */ function mm_widget_colors($fields, $default = '#ffffff', $roles = '', $templates = '') { if (!useThisRule($roles, $templates)) { return; } global $modx; $e =& $modx->Event; $output = ''; if ($e->name == 'OnDocFormPrerender') { $output .= includeJsCss($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/colors/farbtastic.js', 'html', 'farbtastic', '1.2'); $output .= includeJsCss($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/colors/farbtastic.css', 'html'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { global $mm_current_page, $mm_fields; // if we've been supplied with a string, convert it into an array $fields = makeArray($fields); // Does this page's template use any of these TVs? If not, quit. $tv_count = tplUseTvs($mm_current_page['template'], $fields); if ($tv_count === false) { return; } $output .= "//---------- mm_widget_colors :: Begin -----\n"; // Go through each of the fields supplied foreach ($fields as $tv) { $tv_id = $mm_fields[$tv]['fieldname']; $output .= ' $j("#' . $tv_id . '").css("background-image","none"); $j("#' . $tv_id . '").after(\'<div id="colorpicker' . $tv_id . '"></div>\'); if ($j("#' . $tv_id . '").val() == ""){ $j("#' . $tv_id . '").val("' . $default . '"); } $j("#colorpicker' . $tv_id . '").farbtastic("#' . $tv_id . '"); $j("#colorpicker' . $tv_id . '").mouseup(function(){ // mark the document as dirty, or the value wont be saved $j("#' . $tv_id . '").trigger("change"); }); '; } $output .= "//---------- mm_widget_colors :: End -----\n"; $e->output($output); } } }
/** * mm_ddYMap * @version 1.4.3 (2013-12-10) * * @desc A widget for ManagerManager plugin allowing Yandex Maps integration. * * @uses ManagerManager plugin 0.6. * * @param $tvs {comma separated string} - TV names to which the widget is applied. @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 $w {'auto'; integer} - Width of the map container. Default: 'auto'. * @param $h {integer} - Height of the map container. Default: 400. * @param $hideField {boolean} - Original coordinates field hiding status (true — hide, false — show). Default: true. * * @event OnDocFormPrerender * @event OnDocFormRender * * @link http://code.divandesign.biz/modx/mm_ddymap/1.4.3 * * @copyright 2013, DivanDesign * http://www.DivanDesign.biz */ function mm_ddYMap($tvs, $roles = '', $templates = '', $w = 'auto', $h = '400', $hideField = true) { if (!useThisRule($roles, $templates)) { return; } global $modx; $e =& $modx->Event; if ($e->name == 'OnDocFormPrerender') { //The main js file including $output = includeJsCss($modx->config['site_url'] . 'assets/plugins/managermanager/widgets/ddymap/jquery.ddMM.mm_ddYMap.js', 'html', 'jquery.ddMM.mm_ddYMap', '1.0.2'); //The Yandex.Maps library including $output .= includeJsCss('http://api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU&onload=mm_ddYMap_init', 'html', 'api-maps.yandex.ru', '2.0'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { global $mm_current_page; $output = ''; //if we've been supplied with a string, convert it into an array $tvs = makeArray($tvs); $usedTvs = tplUseTvs($mm_current_page['template'], $tvs, '', 'id', 'name'); if ($usedTvs == false) { return; } $output .= "//---------- mm_ddYMap :: Begin -----\n"; //Iterate over supplied TVs instead of doing so to the result of tplUseTvs() to maintain rendering order. foreach ($tvs as $tv) { //If this $tv is used in a current template if (isset($usedTvs[$tv])) { $output .= ' $j("#tv' . $usedTvs[$tv]['id'] . '").mm_ddYMap({ hideField: ' . intval($hideField) . ', width: "' . $w . '", height: "' . $h . '" }); '; } } $output .= "//---------- mm_ddYMap :: End -----\n"; $e->output($output); } } }
/** * mm_ddGMap * @version 1.2b (2014-05-14) * * @desc Widget for ManagerManager plugin allowing Google Maps integration. * * @uses ManagerManager plugin 0.6.1. * * @param $tvs {comma separated string} - TV names to which the widget is applied. @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 $w {'auto'; integer} - Width of the map container. Default: 'auto'. * @param $h {integer} - Height of the map container. Default: 400. * @param $hideField {0; 1} - Original coordinates field hiding status (1 — hide, 0 — show). Default: 1. * * @link http://code.divandesign.biz/modx/mm_ddgmap/1.2b * * @copyright 2014, DivanDesign * http://www.DivanDesign.biz */ function mm_ddGMap($tvs, $roles = '', $templates = '', $w = 'auto', $h = '400', $hideField = true) { if (!useThisRule($roles, $templates)) { return; } global $modx; $e =& $modx->Event; if ($e->name == 'OnDocFormPrerender') { global $modx_lang_attribute; //The main js file including $output = includeJsCss($modx->config['site_url'] . 'assets/plugins/managermanager/widgets/ddgmap/jquery.ddMM.mm_ddGMap.js', 'html', 'jquery.ddMM.mm_ddGMap', '1.0'); //The Google.Maps library including $output .= includeJsCss('http://maps.google.com/maps/api/js?sensor=false&hl=' . $modx_lang_attribute . '&callback=mm_ddGMap_init', 'html', 'maps.google.com', '0'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { global $mm_current_page; $output = ''; $tvs = makeArray($tvs); $usedTvs = tplUseTvs($mm_current_page['template'], $tvs, '', 'id', 'name'); if ($usedTvs == false) { return; } $output .= "//---------- mm_ddGMap :: Begin -----\n"; //Iterate over supplied TVs instead of doing so to the result of tplUseTvs() to maintain rendering order. foreach ($tvs as $tv) { //If this $tv is used in a current template if (isset($usedTvs[$tv])) { $output .= ' $j("#tv' . $usedTvs[$tv]['id'] . '").mm_ddGMap({ hideField: ' . intval($hideField) . ', width: "' . $w . '", height: "' . $h . '" }); '; } } $output .= "//---------- mm_ddGMap :: End -----\n"; $e->output($output); } } }
/** * mm_widget_template * @version 1.0 (2013-01-01) * * A template for creating new widgets * * @uses ManagerManager plugin 0.6. * * @event OnDocFormPrerender * @event OnDocFormRender * * @link http:// * * @copyright 2013 */ function mm_widget_template($fields, $other_param = 'defaultValue', $roles = '', $templates = '') { if (!useThisRule($roles, $templates)) { return; } global $modx; $e =& $modx->Event; $output = ''; if ($e->name == 'OnDocFormPrerender') { // We have functions to include JS or CSS external files you might need // The standard ModX API methods don't work here $output .= includeJsCss('/assets/plugins/managermanager/widgets/template/javascript.js', 'html'); $output .= includeJsCss('/assets/plugins/managermanager/widgets/template/styles.css', 'html'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { global $mm_fields, $mm_current_page; // if we've been supplied with a string, convert it into an array $fields = makeArray($fields); $tvs = tplUseTvs($mm_current_page['template'], $fields); if ($tvs == false) { return; } // Your output should be stored in a string, which is outputted at the end // It will be inserted as a Javascript block (with jQuery), which is executed on document ready // We always put a JS comment, which makes debugging much easier $output .= "//---------- mm_widget_template :: Begin -----\n"; // Do something for each of the fields supplied foreach ($fields as $targetTv) { // If it's a TV, we may need to map the field name, to what it's ID is. // This can be obtained from the mm_fields array $tv_id = $mm_fields[$targetTv]['fieldname']; } //JS comment for end of widget $output .= "//---------- mm_widget_template :: End -----\n"; // Send the output to the browser $e->output($output); } } }
/** * mm_ddHTMLCleaner * @version 1.0.4 (2014-03-14) * * @desc A widget for the plugin ManagerManager. It removes forbidden HTML attributes and styles from document fields and TVs when required. * * @uses ManagerManager plugin 0.6. * * @param $fields {comma separated string} - The name(s) of the document fields (or TVs) which the widget is applied to. @required * @param $roles {comma separated string} - 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 $validAttrsForAllTags {comma separated string} - Default: 'title,class'. * @param $validStyles {comma separated string} - Default: 'word-spacing'. * @param $validAttrs {string: JSON} - Default: '{"img":"src,alt,width,height","a":"href,target"}'. * * @event OnDocFormPrerender * @event OnDocFormRender * * @link http://code.divandesign.biz/modx/mm_ddhtmlcleaner/1.0.4 * * @copyright 2014, DivanDesign * http://www.DivanDesign.biz */ function mm_ddHTMLCleaner($fields, $roles = '', $templates = '', $validAttrsForAllTags = 'title,class', $validStyles = 'word-spacing', $validAttrs = '{"img":"src,alt,width,height","a":"href,target"}') { if (!useThisRule($roles, $templates)) { return; } global $modx; $e =& $modx->Event; if ($e->name == 'OnDocFormPrerender') { $widgetDir = $modx->config['site_url'] . 'assets/plugins/managermanager/widgets/mm_ddhtmlcleaner/'; $output = includeJsCss($widgetDir . 'jquery.ddHTMLCleaner-0.2.min.js', 'html', 'jquery.ddHTMLCleaner', '0.2'); $output .= includeJsCss($widgetDir . 'jquery.ddMM.mm_ddHTMLCleaner.js', 'html', 'jquery.ddMM.mm_ddHTMLCleaner', '1.0.1'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { global $mm_fields, $content; if ($content['contentType'] != 'text/html') { return; } $fields = getTplMatchedFields($fields); if ($fields == false) { return; } $selectors = array(); foreach ($fields as $field) { $selectors[] = $mm_fields[$field]['fieldtype'] . '[name=\\"' . $mm_fields[$field]['fieldname'] . '\\"]'; } $output = "//---------- mm_ddHTMLCleaner :: Begin -----\n"; $output .= ' $j.ddMM.mm_ddHTMLCleaner.addInstance("' . implode(',', $selectors) . '", { validAttrsForAllTags: "' . $validAttrsForAllTags . '", validAttrs: ' . $validAttrs . ', validStyles: "' . $validStyles . '" }); '; $output .= "//---------- mm_ddHTMLCleaner :: End -----\n"; $e->output($output); } } }
/** * mm_widget_accessdenied * @version 1.1.1 (2013-12-11) * * @desc A widget for ManagerManager plugin that allows access to specific documents (by ID) to be denied without inheritance on the document editing page. * * @uses ManagerManager plugin 0.6. * * @param $ids {comma separated string} - List of documents ID to prevent access. @required * @param $message {string} - HTML formatted message. Default: 'Access denied - Access to current document closed for security reasons.'. * @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: ''. * * @link http://code.divandesign.biz/modx/mm_widget_accessdenied/1.1.1 * * Icon by designmagus.com * Originally written by Metaller * @copyright 2013 */ function mm_widget_accessdenied($ids = '', $message = '', $roles = '') { global $modx; $e =& $modx->Event; if ($e->name == 'OnDocFormRender' && useThisRule($roles)) { if (empty($message)) { $message = '<span>Access denied</span>Access to current document closed for security reasons.'; } $docid = (int) $_GET[id]; $ids = makeArray($ids); $output = "//---------- mm_widget_accessdenied :: Begin -----\n"; if (in_array($docid, $ids)) { $output .= includeJsCss($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/accessdenied/accessdenied.css', 'js'); $output .= ' $j("input, div, form[name=mutate]").remove(); // Remove all content from the page $j("body").prepend(\'<div id="aback"><div id="amessage">' . $message . '</div></div>\'); $j("#aback").css({height: $j("body").height()} ); '; } $output .= "//---------- mm_widget_accessdenied :: End -----\n"; $e->output($output); } }
/** * mm_ddMaxLength * @version 1.1.1 (2013-12-10) * * Widget for ManagerManager plugin allowing number limitation of chars inputing in fields (or TVs). * * @uses ManagerManager plugin 0.6. * * @param $fields {comma separated string} - The name(s) of the document fields (or TVs) which the widget is applied 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. Default: ''. * @param $length {integer} - Maximum number of inputing chars. Default: 150. * * @event OnDocFormPrerender * @event OnDocFormRender * * @link http://code.divandesign.biz/modx/mm_ddmaxlength/1.1.1 * * @copyright 2013, DivanDesign * http://www.DivanDesign.biz */ function mm_ddMaxLength($fields = '', $roles = '', $templates = '', $length = 150) { if (!useThisRule($roles, $templates)) { return; } global $modx; $e =& $modx->Event; $output = ''; if ($e->name == 'OnDocFormPrerender') { $widgetDir = $modx->config['site_url'] . 'assets/plugins/managermanager/widgets/ddmaxlength/'; $output .= includeJsCss($widgetDir . 'ddmaxlength.css', 'html'); $output .= includeJsCss($widgetDir . 'jquery.ddMM.mm_ddMaxLength.js', 'html', 'jquery.ddMM.mm_ddMaxLength', '1.0'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { global $mm_fields; $fields = getTplMatchedFields($fields, 'text,textarea'); if ($fields == false) { return; } $output .= "//---------- mm_ddMaxLength :: Begin -----\n"; foreach ($fields as $field) { $output .= ' $j("' . $mm_fields[$field]['fieldtype'] . '[name=' . $mm_fields[$field]['fieldname'] . ']").addClass("ddMaxLengthField").each(function(){ $j(this).parent().append("<div class=\\"ddMaxLengthCount\\"><span></span></div>"); }).ddMaxLength({ max: ' . $length . ', containerSelector: "div.ddMaxLengthCount span", warningClass: "maxLengthWarning" }); '; } $output .= "//---------- mm_ddMaxLength :: End -----\n"; $e->output($output); } } }
/** * mm_widget_showimagetvs * @version 1.2.1 (2014-05-07) * * @desc A widget for ManagerManager plugin that allows the preview of images chosen in image TVs to be shown on the document editing page. * Emulates showimagestv plugin, which is not compatible with ManagerManager. * * @uses ManagerManager plugin 0.6.1. * * @param $tvs {comma separated string} - The name(s) of the template variables this should apply to. Default: ''. * @param $maxWidth {integer} - Preferred maximum width of the preview. Default: 300. * @param $maxHeight {integer} - Preferred maximum height of the preview. Default: 100. * @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_widget_showimagetvs/1.2.1 * * @copyright 2014 */ function mm_widget_showimagetvs($tvs = '', $maxWidth = 300, $maxHeight = 100, $thumbnailerUrl = '', $roles = '', $templates = '') { if (!useThisRule($roles, $templates)) { return; } global $modx; $e =& $modx->Event; if ($e->name == 'OnDocFormPrerender') { //The main js file including $output = includeJsCss($modx->config['site_url'] . 'assets/plugins/managermanager/widgets/showimagetvs/jquery.ddMM.mm_widget_showimagetvs.js', 'html', 'jquery.ddMM.mm_widget_showimagetvs', '1.0.1'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { global $mm_current_page; $output = ''; // Does this page's template use any image TVs? If not, quit now! $tvs = tplUseTvs($mm_current_page['template'], $tvs, 'image'); if ($tvs == false) { return; } $output .= "//---------- mm_widget_showimagetvs :: Begin -----\n"; // Go through each TV foreach ($tvs as $tv) { $output .= ' $j("#tv' . $tv['id'] . '").mm_widget_showimagetvs({ thumbnailerUrl: "' . trim($thumbnailerUrl) . '", width: ' . intval($maxWidth) . ', height: ' . intval($maxHeight) . ', }); '; } $output .= "//---------- mm_widget_showimagetvs :: End -----\n"; $e->output($output); } } }
/** * mm_ddSelectDocuments * @version 1.2.2 (2014-02-14) * * @desc A widget for ManagerManager that makes selection of documents ids easier. * * @uses ManagerManager 0.6. * @uses ddTools 0.10. * * @param $tvs {comma separated string} - TVs names that the widget is applied to. @required * @param $roles {comma separated string} - 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 $parentIds {comma separated string} - Parent documents IDs. @required * @param $depth {integer} - Depth of search. Default: 1. * @param $filter {separated string} - Filter clauses, separated by '&' between pairs and by '=' between keys and values. For example, 'template=15&published=1' means to choose the published documents with template id=15. Default: ''. * @param $max {integer} - The largest number of elements that can be selected by user (“0” means selection without a limit). Default: 0. * @param $labelMask {string} - Template to be used while rendering elements of the document selection list. It is set as a string containing placeholders for document fields and TVs. Also, there is the additional placeholder “[+title+]” that is substituted with either “menutitle” (if defined) or “pagetitle”. Default: '[+title+] ([+id+])'. * * @event OnDocFormPrerender * @event OnDocFormRender * * @link http://code.divandesign.biz/modx/mm_ddselectdocuments/1.2.2 * * @copyright 2014, DivanDesign * http://www.DivanDesign.biz */ function mm_ddSelectDocuments($tvs = '', $roles = '', $templates = '', $parentIds, $depth = 1, $filter = '', $max = 0, $labelMask = '[+title+] ([+id+])') { if (empty($parentIds) || !useThisRule($roles, $templates)) { return; } global $modx; $e =& $modx->Event; $output = ''; if ($e->name == 'OnDocFormPrerender') { $pluginDir = $modx->config['site_url'] . 'assets/plugins/managermanager/'; $widgetDir = $pluginDir . 'widgets/ddselectdocuments/'; $output .= includeJsCss($widgetDir . 'ddselectdocuments.css', 'html'); $output .= includeJsCss($pluginDir . 'js/jquery-ui-1.10.3.min.js', 'html', 'jquery-ui', '1.10.3'); $output .= includeJsCss($widgetDir . 'jquery.ddMultipleInput-1.2.1.min.js', 'html', 'jquery.ddMultipleInput', '1.2.1'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { global $mm_current_page; $tvs = tplUseTvs($mm_current_page['template'], $tvs); if ($tvs == false) { return; } $filter = ddTools::explodeAssoc($filter, '&', '='); //Необходимые поля preg_match_all('~\\[\\+([^\\+\\]]*?)\\+\\]~', $labelMask, $matchField); $fields = array_unique(array_merge(array_keys($filter), array('pagetitle', 'id'), $matchField[1])); if (($title_pos = array_search('title', $fields)) !== false) { unset($fields[$title_pos]); $fields = array_unique(array_merge($fields, array('menutitle'))); } //Рекурсивно получает все необходимые документы if (!function_exists('ddGetDocs')) { function ddGetDocs($parentIds = array(0), $filter = array(), $depth = 1, $labelMask = '[+pagetitle+] ([+id+])', $fields = array('pagetitle', 'id')) { //Получаем дочерние документы текущего уровня $docs = array(); //Перебираем всех родителей foreach ($parentIds as $parent) { //Получаем документы текущего родителя $tekDocs = ddTools::getDocumentChildrenTVarOutput($parent, $fields, false); //Если что-то получили if (is_array($tekDocs)) { //Запомним $docs = array_merge($docs, $tekDocs); } } $result = array(); //Если что-то есть if (count($docs) > 0) { //Перебираем полученные документы foreach ($docs as $val) { //Если фильтр пустой, либо не пустой и документ удовлетворяет всем условиям if (empty($filter) || count(array_intersect_assoc($filter, $val)) == count($filter)) { $val['title'] = empty($val['menutitle']) ? $val['pagetitle'] : $val['menutitle']; //Записываем результат $tmp = ddTools::parseText($labelMask, $val, '[+', '+]', false); if (strlen(trim($tmp)) == 0) { $tmp = ddTools::parseText('[+pagetitle+] ([+id+])', $val, '[+', '+]', false); } $result[] = array('label' => $tmp, 'value' => $val['id']); } //Если ещё надо двигаться глубже if ($depth > 1) { //Сливаем результат с дочерними документами $result = array_merge($result, ddGetDocs(array($val['id']), $filter, $depth - 1, $labelMask, $fields)); } } } return $result; } } //Получаем все дочерние документы $docs = ddGetDocs(explode(',', $parentIds), $filter, $depth, $labelMask, $fields); if (count($docs) == 0) { return; } if (version_compare(PHP_VERSION, '5.4.0') >= 0) { $jsonDocs = json_encode($docs, JSON_UNESCAPED_UNICODE); } else { $jsonDocs = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', create_function('$matches', '$sym = mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UTF-16"); return $sym;'), json_encode($docs)); } $output .= "//---------- mm_ddSelectDocuments :: Begin -----\n"; foreach ($tvs as $tv) { $output .= ' $j("#tv' . $tv['id'] . '").ddMultipleInput({source: ' . $jsonDocs . ', max: ' . $max . '}); '; } $output .= "//---------- mm_ddSelectDocuments :: End -----\n"; $e->output($output); } } }
/** * @deprecated, use the includeJsCss() */ function includeCss($url, $output_type = 'js') { return includeJsCss($url, $output_type); }
/** * mm_ddMultipleFields * @version 4.5.1 (2014-05-15) * * @desc Widget for plugin ManagerManager that allows you to add any number of fields values (TV) in one document (values is written as one with using separator symbols). For example: a few images. * * @uses ManagerManager plugin 0.6. * * @param $tvs {comma separated string} - Names of TV for which the widget is applying. @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 $columns {comma separated string} - Column types: field — field type column; text — text type column; textarea — multiple lines column; richtext — column with rich text editor; date — date column; id — hidden column containing unique id; select — list with options (parameter “columnsData”). Default: 'field'. * @param $columnsTitle {comma separated string} - Columns titles. Default: ''. * @param $colWidth {comma separated string} - Columns width (one value can be set). Default: 180; * @param $splY {string} - Strings separator. Default: '||'. * @param $splX {string} - Columns separator. Default: '::'. * @param $imgW {integer} - Maximum value of image preview width. Default: 300. * @param $imgH {integer} - Maximum value of image preview height. Default: 100. * @param $minRow {integer} - Minimum number of strings. Default: 0. * @param $maxRow {integer} - Maximum number of strings. Default: 0 (без лимита). * @param $columnsData {separated string} - List of valid values in json format (with “||”). Default: ''. * * @event OnDocFormPrerender * @event OnDocFormRender * * @link http://code.divandesign.biz/modx/mm_ddmultiplefields/4.5.1 * * @copyright 2014, DivanDesign * http://www.DivanDesign.biz */ function mm_ddMultipleFields($tvs = '', $roles = '', $templates = '', $columns = 'field', $columnsTitle = '', $colWidth = '180', $splY = '||', $splX = '::', $imgW = 300, $imgH = 100, $minRow = 0, $maxRow = 0, $columnsData = '') { if (!useThisRule($roles, $templates)) { return; } global $modx; $e =& $modx->Event; $output = ''; $site = $modx->config['site_url']; $widgetDir = $site . 'assets/plugins/managermanager/widgets/ddmultiplefields/'; if ($e->name == 'OnDocFormPrerender') { global $_lang; $output .= includeJsCss($site . 'assets/plugins/managermanager/js/jquery-ui-1.10.3.min.js', 'html', 'jquery-ui', '1.10.3'); $output .= includeJsCss($widgetDir . 'ddmultiplefields.css', 'html'); $output .= includeJsCss($widgetDir . 'jquery.ddMM.mm_ddMultipleFields.js', 'html', 'jquery.ddMM.mm_ddMultipleFields', '1.1.1'); $output .= includeJsCss('$j.ddMM.lang.edit = "' . $_lang['edit'] . '";', 'html', 'mm_ddMultipleFields_plain', '1', true, 'js'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { global $mm_current_page; if ($columnsData) { $columnsDataTemp = explode('||', $columnsData); $columnsData = array(); foreach ($columnsDataTemp as $value) { //Евалим знение и записываем результат или исходное значени $eval = @eval($value); $columnsData[] = $eval ? addslashes(json_encode($eval)) : addslashes($value); } //Сливаем в строку, что бы передать на клиент $columnsData = implode('||', $columnsData); } //Стиль превью изображения $stylePrewiew = "max-width:{$imgW}px; max-height:{$imgH}px; margin: 4px 0; cursor: pointer;"; $tvsMas = tplUseTvs($mm_current_page['template'], $tvs, 'image,file,text,email,textarea', 'id,type'); if ($tvsMas == false) { return; } $output .= "//---------- mm_ddMultipleFields :: Begin -----\n"; foreach ($tvsMas as $tv) { if ($tv['type'] == 'image') { $browseFuntion = 'BrowseServer'; $makeFieldFunction = 'makeImage'; } else { if ($tv['type'] == 'file') { $browseFuntion = 'BrowseFileServer'; $makeFieldFunction = 'makeNull'; } else { $browseFuntion = 'false'; $makeFieldFunction = 'makeNull'; } } $output .= ' $j("#tv' . $tv['id'] . '").mm_ddMultipleFields({ splY: "' . $splY . '", splX: "' . $splX . '", coloumns: "' . $columns . '", coloumnsTitle: "' . $columnsTitle . '", coloumnsData: "' . $columnsData . '", colWidth: "' . $colWidth . '", imageStyle: "' . $stylePrewiew . '", minRow: "' . $minRow . '", maxRow: "' . $maxRow . '", makeFieldFunction: "' . $makeFieldFunction . '", browseFuntion: ' . $browseFuntion . ' }); '; } $output .= "//---------- mm_ddMultipleFields :: End -----\n"; $e->output($output); } } }
/** * mm_ddMultipleFields * @version 4.6 (2014-10-24) * * @desc Widget for plugin ManagerManager that allows you to add any number of fields values (TV) in one document (values is written as one with using separator symbols). For example: a few images. * * @uses ManagerManager plugin 0.6.3. * * @param $tvs {comma separated string} - Names of TV for which the widget is applying. @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 $columns {comma separated string} - Column types: field — field type column; text — text type column; textarea — multiple lines column; richtext — column with rich text editor; date — date column; id — hidden column containing unique id; select — list with options (parameter “columnsData”). Default: 'field'. * @param $columnsTitle {comma separated string} - Columns titles. Default: ''. * @param $colWidth {comma separated string} - Columns width (one value can be set). Default: 180; * @param $splY {string} - Strings separator. Default: '||'. * @param $splX {string} - Columns separator. Default: '::'. * @param $imgW {integer} - Maximum value of image preview width. Default: 300. * @param $imgH {integer} - Maximum value of image preview height. Default: 100. * @param $minRow {integer} - Minimum number of strings. Default: 0. * @param $maxRow {integer} - Maximum number of strings. Default: 0 (без лимита). * @param $columnsData {separated string} - List of valid values in json format (with “||”). Default: ''. Example: '[['','No selected'],['0','No'],['1','Yes',1]]' * * @event OnDocFormPrerender * @event OnDocFormRender * * @link http://code.divandesign.biz/modx/mm_ddmultiplefields/4.5.1 * * @copyright 2014, DivanDesign * http://www.DivanDesign.biz */ function mm_ddMultipleFields($tvs = '', $roles = '', $templates = '', $columns = 'field', $columnsTitle = '', $colWidth = '180', $splY = '||', $splX = '::', $imgW = 300, $imgH = 100, $minRow = 0, $maxRow = 0, $columnsData = '', $options = array()) { if (!useThisRule($roles, $templates)) { return; } if (is_array($options)) { $options = json_encode($options); } global $modx; $e =& $modx->Event; $output = ''; $site = $modx->config['site_url']; $widgetDir = $site . 'assets/plugins/managermanager/widgets/ddmultiplefields/'; if ($e->name == 'OnDocFormPrerender') { global $_lang; $output .= includeJsCss($site . 'assets/plugins/managermanager/js/jquery-ui-1.10.3.min.js', 'html', 'jquery-ui', '1.10.3'); $output .= includeJsCss($widgetDir . 'ddmultiplefields.css', 'html'); $output .= includeJsCss($widgetDir . 'jquery.ddMM.mm_ddMultipleFields.js', 'html', 'jquery.ddMM.mm_ddMultipleFields', '1.1.1'); $output .= includeJsCss('$j.ddMM.lang.edit = "' . $_lang['edit'] . '";$j.ddMM.lang.confirm_delete_record = "' . $_lang["confirm_delete_record"] . '";', 'html', 'mm_ddMultipleFields_plain', '1', true, 'js'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { global $mm_current_page; if ($columnsData) { $columnsDataTemp = explode('||', $columnsData); $columnsData = array(); foreach ($columnsDataTemp as $value) { //Евалим знение и записываем результат или исходное значени $eval = @eval($value); $columnsData[] = $eval ? addslashes(json_encode($eval)) : addslashes($value); } //Сливаем в строку, что бы передать на клиент $columnsData = implode('||', $columnsData); } //Стиль превью изображения $imgW = $imgW . (is_numeric($imgW) ? "px" : ""); $imgH = $imgH . (is_numeric($imgH) ? "px" : ""); $stylePrewiew = "max-width:{$imgW}; max-height:{$imgH}; margin: 4px 0; cursor: pointer;"; $tvsMas = tplUseTvs($mm_current_page['template'], $tvs, 'image,file,text,email,textarea', 'id,type'); if ($tvsMas == false) { return; } $output .= "//---------- mm_ddMultipleFields :: Begin -----\n"; //For backward compatibility $columns = makeArray($columns); //Находим колонки, заданные как «field», теперь их нужно будет заменить на «image» и «file» соответственно $columns_fieldIndex = array_keys($columns, 'field'); foreach ($tvsMas as $tv) { //For backward compatibility if ($tv['type'] == 'image' || $tv['type'] == 'file') { //Проходимся по всем колонкам «field» и заменяем на соответствующий тип foreach ($columns_fieldIndex as $val) { $columns[$val] = $tv['type']; } } $output .= ' $j("#tv' . $tv['id'] . '").mm_ddMultipleFields({ splY: "' . $splY . '", splX: "' . $splX . '", coloumns: "' . implode(',', $columns) . '", coloumnsTitle: "' . $columnsTitle . '", coloumnsData: "' . $columnsData . '", colWidth: "' . $colWidth . '", imageStyle: "' . $stylePrewiew . '", minRow: "' . $minRow . '", maxRow: "' . $maxRow . '", options: ' . $options . ' }); '; } //Поругаемся if (!empty($columns_fieldIndex)) { $modx->logEvent(1, 2, '<p>You are currently using the deprecated column type “field”. Please, replace it with “image” or “file” respectively.</p><p>The plugin has been called in the document with template id ' . $mm_current_page['template'] . '.</p>', 'ManagerManager: mm_ddMultipleFields'); } $output .= "//---------- mm_ddMultipleFields :: End -----\n"; $e->output($output); } } }
}finally{ // Whatever happens, hide the loading mask $j("#loadingmask").hide(); } }); </script> <!-- ManagerManager Plugin :: End --> '); break; case 'OnTVFormRender': // Should we remove deprecated Template variable types from the TV creation list? $remove_deprecated_tv_types = $e->params['remove_deprecated_tv_types_pref'] == 'yes' ? true : false; if ($remove_deprecated_tv_types) { // Load the jquery library echo '<!-- Begin ManagerManager output -->'; echo includeJsCss($jsUrls['jq']['url'], 'html', $jsUrls['jq']['name'], $jsUrls['jq']['version']); // Create a mask to cover the page while the fields are being rearranged echo ' <script type="text/javascript"> var $j = jQuery.noConflict(); $j("select[name=type] option").each(function(){ var $this = $j(this); if(!($this.text().match("deprecated") == null)){ $this.remove(); } }); </script> '; echo '<!-- End ManagerManager output -->'; }
/** * mm_widget_tags * @version 1.1.2 (2013-12-11) * * Adds a tag selection widget to the specified TVs. * * @uses ManagerManager plugin 0.6. * * @param $fields {comma separated string} - The name(s) of the template variables this should apply to. @required * @param $delimiter {string} - The sign that separates tags in the field. Default: ','. * @param $source {comma separated string} - The names(s) of the template variables the list of tags should come from. This allows the list of tags to come from a different field than the widget. By default it uses all the TVs listed in “fields” parameter. Default: =$fields. * @param $display_count {boolean} - Display the number of documents using each tag (in brackets after it). Default: false. * @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} - The templates that the widget is applied to (when this parameter is empty then widget is applied to the all templates). Default: ''. * * @event OnDocFormPrerender * @event OnDocFormRender * * @link http://code.divandesign.biz/modx/mm_widget_tags/1.1.2 * * @copyright 2013 */ function mm_widget_tags($fields, $delimiter = ',', $source = '', $display_count = false, $roles = '', $templates = '') { if (!useThisRule($roles, $templates)) { return; } global $modx; $e =& $modx->Event; $output = ''; if ($e->name == 'OnDocFormPrerender') { $output .= includeJsCss($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/tags/tags.js', 'html', 'mm_widget_tags', '1.0'); $output .= includeJsCss($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/tags/tags.css', 'html'); $e->output($output); } else { if ($e->name == 'OnDocFormRender') { global $mm_current_page, $mm_fields; // if we've been supplied with a string, convert it into an array $fields = makeArray($fields); // And likewise for the data source (if supplied) $source = empty($source) ? $fields : makeArray($source); // Does this page's template use any of these TVs? If not, quit. $field_tvs = tplUseTvs($mm_current_page['template'], $fields); if ($field_tvs == false) { return; } $source_tvs = tplUseTvs($mm_current_page['template'], $source); if ($source_tvs == false) { return; } $output .= "//---------- mm_widget_tags :: Begin -----\n"; // Go through each of the fields supplied foreach ($fields as $targetTv) { $tv_id = $mm_fields[$targetTv]['fieldname']; // Make an SQL friendly list of fields to look at: //$escaped_sources = array(); //foreach ($source as $s){ // $s=substr($s,2,1); // $escaped_sources[] = "'".$s."'"; //} $sql_sources = implode(',', $source_tvs[0]); // Get the list of current values for this TV $sql = 'SELECT `value` FROM ' . $modx->getFullTableName('site_tmplvar_contentvalues') . ' WHERE tmplvarid IN (' . $sql_sources . ')'; $result = $modx->db->query($sql); $all_docs = $modx->db->makeArray($result); $foundTags = array(); foreach ($all_docs as $theDoc) { $theTags = explode($delimiter, $theDoc['value']); foreach ($theTags as $t) { $foundTags[trim($t)]++; } } // Sort the TV values (case insensitively) uksort($foundTags, 'strcasecmp'); $lis = ''; foreach ($foundTags as $t => $c) { $lis .= '<li title="Used ' . $c . ' times">' . jsSafe($t) . ($display_count ? ' (' . $c . ')' : '') . '</li>'; } $html_list = '<ul class="mmTagList" id="' . $tv_id . '_tagList">' . $lis . '</ul>'; // Insert the list of tags after the field $output .= ' //mm_widget_tags for “' . $targetTv . '” (' . $tv_id . ') $j("#' . $tv_id . '").after(\'' . $html_list . '\'); '; // Initiate the tagCompleter class for this field $output .= 'var ' . $tv_id . '_tags = new TagCompleter("' . $tv_id . '", "' . $tv_id . '_tagList", "' . $delimiter . '");' . "\n"; } $output .= "//---------- mm_widget_tags :: End -----\n"; $e->output($output); } } }
}finally{ // Whatever happens, hide the loading mask $j("#loadingmask").hide(); } }); </script> <!-- ManagerManager Plugin :: End --> '); break; case 'OnTVFormRender': // Should we remove deprecated Template variable types from the TV creation list? $remove_deprecated_tv_types = $e->params['remove_deprecated_tv_types_pref'] == 'yes' ? true : false; if ($remove_deprecated_tv_types) { // Load the jquery library echo '<!-- Begin ManagerManager output -->'; echo includeJsCss($jsUrls['jq'], 'html', 'jquery', '1.9.1'); // Create a mask to cover the page while the fields are being rearranged echo ' <script type="text/javascript"> var $j = jQuery.noConflict(); $j("select[name=type] option").each(function(){ var $this = $j(this); if( !($this.text().match("deprecated")==null)){ $this.remove(); } }); </script> '; echo '<!-- End ManagerManager output -->'; } break;