Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
full.php
Go to the documentation of this file.
1 <?php
16 /* @var ElggPlugin $plugin */
17 $plugin = $vars['entity'];
18 $reordering = elgg_extract('display_reordering', $vars, false);
19 $priority = $plugin->getPriority();
20 $active = $plugin->isActive();
21 
22 $can_activate = $plugin->canActivate();
24 $actions_base = '/action/admin/plugins/';
25 $css_id = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID());
26 
27 // build reordering links
28 $links = '';
29 $classes = array('elgg-plugin');
30 
31 if ($reordering) {
32  $classes[] = 'elgg-state-draggable';
33 
34  // top and up link only if not at top
35  if ($priority > 1) {
36  $top_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
37  'plugin_guid' => $plugin->guid,
38  'priority' => 'first',
39  'is_action' => true
40  ));
41 
42  $links .= "<li>" . elgg_view('output/url', array(
43  'href' => $top_url,
44  'text' => elgg_echo('top'),
45  'is_action' => true,
46  'is_trusted' => true,
47  )) . "</li>";
48 
49  $up_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
50  'plugin_guid' => $plugin->guid,
51  'priority' => '-1',
52  'is_action' => true
53  ));
54 
55  $links .= "<li>" . elgg_view('output/url', array(
56  'href' => $up_url,
57  'text' => elgg_echo('up'),
58  'is_action' => true,
59  'is_trusted' => true,
60  )) . "</li>";
61  }
62 
63  // down and bottom links only if not at bottom
64  if ($priority < $max_priority) {
65  $down_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
66  'plugin_guid' => $plugin->guid,
67  'priority' => '+1',
68  'is_action' => true
69  ));
70 
71  $links .= "<li>" . elgg_view('output/url', array(
72  'href' => $down_url,
73  'text' => elgg_echo('down'),
74  'is_action' => true,
75  'is_trusted' => true,
76  )) . "</li>";
77 
78  $bottom_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
79  'plugin_guid' => $plugin->guid,
80  'priority' => 'last',
81  'is_action' => true
82  ));
83 
84  $links .= "<li>" . elgg_view('output/url', array(
85  'href' => $bottom_url,
86  'text' => elgg_echo('bottom'),
87  'is_action' => true,
88  'is_trusted' => true,
89  )) . "</li>";
90  }
91 
92  if ($links) {
93  $links = '<ul class="elgg-menu elgg-plugin-list-reordering">' . $links . '</ul>';
94  }
95 } else {
96  $classes[] = 'elgg-state-undraggable';
97 }
98 
99 
100 // activate / deactivate links
101 
102 // always let them deactivate
103 $options = array(
104  'is_action' => true,
105  'is_trusted' => true,
106 );
107 if ($active) {
108  $classes[] = 'elgg-state-active';
109  $action = 'deactivate';
110  $options['title'] = elgg_echo('admin:plugins:deactivate');
111  $options['class'] = 'elgg-button elgg-button-cancel';
112  $options['text'] = elgg_echo('admin:plugins:deactivate');
113  if (!$can_activate) {
114  $classes[] = 'elgg-state-cannot-activate';
115  }
116 } else if ($can_activate) {
117  $classes[] = 'elgg-state-inactive';
118  $action = 'activate';
119  $options['title'] = elgg_echo('admin:plugins:activate');
120  $options['class'] = 'elgg-button elgg-button-submit';
121  $options['text'] = elgg_echo('admin:plugins:activate');
122 
123 } else {
124  $classes[] = 'elgg-state-inactive elgg-state-cannot-activate';
125  $action = '';
126  $options['text'] = elgg_echo('admin:plugins:cannot_activate');
127 
128  $options['disabled'] = 'disabled';
129 }
130 
131 if ($action) {
133  'plugin_guids[]' => $plugin->guid
134  ));
135 
136  $options['href'] = $url;
137 }
139 
140 $action_button = elgg_trigger_plugin_hook("action_button", "plugin", array("entity" => $plugin), $action_button);
141 
142 // Display categories and make category classes
143 $categories = $plugin->getManifest()->getCategories();
144 
145 $categories[] = "all";
146 
147 if (!in_array("bundled", $categories)) {
148  $categories[] = "nonbundled";
149 }
150 
151 if ($active) {
152  $categories[] = "active";
153 } else {
154  $categories[] = "inactive";
155 }
156 
158 if ($categories) {
159  foreach ($categories as $category) {
160  $css_class = preg_replace('/[^a-z0-9-]/i', '-', $category);
161  $classes[] = "elgg-plugin-category-$css_class";
162  }
163 }
164 
165 // metadata
166 $description = elgg_view('output/longtext', array('value' => $plugin->getManifest()->getDescription()));
167 
168 $settings_view_old = 'settings/' . $plugin->getID() . '/edit';
169 $settings_view_new = 'plugins/' . $plugin->getID() . '/settings';
172  $link = elgg_get_site_url() . "admin/plugin_settings/" . $plugin->getID();
173  $settings_link = "<a class='elgg-plugin-settings' href='$link' title='" . elgg_echo('settings') . "'>" . elgg_view_icon("settings-alt") . "</a>";
174 }
175 
177  'class' => $classes,
178  'id' => $css_id,
179  'data-guid' => $plugin->guid,
180 ];
181 
182 ?>
183 <div <?= elgg_format_attributes($attrs) ?>>
184  <div class="elgg-image-block">
185  <div class="elgg-image">
186  <div>
187  <?php echo $action_button; ?>
188  </div>
189  </div>
190  <div class="elgg-body">
191  <div class="elgg-head">
192  <?php
193  echo $links;
194  $url_options = array(
195  "href" => "ajax/view/object/plugin/details?guid=" . $plugin->getGUID(),
196  "text" => $plugin->getManifest()->getName(),
197  "class" => "elgg-lightbox",
198  );
199  echo elgg_view("output/url", $url_options);
200 
201  echo " ". $settings_link;
202  ?>
203  <span class="elgg-plugin-list-description">
204  <?php echo $description;?>
205  </span>
206  </div>
207  </div>
208  </div>
209 </div>
if($action) $action_button
Definition: full.php:138
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL's query string.
Definition: elgglib.php:1171
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:299
elgg_view_icon($name, $vars=array())
View one of the icons.
Definition: views.php:1447
$settings_view_new
Definition: full.php:169
$action
Definition: full.php:125
$categories_html
Definition: full.php:157
$priority
Definition: full.php:19
$max_priority
Definition: full.php:23
$settings_view_old
Definition: full.php:168
$links
Definition: full.php:28
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:143
$can_activate
Definition: full.php:22
$url
Definition: exceptions.php:24
$vars['entity']
$plugin
Definition: full.php:17
if($categories) $description
Definition: full.php:166
if(elgg_view_exists($settings_view_old)||elgg_view_exists($settings_view_new)) $attrs
Definition: full.php:176
if(elgg_view_exists($settings_view_old)||elgg_view_exists($settings_view_new)) $url_options
Definition: full.php:194
$active
Definition: full.php:20
$reordering
Definition: full.php:18
$classes
Definition: full.php:29
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:801
_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:342
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
$css_id
Definition: full.php:25
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:1310
$settings_link
Definition: full.php:170
$actions_base
Definition: full.php:24
$options
Definition: full.php:103