function mm_widget_evogallery($moduleid, $title = '', $roles = '', $templates = '') { global $modx, $content, $mm_fields; $e =& $modx->Event; if (useThisRule($roles, $templates)) { //Include language file $langpath = $modx->config['base_path'] . "assets/modules/evogallery/lang/"; //First include english if (file_exists($langpath . 'english.inc.php')) { include $langpath . 'english.inc.php'; } //Include current manager language if (file_exists($langpath . $modx->config['manager_language'] . '.inc.php')) { include $langpath . $modx->config['manager_language'] . '.inc.php'; } $title = empty($title) ? $_lang['mm_tab_name'] : $title; //TODO: Add iframe autoheight if (isset($content['id'])) { $iframecontent = '<iframe id="mm_evogallery" src="' . $modx->config['site_url'] . 'manager/index.php?a=112&id=' . $moduleid . '&onlygallery=1&action=view&content_id=' . $content['id'] . '" style="width:100%;height:600px;" scrolling="auto" frameborder="0"></iframe>'; } else { $iframecontent = '<p class="warning">' . $_lang['mm_save_required'] . '</p>'; } mm_createTab($title, 'evogallery', '', '', '<strong>' . $_lang['mm_manage_images'] . '</strong>', '100%'); $output = "\$j('#table-evogallery').append('<tr><td>{$iframecontent}</td></tr>');"; } // end if $e->output($output . "\n"); // Send the output to the browser }
function mm_images($moduleid, $title = '', $templates = '') { global $modx, $content, $mm_fields; $e =& $modx->Event; $templates = explode(",", $templates); if (in_array($content['template'], $templates)) { $title = empty($title) ? "Управление изображениями" : $title; if (isset($content['id'])) { $iframecontent = '<iframe id="mm_images" src="' . $modx->config['site_url'] . 'manager/index.php?a=112&id=' . $moduleid . '&category=' . $content['id'] . '&get=category" style="width:100%;height:800px;" scrolling="auto" frameborder="0"></iframe>'; } else { $iframecontent = '<p class="warning">Прежде чем добавлять изображения сохраните </p>'; } mm_createTab($title, 'wgt_images', '', '', $iframecontent); $e->output($output . "\n"); } }
$class = $count % 2 ? 'gridItem' : 'gridAltItem'; $roles_table .= '<tr>'; $roles_table .= '<td class="' . $class . '">' . jsSafe($role['name']) . '</td>'; $roles_table .= '<td class="' . $class . '">' . $role['id'] . '</td>'; $roles_table .= '</tr>'; } $roles_table .= '</table>'; // Load the jquery library $output = '<!-- Begin ManagerManager output -->' . "\n"; $output .= includeJs($js_url, 'html'); $output .= '<script type="text/javascript">' . "\n"; $output .= "var \$j = jQuery.noConflict(); \n"; //produces var $j = jQuery.noConflict(); $output .= "mm_lastTab = 'tabEvents'; \n"; $e->output($output); mm_createTab('Templates, TVs & Roles', 'rolestemplates', '', '', '<p>These are the IDs for current templates,tvs and roles in your site.</p>' . $template_table . ' ' . $tvs_table . ' ' . $roles_table); $e->output('</script>'); $e->output('<!-- End ManagerManager output -->' . "\n"); } break; case 'OnDocFormPrerender': // Are we clashing with the ShowImageTVs (or any other) plugins? //$conflicted_plugins = array('ShowImageTVs'); //$conflicts = array(); //foreach ($conflicted_plugins as $plg) { // $sql= "SELECT * FROM " . $this->getFullTableName("site_plugins") . " WHERE name='" . $plg . "' OR name='" . strtolower($plg) . "'AND disabled=0;"; // $result= $modx->db->query($sql); // if ($modx->db->getRecordCount($result) > 0) { // $conflicts[] = $plg; // } //}
// in the plugin configuration tab. // If you want to refer to a role of template, you can define it in a variable to make your // rules more readable, and more easily maintainable. // Here, we have a role set up for News Editors - the ID of this role is 3 $news_role = '3'; // Our news editors are non-technical, so hide some fields which may scare them mm_hideFields('pagetitle,menutitle,link_attributes,template,menuindex,description,show_in_menu,which_editor,is_folder,is_richtext,log,searchable,cacheable,clear_cache', $news_role); // Rename the settings tab for news editors to make it clearer mm_renameTab('settings', 'Publication settings', $news_role); // Rename the longtitle firled to make it more appropriate for news editors mm_renameField('longtitle', 'Headline', $news_role, '', 'This will be displayed at the top of each page'); // We'd like to treat our news stories differently from other documents, so let's customise them. They use a specific // template (ID 10) so let's set a variable with this ID in. $news_tpl = '10'; // We categorise our news stories with a TV (news_category), so let's put this on a new tab to make it obvious to editors mm_createTab('Categories', 'cats', '', $news_tpl, '', '600'); mm_moveFieldsToTab('news_category', 'cats', '', $news_tpl); // Some of our field names could be clarified for news stories... mm_changeFieldHelp('longtitle', 'The story\'s headline', '', $news_tpl); mm_changeFieldHelp('introtext', 'A short summary of the story', '', $news_tpl); // We don't need to show these, as news stories aren't shown in menus mm_hideFields('menuindex,show_in_menu', '', $news_tpl); // Always make the page, menu and long titles the same mm_synch_fields('pagetitle,menutitle,longtitle', '', $news_tpl); // Set some defaults for everyone // Always set the default publication date to today mm_default('pub_date'); // Change the introtext field name to something more plain English mm_renameField('introtext', 'Summary'); // and do the same for some of the help messages mm_changeFieldHelp('alias', 'The URL that will be used to reach this story. Only numbers, letters and hyphens can be used');
foreach ($langIds as $langId) { $aliasesToHideArray[] = YAMSTVDataToMMName('alias_' . $langId, $id, 'tv', $mm_version); } if (count($aliasesToHideArray) > 0) { $aliasesToHide = implode(',', $aliasesToHideArray); mm_hideFields($aliasesToHide, '', $activeTemplateList); } unset($aliasesToHideArray); } } if ($yams->GetTabifyLangs()) { foreach ($langIds as $langId) { $rolesAccessList = $yams->GetRolesAccessList($langId); $rolesNoAccessList = $yams->GetRolesNoAccessList($langId); $langName = $yams->GetLangName($langId); mm_createTab($langName, $langId, $rolesAccessList, $activeTemplateList); // Get the names and ids of all the multilingual template variables // ending in _{langid} $result = $modx->db->select('id,name,rank', $modx->getFullTableName('site_tmplvars'), 'name LIKE \'%\\_' . $modx->db->escape($langId) . '\''); $nRows = $modx->db->getRecordCount($result); // Loop over the multilingual tvs and sort into custom and standard. // The standard ones are ordered in the normal order. // The custom ones are ordered as is (by probably should respect the // tv order specified in the database...) // For each tv, calculate the name required by ManagerManager $standardTVs = array(); $customTVs = array(); for ($i = 0; $i < $nRows; $i++) { $idNameArray = $modx->db->getRow($result); $name = $idNameArray['name']; $id = $idNameArray['id'];
function run() { global $modx; extract($modx->event->params); $mm_version = '0.4'; $pluginDir = $modx->config['base_path'] . 'assets/plugins/managermanager'; //Include Utilites include_once $pluginDir . '/utilities.inc.php'; // When loading widgets, ignore folders / files beginning with these chars $ignore_first_chars = array('.', '_', '!'); // Include widgets // We look for a PHP file with the same name as the directory - e.g. // /widgets/widgetname/widgetname.php $widget_dir = $pluginDir . '/widgets'; if ($handle = opendir($widget_dir)) { while (false !== ($file = readdir($handle))) { if (!in_array(substr($file, 0, 1), $ignore_first_chars) && $file != ".." && is_dir($widget_dir . '/' . $file)) { include_once "{$widget_dir}/{$file}/{$file}.php"; } } closedir($handle); } // Set variables global $content, $default_template, $mm_current_page, $mm_fields, $splitter; $mm_current_page = array(); if (isset($_POST['template'])) { $mm_current_page['template'] = $_POST['template']; } elseif (isset($_GET['newtemplate'])) { $mm_current_page['template'] = $_GET['newtemplate']; } elseif (isset($content['template'])) { $mm_current_page['template'] = $content['template']; } else { $mm_current_page['template'] = $default_template; } $mm_current_page['role'] = $_SESSION['mgrRole']; // What are the fields we can change, and what types are they? $field['pagetitle'] = array('input', 'pagetitle', 'pagetitle'); $field['longtitle'] = array('input', 'longtitle', 'longtitle'); $field['description'] = array('textarea', 'description', 'description'); $field['alias'] = array('input', 'alias', 'alias'); $field['link_attributes'] = array('input', 'link_attributes', 'link_attributes'); $field['menutitle'] = array('input', 'menutitle', 'menutitle'); $field['menuindex'] = array('input', 'menuindex', 'menuindex'); $field['show_in_menu'] = array('input', 'hidemenucheck', 'hidemenu'); $field['hide_menu'] = array('input', 'hidemenucheck', 'hidemenu'); // synonym for show_in_menu $field['parent'] = array('input', 'parent', 'parent'); $field['is_folder'] = array('input', 'isfoldercheck', 'isfolder'); $field['is_richtext'] = array('input', 'richtextcheck', 'richtext'); $field['log'] = array('input', 'donthitcheck', 'donthit'); $field['published'] = array('input', 'publishedcheck', 'published'); $field['pub_date'] = array('input', 'pub_date', 'pub_date'); $field['unpub_date'] = array('input', 'unpub_date', 'unpub_date'); $field['searchable'] = array('input', 'searchablecheck', 'searchable'); $field['cacheable'] = array('input', 'cacheablecheck', 'cacheable'); $field['clear_cache'] = array('input', 'syncsitecheck', ''); $field['weblink'] = array('input', 'ta', 'content'); $field['introtext'] = array('textarea', 'introtext', 'introtext'); $field['content'] = array('textarea', 'ta', 'content'); $field['template'] = array('select', 'template', 'template'); $field['content_type'] = array('select', 'contentType', 'contentType'); $field['content_dispo'] = array('select', 'content_dispo', 'content_dispo'); $field['keywords'] = array('select', 'keywords[]', ''); $field['metatags'] = array('select', 'metatags[]', ''); $field['which_editor'] = array('select', 'which_editor', ''); $field['resource_type'] = array('select', 'type', 'isfolder'); foreach ($field as $k => $a) { $mm_fields[$k]['fieldtype'] = $a[0]; $mm_fields[$k]['fieldname'] = $a[1]; $mm_fields[$k]['dbname'] = $a[2]; $mm_fields[$k]['tv'] = false; } unset($field); // Add in TVs to the list of available fields $all_tvs = $modx->db->makeArray($modx->db->select('name,type,id,elements', $modx->getFullTableName('site_tmplvars'), '', 'name ASC')); foreach ($all_tvs as $thisTv) { $n = $thisTv['name']; // What is the field name? // Checkboxes place an underscore in the ID, so accommodate this... $fieldname_suffix = ''; switch ($thisTv['type']) { // What fieldtype is this TV type? case 'textarea': case 'rawtextarea': case 'textareamini': case 'richtext': $t = 'textarea'; break; case 'dropdown': case 'listbox': $t = 'select'; break; case 'listbox-multiple': $t = 'select'; $fieldname_suffix = '[]'; break; case 'checkbox': $t = 'input'; $fieldname_suffix = '[]'; break; case 'custom_tv': if (strpos($thisTv['elements'], 'tvtype="text"') !== false) { $t = 'input'; } elseif (strpos($thisTv['elements'], 'tvtype="textarea"') !== false) { $t = 'textarea'; } elseif (strpos($thisTv['elements'], 'tvtype="select"') !== false) { $t = 'select'; } elseif (strpos($thisTv['elements'], 'tvtype="checkbox"') !== false) { $t = 'input'; $fieldname_suffix = '[]'; } elseif (strpos($thisTv['elements'], '<textarea') !== false) { $t = 'textarea'; } elseif (strpos($thisTv['elements'], '<select') !== false) { $t = 'select'; } elseif (strpos($thisTv['elements'], '"checkbox"') !== false) { $t = 'input'; $fieldname_suffix = '[]'; } else { $t = 'input'; } break; default: $t = 'input'; break; } // check if there are any name clashes between TVs and default field names? If there is, preserve the default field if (!isset($mm_fields[$n])) { $mm_fields[$n] = array('fieldtype' => $t, 'fieldname' => 'tv' . $thisTv['id'] . $fieldname_suffix, 'dbname' => '', 'tv' => true); } $mm_fields['tv' . $n] = array('fieldtype' => $t, 'fieldname' => 'tv' . $thisTv['id'] . $fieldname_suffix, 'dbname' => '', 'tv' => true); } // Check the current event global $e; $e =& $modx->event; // The start of adding or editing a document (before the main form) switch ($e->name) { // if it's the plugin config form, give us a copy of all the relevant values case 'OnPluginFormRender': $plugin_id_editing = $e->params['id']; // The ID of the plugin we're editing $result = $modx->db->select('name, id', $modx->getFullTableName('site_plugins'), "id='{$plugin_id_editing}'"); $plugin_editing_name = $modx->db->getValue($result); // if it's the right plugin if (strtolower($plugin_editing_name) == 'managermanager') { // Get all templates $result = $modx->db->select('templatename, id, description', $modx->getFullTableName('site_templates'), '', 'templatename ASC'); $all_templates = $modx->db->makeArray($result); $template_table = '<table>'; $template_table .= '<tr><th class="gridHeader">ID</th><th class="gridHeader">Template name</th><th class="gridHeader">Template description</th></tr>'; $template_table .= '<tr><td class="gridItem">0</td><td class="gridItem">(blank)</td><td class="gridItem">Blank</td></tr>'; foreach ($all_templates as $count => $tpl) { $class = $count % 2 ? 'gridItem' : 'gridAltItem'; $template_table .= '<tr>'; $template_table .= '<td class="' . $class . '">' . $tpl['id'] . '</td>'; $template_table .= '<td class="' . $class . '">' . jsSafe($tpl['templatename']) . '</td>'; $template_table .= '<td class="' . $class . '">' . jsSafe($tpl['description']) . '</td>'; $template_table .= '</tr>'; } $template_table .= '</table>'; // Get all tvs $result = $modx->db->select('name,caption,id', $modx->getFullTableName('site_tmplvars'), '', 'name ASC'); $all_tvs = $modx->db->makeArray($result); $tvs_table = '<table>'; $tvs_table .= '<tr><th class="gridHeader">ID</th><th class="gridHeader">TV name</th><th class="gridHeader">TV caption</th></tr>'; foreach ($all_tvs as $count => $tv) { $class = $count % 2 ? 'gridItem' : 'gridAltItem'; $tvs_table .= '<tr>'; $tvs_table .= '<td class="' . $class . '">' . $tv['id'] . '</td>'; $tvs_table .= '<td class="' . $class . '">' . jsSafe($tv['name']) . '</td>'; $tvs_table .= '<td class="' . $class . '">' . jsSafe($tv['caption']) . '</td>'; $tvs_table .= '</tr>'; } $tvs_table .= '</table>'; // Get all roles $result = $modx->db->select('name, id', $modx->getFullTableName('user_roles'), '', 'name ASC'); $all_roles = $modx->db->makeArray($result); $roles_table = '<table>'; $roles_table .= '<tr><th class="gridHeader">ID</th><th class="gridHeader">Role name</th></tr>'; foreach ($all_roles as $count => $role) { $class = $count % 2 ? 'gridItem' : 'gridAltItem'; $roles_table .= '<tr>'; $roles_table .= '<td class="' . $class . '">' . $role['id'] . '</td>'; $roles_table .= '<td class="' . $class . '">' . jsSafe($role['name']) . '</td>'; $roles_table .= '</tr>'; } $roles_table .= '</table>'; // Load the jquery library $output = '<!-- Begin ManagerManager output -->' . "\n"; $output .= '<script type="text/javascript">' . "\n"; $output .= "mm_lastTab = 'tabEvents'; \n"; $e->output($output); mm_createTab('Templates, TVs & Roles', 'rolestemplates', '', '', '<p>These are the IDs for current templates,tvs and roles in your site.</p>' . $template_table . ' ' . $tvs_table . ' ' . $roles_table); $e->output('</script>'); $e->output('<!-- End ManagerManager output -->' . "\n"); } break; case 'OnDocFormPrerender': // Load the jquery library echo '<!-- Begin ManagerManager output -->' . "\n"; // Create a mask to cover the page while the fields are being rearranged echo ' <div id="loadingmask"> </div> <script type="text/javascript"> $j("#loadingmask").css( {width: "100%", height: $j("body").height(), position: "absolute", zIndex: "1000", backgroundColor: "#ffffff"} ); </script> '; echo '<!-- End ManagerManager output -->'; break; // The main document editing form // The main document editing form case 'OnDocFormRender': // Include the JQuery call $e->output(' <!-- ManagerManager Plugin :: ' . $mm_version . ' --> <!-- This document is using template: ' . $mm_current_page['template'] . ' --> <!-- You are logged into the following role: ' . $mm_current_page['role'] . ' --> <script type="text/javascript" charset="' . $modx->config['modx_charset'] . '"> var mm_lastTab = "tabGeneral"; var mm_sync_field_count = 0; var synch_field = new Array(); $j(document).ready(function(){ // Lets handle errors nicely... try { // Change section index depending on Content History running or not var sidx = ($j("div.sectionBody:eq(1)").attr("id") == "ch-body")?1:0; //ch-body is the CH id name (currently at least) // Give IDs to the sections of the form // This assumes they appear in a certain order $j("div.sectionHeader:eq(sidx)").attr("id", "sectionContentHeader"); $j("div.sectionHeader:eq(sidx+1)").attr("id", "sectionTVsHeader"); $j("div.sectionBody:eq(sidx+1)").attr("id", "sectionContentBody"); $j("div.sectionBody:eq(sidx+2)").attr("id", "sectionTVsBody"); '); // Get the JS for the changes & display the status $e->output($this->make_changes($config_chunk)); // Close it off $e->output(' // Misc tidying up // General tab table container is too narrow for receiving TVs -- make it a bit wider $j("div#tabGeneral table").attr("width", "100%"); // if template variables containers are empty, remove their section if ($j("div.tmplvars :input").length == 0){ $j("div.tmplvars").hide(); // Still contains an empty table and some dividers $j("div.tmplvars").prev("div").hide(); // Still contains an empty table and some dividers //$j("#sectionTVsHeader").hide(); } // If template category is empty, hide the optgroup $j("#template optgroup").each( function(){ var $this = $j(this), visibleOptions = 0; $this.find("option").each( function() { if ($j(this).css("display") != "none") visibleOptions++ ; }); if (visibleOptions == 0) $this.hide(); }); }catch(e){ // If theres an error, fail nicely alert("ManagerManager: An error has occurred: " + e.name + " - " + e.message); }finally{ // Whatever happens, hide the loading mask $j("#loadingmask").hide(); } }); </script> <!-- ManagerManager Plugin :: End --> '); break; case 'OnBeforeDocFormSave': global $template; $mm_current_page['template'] = $template; $this->make_changes($config_chunk); break; case 'OnManagerMainFrameHeaderHTMLBlock': global $action; if (empty($action) && isset($_GET['a'])) { $action = $_GET['a']; } switch ($action) { case '4': case '27': case '72': case '73': case '76': case '300': case '301': $output = '<!-- Begin ManagerManager output -->' . "\n"; $e->output($output); break; default: return; } break; } // end switch }