diff options
author | Brett Profitt <brett.profitt@gmail.com> | 2011-04-16 11:52:37 -0400 |
---|---|---|
committer | Brett Profitt <brett.profitt@gmail.com> | 2011-04-16 11:52:37 -0400 |
commit | 309dff2bf948ab191ccb1e8d4a777e49ad498820 (patch) | |
tree | 813350181be64e239287c0bb587a3a49320a49b7 | |
parent | 119ec1f1425ab77ed29c696d99c0c80df3886791 (diff) | |
parent | 2b2afd98c05139c1a5c25f1752e2bb412e26e335 (diff) | |
download | elgg-309dff2bf948ab191ccb1e8d4a777e49ad498820.tar.gz elgg-309dff2bf948ab191ccb1e8d4a777e49ad498820.tar.bz2 |
Merge branch 'master' of github.com:Elgg/Elgg
47 files changed, 354 insertions, 231 deletions
diff --git a/engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php b/actions/widgets/upgrade.php index 6a5f2fa02..0a5cf8d48 100644 --- a/engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php +++ b/actions/widgets/upgrade.php @@ -1,10 +1,12 @@ <?php /** - * Elgg 1.8-svn upgrade 2011032300 - * update_default_widgets + * Upgrade default widgets for Elgg 1.8 * * Pre-1.8, default widgets were stored as metadata on a defaultwidgets object. * Now they are stored as widget objects owned by the site. + * + * @package Elgg.Core + * @subpackage Widgets.Management */ $object = elgg_get_entities(array( @@ -14,8 +16,7 @@ $object = elgg_get_entities(array( )); if (!$object) { - // nothing to upgrade - return true; + forward(REFERER); } $object = $object[0]; @@ -58,3 +59,7 @@ foreach (array('profile', 'dashboard') as $context) { } } elgg_set_ignore_access($ia); + +$object->delete(); +system_message(elgg_echo('upgrade:core')); +forward(REFERER); diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index cfdaede71..79b8c2a4e 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -246,18 +246,20 @@ abstract class ElggEntity extends ElggData implements * @return mixed The value, or NULL if not found. */ public function getMetaData($name) { - if ((int) ($this->guid) > 0) { - $md = elgg_get_metadata(array( - 'guid' => $this->getGUID(), - 'metadata_name' => $name, - 'limit' => 0, - )); - } else { + if ((int) ($this->guid) == 0) { if (isset($this->temp_metadata[$name])) { return $this->temp_metadata[$name]; + } else { + return null; } } + $md = elgg_get_metadata(array( + 'guid' => $this->getGUID(), + 'metadata_name' => $name, + 'limit' => 0, + )); + if ($md && !is_array($md)) { return $md->value; } elseif (count($md) == 1) { @@ -717,6 +719,9 @@ abstract class ElggEntity extends ElggData implements * * @warning By default, annotations are private. * + * @warning Annotating an unsaved entity more than once with the same name + * will only save the last annotation. + * * @param string $name Annotation name * @param mixed $value Annotation value * @param int $access_id Access ID @@ -761,8 +766,10 @@ abstract class ElggEntity extends ElggData implements } return elgg_get_annotations($options); + } else if (isset($this->temp_annotations[$name])) { + return array($this->temp_annotations[$name]); } else { - return $this->temp_annotations[$name]; + return array(); } } diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index 98a3d7d24..bf6cf2edc 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -127,6 +127,11 @@ class ElggMenuItem { $item->setLinkClass($options['class']); unset($options['class']); } + + if (isset($options['item_class'])) { + $item->setItemClass($options['item_class']); + unset($options['item_class']); + } foreach ($options as $key => $value) { $item->$key = $value; diff --git a/engine/classes/ElggPAM.php b/engine/classes/ElggPAM.php index 37436fba3..0681a909b 100644 --- a/engine/classes/ElggPAM.php +++ b/engine/classes/ElggPAM.php @@ -41,9 +41,14 @@ class ElggPAM { * @param array $credentials Credentials array dependant on policy type * @return bool */ - public function authenticate($credentials) { + public function authenticate($credentials = array()) { global $_PAM_HANDLERS; + if (!isset($_PAM_HANDLERS[$this->policy]) || + !is_array($_PAM_HANDLERS[$this->policy])) { + return false; + } + $authenticated = false; foreach ($_PAM_HANDLERS[$this->policy] as $k => $v) { diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php index 5c65a4d66..1af4cdc3a 100644 --- a/engine/classes/ElggUser.php +++ b/engine/classes/ElggUser.php @@ -59,9 +59,11 @@ class ElggUser extends ElggEntity // See if this is a username } else if (is_string($guid)) { - $guid = get_user_by_username($guid); - foreach ($guid->attributes as $key => $value) { - $this->attributes[$key] = $value; + $user = get_user_by_username($guid); + if ($user) { + foreach ($user->attributes as $key => $value) { + $this->attributes[$key] = $value; + } } // Is $guid is an ElggUser? Use a copy constructor diff --git a/engine/handlers/cache_handler.php b/engine/handlers/cache_handler.php index 05c35171b..7d6f42dc3 100644 --- a/engine/handlers/cache_handler.php +++ b/engine/handlers/cache_handler.php @@ -3,7 +3,7 @@ * Cache handler. * * External access to cached CSS and JavaScript views. The cached file URLS - * should be of the form: cache/<type>/<view>/<viewtype>/<unique_id> where + * should be of the form: cache/<type>/<viewtype>/<name/of/view>.<unique_id>.<type> where * type is either css or js, view is the name of the cached view, and * unique_id is an identifier that is updated every time the cache is flushed. * The simplest way to maintain a unique identifier is to use the lastcache @@ -50,13 +50,16 @@ if (!$request || !$simplecache_enabled) { echo 'Cache error: bad request'; exit; } -$request = explode('/', $request); +// testing showed regex to be marginally faster than array / string functions over 100000 reps +// it won't make a difference in real life and regex is easier to read. +// <type>/<viewtype>/<name/of/view.and.dots>.<ts>.<type> +$regex = '|([^/]+)/([^/]+)/(.+)\.([^\.]+)\.([^.]+)$|'; +preg_match($regex, $request, $matches); -//cache/<type>/<view>/<viewtype>/ -$type = $request[0]; -$view = $request[1]; -$viewtype = $request[2]; +$type = $matches[1]; +$viewtype = $matches[2]; +$view = $matches[3]; switch ($type) { case 'css': diff --git a/engine/lib/actions.php b/engine/lib/actions.php index 407b99f87..47e4dd4a4 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -113,7 +113,11 @@ function action($action, $forwarder = "") { register_error(elgg_echo('actionundefined', array($action))); } - forward($forwarder); + if (!empty($forwarder)) { + forward($forwarder); + } else { + forward(REFERER); + } } /** diff --git a/engine/lib/cache.php b/engine/lib/cache.php index d4888f9d9..8529ae7fa 100644 --- a/engine/lib/cache.php +++ b/engine/lib/cache.php @@ -166,7 +166,7 @@ function elgg_get_simplecache_url($type, $view) { if (elgg_is_simplecache_enabled()) { $viewtype = elgg_get_viewtype(); - $url = elgg_get_site_url() . "cache/$type/$view/$viewtype/$view.$lastcache.$type"; + $url = elgg_get_site_url() . "cache/$type/$viewtype/$view.$lastcache.$type"; } else { $url = elgg_get_site_url() . "$type/$view.$lastcache.$type"; } diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php index 165546d31..bb52881cd 100644 --- a/engine/lib/deprecated-1.8.php +++ b/engine/lib/deprecated-1.8.php @@ -115,7 +115,7 @@ function get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = $options['limit'] = $limit; $options['offset'] = $offset; - $options['order_by'] = "calculated $orderdir"; + $options['order_by'] = "calculation $orderdir"; $options['count'] = $count; @@ -179,7 +179,7 @@ function get_entities_from_annotation_count($entity_type = "", $entity_subtype = $options['limit'] = $limit; $options['offset'] = $offset; - $options['order_by'] = "calculated $orderdir"; + $options['order_by'] = "calculation $orderdir"; $options['count'] = $count; @@ -241,7 +241,7 @@ function list_entities_from_annotation_count($entity_type = "", $entity_subtype $options['limit'] = $limit; - $options['order_by'] = "calculated $orderdir"; + $options['order_by'] = "calculation $orderdir"; return elgg_get_entities_from_annotation_calculation($options); } @@ -1152,10 +1152,22 @@ function list_entities_from_metadata($meta_name, $meta_value = "", $entity_type $offset = (int)get_input('offset'); $limit = (int)$limit; - $options = array('metadata_name' => $meta_name, 'metadata_value' => $meta_value, - 'types' => $entity_type, 'subtypes' => $entity_subtype, 'owner_guid' => $owner_guid, - 'limit' => $limit, 'offset' => $offset, 'count' => TRUE, - 'metadata_case_sensitive' => $case_sensitive); + $options = array( + 'metadata_name' => $meta_name, + 'metadata_value' => $meta_value, + 'types' => $entity_type, + 'subtypes' => $entity_subtype, + 'limit' => $limit, + 'offset' => $offset, + 'count' => TRUE, + 'metadata_case_sensitive' => $case_sensitive + ); + + // previous function allowed falsy $owner_guid for anything + if ($owner_guid) { + $options['owner_guid'] = $owner_guid; + } + $count = elgg_get_entities_from_metadata($options); $options['count'] = FALSE; @@ -3492,7 +3504,7 @@ $asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $or $options['limit'] = $limit; - $options['order_by'] = "calculated $orderdir"; + $options['order_by'] = "calculation $orderdir"; return elgg_get_entities_from_annotation_calculation($options); } diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 1aef48ef4..6c94133df 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -400,7 +400,7 @@ function elgg_get_loaded_external_files($type, $location) { if (isset($CONFIG->externals) && isset($CONFIG->externals[$type])) { $items = array_values($CONFIG->externals[$type]); - $callback = "return \$v->loaded == true && \$v->location == $location;"; + $callback = "return \$v->loaded == true && \$v->location == '$location';"; $items = array_filter($items, create_function('$v', $callback)); if ($items) { usort($items, create_function('$a,$b','return $a->priority >= $b->priority;')); @@ -1685,21 +1685,7 @@ function _elgg_shutdown_hook() { * @elgg_pagehandler js */ function elgg_js_page_handler($page) { - if (is_array($page) && sizeof($page)) { - $js = implode('/', $page); - $js = substr($js, 0, strpos($js, '.')); - $return = elgg_view('js/' . $js); - - header('Content-type: text/javascript'); - - // @todo should js be cached when simple cache turned off - //header('Expires: ' . date('r', time() + 864000)); - //header("Pragma: public"); - //header("Cache-Control: public"); - //header("Content-Length: " . strlen($return)); - - echo $return; - } + return elgg_cacheable_view_page_handler($page, 'js'); } /** @@ -1749,18 +1735,60 @@ function elgg_css_page_handler($page) { // default css $page[0] = 'elgg'; } + + return elgg_cacheable_view_page_handler($page, 'css'); +} + +/** + * Serves a JS or CSS view with headers for caching. + * + * /<css||js>/name/of/view.<last_cache>.<css||js> + * + * @param array $page The page array + * @param string $type The type: js or css + * + * @return mixed + */ +function elgg_cacheable_view_page_handler($page, $type) { + + switch ($type) { + case 'js': + $content_type = 'text/javascript'; + break; + + case 'css': + $content_type = 'text/css'; + break; + + default: + return false; + break; + } - $css = substr($page[0], 0, strpos($page[0], '.')); - $return = elgg_view("css/$css"); + if ($page) { + // the view file names can have multiple dots + // eg: views/default/js/calendars/jquery.fullcalendar.min.php + // translates to the url /js/calendars/jquery.fullcalendar.min.<ts>.js + // and the view js/calendars/jquery.fullcalendar.min + // we ignore the last two dots for the ts and the ext. + $page = implode('/', $page); + $regex = '|(.+)\.([^\.]+)\.([^.]+)$|'; + preg_match($regex, $page, $matches); + $view = $matches[1]; + $return = elgg_view("$type/$view"); - header("Content-type: text/css", true); + header("Content-type: $content_type"); - // @todo should css be cached when simple cache is turned off - //header('Expires: ' . date('r', time() + 86400000), true); - //header("Pragma: public", true); - //header("Cache-Control: public", true); + // @todo should js be cached when simple cache turned off + //header('Expires: ' . date('r', time() + 864000)); + //header("Pragma: public"); + //header("Cache-Control: public"); + //header("Content-Length: " . strlen($return)); - echo $return; + echo $return; + } + + return true; } /** diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 742630cc7..685c68a5b 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -740,7 +740,7 @@ function elgg_entity_exists($guid) { * type_subtype_pairs => NULL|ARR (array('type' => 'subtype')) * (type = '$type' AND subtype = '$subtype') pairs * - * entity_guids => NULL|ARR Array of entity guids + * guids => NULL|ARR Array of entity guids * * owner_guids => NULL|ARR Array of owner guids * diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index 6db4e6d7c..604c7f765 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -75,7 +75,7 @@ function get_metastring_id($string, $case_sensitive = TRUE) { $ids[] = $metaString->id; } return $ids; - } else if ($metaStrings) { + } else if (isset($metaStrings[0])) { $row = $metaStrings[0]; } } diff --git a/engine/lib/output.php b/engine/lib/output.php index 8c2a3d50d..3f35a1576 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -170,7 +170,7 @@ function elgg_format_attributes(array $attrs) { } // ignore $vars['entity'] => ElggEntity stuff - if (is_not_null($val) && (is_array($val) || !is_object($var))) { + if (is_not_null($val) && (is_array($val) || !is_object($val))) { // allow $vars['class'] => array('one', 'two'); // @todo what about $vars['style']? Needs to be semi-colon separated... diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php index 5d45cc73d..ae42956a9 100644 --- a/engine/lib/sessions.php +++ b/engine/lib/sessions.php @@ -155,9 +155,9 @@ function elgg_authenticate($username, $password) { * @return bool * @throws LoginException */ -function pam_auth_userpass($credentials = NULL) { +function pam_auth_userpass(array $credentials = array()) { - if (!is_array($credentials) || !isset($credentials['username']) || !isset($credentials['password'])) { + if (!isset($credentials['username']) || !isset($credentials['password'])) { return false; } diff --git a/engine/lib/upgrade.php b/engine/lib/upgrade.php index 755c100dd..85810956b 100644 --- a/engine/lib/upgrade.php +++ b/engine/lib/upgrade.php @@ -147,6 +147,8 @@ function elgg_get_upgrade_files($upgrade_path = null) { $upgrade_files[] = $upgrade_file; } + sort($upgrade_files); + return $upgrade_files; } diff --git a/engine/lib/upgrades/2011010101.php b/engine/lib/upgrades/2011010101.php index be1adac1a..9dbaff1e4 100644 --- a/engine/lib/upgrades/2011010101.php +++ b/engine/lib/upgrades/2011010101.php @@ -73,3 +73,21 @@ remove_metadata($site->guid, 'pluginorder'); remove_metadata($site->guid, 'enabled_plugins'); elgg_set_ignore_access($old_id); + +/** + * @hack + * + * We stop the upgrade at this point because plugins weren't given the chance to + * load due to the new plugin code introduced with Elgg 1.8. Instead, we manually + * set the version and start the upgrade process again. + * + * The variables from upgrade_code() are available because this script was included + */ +if ($upgrade_version > $version) { + datalist_set('version', $upgrade_version); +} + +$processed_upgrades = array_unique($processed_upgrades); +datalist_set('processed_upgrades', serialize($processed_upgrades)); + +forward('upgrade.php'); diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php index b20f92f74..cc3cf20e4 100644 --- a/engine/lib/widgets.php +++ b/engine/lib/widgets.php @@ -272,6 +272,7 @@ function elgg_widgets_init() { elgg_register_action('widgets/add'); elgg_register_action('widgets/move'); elgg_register_action('widgets/delete'); + elgg_register_action('widgets/upgrade', '', 'admin'); run_function_once("elgg_widget_run_once"); } diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php index 1633cbe19..aef7a991e 100644 --- a/engine/tests/api/entity_getter_functions.php +++ b/engine/tests/api/entity_getter_functions.php @@ -1341,7 +1341,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $invalid_md_name = 'test_metadata_name_' . rand(); $e = new ElggObject(); $e->subtype = $subtype; - $e->$md_name = $invalid_md_value; + $e->$invalid_md_name = $md_value; $e->save(); $guids[] = $e->getGUID(); @@ -1406,11 +1406,13 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { // make some bad ones $invalid_md_name = 'test_metadata_name_' . rand(); + $invalid_md_name2 = 'test_metadata_name_' . rand(); + $invalid_md_name3 = 'test_metadata_name_' . rand(); $e = new ElggObject(); $e->subtype = $subtype; - $e->$md_name = $invalid_md_value; - $e->$md_name2 = $invalid_md_value; - $e->$md_name3 = $invalid_md_value; + $e->$invalid_md_name = $md_value; + $e->$invalid_md_name2 = $md_value2; + $e->$invalid_md_name3 = $md_value3; $e->save(); $guids[] = $e->getGUID(); @@ -1483,10 +1485,11 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { // make some bad ones $invalid_md_name = 'test_metadata_name_' . rand(); + $invalid_md_name2 = 'test_metadata_name_' . rand(); $e = new ElggObject(); $e->subtype = $subtype; - $e->$md_name = $invalid_md_value; - $e->$md_name2 = $invalid_md_value; + $e->$invalid_md_name = $md_value; + $e->$invalid_md_name2 = $md_value2; $e->save(); $guids[] = $e->getGUID(); @@ -1572,11 +1575,11 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $invalid_md_name = 'test_metadata_name_' . rand(); $e = new ElggObject(); $e->subtype = $subtype; - $e->$md_name = $invalid_md_value; - $e->$md_name2 = $invalid_md_value; - $e->$md_name3 = $invalid_md_value; - $e->$md_name4 = $invalid_md_value; - $e->$md_name5 = $invalid_md_value; + $e->$invalid_md_name = $md_value; + $e->$md_name2 = $md_value2; + $e->$md_name3 = $md_value3; + $e->$md_name4 = $md_value4; + $e->$md_name5 = $md_value5; $e->save(); $guids[] = $e->getGUID(); @@ -1649,7 +1652,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $invalid_md_name = 'test_metadata_name_' . rand(); $e = new ElggObject(); $e->subtype = $subtype; - $e->$md_name = $invalid_md_value; + $e->$invalid_md_name = $md_value; $e->save(); $guids[] = $e->getGUID(); @@ -1694,7 +1697,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $invalid_md_name = 'test_metadata_name_' . rand(); $e = new ElggObject(); $e->subtype = $subtype; - $e->$md_name = $invalid_md_value; + $e->$invalid_md_name = $md_value; $e->save(); $guids[] = $e->getGUID(); @@ -1758,7 +1761,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $invalid_md_name = 'test_metadata_name_' . rand(); $e = new ElggObject(); $e->subtype = $subtype; - $e->$md_name = $invalid_md_value; + $e->$invalid_md_name = $md_value; $e->save(); $guids[] = $e->getGUID(); @@ -1836,7 +1839,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $invalid_md_name = 'test_metadata_name_' . rand(); $e = new ElggObject(); $e->subtype = $subtype; - $e->$md_name = $invalid_md_value; + $e->$invalid_md_name = $md_value; $e->save(); $guids[] = $e->getGUID(); @@ -1888,33 +1891,32 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $subtypes = $this->getRandomValidSubtypes(array('object'), 1); $subtype = $subtypes[0]; $md_name = 'test_metadata_name_' . rand(); - $md_value = 2; $guids = array(); $valid_guids = array(); // our targets $valid = new ElggObject(); $valid->subtype = $subtype; - $valid->$md_name = $md_value; + $valid->$md_name = 1; $valid->save(); $guids[] = $valid->getGUID(); $valid_guids[] = $valid->getGUID(); $valid2 = new ElggObject(); $valid2->subtype = $subtype; - $valid2->$md_name = 3; + $valid2->$md_name = 2; $valid2->save(); $guids[] = $valid->getGUID(); $valid_guids[] = $valid2->getGUID(); $valid3 = new ElggObject(); $valid3->subtype = $subtype; - $valid3->$md_name = 1; + $valid3->$md_name = 3; $valid3->save(); $guids[] = $valid->getGUID(); $valid_guids[] = $valid3->getGUID(); - $md_valid_values = array($md_value, $md_value2); + $md_valid_values = array(1, 2, 3); $options = array( 'type' => 'object', @@ -1947,33 +1949,32 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $subtypes = $this->getRandomValidSubtypes(array('object'), 1); $subtype = $subtypes[0]; $md_name = 'test_metadata_name_' . rand(); - $md_value = 'b'; $guids = array(); $valid_guids = array(); // our targets $valid = new ElggObject(); $valid->subtype = $subtype; - $valid->$md_name = $md_value; + $valid->$md_name = 'a'; $valid->save(); $guids[] = $valid->getGUID(); $valid_guids[] = $valid->getGUID(); $valid2 = new ElggObject(); $valid2->subtype = $subtype; - $valid2->$md_name = 'c'; + $valid2->$md_name = 'b'; $valid2->save(); $guids[] = $valid->getGUID(); $valid_guids[] = $valid2->getGUID(); $valid3 = new ElggObject(); $valid3->subtype = $subtype; - $valid3->$md_name = 'a'; + $valid3->$md_name = 'c'; $valid3->save(); $guids[] = $valid->getGUID(); $valid_guids[] = $valid3->getGUID(); - $md_valid_values = array($md_value, $md_value2); + $md_valid_values = array('a', 'b', 'c'); $options = array( 'type' => 'object', diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php index 1362b3c9d..461627547 100644 --- a/engine/tests/api/helpers.php +++ b/engine/tests/api/helpers.php @@ -109,7 +109,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { $this->assertIdentical('http://test1.com', $CONFIG->externals['js']['key']->url); // send a bad url - $result = elgg_register_js(); + $result = @elgg_register_js('bad'); $this->assertFalse($result); } @@ -140,7 +140,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { $result = elgg_unregister_js('id1'); $this->assertTrue($result); - $this->assertNULL($CONFIG->externals['js']['head']['id1']); + @$this->assertNULL($CONFIG->externals['js']['head']['id1']); $result = elgg_unregister_js('id1'); $this->assertFalse($result); diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index ca3abb274..c04bc60ff 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -107,7 +107,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { // set and check temp annotation $this->assertTrue($this->entity->annotate('non_existent', 'testing')); - $this->assertIdentical($this->entity->getAnnotations('non_existent'), 'testing'); + $this->assertIdentical($this->entity->getAnnotations('non_existent'), array('testing')); $this->assertTrue(array_key_exists('non_existent', $this->entity->expose_annotations())); // save entity and check for annotation diff --git a/engine/tests/services/api.php b/engine/tests/services/api.php index 39951da1c..3d07c0bbb 100644 --- a/engine/tests/services/api.php +++ b/engine/tests/services/api.php @@ -19,7 +19,7 @@ class ElggCoreServicesApiTest extends ElggCoreUnitTest { // expose_function public function testExposeFunctionNoMethod() { try { - expose_function(); + @expose_function(); $this->assertTrue(FALSE); } catch (Exception $e) { $this->assertIsA($e, 'InvalidParameterException'); @@ -29,7 +29,7 @@ class ElggCoreServicesApiTest extends ElggCoreUnitTest { public function testExposeFunctionNoFunction() { try { - expose_function('test'); + @expose_function('test'); $this->assertTrue(FALSE); } catch (Exception $e) { $this->assertIsA($e, 'InvalidParameterException'); @@ -39,7 +39,7 @@ class ElggCoreServicesApiTest extends ElggCoreUnitTest { public function testExposeFunctionBadParameters() { try { - expose_function('test', 'test', 'BAD'); + @expose_function('test', 'test', 'BAD'); $this->assertTrue(FALSE); } catch (Exception $e) { $this->assertIsA($e, 'InvalidParameterException'); @@ -59,7 +59,7 @@ class ElggCoreServicesApiTest extends ElggCoreUnitTest { public function testExposeFunctionBadHttpMethod() { try { - expose_function('test', 'test', null, '', 'BAD'); + @expose_function('test', 'test', null, '', 'BAD'); $this->assertTrue(FALSE); } catch (Exception $e) { $this->assertIsA($e, 'InvalidParameterException'); diff --git a/js/lib/elgglib.js b/js/lib/elgglib.js index 5ba80fc06..f2545fb6c 100644 --- a/js/lib/elgglib.js +++ b/js/lib/elgglib.js @@ -379,4 +379,4 @@ elgg.getSelectorFromUrlFragment = function(url) { } } return ''; -}
\ No newline at end of file +};
\ No newline at end of file diff --git a/js/lib/languages.js b/js/lib/languages.js index 0e3cf4472..4cfe84968 100644 --- a/js/lib/languages.js +++ b/js/lib/languages.js @@ -25,11 +25,10 @@ elgg.add_translation = function(lang, translations) { */ elgg.reload_all_translations = function(language) { var lang = language || elgg.get_language(); - // This...................vvvvv is a double encoded question mark (? -> %2f -> %252f) - elgg.getJSON('js/languages%252f' + lang + '.js', { + + elgg.getJSON('ajax/view/js/languages', { data: { - 'viewtype': 'default', - 'lastcache': elgg.config.lastcache + language: lang }, success: function(json) { elgg.add_translation(lang, json); diff --git a/languages/en.php b/languages/en.php index 427452aa9..86fa9c7e7 100644 --- a/languages/en.php +++ b/languages/en.php @@ -795,6 +795,7 @@ $english = array( 'post' => 'Post', 'submit' => 'Submit', 'comment' => 'Comment', + 'upgrade' => 'Upgrade', 'site' => 'Site', 'activity' => 'Activity', diff --git a/mod/bookmarks/languages/en.php b/mod/bookmarks/languages/en.php index e3f8cd64f..42865f8cf 100644 --- a/mod/bookmarks/languages/en.php +++ b/mod/bookmarks/languages/en.php @@ -52,8 +52,7 @@ $english = array( /** * Widget and bookmarklet */ - 'bookmarks:widget:description' => - "This widget displays your latest bookmarks.", + 'bookmarks:widget:description' => "Display your latest bookmarks.", 'bookmarks:bookmarklet:description' => "The bookmarks bookmarklet allows you to share any resource you find on the web with your friends, or just bookmark it for yourself. To use it, simply drag the following button to your browser's links bar:", diff --git a/mod/bookmarks/start.php b/mod/bookmarks/start.php index 600293b5a..2dc86bc1a 100644 --- a/mod/bookmarks/start.php +++ b/mod/bookmarks/start.php @@ -35,7 +35,9 @@ function bookmarks_init() { elgg_extend_view('css/elgg', 'bookmarks/css'); elgg_extend_view('js/elgg', 'bookmarks/js'); - + + elgg_register_widget_type('bookmarks', elgg_echo('bookmarks'), elgg_echo('bookmarks:widget:description')); + if (elgg_is_logged_in()) { $user_guid = elgg_get_logged_in_user_guid(); $address = urlencode(current_page_url()); diff --git a/mod/file/start.php b/mod/file/start.php index 218edef51..d4f12e903 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -151,7 +151,7 @@ function file_owner_block_menu($hook, $type, $return, $params) { $item = new ElggMenuItem('file', elgg_echo('file'), $url); $return[] = $item; } else { - if ($params['entity']->files_enable != "no") { + if ($params['entity']->file_enable != "no") { $url = "file/group/{$params['entity']->guid}/owner"; $item = new ElggMenuItem('file', elgg_echo('file:group'), $url); $return[] = $item; diff --git a/mod/profile/start.php b/mod/profile/start.php index cc4c74fb2..d91b66371 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -29,7 +29,7 @@ function profile_init() { // Register a page handler, so we can have nice URLs elgg_register_page_handler('profile', 'profile_page_handler'); - elgg_extend_view('html_head/extend', 'profile/metatags'); + elgg_extend_view('page/elements/head', 'profile/metatags'); elgg_extend_view('css/elgg', 'profile/css'); elgg_extend_view('js/elgg', 'profile/js'); diff --git a/mod/twitter_api/lib/twitter_api.php b/mod/twitter_api/lib/twitter_api.php index 167dbe0f5..0621c2b13 100644 --- a/mod/twitter_api/lib/twitter_api.php +++ b/mod/twitter_api/lib/twitter_api.php @@ -283,7 +283,7 @@ function twitter_api_revoke() { /** * Returns the url to authorize a user. * - * @param string $callback The callback URL? + * @param string $callback The callback URL */ function twitter_api_get_authorize_url($callback = NULL) { global $SESSION; @@ -341,4 +341,4 @@ function twitter_api_allow_new_users_with_twitter() { } return false; -} +}
\ No newline at end of file diff --git a/views/default/admin/appearance/default_widgets.php b/views/default/admin/appearance/default_widgets.php index ce9f6a5c2..5ce0d0acf 100644 --- a/views/default/admin/appearance/default_widgets.php +++ b/views/default/admin/appearance/default_widgets.php @@ -6,6 +6,22 @@ * @subpackage Administration.DefaultWidgets */ +$object = elgg_get_entities(array( + 'type' => 'object', + 'subtype' => 'moddefaultwidgets', + 'limit' => 1, +)); + +if ($object) { + echo elgg_view('output/url', array( + 'text' => elgg_echo('upgrade'), + 'href' => 'action/widgets/upgrade', + 'is_action' => true, + 'class' => 'elgg_button elgg-button-submit', + 'title' => 'Upgrade your default widgets to work on Elgg 1.8', + )); +} + elgg_push_context('default_widgets'); $widget_context = get_input('widget_context'); $list = elgg_trigger_plugin_hook('get_list', 'default_widgets', null, array()); diff --git a/views/default/css/admin.php b/views/default/css/admin.php index 949824831..b41649c06 100644 --- a/views/default/css/admin.php +++ b/views/default/css/admin.php @@ -223,6 +223,7 @@ table.mceLayout { padding: 10px; margin-bottom: 10px; border: 2px solid #ddd; + cursor: pointer; } /* *************************************** @@ -871,9 +872,11 @@ a.elgg-longtext-control { display: inline-block; margin: 0 2px; } +.elgg-icon-delete:hover, .elgg-icon-delete-alt:hover { background-position: 0 -0px; } +.elgg-icon-delete, .elgg-icon-delete-alt { background-position: 0 -18px; } diff --git a/views/default/css/elements/buttons.php b/views/default/css/elements/buttons.php index 6a2342942..e9c99cf96 100644 --- a/views/default/css/elements/buttons.php +++ b/views/default/css/elements/buttons.php @@ -19,7 +19,6 @@ -moz-border-radius: 5px; border-radius: 5px; - display: inline-block; width: auto; padding: 2px 4px; cursor: pointer; diff --git a/views/default/css/elements/components.php b/views/default/css/elements/components.php index bb573f4ec..0fcbe3619 100644 --- a/views/default/css/elements/components.php +++ b/views/default/css/elements/components.php @@ -21,23 +21,6 @@ ?> /* *************************************** - Body -*************************************** */ -.elgg-body { - width: auto; - word-wrap: break-word; - overflow: hidden; -} -.elgg-body:after { - display: block; - visibility: hidden; - height: 0 !important; - line-height: 0; - font-size: xx-large; - content: " x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x "; -} - -/* *************************************** Image Block *************************************** */ .elgg-image-block { diff --git a/views/default/css/elements/core.php b/views/default/css/elements/core.php new file mode 100644 index 000000000..c5d99512f --- /dev/null +++ b/views/default/css/elements/core.php @@ -0,0 +1,108 @@ +<?php +/** + * Core CSS + * + * This file holds all the complicated/hacky stuff that you really + * shouldn't touch or override unless you're sure you know what you're doing. + * + * Provides classes that implement cross-browser support for the following features: + * * clearfix + * * fluid-width content area that doesn't wrap around floats + * * menu's with separators + * * inline-block + * * horizontal menus + * * fluid gallery without using tables + */ +?> + +/* Clearfix */ +.clearfix:after, +.elgg-grid:after, +.elgg-layout:after, +.elgg-inner:after, +.elgg-page-header:after, +.elgg-page-footer:after, +.elgg-head:after, +.elgg-foot:after, +.elgg-col:after, +.elgg-image-block:after { + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; +} + +/* Fluid width container that does not wrap floats */ +.elgg-body, +.elgg-col-last { + display: block; + width: auto; + word-wrap: break-word; + overflow: hidden; + + /* IE 6, 7 */ + zoom:1; + *overflow:visible; +} + +<?php //@todo isn't this only needed if we use display:table-cell? ?> +.elgg-body:after, +.elgg-col-last:after { + display: block; + visibility: hidden; + height: 0 !important; + line-height: 0; + + /* Stretch to fill up available space */ + font-size: xx-large; + content: " x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x "; +} + +/* *************************************** + * MENUS + * + * To add separators to a menu: + * .elgg-menu-$menu > li:after {content: '|'; background: ...;} + *************************************** */ +/* Enabled nesting of dropdown/flyout menus */ +.elgg-menu > li { position: relative; } + +/* Separators should only come between list items */ +.elgg-menu > li:last-child:after { display: none } + +/* Maximize click target */ +.elgg-menu > li > a { display: block } + +/* Horizontal menus w/ separator support */ +.elgg-menu-hz > li, +.elgg-menu-hz > li:after, +.elgg-menu-hz > li > a, +.elgg-menu-hz > li > span { + vertical-align: middle; +} + +/* Allow inline image blocks in horizontal menus */ +.elgg-menu-hz .elgg-body:after { content: '.'; } + +<?php //@todo This isn't going to work as-is. Needs testing ?> +/* Inline block */ +.elgg-gallery > li, +.elgg-button, +.elgg-icon, +.elgg-menu-hz > li, +.elgg-menu-hz > li:after, +.elgg-menu-hz > li > a, +.elgg-menu-hz > li > span { + /* Google says do this, but why? */ + position: relative; + + /* FF2 */ + display: -moz-inline-box; + + display: inline-block; + + /* Inline-block: IE 6, 7 */ + zoom: 1; + *display: inline; +}
\ No newline at end of file diff --git a/views/default/css/elements/grid.php b/views/default/css/elements/grid.php index 00cd448b9..fdbaf4aca 100644 --- a/views/default/css/elements/grid.php +++ b/views/default/css/elements/grid.php @@ -13,14 +13,6 @@ /* *************************************** GRID *************************************** */ -.elgg-grid:after { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; -} - .elgg-col { float: left; } @@ -60,18 +52,3 @@ .elgg-col-5of6 { width: 83.33%; } -.elgg-col-last { - width: auto; - float: none; - display: table-cell; -} -.elgg-col-last:after { - clear: both; - display: block; - visibility: hidden; - overflow: hidden; - height: 0 !important; - line-height: 0; - font-size: xx-large; - content: " x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x "; -} diff --git a/views/default/css/elements/helpers.php b/views/default/css/elements/helpers.php index 21e3dd984..e6f59260d 100644 --- a/views/default/css/elements/helpers.php +++ b/views/default/css/elements/helpers.php @@ -13,14 +13,6 @@ clear: both; } -.clearfix:after { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; -} - .hidden { display: none; } diff --git a/views/default/css/elements/icons.php b/views/default/css/elements/icons.php index 8bbc919b3..08948df50 100644 --- a/views/default/css/elements/icons.php +++ b/views/default/css/elements/icons.php @@ -16,7 +16,6 @@ background: transparent url(<?php echo elgg_get_site_url(); ?>_graphics/elgg_sprites.png) no-repeat left; width: 16px; height: 16px; - display: inline-block; margin: 0 2px; } .elgg-icon-arrow-left { diff --git a/views/default/css/elements/layout.php b/views/default/css/elements/layout.php index d512c3602..d52938aee 100644 --- a/views/default/css/elements/layout.php +++ b/views/default/css/elements/layout.php @@ -72,14 +72,6 @@ .elgg-layout { min-height: 360px; } -<?php // elgg-layout gets clearfix ?> -.elgg-layout:after { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; -} .elgg-layout-one-column { padding: 10px 0; } diff --git a/views/default/css/elements/navigation.php b/views/default/css/elements/navigation.php index b72124001..25b45bbee 100644 --- a/views/default/css/elements/navigation.php +++ b/views/default/css/elements/navigation.php @@ -87,41 +87,6 @@ } /* *************************************** - * MENUS - * - * To add separators to a menu: - * .elgg-menu-$menu > li:after {content: '|'; background: ...;} - *************************************** */ -/* For dropdown/flyout menus */ -.elgg-menu > li { - position: relative; -} - -/* For separators */ -.elgg-menu > li:last-child:after { - display: none -} - -/* Maximize click target */ -.elgg-menu > li > a { - display: block -} - -/* Horizontal menus w/ separator support */ -.elgg-menu-hz > li, -.elgg-menu-hz > li:after, -.elgg-menu-hz > li > a, -.elgg-menu-hz > li > span { - display: inline-block; - vertical-align: middle; -} - -/* Allow inline image blocks in horizontal menus */ -.elgg-menu-hz .elgg-body:after { - content: '.'; -} - -/* *************************************** BREADCRUMBS *************************************** */ .elgg-breadcrumbs { diff --git a/views/default/css/elgg.php b/views/default/css/elgg.php index 977eb9f2f..675af860d 100644 --- a/views/default/css/elgg.php +++ b/views/default/css/elgg.php @@ -25,11 +25,13 @@ if ($old_css_view != elgg_get_config('viewpath')) { Base CSS * CSS reset + * core * helpers * grid *******************************************************************************/ echo elgg_view('css/elements/reset', $vars); +echo elgg_view('css/elements/core', $vars); echo elgg_view('css/elements/helpers', $vars); echo elgg_view('css/elements/grid', $vars); @@ -49,7 +51,6 @@ Skin CSS *******************************************************************************/ echo elgg_view('css/elements/typography', $vars); -echo elgg_view('css/elements/chrome', $vars); echo elgg_view('css/elements/forms', $vars); echo elgg_view('css/elements/buttons', $vars); echo elgg_view('css/elements/icons', $vars); diff --git a/views/default/js/elgg.php b/views/default/js/elgg.php index a434afc7d..76388f80c 100644 --- a/views/default/js/elgg.php +++ b/views/default/js/elgg.php @@ -57,11 +57,6 @@ elgg.release = '<?php echo get_version(true); ?>'; elgg.config.wwwroot = '<?php echo elgg_get_site_url(); ?>'; elgg.security.interval = 5 * 60 * 1000; <?php //@todo make this configurable ?> -//Mimic PHP engine boot process - -//Before the DOM is ready -- note that plugins aren't loaded yet -elgg.trigger_hook('boot', 'system'); - //After the DOM is ready $(function() { elgg.trigger_hook('init', 'system'); diff --git a/views/default/js/initialize_elgg.php b/views/default/js/initialize_elgg.php index 9032d8a63..09e0b27bc 100644 --- a/views/default/js/initialize_elgg.php +++ b/views/default/js/initialize_elgg.php @@ -1,6 +1,6 @@ <?php /** - * + * Initialize Elgg's js lib with the uncacheable data */ ?> @@ -8,11 +8,15 @@ * Don't want to cache these -- they could change for every request */ elgg.config.lastcache = <?php echo (int)elgg_get_config('lastcache'); ?>; +elgg.config.viewtype = '<?php echo elgg_get_viewtype(); ?>'; +elgg.config.simplecache_enabled = <?php echo (int)elgg_is_simplecache_enabled(); ?>; elgg.security.token.__elgg_ts = <?php echo $ts = time(); ?>; elgg.security.token.__elgg_token = '<?php echo generate_action_token($ts); ?>'; <?php +// @todo json export should be smoother than this... +// @todo Might also be nice to make url exportable. $entity->url? yes please! $page_owner = elgg_get_page_owner_entity(); if ($page_owner instanceof ElggEntity) { @@ -24,7 +28,7 @@ if ($page_owner instanceof ElggEntity) { $page_owner_json['subtype'] = $page_owner->getSubtype(); $page_owner_json['url'] = $page_owner->getURL(); - echo 'elgg.page_owner = '.json_encode($page_owner_json).';'; + echo 'elgg.page_owner = ' . json_encode($page_owner_json) . ';'; } $user = elgg_get_logged_in_user_entity(); @@ -38,6 +42,9 @@ if ($user instanceof ElggUser) { $user_json['subtype'] = $user->getSubtype(); $user_json['url'] = $user->getURL(); - echo 'elgg.session.user = new elgg.ElggUser('.json_encode($user_json).');'; + echo 'elgg.session.user = new elgg.ElggUser(' . json_encode($user_json) . ');'; } ?> + +//Before the DOM is ready, but elgg's js framework is fully initalized +elgg.trigger_hook('boot', 'system');
\ No newline at end of file diff --git a/views/default/page/admin.php b/views/default/page/admin.php index d0e7915cc..2b2ec9e4a 100644 --- a/views/default/page/admin.php +++ b/views/default/page/admin.php @@ -55,16 +55,7 @@ if ($notices) { </div> </div> </div> -<?php - -echo elgg_view('footer/analytics'); -$js = elgg_get_loaded_js('footer'); -foreach ($js as $script) { ?> - <script type="text/javascript" src="<?php echo $script; ?>"></script> -<?php -} - -?> + <?php echo elgg_view('page/elements/foot'); ?> </body> </html>
\ No newline at end of file diff --git a/views/default/page/default.php b/views/default/page/default.php index 77f79157b..9effce1ec 100644 --- a/views/default/page/default.php +++ b/views/default/page/default.php @@ -60,15 +60,6 @@ header("Content-type: text/html; charset=UTF-8"); </div> </div> </div> -<?php - -echo elgg_view('footer/analytics'); -$js = elgg_get_loaded_js('footer'); -foreach ($js as $script) { ?> - <script type="text/javascript" src="<?php echo $script; ?>"></script> -<?php -} - -?> +<?php echo elgg_view('page/elements/foot'); ?> </body> </html>
\ No newline at end of file diff --git a/views/default/page/elements/foot.php b/views/default/page/elements/foot.php new file mode 100644 index 000000000..a56b373b4 --- /dev/null +++ b/views/default/page/elements/foot.php @@ -0,0 +1,11 @@ +<?php + +echo elgg_view('footer/analytics'); + +$js = elgg_get_loaded_js('footer'); +foreach ($js as $script) { ?> + <script type="text/javascript" src="<?php echo $script; ?>"></script> +<?php +} + +?>
\ No newline at end of file diff --git a/views/default/page/elements/head.php b/views/default/page/elements/head.php index 5f9bf4798..048edec40 100644 --- a/views/default/page/elements/head.php +++ b/views/default/page/elements/head.php @@ -70,7 +70,6 @@ echo $feedref; $metatags = elgg_view('metatags', $vars); if ($metatags) { - elgg_deprecated_notice("The metatags view has been deprecated for html_head/extend", 1.8); + elgg_deprecated_notice("The metatags view has been deprecated. Extend page/elements/head instead", 1.8); echo $metatags; -} -echo elgg_view('html_head/extend', $vars); +}
\ No newline at end of file diff --git a/views/default/page/walled_garden.php b/views/default/page/walled_garden.php index 662e90f45..95d17fcff 100644 --- a/views/default/page/walled_garden.php +++ b/views/default/page/walled_garden.php @@ -39,6 +39,6 @@ $title = $site->name; <div id="elgg-walledgarden-bottom"></div> </div> </div> -<?php echo elgg_view('footer/analytics'); ?> +<?php echo elgg_view('page/elements/foot'); ?> </body> </html>
\ No newline at end of file |