/** * Init * @return void */ function prototyper_validators_init() { elgg_extend_view('prototyper/elements/help', 'prototyper/elements/validation'); elgg_extend_view('prototyper/input/before', 'prototyper/elements/js_validation'); elgg_register_plugin_hook_handler('validate:type', 'prototyper', 'prototyper_validate_type'); hypePrototyper()->config->registerValidationRule('type', array('string', 'alnum', 'alpha', 'int', 'numeric', 'date', 'url', 'email', 'guid', 'image')); elgg_register_plugin_hook_handler('validate:min', 'prototyper', 'prototyper_validate_min'); hypePrototyper()->config->registerValidationRule('min'); elgg_register_plugin_hook_handler('validate:max', 'prototyper', 'prototyper_validate_max'); hypePrototyper()->config->registerValidationRule('max'); elgg_register_plugin_hook_handler('validate:minlength', 'prototyper', 'prototyper_validate_minlength'); hypePrototyper()->config->registerValidationRule('minlength'); elgg_register_plugin_hook_handler('validate:maxlength', 'prototyper', 'prototyper_validate_maxlength'); hypePrototyper()->config->registerValidationRule('maxlength'); elgg_register_plugin_hook_handler('validate:contains', 'prototyper', 'prototyper_validate_contains'); hypePrototyper()->config->registerValidationRule('contains'); elgg_register_plugin_hook_handler('validate:regex', 'prototyper', 'prototyper_validate_regex'); hypePrototyper()->config->registerValidationRule('regex'); if (\hypeJunction\Integration::isElggVersionBelow('1.9.0')) { elgg_register_js('parsley', '/mod/hypePrototyperValidators/vendors/parsley/parsley.min.js', 'footer'); elgg_register_simplecache_view('js/framework/legacy/prototyper_validation'); elgg_register_js('prototyper_validation', elgg_get_simplecache_url('js', 'framework/legacy/prototyper_validation'), 'footer'); } else { elgg_define_js('parsley', array('src' => '/mod/hypePrototyperValidators/vendors/parsley/parsley.min.js', 'deps' => array('jquery'))); } elgg_register_plugin_hook_handler('input_vars', 'prototyper', 'prototyper_filter_input_view_vars'); }
/** * Retreive values from datalists table * * @param array $names Parameter names to retreive * @return array */ protected function getDatalistValue(array $names = array()) { $services = \hypeJunction\Integration::getServiceProvider(); foreach ($names as $name) { $values[$name] = $services->datalist->get($name); } return $values; }
/** * System init callback * @return void */ public function init() { elgg_register_page_handler($this->router->getPageHandlerId(), array($this->router, 'handlePages')); elgg_register_plugin_hook_handler('entity:url', 'object', array($this->hooks, 'urlHandler')); elgg_register_entity_type('object', Post::SUBTYPE); elgg_extend_view('css/elgg', 'css/framework/wall/stylesheet'); elgg_extend_view('js/initialize_elgg', 'js/framework/wall/config'); // AJAX view to load URL previews elgg_register_ajax_view('output/wall/url'); if (\hypeJunction\Integration::isElggVersionBelow('1.9.0')) { elgg_load_js('jquery.form'); elgg_extend_view('js/elgg', 'js/framework/wall/legacy/status'); // Display wall form elgg_extend_view('page/layouts/content/filter', 'framework/wall/container', 100); // Notifications register_notification_object('object', Post::SUBTYPE, elgg_echo('wall:new:notification:generic')); elgg_register_event_handler('publish', 'object', array($this->notifications, 'sendMessageLegacy')); elgg_register_plugin_hook_handler('object:notifications', 'object', array($this->notifications, 'disableDefaultHandlerLegacy')); elgg_register_plugin_hook_handler('notify:entity:message', 'object', array($this->notifications, 'formatMessageLegacy')); } else { // Display wall form elgg_extend_view('page/layouts/elements/filter', 'framework/wall/container', 100); // JS elgg_extend_view('js/elgg', 'js/framework/wall/elgg.js'); // Notifications elgg_register_event_handler('publish', 'object', array($this->notifications, 'sendCustomNotifications')); elgg_register_notification_event('object', 'hjwall', array('publish')); elgg_register_notification_event('object', 'thewire', array('publish')); elgg_register_plugin_hook_handler('prepare', 'notification:publish:object:hjwall', array($this->notifications, 'formatMessage')); elgg_register_plugin_hook_handler('prepare', 'notification:publish:object:thewire', array($this->notifications, 'formatMessage')); elgg_register_plugin_hook_handler('likes:is_likable', 'object:hjwall', 'Elgg\\Values::getTrue'); } $action_path = $this->plugin->getPath() . '/actions/'; elgg_register_action('wall/status', $action_path . 'wall/status.php'); elgg_register_action('wall/photo', $action_path . 'wall/status.php'); elgg_register_action('wall/file', $action_path . 'wall/status.php'); elgg_register_action('wall/url', $action_path . 'wall/status.php'); elgg_register_action('wall/content', $action_path . 'wall/status.php'); elgg_register_action('wall/delete', $action_path . 'wall/delete.php'); elgg_register_action('wall/remove_tag', $action_path . 'wall/remove_tag.php'); elgg_register_action('wall/geopositioning/update', $action_path . 'wall/geopositioning/update.php', 'public'); elgg_register_plugin_hook_handler('container_permissions_check', 'object', array($this->hooks, 'containerPermissionsCheck')); elgg_register_plugin_hook_handler('register', 'menu:river', array($this->hooks, 'riverMenuSetup')); elgg_register_plugin_hook_handler('register', 'menu:entity', array($this->hooks, 'entityMenuSetup')); elgg_register_plugin_hook_handler('register', 'menu:owner_block', array($this->hooks, 'ownerBlockMenuSetup')); elgg_register_plugin_hook_handler('register', 'menu:user_hover', array($this->hooks, 'userHoverMenuSetup')); elgg_register_plugin_hook_handler('get_views', 'ecml', array($this->hooks, 'getECMLViews')); elgg_register_plugin_hook_handler('view', 'object/thewire', array($this->hooks, 'hijackWire')); elgg_register_plugin_hook_handler('view', 'river/object/thewire/create', array($this->hooks, 'hijackWireRiver')); elgg_register_widget_type('wall', elgg_echo('wall'), elgg_echo('wall:widget:description')); add_group_tool_option('wall', elgg_echo('wall:groups:enable'), false); elgg_extend_view('groups/tool_latest', 'framework/wall/group_module'); // Export $subtype = Post::SUBTYPE; elgg_register_plugin_hook_handler('aliases', 'graph', array($this->hooks, 'getGraphAlias')); elgg_register_plugin_hook_handler('graph:properties', "object:{$subtype}", array($this->hooks, 'getPostProperties')); // @todo Move graph controller when interface is implemented in hypeApps }
public function init() { elgg_register_action('dropzone/upload', $this->plugin->getPath() . 'actions/dropzone/upload.php'); /** * JS, CSS and Views */ elgg_extend_view('css/elgg', 'css/dropzone/stylesheet'); if (\hypeJunction\Integration::isElggVersionAbove('1.9.0')) { elgg_define_js('dropzone/lib', array('src' => '/mod/hypeDropzone/vendors/dropzone/dropzone-amd-module.min.js', 'deps' => array('jquery'), 'exports' => 'dropzone')); } else { elgg_register_js('dropzone.min.js', '/mod/hypeDropzone/vendors/dropzone/dropzone.min.js', 'footer'); elgg_register_simplecache_view('js/dropzone/legacy/lib'); elgg_register_js('dropzone', elgg_get_simplecache_url('js', 'dropzone/legacy/dropzone')); } }
/** * Init * @return void */ function prototyper_ui_init() { elgg_extend_view('css/elgg', 'css/framework/prototyper/ui/stylesheet'); if (\hypeJunction\Integration::isElggVersionBelow('1.9.0')) { elgg_register_simplecache_view('js/framework/legacy/prototyper_ui'); elgg_register_js('prototyper_ui', elgg_get_simplecache_url('js', 'framework/legacy/prototyper_ui'), 'footer'); elgg_register_js('jquery.cropper', '/mod/hypePrototyperUI/vendors/jquery.cropper/cropper.min.js', 'footer'); elgg_register_simplecache_view('js/framework/legacy/prototyper_cropper'); elgg_register_js('prototyper_cropper', elgg_get_simplecache_url('js', 'framework/legacy/prototyper_cropper'), 'footer'); } else { elgg_define_js('cropper', array('src' => '/mod/hypePrototyperUI/vendors/jquery.cropper/cropper.min.js', 'deps' => array('jquery'))); } elgg_register_css('jquery.cropper', '/mod/hypePrototyperUI/vendors/jquery.cropper/cropper.min.css'); elgg_extend_view('input/file', 'prototyper/ui/cropper'); }
/** * Init callback */ public function init() { elgg_extend_view('css/elgg', 'css/framework/prototyper/stylesheet'); elgg_extend_view('css/admin', 'css/framework/prototyper/stylesheet'); elgg_register_css('jquery.cropper', '/mod/hypePrototyper/vendors/jquery.cropper/cropper.min.css'); elgg_extend_view('prototyper/input/before', 'prototyper/elements/js'); if (\hypeJunction\Integration::isElggVersionBelow('1.9.0')) { // Prototyper interface elgg_register_simplecache_view('js/framework/legacy/prototyper'); elgg_register_js('prototyper', elgg_get_simplecache_url('js', 'framework/legacy/prototyper'), 'footer'); elgg_register_js('jquery.cropper', '/mod/hypePrototyper/vendors/jquery.cropper/cropper.min.js', 'footer'); elgg_register_simplecache_view('js/framework/legacy/prototyper_cropper'); elgg_register_js('prototyper_cropper', elgg_get_simplecache_url('js', 'framework/legacy/prototyper_cropper'), 'footer'); } else { elgg_define_js('cropper', array('src' => '/mod/hypePrototyper/vendors/jquery.cropper/cropper.min.js', 'deps' => array('jquery'))); } elgg_extend_view('input/file', 'prototyper/ui/cropper'); hypePrototyper()->config->registerType('title', Elements\AttributeField::CLASSNAME, array('shortname' => 'title', 'input_view' => 'input/text', 'output_view' => 'output/text', 'value_type' => 'text', 'show_access' => false, 'multiple' => false, 'required' => true, 'ui_sections' => array('multiple' => false, 'access' => false))); hypePrototyper()->config->registerType('name', Elements\AttributeField::CLASSNAME, array('shortname' => 'name', 'input_view' => 'input/text', 'output_view' => 'output/text', 'value_type' => 'text', 'show_access' => false, 'multiple' => false, 'required' => true, 'ui_sections' => array('multiple' => false, 'access' => false))); hypePrototyper()->config->registerType('description', Elements\AttributeField::CLASSNAME, array('shortname' => 'description', 'input_view' => 'input/longtext', 'output_view' => 'output/longtext', 'value_type' => 'text', 'show_access' => false, 'multiple' => false, 'ui_sections' => array('multiple' => false, 'access' => false))); hypePrototyper()->config->registerType('access', Elements\AttributeField::CLASSNAME, array('shortname' => 'access_id', 'value' => get_default_access(), 'input_view' => 'input/access', 'output_view' => 'output/access', 'value_type' => 'int', 'show_access' => false, 'multiple' => false, 'required' => true, 'ui_sections' => array('multiple' => false, 'access' => false))); hypePrototyper()->config->registerType('text', Elements\MetadataField::CLASSNAME); hypePrototyper()->config->registerType('text', Elements\AnnotationField::CLASSNAME); hypePrototyper()->config->registerType('plaintext', Elements\MetadataField::CLASSNAME, array('value_type' => 'text')); hypePrototyper()->config->registerType('longtext', Elements\MetadataField::CLASSNAME, array('value_type' => 'text')); hypePrototyper()->config->registerType('hidden', Elements\MetadataField::CLASSNAME, array('multiple' => false, 'required' => false, 'show_access' => false, 'label' => false, 'help' => false, 'ui_sections' => array('required' => false, 'access' => false, 'multiple' => false, 'label' => false, 'help' => false))); hypePrototyper()->config->registerType('select', Elements\MetadataField::CLASSNAME, array('ui_sections' => array('optionsvalues' => true))); hypePrototyper()->config->registerType('access', Elements\MetadataField::CLASSNAME, array('ui_sections' => array('optionsvalues' => false))); hypePrototyper()->config->registerType('checkboxes', Elements\MetadataField::CLASSNAME, array('ui_sections' => array('multiple' => false, 'optionsvalues' => true))); hypePrototyper()->config->registerType('radio', Elements\MetadataField::CLASSNAME, array('ui_sections' => array('multiple' => false, 'optionsvalues' => true))); hypePrototyper()->config->registerType('tags', Elements\MetadataField::CLASSNAME, array('ui_sections' => array('multiple' => false))); hypePrototyper()->config->registerType('date', Elements\MetadataField::CLASSNAME, array('timestamp' => false)); hypePrototyper()->config->registerType('time', Elements\MetadataField::CLASSNAME, array('input_view' => 'input/prototyper/time', 'format' => 'g:ia', 'interval' => 900)); hypePrototyper()->config->registerType('email', Elements\MetadataField::CLASSNAME); hypePrototyper()->config->registerType('url', Elements\MetadataField::CLASSNAME); hypePrototyper()->config->registerType('stars', Elements\MetadataField::CLASSNAME, array('value_type' => 'number', 'ui_sections' => array('validation' => false))); hypePrototyper()->config->registerType('stars', Elements\AnnotationField::CLASSNAME, array('value_type' => 'number', 'ui_sections' => array('validation' => false))); hypePrototyper()->config->registerType('userpicker', Elements\RelationshipField::CLASSNAME, array('value_type' => 'guid', 'inverse_relationship' => false, 'bilateral' => false, 'multiple' => false, 'show_access' => false, 'ui_sections' => array('access' => false, 'multiple' => false, 'relationship' => true))); hypePrototyper()->config->registerType('friendspicker', Elements\RelationshipField::CLASSNAME, array('value_type' => 'guid', 'inverse_relationship' => false, 'bilateral' => false, 'multiple' => false, 'show_access' => false, 'ui_sections' => array('access' => false, 'multiple' => false, 'relationship' => true))); if (elgg_is_active_plugin('hypeCategories')) { hypePrototyper()->config->registerType('category', Elements\CategoryField::CLASSNAME, array('value_type' => 'guid', 'inverse_relationship' => false, 'bilateral' => false, 'multiple' => true, 'show_access' => false, 'ui_sections' => array('access' => false, 'multiple' => true, 'relationship' => false))); } hypePrototyper()->config->registerType('icon', Elements\IconField::CLASSNAME, array('accept' => 'image/*', 'value_type' => 'image', 'multiple' => false, 'show_access' => false, 'input_view' => 'input/file', 'output_view' => 'icon/default', 'ui_sections' => array('value' => false, 'access' => false, 'multiple' => false))); hypePrototyper()->config->registerType('upload', Elements\UploadField::CLASSNAME, array('multiple' => false, 'show_access' => false, 'input_view' => 'input/file', 'ui_sections' => array('value' => true, 'access' => false, 'multiple' => false, 'validation' => true))); hypePrototyper()->config->registerType('image_upload', Elements\ImageUploadField::CLASSNAME, array('multiple' => false, 'accept' => 'image/*', 'value_type' => 'image', 'show_access' => false, 'input_view' => 'input/file', 'validation_rules' => array('type' => 'image'), 'ui_sections' => array('value' => true, 'access' => false, 'multiple' => false, 'validation' => true))); }
/** * Set session geopositioning * * @param string $location Location * @param float $latitude Latitude * @param float $longitude Longitude * @return stdClass */ public function set($location = '', $latitude = 0, $longitude = 0) { $location = sanitize_string($location); $lat = (double) $latitude; $long = (double) $longitude; if (!$lat || !$long) { $latlong = $this->geocode($location); if ($latlong) { $lat = elgg_extract('lat', $latlong); $long = elgg_extract('long', $latlong); } } $geopositioning = array('location' => $location, 'latitude' => $lat, 'longitude' => $long); $cookie_value = base64_encode(serialize($geopositioning)); if (\hypeJunction\Integration::isElggVersionAbove('1.9.0')) { $cookie = new \ElggCookie(self::COOKIE_NAME); $cookie->value = $cookie_value; elgg_set_cookie($cookie); } else { setcookie(self::COOKIE_NAME, $cookie_value, strtotime("+30days"), "/", ""); } return (object) $geopositioning; }
<?php $field = elgg_extract('field', $vars); $entity = elgg_extract('entity', $vars); if (!$field instanceof hypeJunction\Prototyper\Elements\CategoryField) { return; } $name = $field->getShortname(); if (!$entity || !$name) { return; } if (\hypeJunction\Integration::isElggVersionBelow('1.9.0')) { elgg_load_js('prototyper'); } else { elgg_require_js('framework/prototyper'); } $label = $field->getLabel(); $view = $field->getOutputView(); $relationships = $field->getValues($entity); if (!count($relationships)) { return; } if ($relationships) { foreach ($relationships as $guid) { $entity = get_entity($guid); if ($entity) { $entities[] = get_entity($guid); } } } if (empty($entities)) {
<?php /** * Drag and drop file upload input * * @uses $vars['class'] CSS classes to apply to the dropzone * @uses $vars['name'] Name of the input that you can use in your action. Defaults to file_guids * @uses $vars['value'] Were any files uploaded using this dropzone previously? Will the files be overwritten? * @uses $vars['multiple'] Allow multiple file uploads * @uses $vars['max'] Maximum number of files to handle, defaults to 10 * @uses $vars['accept'] File types to accept * @uses $vars['action'] Alternative elgg action to handle temporary file uploads. Defaults to 'action/dropzone/upload' * @uses $vars['container_guid'] GUID of the container entity to which new files should be uploaded * @uses $vars['subtype'] Subtype of the file to be created */ if (\hypeJunction\Integration::isElggVersionAbove('1.9.0')) { elgg_require_js('dropzone/dropzone'); } else { elgg_load_js('dropzone.min.js'); elgg_load_js('dropzone'); } $uid = substr(md5(microtime() . rand()), 0, 10); $options['id'] = "dropzone-{$uid}"; $fallback_input_id = "dropzone-fallback-{$uid}"; $vars['id'] = $options['data-fallback-id'] = $fallback_input_id; elgg_load_js('dropzone.js'); elgg_load_js('elgg.dropzone.js'); elgg_load_css('elgg.dropzone.css'); // Add dropzone class for JS initialization if (isset($vars['class'])) { $options['class'] = "elgg-input-dropzone {$vars['class']}";
/** * Parses action name * * @param string $action Action name * @return string */ public function parseActionName($action = null) { if (is_string($action) && elgg_action_exists($action)) { return $action; } if (Integration::isElggVersionBelow('1.9.0')) { return get_input('action'); } $uri = trim(get_input('__elgg_uri', ''), '/'); $segments = explode('/', $uri); $handler = array_shift($segments); if ($handler == 'action') { return implode('/', $segments); } return $uri; }
/** * Tokeninput callback * * @param string $term Query string * @return array */ public function searchRecipients($term) { $term = sanitize_string($term); // replace mysql vars with escaped strings $q = str_replace(array('_', '%'), array('\\_', '\\%'), $term); $message_type = get_input('message_type', Message::TYPE_PRIVATE); $options = $this->getUserQueryOptions($message_type); if (Integration::isElggVersionAbove('2.1')) { $options['query'] = $q; $search_results = (array) elgg_trigger_plugin_hook('search', 'user', $options, []); $results = elgg_extract('entities', $search_results, []); } else { $list = new ElggList($options); $list->setSearchQuery(array('user' => $q)); $batch = $list->getItems(); /* @var \\ElggBatch $batch */ $results = array(); foreach ($batch as $b) { $results[] = $b; } } return $results; }
/** * {@inheritdoc} */ public function execute() { if (!$this->post) { if ($this->subtype == 'thewire' && is_callable('thewire_save_post')) { $guid = thewire_save_post($this->status, $this->poster->guid, $this->access_id, 0, 'wall'); $this->post = get_entity($guid); } else { $this->post = new Post(); $this->post->subtype = $this->subtype; $this->post->owner_guid = $this->poster->guid; $this->post->container_guid = $this->container->guid; $guid = $this->post->save(); } } $this->post->title = $this->title; $this->post->description = $this->status; $this->post->access_id = $this->access_id; if (!$this->post->guid) { $this->result->addError(elgg_echo('wall:create:error')); return; } if (Integration::isElggVersionBelow('1.9.0')) { $river_id = add_to_river('river/object/hjwall/create', 'create', $this->poster->guid, $this->post->guid); } else { // Create a river entry for this wall post $river_id = elgg_create_river_item(array('view' => 'river/object/hjwall/create', 'action_type' => 'create', 'subject_guid' => $this->post->owner_guid, 'object_guid' => $this->post->guid, 'target_guid' => $this->post->container_guid)); } $river = elgg_get_river(array('ids' => $river_id)); $this->river = $river ? $river[0] : null; $this->post->origin = 'wall'; $qualifiers = elgg_trigger_plugin_hook('extract:qualifiers', 'wall', array('source' => $this->post->description), array()); if (count($qualifiers['hashtags'])) { $this->post->tags = $qualifiers['hashtags']; } if (count($qualifiers['usernames'])) { foreach ($qualifiers['usernames'] as $username) { $user = get_user_by_username($username); if (elgg_instanceof($user) && !in_array($user->guid, $this->friend_guids)) { $this->friend_guids[] = $user->guid; } } } // Add 'tagged_in' relationships // If the access level for the post is not set to private, also create a river item // with the access level specified in their settings by the tagged user if (!empty($this->friend_guids)) { foreach ($this->friend_guids as $friend_guid) { if (add_entity_relationship($friend_guid, 'tagged_in', $this->post->guid)) { if (!in_array($this->access_id, array(ACCESS_PRIVATE, ACCESS_LOGGED_IN, ACCESS_PUBLIC))) { $river_access_id = elgg_get_plugin_user_setting('river_access_id', $friend_guid, 'hypeWall'); if (!is_null($river_access_id) && $river_access_id !== ACCESS_PRIVATE) { $river_id = elgg_create_river_item(array('view' => 'river/relationship/tagged/create', 'action_type' => 'tagged', 'subject_guid' => $friend_guid, 'object_guid' => $this->post->getGUID(), 'target_guid' => $this->post->getContainerGUID(), 'access_id' => $river_access_id)); } } } } } // Wall post access id is set to private, which means it should be visible only to the poster and tagged users // Creating a new ACL for that if ($this->access_id == ACCESS_PRIVATE && count($this->friend_guids)) { $members = $this->friend_guids; $members[] = $this->poster->guid; $members[] = $this->container->guid; $acl_id = AccessCollection::create($members); $this->post->access_id = $acl_id; $this->post->save(); } if (!empty($this->attachment_guids)) { foreach ($this->attachment_guids as $attachment_guid) { add_entity_relationship($attachment_guid, 'attached', $this->post->guid); } } // files being uploaded via $_FILES $uploads = hypeApps()->uploader->handle('upload_guids'); $uploaded_file_guids = []; if ($uploads) { foreach ($uploads as $upload) { if ($upload instanceof \ElggFile) { $file_obj = $upload; } else { if ($upload instanceof \hypeJunction\Files\Upload) { $file_obj = $upload->file; } } if ($file_obj->guid) { $uploaded_file_guids[] = $file_obj->guid; } } } // Something is broken in the hypeApps setter, so doing this hack for now $this->upload_guids = array_merge($this->upload_guids, $uploaded_file_guids); if (!empty($this->upload_guids)) { foreach ($this->upload_guids as $upload_guid) { $upload = get_entity($upload_guid); if ($upload) { $upload->description = $this->post->description; $upload->origin = 'wall'; $upload->access_id = $this->post->access_id; $upload->container_guid = $this->container->canWriteToContainer($this->poster->guid, 'object', 'file') ? $this->container->guid : ELGG_ENTITIES_ANY_VALUE; if ($upload->save()) { add_entity_relationship($upload_guid, 'attached', $this->post->guid); } } } } $this->post->setLocation($this->location); $this->post->address = $this->address; if ($this->post->address && $this->make_bookmark) { $document = elgg_trigger_plugin_hook('extract:meta', 'wall', array('src' => $this->post->address)); $bookmark = new ElggObject(); $bookmark->subtype = "bookmarks"; $bookmark->container_guid = $this->container->canWriteToContainer($this->poster->guid, 'object', 'bookmarks') ? $this->container->guid : ELGG_ENTITIES_ANY_VALUE; $bookmark->address = $this->post->address; $bookmark->access_id = $this->post->access_id; $bookmark->origin = 'wall'; if (!$document) { $bookmark->title = $this->post->title; $bookmark->description = $this->post->description; $bookmark->tags = $this->post->tags; } else { $bookmark->title = filter_tags($document->meta->title); $bookmark->description = filter_tags($document->meta->description); $bookmark->tags = string_to_tag_array(filter_tags($document->meta->keywords)); } $bookmark->save(); $this->bookmark = $bookmark; } if ($this->post->save()) { $message = $this->post->formatMessage(); $params = array('entity' => $this->post, 'user' => $this->poster, 'message' => $message, 'url' => $this->post->getURL(), 'origin' => 'wall'); elgg_trigger_plugin_hook('status', 'user', $params); // Trigger a publish event, so that we can send out notifications elgg_trigger_event('publish', 'object', $this->post); if (get_input('widget')) { elgg_push_context('widgets'); } if (elgg_is_xhr()) { $this->result->output .= elgg_list_river(array('object_guids' => $this->post->guid, 'pagination' => false, 'pagination_type' => false, 'limit' => 0)); } $this->result->addMessage(elgg_echo('wall:create:success')); if ($this->container instanceof \ElggUser) { $this->result->setForwardURL(hypeWall()->router->normalize("owner/{$this->container->username}")); } else { $this->result->setForwardURL(hypeWall()->router->normalize("container/{$this->container->guid}")); } } else { $this->result->addError(elgg_echo('wall:create:error')); } }
/** * 'init','system' callback */ public function init() { elgg_register_page_handler($this->config->get('pagehandler_id'), array($this->router, 'handlePages')); elgg_register_plugin_hook_handler('format:src', 'embed', array($this->hooks, 'formatEmbedView')); elgg_register_plugin_hook_handler('extract:meta', 'all', array($this->hooks, 'getEmbedMetadata')); elgg_register_plugin_hook_handler('extract:qualifiers', 'all', array($this->hooks, 'extractQualifiers')); elgg_register_plugin_hook_handler('link:qualifiers', 'all', array($this->hooks, 'linkQualifiers')); elgg_extend_view('css/elgg', 'css/framework/scraper/stylesheet'); if (\hypeJunction\Integration::isElggVersionBelow('1.9.0')) { elgg_register_simplecache_view('js/scraper/legacy/play'); elgg_register_js('scraper/play', elgg_get_simplecache_url('js', 'scraper/legacy/play'), 'footer'); } }
/** * {@inheritdoc} */ public function serve() { if (headers_sent()) { return; } if (!$this->uid || !$this->ts || !$this->path || !$this->hmac) { header("HTTP/1.1 400 Bad Request"); exit; } $etag = md5($this->ts . $this->uid); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"{$etag}\"") { header("HTTP/1.1 304 Not Modified"); exit; } $this->openDbLink(); $values = $this->getDatalistValue(array('dataroot', '__site_secret__')); $this->closeDbLink(); if (empty($values)) { header("HTTP/1.1 404 Not Found"); exit; } $data_root = $values['dataroot']; $key = $values['__site_secret__']; $hmac = hash_hmac('sha256', $this->uid . $this->path, $key); if ($this->hmac !== $hmac) { header("HTTP/1.1 403 Forbidden"); exit; } if (\hypeJunction\Integration::isElggVersionBelow('1.9.0')) { $time_created = date('Y/m/d', $this->dts); $d = "{$time_created}/{$this->d}/"; } else { $locator = new \Elgg\EntityDirLocator($this->d); $d = $locator->getPath(); } $filename = "{$data_root}{$d}{$this->path}"; if (!file_exists($filename) || !is_readable($filename)) { header("HTTP/1.1 404 Not Found"); exit; } $filesize = filesize($filename); $ext = pathinfo($filename, PATHINFO_EXTENSION); switch ($ext) { default: $mimetype = 'application/otcet-stream'; break; case 'jpg': case 'jpeg': $mimetype = 'image/jpeg'; break; case 'png': $mimetype = 'image/png'; break; case 'gif': $mimetype = 'image/gif'; break; } header("Content-type: {$mimetype}"); header("Content-disposition: inline"); header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime("+6 months")), true); header("Pragma: public"); header("Cache-Control: public"); header("Content-Length: {$filesize}"); header("ETag: \"{$etag}\""); readfile($filename); exit; }