Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions assets/plugins/managermanager/functions/topmenu.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?php

global $mm_top_menu,$mm_debug;
$mm_debug = false;//debug?
$mm_top_menu = array(
'site'=>array('id'=>'#limenu3','href'=>'#menu3'),
'home'=>array('href'=>'index.php?a=2'),
'preview'=>array('href'=>'../'),
'clear cache'=>array('href'=>'index.php?a=26'),
'search'=>array('href'=>'index.php?a=71'),
'new resource'=>array('href'=>'index.php?a=4'),
'new weblink'=>array('href'=>'index.php?a=72'),

'elements'=>array('id'=>'#limenu5','href'=>'#menu5'),
'manage elements'=>array('href'=>'index.php?a=76'),
'manage files'=>array('href'=>'index.php?a=31'),
'manage metatags'=>array('href'=>'index.php?a=81'),

'modules'=>array('id'=>'#limenu9','href'=>'#menu9'),
'manage modules'=>array('href'=>'index.php?a=106'),

'security'=>array('id'=>'#limenu2','href'=>'#menu2'),
'manager users'=>array('href'=>'index.php?a=75'),
'web users'=>array('href'=>'index.php?a=99'),
'roles'=>array('href'=>'index.php?a=86'),
'manager permissions'=>array('href'=>'index.php?a=40'),
'web permissions'=>array('href'=>'index.php?a=91'),

'tools'=>array('id'=>'#limenu1-1','href'=>'#menu1-1'),
'backup'=>array('href'=>'index.php?a=93'),
'remove locks'=>array('href'=>'javascript:removeLocks();'),
'import html'=>array('href'=>'index.php?a=95'),
'export html'=>array('href'=>'index.php?a=83'),
'configuration'=>array('href'=>'index.php?a=17'),

'reports'=>array('id'=>'#limenu1-2','href'=>'#menu1-2'),
'shedule'=>array('href'=>'index.php?a=70'),
'system events'=>array('href'=>'index.php?a=114'),
'manager actions'=>array('href'=>'index.php?a=13'),
'system info'=>array('href'=>'index.php?a=53')
);


function renameMenu($name, $newname, $roles='') {
$name = strtolower($name);
global $mm_top_menu;
if (useThisRule($roles)) {
$output .= " // ----------- rename tab -------------- \n";
if((int)$name > 0) {
//rename module tab
$output .= "\$j(\"a[href='index.php?a=112&id=".$name."']\").html('".$newname."');\n";
}
else {
//rename tab
$output .= "\$j(\"a[href='".$mm_top_menu[$name]['href']."']\").html('".$newname."');\n";
}
echo ($output . "\n");
}
}


function hideMenu($names, $roles='') {
$name = strtolower($name);
global $mm_top_menu;
if (useThisRule($roles)) {
$output .= " // ----------- hide tab -------------- \n";
$tabsArray = explode(',',$names);
foreach($tabsArray as $name) {
if((int)$name > 0) {
//hide module tab
$output .= "\$j(\"a[href='index.php?a=112&id=".$name."']\").parent().remove();\n";
}
else {
//hide tab
$output .= "\$j(\"a[href='".$mm_top_menu[$name]['href']."']\").parent().remove();\n";
}
}
echo ($output . "\n");
}
}

function moveMenu($name, $index='', $roles='') {
$name = strtolower($name);
global $mm_top_menu;
(int)$index;
if (useThisRule($roles)) {
$output = " // ----------- move top tab -------------- \n";
if($index) {
$output .= "tab = \$j('".$mm_top_menu[$name]['id']."');\n";
$output .= "tabs = \$j('#nav').children('li');\n";
$output .= "tabs.eq(larry(".$index.", tabs.size())).before(tab);\n";
}
else {
$output .= "\$j('#nav').append(tab);\n";
}
echo ($output . "\n");
}
}


function addMenu($name,$id,$index='', $roles='') {
global $mm_debug;
(int)$index;
if (useThisRule($roles)) {
$output .= " // ----------- add top tab -------------- \n";
$output.="tab = \$j('<li id=\"limenu".$id."\"><a onclick=\"new NavToggle(this); return false;\" href=\"#menu".$id."\">".$name."</a><ul id=\"menu".$id."\" class=\"subnav\"></ul></li>');\n";
if($index) {
$output .= "tabs = \$j('#nav').children('li');\n";
$output .= "tabs.eq(larry(".$index.", tabs.size())).before(tab);\n";

}
else {
$output .= "\$j('#nav').append(tab);\n";
}

echo ($output . "\n");
}
}

function addSubMenu($name,$parentTabId,$path='',$index='', $roles='') {
global $mm_top_menu,$mm_debug;
(int)$index;
if (useThisRule($roles)) {
$output .= " // ----------- add subtab -------------- \n";
if(in_array($parentTabId,array_keys($mm_top_menu))) {
$output.= "parentTab = \$j('".$mm_top_menu[$parentTabId]['id']."');\n";
}
else {
$output.= "parentTab = \$j('#limenu".$parentTabId."');\n";
}
$output.="tab = \$j('<li class=\"\"><a target=\"main\" href=\"".$path."\" onclick=\"this.blur();\">".$name."</a></li>');\n";
$output.="tabs = \$j(parentTab).children('ul').children('li');\n";
if($mm_debug) {
$output .= "console.log(\"add subtab ".$name."\",tabs,tabs.length);\n";
}
if($index) {
$output .= "tabs.eq(larry(".$index.", tabs.length)).after(tab);\n";
}
else {
$output .= "\$j(tab).appendTo(parentTab.children('ul'));\n";
}

echo ($output . "\n");
}
}










?>
65 changes: 60 additions & 5 deletions assets/plugins/managermanager/mm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
$ignore_first_chars = array('.', '_', '!');

// Include functions - we'll load all *.inc.php files in the "functions" folder
$function_dir = $modx->config['base_path'] . 'assets/plugins/managermanager/functions';
$function_dir = $mm_path . 'functions';
if ($handle = opendir($function_dir)) {
while (false !== ($file = readdir($handle))) {
if (!in_array(substr($file, 0, 1), $ignore_first_chars) && $file != ".." && substr($file, -8) == '.inc.php') {
Expand All @@ -66,7 +66,7 @@
// Include widgets
// We look for a PHP file with the same name as the directory - e.g.
// /widgets/widgetname/widgetname.php
$widget_dir = $modx->config['base_path'] . 'assets/plugins/managermanager/widgets';
$widget_dir = $mm_path . '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)) {
Expand Down Expand Up @@ -116,7 +116,8 @@
'which_editor' => array('fieldtype'=>'select', 'fieldname'=>'which_editor','dbname'=>'', 'tv'=>false),
'resource_type' => array('fieldtype'=>'select', 'fieldname'=>'type', 'dbname'=>'isfolder', 'tv'=>false),
'weblink' => array('fieldtype'=>'input', 'fieldname'=>'ta', 'dbname'=>'content', 'tv'=>false)
);
);



// Add in TVs to the list of available fields
Expand Down Expand Up @@ -169,7 +170,7 @@
function make_changes($chunk) {

global $modx; // Global modx object
$config_file = $modx->config['base_path'] . 'assets/plugins/managermanager/mm_rules.inc.php';
$config_file = $mm_path . 'mm_rules.inc.php';

// See if there is any chunk output (e.g. it exists, and is not empty)
$chunk_output = $modx->getChunk($chunk);
Expand Down Expand Up @@ -358,7 +359,7 @@ function make_changes($chunk) {


// Where would we get the config file from?
$config_file = $modx->config['base_path'] . 'assets/plugins/managermanager/mm_rules.inc.php';
$config_file = $mm_path . 'mm_rules.inc.php';

// See if there is any chunk output (e.g. it exists, and is not empty)
$chunk_output = $modx->getChunk($config_chunk);
Expand Down Expand Up @@ -451,8 +452,62 @@ function make_changes($chunk) {
}

break;
//MODx manager top menu
case 'OnManagerPageInit':
if($_REQUEST['f'] == 'menu') {
echo includeJs($js_url, 'html');
echo '
<!-- ManagerManager Plugin :: '.$mm_version.':: Top menu start -->

<!-- You are logged into the following role: '. $mm_current_page['role'] .' -->
<style type="text/css">
/*hide top menu*/
#topMenu{
display:none;
}
</style>
<script type="text/javascript" charset="'.$modx->config['modx_charset'].'">
var $j = jQuery.noConflict();
function larry( index, length ){
if( ( index = parseInt( index ) ) != 0 ){
index = index < 0 ? length + index : index - 1;
}
return index < 0 ? 0 : index > length ? length - 1 : index;
}

$j(document).ready(function() {

';
// Where would we get the config file from?
$config_file = $mm_path . 'mm_topmenu_rules.inc.php';

// See if there is any chunk output (e.g. it exists, and is not empty)
$chunk_output = $modx->getChunk($topmenu_config_chunk);
if (!empty($chunk_output)) {
echo "// Getting rules from chunk: $topmenu_config_chunk \n\n";

eval($chunk_output); // If there is, run it.
} else if (is_readable($config_file)) { // If there's no chunk output, read in the file.
echo "// Getting rules from file: $config_file \n\n";
include($config_file);
} else {
echo "// No rules found \n\n";
}

echo '
//set first tab active
$j("#nav").children("li").removeClass("active").filter(":first").addClass("active");
//show top menu
$j("#topMenu").css("display","block").hide().fadeIn(400);

});
</script>
<!-- ManagerManager Plugin :: Top menu :: End -->
';

}

break;

} // end switch

Expand Down
6 changes: 3 additions & 3 deletions assets/plugins/managermanager/widgets/!template/!template.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//---------------------------------------------------------------------------------
function mm_widget_template($fields, $other_param='defaultValue', $roles='', $templates='') {

global $modx, $content, $mm_fields;
global $modx, $content, $mm_fields, $mm_url;
$e = &$modx->Event;

if (useThisRule($roles, $templates)) {
Expand Down Expand Up @@ -42,8 +42,8 @@ function mm_widget_template($fields, $other_param='defaultValue', $roles='', $te

// We have functions to include JS or CSS external files you might need
// The standard ModX API methods don't work here
$output .= includeJs('/assets/plugins/managermanager/widgets/template/javascript.js');
$output .= includeCss('/assets/plugins/managermanager/widgets/template/styles.css');
$output .= includeJs($mm_url . 'widgets/template/javascript.js');
$output .= includeCss($mm_url . 'widgets/template/styles.css');


// Do something for each of the fields supplied
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//---------------------------------------------------------------------------------
function mm_widget_accessdenied($ids='', $message='', $roles='') {

global $modx, $content;
global $modx, $content, $mm_url;
$e = &$modx->Event;

if (empty($message)) $message='<span>Access denied</span>Access to current document closed for security reasons.';
Expand All @@ -23,7 +23,7 @@ function mm_widget_accessdenied($ids='', $message='', $roles='') {

if (in_array($docid, $ids))
{
$output .= includeCss($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/accessdenied/accessdenied.css');
$output .= includeCss($mm_url . 'widgets/accessdenied/accessdenied.css');

$output .= '
$j("input, div, form[name=mutate]").remove(); // Remove all content from the page
Expand Down
6 changes: 3 additions & 3 deletions assets/plugins/managermanager/widgets/colors/colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Adds a color selection widget to the specified TVs
//---------------------------------------------------------------------------------
function mm_widget_colors($fields, $default='#ffffff', $roles='', $templates='') {
global $modx, $content, $mm_fields;
global $modx, $content, $mm_fields, $mm_url;
$e = &$modx->Event;

if (useThisRule($roles, $templates)) {
Expand All @@ -33,10 +33,10 @@ function mm_widget_colors($fields, $default='#ffffff', $roles='', $templates='')
}

// Insert some JS
$output .= includeJs($modx->config['base_url'] .'assets/plugins/managermanager/widgets/colors/farbtastic.js');
$output .= includeJs($mm_url .'widgets/colors/farbtastic.js');

// Insert some CSS
$output .= includeCss($modx->config['base_url'] .'assets/plugins/managermanager/widgets/colors/farbtastic.css');
$output .= includeCss($mm_url .'widgets/colors/farbtastic.css');

// Go through each of the fields supplied
foreach ($fields as $tv) {
Expand Down
10 changes: 5 additions & 5 deletions assets/plugins/managermanager/widgets/tags/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//---------------------------------------------------------------------------------
function mm_widget_tags($fields, $delimiter=',', $source='', $display_count=false, $roles='', $templates='') {

global $modx, $content, $mm_fields;
global $modx, $content, $mm_fields, $mm_url;
$e = &$modx->Event;

if (useThisRule($roles, $templates)) {
Expand Down Expand Up @@ -43,9 +43,9 @@ function mm_widget_tags($fields, $delimiter=',', $source='', $display_count=fals


// Insert some JS and a style sheet into the head
$output .= "// -------------- Tag widget include ------------- \n";
$output .= includeJs($modx->config['base_url'] .'assets/plugins/managermanager/widgets/tags/tags.js');
$output .= includeCss($modx->config['base_url'] .'assets/plugins/managermanager/widgets/tags/tags.css');
$output .= "// -------------- Tag widget include ".$mm_url."------------- \n";
$output .= includeJs($mm_url . 'widgets/tags/tags.js');
$output .= includeCss($mm_url . 'widgets/tags/tags.css');


// Go through each of the fields supplied
Expand Down Expand Up @@ -98,4 +98,4 @@ function mm_widget_tags($fields, $delimiter=',', $source='', $display_count=fals
}
$e->output($output . "\n");
}
?>
?>
13 changes: 9 additions & 4 deletions plugin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* @category plugin
* @version 0.3.9dev
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL)
* @internal @properties &config_chunk=Configuration Chunk;text;mm_demo_rules; &remove_deprecated_tv_types_pref=Remove deprecated TV types;list;yes,no;yes &which_jquery=jQuery source;list;local (assets/js),remote (google code),manual url (specify below);local (assets/js) &js_src_type=jQuery URL override;text;
* @internal @events OnDocFormRender,OnDocFormPrerender,OnPluginFormRender,OnTVFormRender
* @internal @properties &topmenu_config_chunk=Top Menu Configuration Chunk;text;topmenu_rules &config_chunk=Configuration Chunk;text;mm_demo_rules &remove_deprecated_tv_types_pref=Remove deprecated TV types;list;yes,no;yes &which_jquery=jQuery source;list;local (assets/js),remote (google code),manual url (specify below);local (assets/js) &js_src_type=jQuery URL override;text;
* @internal @events OnDocFormRender,OnDocFormPrerender,OnPluginFormRender,OnTVFormRender,OnManagerPageInit
* @internal @modx_category Manager and Admin
* @internal @legacy_names Image TV Preview, Show Image TVs
*/
Expand Down Expand Up @@ -37,5 +37,10 @@ $js_default_url_remote = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jque
//-------------------------------------------------------

// Run the main code
$asset_path = $modx->config['base_path'] . 'assets/plugins/managermanager/mm.inc.php';
include($asset_path);

global $mm_url;

$mm_url = $modx->config['base_url'] . 'assets/plugins/managermanager/' ;
$mm_path = $modx->config['base_path'] . 'assets/plugins/managermanager/';

include($mm_path.'mm.inc.php');