aboutsummaryrefslogtreecommitdiff
path: root/engine/classes
diff options
context:
space:
mode:
Diffstat (limited to 'engine/classes')
-rw-r--r--engine/classes/ElggEntity.php7
-rw-r--r--engine/classes/ElggMenuItem.php56
-rw-r--r--engine/classes/ElggPlugin.php7
-rw-r--r--engine/classes/ElggPluginPackage.php13
-rw-r--r--engine/classes/ElggSite.php11
5 files changed, 66 insertions, 28 deletions
diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php
index 79b8c2a4e..8fc1e46cb 100644
--- a/engine/classes/ElggEntity.php
+++ b/engine/classes/ElggEntity.php
@@ -850,12 +850,11 @@ abstract class ElggEntity extends ElggData implements
* @since 1.8.0
*/
function countComments() {
- $type = $this->getType();
$params = array('entity' => $this);
- $number = elgg_trigger_plugin_hook('comments:count', $type, $params, false);
+ $num = trigger_plugin_hook('comments:count', $this->getType(), $params);
- if ($number) {
- return $number;
+ if (is_int($num)) {
+ return $num;
} else {
return $this->getAnnotationCalculation('generic_comment', 'count');
}
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php
index 61dbf539e..cd6267ad6 100644
--- a/engine/classes/ElggMenuItem.php
+++ b/engine/classes/ElggMenuItem.php
@@ -132,7 +132,7 @@ class ElggMenuItem {
$item->setItemClass($options['item_class']);
unset($options['item_class']);
}
-
+
foreach ($options as $key => $value) {
$item->$key = $value;
}
@@ -153,9 +153,20 @@ class ElggMenuItem {
public function getName() {
return $this->name;
}
+
+ /**
+ * Set the display text of the menu item
+ *
+ * @param string $text The display text
+ *
+ * @return void
+ */
+ public function setText($text) {
+ $this->text = $text;
+ }
/**
- * Get the display text of the menu
+ * Get the display text of the menu item
*
* @return string
*/
@@ -164,6 +175,15 @@ class ElggMenuItem {
}
/**
+ * Set the URL of the menu item
+ *
+ * @return void
+ */
+ public function setHref($href) {
+ $this->href = $href;
+ }
+
+ /**
* Get the URL of the menu item
*
* @return string
@@ -325,7 +345,16 @@ class ElggMenuItem {
* @return string
*/
public function getItemClass() {
- return implode(' ', $this->itemClass);
+ //allow people to specify name with underscores and colons
+ $name = str_replace('_', '-', $this->getName());
+ $name = str_replace(':', '-', $name);
+
+ $class = implode(' ', $this->itemClass);
+ if ($class) {
+ return "elgg-menu-item-$name $class";
+ } else {
+ return "elgg-menu-item-$name";
+ }
}
/**
@@ -420,6 +449,17 @@ class ElggMenuItem {
}
/**
+ * Set the menu item's children
+ *
+ * @param array $children Array of ElggMenuItems
+ *
+ * @return void
+ */
+ public function setChildren($children) {
+ $this->children = $children;
+ }
+
+ /**
* Get the children menu items
*
* @return array
@@ -445,7 +485,7 @@ class ElggMenuItem {
* @params array $vars Options to pass to output/url if a link
*
* @return string
- *
+ *
* @todo View code in a model. How do we feel about that?
*/
public function getContent(array $vars = array()) {
@@ -455,7 +495,7 @@ class ElggMenuItem {
}
$vars['text'] = $this->text;
-
+
if ($this->href) {
$vars['href'] = $this->href;
}
@@ -463,15 +503,15 @@ class ElggMenuItem {
if ($this->linkClass) {
$vars['class'] = $this->getLinkClass();
}
-
+
if ($this->rel) {
$vars['rel'] = $this->rel;
}
-
+
if ($this->title) {
$vars['title'] = $this->title;
}
-
+
if ($this->is_action) {
$vars['is_action'] = $this->is_action;
}
diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php
index eb911455a..95a7362e2 100644
--- a/engine/classes/ElggPlugin.php
+++ b/engine/classes/ElggPlugin.php
@@ -839,12 +839,7 @@ class ElggPlugin extends ElggObject {
return true;
}
- // but need to have working ones.
- if (!elgg_register_classes($classes_path)) {
- $msg = elgg_echo('ElggPlugin:Exception:CannotRegisterClasses',
- array($this->getID(), $this->guid, $classes_path));
- throw new PluginException($msg);
- }
+ elgg_register_classes($classes_path);
return true;
}
diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php
index 9aa4af8bf..977b72d76 100644
--- a/engine/classes/ElggPluginPackage.php
+++ b/engine/classes/ElggPluginPackage.php
@@ -457,16 +457,11 @@ class ElggPluginPackage {
// grab the ElggPlugin using this package.
$plugin_package = elgg_get_plugin_from_id($this->getID());
$plugin_priority = $plugin_package->getPriority();
+ $test_plugin = elgg_get_plugin_from_id($dep['plugin']);
- foreach ($plugins as $test_plugin) {
- if ($test_plugin->getID() == $dep['plugin']) {
- break;
- }
- }
-
- // If this isn't a plugin or there are no active plugins,
- // we can't satisfy this dep.
- if (!$plugin_package || !$plugins) {
+ // If this isn't a plugin or the plugin isn't installed or active
+ // priority doesn't matter. Use requires to check if a plugin is active.
+ if (!$plugin_package || !$test_plugin || !$test_plugin->isActive()) {
return array(
'status' => true,
'value' => 'uninstalled'
diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php
index d3cb0d488..e3b8b8f1a 100644
--- a/engine/classes/ElggSite.php
+++ b/engine/classes/ElggSite.php
@@ -148,11 +148,20 @@ class ElggSite extends ElggEntity {
* @return bool
*/
public function save() {
+ global $CONFIG;
+
// Save generic stuff
if (!parent::save()) {
return false;
}
+ // make sure the site guid is set (if not, set to self)
+ if (!$this->get('site_guid')) {
+ $guid = $this->get('guid');
+ update_data("UPDATE {$CONFIG->dbprefix}entities SET site_guid=$guid
+ WHERE guid=$guid");
+ }
+
// Now save specific stuff
return create_site_entity($this->get('guid'), $this->get('name'),
$this->get('description'), $this->get('url'));
@@ -400,7 +409,7 @@ class ElggSite extends ElggEntity {
'action/login',
'register',
'action/register',
- 'pages/account/forgotten_password\.php',
+ 'forgotpassword',
'action/user/requestnewpassword',
'resetpassword',
'upgrade\.php',