forked from litzinger/Disposition
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathacc.disposition.php
158 lines (130 loc) · 5.98 KB
/
acc.disposition.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if (! defined('DISPOSITION_VERSION'))
{
// get the version from config.php
require PATH_THIRD.'disposition/config.php';
define('DISPOSITION_VERSION', $config['version']);
define('DISPOSITION_NAME', $config['name']);
define('DISPOSITION_DESCRIPTION', $config['description']);
define('DISPOSITION_DOCS_URL', $config['docs_url']);
}
/**
* ExpressionEngine Disposition Accessory Class
*
* @package ExpressionEngine
* @subpackage Accessories
* @category Disposition
* @author Brian Litzinger
* @copyright Copyright 2010 - Brian Litzinger
* @link http://boldminded.com/add-ons/disposition
*/
class Disposition_acc {
var $name = DISPOSITION_NAME;
var $id = 'disposition';
var $version = DISPOSITION_VERSION;
var $description = DISPOSITION_DESCRIPTION;
var $sections = array();
/**
* Constructor
*/
function Disposition_acc()
{}
function set_sections()
{
$this->EE =& get_instance();
// Remove the tab. This is lame.
$script = '
$("#'. $this->id .'.accessory").remove();
$("#accessoryTabs").find("a.'. $this->id .'").parent("li").remove();
';
if(REQ == 'CP' AND $this->EE->input->get('C') == 'content_edit')
{
$this->EE->load->library('javascript');
$action_url = $this->EE->config->item('site_url') .'?ACT='. $this->EE->cp->fetch_action_id('Disposition', 'update_entry_date');
$settings = $this->EE->db->select('settings')
->where('class', 'Disposition_ext')
->get('extensions')
->row('settings');
$site_id = $this->EE->config->item('site_id');
$settings = unserialize($settings);
$settings = isset($settings[$site_id]['enabled_channels']) ? implode('","', $settings[$site_id]['enabled_channels']) : false;
// If we have no settings, stop here
if(!$settings)
return;
$script .= '
var fixHelper = function(e, ui) {
ui.children().each(function() {
$(this).width($(this).width());
});
return ui;
};
$(".dataTables_wrapper").ajaxSuccess(function(e, xhr, settings)
{
url = settings.url;
var regex = /(M=edit_ajax_filter)/g;
channel_id = $("#f_channel_id").val();
settings = new Array("'. $settings .'");
if(regex.test(url) && $(".mainTable tbody tr").length > 1 && $.inArray(channel_id, settings) > -1)
{
$(".mainTable tbody tr").each(function(){
$(this).find("td:eq(0)").wrapInner(\'<div></div>\');
$(this).find("td:eq(0)").find(\'div\').prepend(\'<span class="disposition_handle"></span>\');
});
$(".mainTable tbody").sortable({
axis: "y",
placeholder: "ui-state-highlight",
distance: 5,
forcePlaceholderSize: true,
items: "tr",
helper: fixHelper,
handle: ".disposition_handle",
update: function(event, ui){
ids = new Array();
$(".mainTable tbody tr").each(function(){
ids.push($(this).find("td:eq(0)").text());
});
dragged = ui.item.find("td:eq(0)").text();
sort_order = $(".mainTable th:eq(4)").attr("class");
sort_order = sort_order == "headerSortDown" ? "desc" : "asc";
$(this).find("tr:odd").removeClass("odd even").addClass("odd");
$(this).find("tr:even").removeClass("odd even").addClass("even");
$.ajax({
type: "POST",
url: "'. $action_url .'",
data: "sort_order="+ sort_order +"&dragged="+ dragged +"&ids="+ ids.toString()
});
}
});
}
});
';
// Output JS, and remove extra white space and line breaks
$this->EE->javascript->output(preg_replace("/\s+/", " ", $script));
$this->EE->javascript->compile();
$css = '
.disposition_handle {
width: 14px;
height: 20px;
background: url(data:image/gif;base64,R0lGODlhEwATAIABAKKiosrklCH5BAEAAAEALAAAAAATABMAQAIXjI+pCO2wopy02steq3rjD4biSJbmKRYAOw%3D%3D) 50% 50% no-repeat;
position: absolute;
top: -4px;
left: -5px;
cursor: move;
}
.mainTable tbody tr td:first-child div {
position: relative;
padding-left: 12px;
}
';
// Output CSS, and remove extra white space and line breaks
$this->EE->cp->add_to_head('<!-- BEGIN Disposition assets --><style type="text/css">'. preg_replace("/\s+/", " ", $css) .'</style><!-- END Disposition assets -->');
}
}
private function debug($str, $die = false)
{
echo '<pre>';
var_dump($str);
echo '</pre>';
if($die) die('debug terminated');
}
}