Elgg  Version 2.3
full.php
Go to the documentation of this file.
1 <?php
14 /* @var ElggPlugin $plugin */
15 $plugin = $vars['entity'];
16 $reordering = elgg_extract('display_reordering', $vars, false);
17 $priority = $plugin->getPriority();
18 $active = $plugin->isActive();
19 
20 if ($plugin->isActive()) {
21  $can_activate = false;
22  $can_deactivate = $plugin->canDeactivate();
23 } else {
24  $can_deactivate = false;
25  $can_activate = $plugin->canActivate();
26 }
27 
29 $actions_base = '/action/admin/plugins/';
30 $css_id = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID());
31 
32 // build reordering links
33 $links = '';
34 $classes = array('elgg-plugin');
35 
36 if ($reordering) {
37  $classes[] = 'elgg-state-draggable';
38 
39  // top and up link only if not at top
40  if ($priority > 1) {
41  $top_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
42  'plugin_guid' => $plugin->guid,
43  'priority' => 'first',
44  'is_action' => true
45  ));
46 
47  $links .= "<li>" . elgg_view('output/url', array(
48  'href' => $top_url,
49  'text' => elgg_echo('top'),
50  'is_action' => true,
51  'is_trusted' => true,
52  )) . "</li>";
53 
54  $up_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
55  'plugin_guid' => $plugin->guid,
56  'priority' => '-1',
57  'is_action' => true
58  ));
59 
60  $links .= "<li>" . elgg_view('output/url', array(
61  'href' => $up_url,
62  'text' => elgg_echo('up'),
63  'is_action' => true,
64  'is_trusted' => true,
65  )) . "</li>";
66  }
67 
68  // down and bottom links only if not at bottom
69  if ($priority < $max_priority) {
70  $down_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
71  'plugin_guid' => $plugin->guid,
72  'priority' => '+1',
73  'is_action' => true
74  ));
75 
76  $links .= "<li>" . elgg_view('output/url', array(
77  'href' => $down_url,
78  'text' => elgg_echo('down'),
79  'is_action' => true,
80  'is_trusted' => true,
81  )) . "</li>";
82 
83  $bottom_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
84  'plugin_guid' => $plugin->guid,
85  'priority' => 'last',
86  'is_action' => true
87  ));
88 
89  $links .= "<li>" . elgg_view('output/url', array(
90  'href' => $bottom_url,
91  'text' => elgg_echo('bottom'),
92  'is_action' => true,
93  'is_trusted' => true,
94  )) . "</li>";
95  }
96 
97  if ($links) {
98  $links = '<ul class="elgg-menu elgg-plugin-list-reordering">' . $links . '</ul>';
99  }
100 } else {
101  $classes[] = 'elgg-state-undraggable';
102 }
103 
104 
105 // activate / deactivate links
106 // always let them deactivate
107 $options = array(
108  'is_action' => true,
109  'is_trusted' => true,
110 );
111 if ($active) {
112  $classes[] = 'elgg-state-active';
113  $options['title'] = elgg_echo('admin:plugins:deactivate');
114  $options['text'] = elgg_echo('admin:plugins:deactivate');
115  if ($can_deactivate) {
116  $action = 'deactivate';
117  $options['class'] = 'elgg-button elgg-button-cancel elgg-plugin-state-change';
118  } else {
119  $action = '';
120  $classes[] = 'elgg-state-cannot-deactivate';
121  $options['title'] = elgg_echo('admin:plugins:cannot_deactivate');
122  $options['class'] = 'elgg-button elgg-button-cancel elgg-state-disabled';
123  $options['disabled'] = 'disabled';
124  }
125 } else if ($can_activate) {
126  $classes[] = 'elgg-state-inactive';
127  $action = 'activate';
128  $options['title'] = elgg_echo('admin:plugins:activate');
129  $options['class'] = 'elgg-button elgg-button-submit elgg-plugin-state-change';
130  $options['text'] = elgg_echo('admin:plugins:activate');
131 } else {
132  $classes[] = 'elgg-state-inactive elgg-state-cannot-activate';
133  $action = '';
134  $options['title'] = elgg_echo('admin:plugins:cannot_activate');
135  $options['class'] = 'elgg-button elgg-button-submit elgg-state-disabled';
136  $options['text'] = elgg_echo('admin:plugins:activate');
137  $options['disabled'] = 'disabled';
138 }
139 
140 if ($action) {
142  'plugin_guids[]' => $plugin->guid
143  ));
144 
145  $options['href'] = $url;
146 }
147 
149 
150 $action_button = elgg_trigger_plugin_hook("action_button", "plugin", array("entity" => $plugin), $action_button);
151 
152 // Display categories and make category classes
153 $categories = $plugin->getManifest()->getCategories();
154 
155 $categories[] = "all";
156 
157 if (!in_array("bundled", $categories)) {
158  $categories[] = "nonbundled";
159 }
160 
161 if ($active) {
162  $categories[] = "active";
163 } else {
164  $categories[] = "inactive";
165 }
166 
168 if ($categories) {
169  foreach ($categories as $category) {
170  $css_class = preg_replace('/[^a-z0-9-]/i', '-', $category);
171  $classes[] = "elgg-plugin-category-$css_class";
172  }
173 }
174 
175 // metadata
176 $description = elgg_view('output/longtext', array('value' => $plugin->getManifest()->getDescription()));
177 
178 $settings_view_old = 'settings/' . $plugin->getID() . '/edit';
179 $settings_view_new = 'plugins/' . $plugin->getID() . '/settings';
182  $link = elgg_get_site_url() . "admin/plugin_settings/" . $plugin->getID();
183  $settings_link = "<a class='elgg-plugin-settings' href='$link' title='" . elgg_echo('settings') . "'>" . elgg_view_icon("settings-alt") . "</a>";
184 }
185 
187  'class' => $classes,
188  'id' => $css_id,
189  'data-guid' => $plugin->guid,
190 ];
191 ?>
192 <div <?= elgg_format_attributes($attrs) ?>>
193  <div class="elgg-image-block">
194  <div class="elgg-image">
195  <div>
196  <?php echo $action_button; ?>
197  </div>
198  </div>
199  <div class="elgg-body">
200  <div class="elgg-head">
201  <?php
202  echo $links;
203  $url_options = array(
204  "href" => "ajax/view/object/plugin/details?guid=" . $plugin->getGUID(),
205  "text" => $plugin->getManifest()->getName(),
206  "class" => "elgg-lightbox elgg-plugin-title",
207  );
208  echo elgg_view("output/url", $url_options);
209 
210  echo " " . $settings_link;
211  ?>
212  <span class="elgg-plugin-list-description">
213  <?php echo $description; ?>
214  </span>
215  </div>
216  <?php
217  $error = $plugin->getError();
218  if ($error) {
219  ?>
220  <div class="elgg-body elgg-plugin-list-error">
221  <?php
223  'class' => $plugin->isActive() ? 'elgg-text-help' : 'elgg-text-help elgg-state-error',
224  ], $error);
225  ?>
226  </div>
227  <?php
228  }
229  ?>
230  </div>
231  </div>
232 </div>
if($action) $action_button
Definition: full.php:148
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:1199
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:293
elgg_view_icon($name, $vars=array())
View one of the icons.
Definition: views.php:1582
$settings_view_new
Definition: full.php:179
$action
Definition: full.php:133
$categories_html
Definition: full.php:167
$priority
Definition: full.php:17
$max_priority
Definition: full.php:28
$settings_view_old
Definition: full.php:178
$links
Definition: full.php:33
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$categories
Definition: full.php:153
$can_activate
Definition: full.php:25
$link
Definition: container.php:14
ui datepicker td span
Definition: admin.css.php:680
$url
Definition: exceptions.php:24
$vars['entity']
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:208
$plugin
Definition: full.php:15
if($categories) $description
Definition: full.php:176
if(elgg_view_exists($settings_view_old)||elgg_view_exists($settings_view_new)) $attrs
Definition: full.php:186
if(elgg_view_exists($settings_view_old)||elgg_view_exists($settings_view_new)) $url_options
Definition: full.php:203
$active
Definition: full.php:18
fieldset div
Definition: admin.css.php:485
$reordering
Definition: full.php:16
$classes
Definition: full.php:34
elgg echo
Translates a string.
Definition: languages.js:48
$error
Definition: full.php:217
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:826
_elgg_get_max_plugin_priority()
Returns the highest priority of the plugins.
Definition: plugins.php:108
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:336
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
$css_id
Definition: full.php:30
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1375
$settings_link
Definition: full.php:180
$actions_base
Definition: full.php:29
$options
Definition: full.php:107