/** * Populate the toolbar * * @param String $today_path Path to the today's calendar */ private function _populate_toolbar($path = null) { // 'New event' should always be in toolbar $nap = new midcom_helper_nav(); $this_node = $nap->get_node($nap->get_current_node()); if ($this->_root_event->can_do('midgard:create')) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => '#', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create event'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_new-event.png', MIDCOM_TOOLBAR_OPTIONS => array('rel' => 'directlink', 'onclick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node)))); } if (method_exists($this->_calendar, 'get_' . $path . '_start')) { $previous = date('Y-m-d', call_user_func(array($this->_calendar, 'get_' . $path . '_start')) - 100); $next = date('Y-m-d', call_user_func(array($this->_calendar, 'get_' . $path . '_end')) + 100); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $path . '/' . $previous . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('previous'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/up.png')); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $path . '/' . $next . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('next'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/down.png')); } if ($this->_topic->can_do('midgard:update') && $this->_topic->can_do('midcom:component_config')) { $this->_node_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'config/', MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('component configuration'), MIDCOM_TOOLBAR_HELPTEXT => $this->_l10n_midcom->get('component configuration helptext'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_folder-properties.png')); } midcom_helper_datamanager2_widget_jsdate::add_head_elements(); midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . "/org.openpsa.calendar/navigation.js"); $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); $default_date = date('Y-m-d', $this->_selected_time); midcom::get('head')->add_jscript(' var org_openpsa_calendar_default_date = "' . $default_date . '", org_openpsa_calendar_prefix = "' . $prefix . $path . '"; '); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => '#', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('go to'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_jump-to.png', MIDCOM_TOOLBAR_OPTIONS => array('rel' => 'directlink', 'id' => 'date-navigation'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "{$path}/" . $this->_get_datestring(time()) . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('today'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/web-calendar.png')); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "filters/?org_openpsa_calendar_returnurl=" . midcom_connection::get_url('uri'), MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('choose calendars'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/preferences-desktop.png')); }
public function run_handler($topic, array $args = array()) { if (is_object($topic)) { $component = $topic->component; } else { $component = $topic; $topic = $this->get_component_node($component); } $context = new midcom_core_context(null, $topic); $context->set_current(); $context->set_key(MIDCOM_CONTEXT_URI, midcom_connection::get_url('self') . $topic->name . '/' . implode('/', $args) . '/'); // Parser Init: Generate arguments and instantiate it. $context->parser = midcom::get('serviceloader')->load('midcom_core_service_urlparser'); $context->parser->parse($args); $handler = $context->get_handler($topic); $context->set_key(MIDCOM_CONTEXT_CONTENTTOPIC, $topic); $this->assertTrue(is_a($handler, 'midcom_baseclasses_components_interface'), $component . ' found no handler for ./' . implode('/', $args) . '/'); $result = $handler->handle(); $this->assertTrue($result !== false, $component . ' handle returned false on ./' . implode('/', $args) . '/'); $data =& $handler->_context_data[$context->id]['handler']->_handler['handler'][0]->_request_data; if (is_object($result) && $result instanceof midcom_response) { $data['__openpsa_testcase_response'] = $result; } $data['__openpsa_testcase_handler'] = $handler->_context_data[$context->id]['handler']->_handler['handler'][0]; $data['__openpsa_testcase_handler_method'] = $handler->_context_data[$context->id]['handler']->_handler['handler'][1]; // added to simulate http uri composition $_SERVER['REQUEST_URI'] = $context->get_key(MIDCOM_CONTEXT_URI); return $data; }
public function _handler_csv($handler_id, array $args, array &$data) { midcom::get('auth')->require_valid_user(); midcom::get()->disable_limits(); $this->_load_datamanager($this->_load_schemadb($handler_id, $args, $data)); $this->_objects = $this->_load_data($handler_id, $args, $data); if (!isset($args[0]) || empty($args[0])) { //We do not have filename in URL, generate one and redirect $fname = preg_replace('/[^a-z0-9-]/i', '_', strtolower($this->_topic->extra)) . '_' . date('Y-m-d') . '.csv'; if (strpos(midcom_connection::get_url('uri'), '/', strlen(midcom_connection::get_url('uri')) - 2)) { return new midcom_response_relocate(midcom_connection::get_url('uri') . $fname); } else { return new midcom_response_relocate(midcom_connection::get_url('uri') . "/{$fname}"); } } if (!isset($data['filename']) || $data['filename'] == '') { $data['filename'] = str_replace('.csv', '', $args[0]); } $this->_init_csv_variables(); midcom::get()->skip_page_style = true; // FIXME: Use global configuration //midcom::get('cache')->content->content_type($this->_config->get('csv_export_content_type')); midcom::get('cache')->content->content_type('application/csv'); _midcom_header('Content-Disposition: filename=' . $data['filename']); }
/** * Read the configuration */ public function __construct($auth) { $this->_cookie_id .= $GLOBALS['midcom_config']['auth_backend_simple_cookie_id']; $this->_cookie_path = $GLOBALS['midcom_config']['auth_backend_simple_cookie_path']; if ($this->_cookie_path == 'auto') { $this->_cookie_path = midcom_connection::get_url('self'); } if (!empty($_SERVER['HTTPS']) && $GLOBALS['midcom_config']['auth_backend_simple_cookie_secure']) { $this->_secure_cookie = true; } parent::__construct($auth); }
public function _populate_post_toolbar($comment) { $toolbar = new midcom_helper_toolbar(); if (midcom::get('auth')->user && $comment->status < net_nehmer_comments_comment::MODERATED) { if (!$comment->can_do('net.nehmer.comments:moderation')) { // Regular users can only report abuse $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "report/{$comment->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('report abuse'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_help-agent.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('mark' => 'abuse', 'return_url' => midcom_connection::get_url('uri')))); } else { $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "report/{$comment->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('confirm abuse'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $comment->can_do('net.nehmer.comments:moderation'), MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('mark' => 'confirm_abuse', 'return_url' => midcom_connection::get_url('uri')))); $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "report/{$comment->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('confirm junk'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $comment->can_do('net.nehmer.comments:moderation'), MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('mark' => 'confirm_junk', 'return_url' => midcom_connection::get_url('uri')))); $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "report/{$comment->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('not abuse'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/ok.png', MIDCOM_TOOLBAR_ENABLED => $comment->can_do('net.nehmer.comments:moderation'), MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('mark' => 'not_abuse', 'return_url' => midcom_connection::get_url('uri')))); $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $_SERVER['REQUEST_URI'], MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/editdelete.png', MIDCOM_TOOLBAR_ENABLED => $comment->can_do('net.nehmer.comments:moderation'), MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('net_nehmer_comment_adminsubmit' => '1', 'guid' => $comment->guid, 'action_delete' => 'action_delete'))); } } return $toolbar; }
function _load_schemadb($handler_id, &$args, &$data) { $data['session'] = new midcom_services_session('org_openpsa_products_csvexport'); if (!empty($_POST)) { $data['session']->set('POST_data', $_POST); } $root_group_guid = $this->_config->get('root_group'); $group_name_to_filename = ''; if ($root_group_guid) { $root_group = org_openpsa_products_product_group_dba::get_cached($root_group_guid); $group_name_to_filename = strtolower(str_replace(' ', '_', $root_group->code)) . '_'; } if (isset($args[0])) { $data['schemadb_to_use'] = str_replace('.csv', '', $args[0]); $data['filename'] = $group_name_to_filename . $data['schemadb_to_use'] . '_' . date('Y-m-d') . '.csv'; } else { if (isset($_POST) && array_key_exists('org_openpsa_products_export_schema', $_POST)) { //We do not have filename in URL, generate one and redirect $schemaname = $_POST['org_openpsa_products_export_schema']; if (strpos(midcom_connection::get_url('uri'), '/', strlen(midcom_connection::get_url('uri')) - 2)) { midcom::get()->relocate(midcom_connection::get_url('uri') . "{$schemaname}"); } else { midcom::get()->relocate(midcom_connection::get_url('uri') . "/{$schemaname}"); } // This will exit } else { $this->_request_data['schemadb_to_use'] = $this->_config->get('csv_export_schema'); } } $this->_schema = $this->_config->get('csv_export_schema'); if (isset($this->_request_data['schemadb_product'][$this->_request_data['schemadb_to_use']])) { $this->_schema = $this->_request_data['schemadb_to_use']; } $this->_schema_fields_to_skip = explode(',', $this->_config->get('export_skip_fields')); return $this->_request_data['schemadb_product']; }
<?php $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); $page =& $data['wikipage']; $history =& $data['history']; $version_string = "<a href=\"{$prefix}__ais/rcs/preview/{$page->guid}/{$data['version']}\">{$data['version']}</a>"; $url = midcom_connection::get_url('self') . "midcom-permalink-{$page->guid}"; ?> <tr> <td> <a rel="note" class="subject url" href="&(url);">&(page.title);</a> </td> <td> &(version_string:h); </td> <td class="revisor"> <?php if ($history['user']) { $user = midcom::get('auth')->get_user($history['user']); if (is_object($user)) { if (class_exists('org_openpsa_widgets_contact')) { $user_card = org_openpsa_widgets_contact::get($user->guid); $person_label = $user_card->show_inline(); } else { $person = $user->get_storage(); $person_label = $person->name; } } echo " {$person_label}\n"; } else { if ($history['ip']) {
<span class="icon">&(data['icon']:h);</span> <span class="title"><a href="&(data['document_url']);" target="document_&(document.guid);">&(document.title:h);</a></span> <ul class="metadata"> <li class="time"><?php echo strftime('%x', $document->metadata->created); ?> </li> <li class="file"> <?php if (count($atts) == 0) { echo midcom::get('i18n')->get_string('no files', 'org.openpsa.documents'); } else { foreach ($atts as $file) { // FIXME: This is a messy way of linking into DM-managed files if ($file->parameter('midcom.helper.datamanager2.type.blobs', 'fieldname') == 'document') { echo "<a target=\"document_{$document->guid}\" href=\"" . midcom_connection::get_url('self') . "midcom-serveattachmentguid-{$file->guid}/{$file->name}\">{$file->name}</a> (" . sprintf(midcom::get('i18n')->get_string('%s document', 'org.openpsa.documents'), midcom::get('i18n')->get_string($file->mimetype, 'org.openpsa.documents')) . ")"; } } } ?> </li> </ul> <div id="org_openpsa_relatedto_details_&(document.guid);" class="details hidden" style="display: none;"> </div> <?php //TODO: get correct node and via it then handle details trough AHAH (and when we have node we can use proper link in document_url as well org_openpsa_relatedto_handler_relatedto::render_line_controls($link, $data['other_obj']); ?> </li>
/** * * @param mixed $handler_id The ID of the handler. * @param array &$data The local request data. */ public function _show_navigation($handler_id, array &$data) { $tree_array = array($this->_request_data['root_topic']->id => $this->_request_data['root_topic']); $this->_tree_array_build($this->_request_data['topic_array'], $this->_request_data['root_topic'], $tree_array); midcom_show_style("show-navigation-start"); $this->_show_navigation_tree($tree_array, midcom_connection::get_url('prefix')); midcom_show_style("show-navigation-end"); }
public static function get_url($attachment) { if (is_string($attachment)) { $guid = $attachment; $mc = self::new_collector('guid', $guid); $name = array_pop($mc->get_values('name')); } else { if (is_a($attachment, 'midcom_db_attachment')) { $guid = $attachment->guid; $name = $attachment->name; } else { throw new midcom_error('Invalid attachment identifier'); } } if ($GLOBALS['midcom_config']['attachment_cache_enabled']) { $subdir = substr($guid, 0, 1); if (file_exists($GLOBALS['midcom_config']['attachment_cache_root'] . '/' . $subdir . '/' . $guid . '_' . $name)) { return $GLOBALS['midcom_config']['attachment_cache_url'] . '/' . $subdir . '/' . $guid . '_' . urlencode($name); } } if (is_object($attachment)) { $nap = new midcom_helper_nav(); $parent = $nap->resolve_guid($attachment->parentguid); if (is_array($parent) && $parent[MIDCOM_NAV_TYPE] == 'node') { //Serve from topic return midcom_connection::get_url('self') . $parent[MIDCOM_NAV_RELATIVEURL] . urlencode($name); } } // Use regular MidCOM attachment server return midcom_connection::get_url('self') . 'midcom-serveattachmentguid-' . $guid . '/' . urlencode($name); }
public static function get_unique_host_name() { if (null === self::_get('config', 'unique_host_name')) { self::$_data['config']['unique_host_name'] = str_replace(':', '_', $_SERVER['SERVER_NAME']) . '_' . str_replace('/', '_', midcom_connection::get_url('prefix')); } return self::$_data['config']['unique_host_name']; }
/** * @todo This function does nothing (and would throw notices if it did) */ private function _add_attachment($att) { return false; $attobj = $this->_article->create_attachment($att['name'], $att['name'], $att['mimetype']); if (!$attobj) { //Could not create attachment debug_add("Could not create attachment '{$att['name']}', errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR); continue; } $fp = @$attobj->open('w'); if (!$fp) { //Could not open for writing, clean up and continue debug_add("Could not open attachment {$attobj->guid} for writing, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR); $attobj->delete(); continue; } if (!fwrite($fp, $att['content'], strlen($att['content']))) { //Could not write, clean up and continue debug_add("Error when writing attachment {$attobj->guid}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR); fclose($fp); $attobj->delete(); continue; } fclose($fp); if (isset($att['part']) && isset($att['part']->headers) && isset($att['part']->headers['content-id'])) { //Attachment is embed, add tag to end of note if (!$embeds_added) { $this->_article->content .= "<p>"; $embeds_added = true; } $this->_article->content .= "<a href=\"" . midcom_connection::get_url('self') . "midcom-serveattachmentguid-{$attobj->guid}/{$attobj->name}\">{$attobj->title}</a><br />"; } else { //Add normal attachments as links to end of note if (!$attachments_added) { //We hope the client handles these so that embeds come first and attachments then so we can avoid double pass over this array $this->_article->content .= "\n\n"; $attachments_added = true; } $this->_article->content .= "[{$attobj->title}](" . midcom_connection::get_url('self') . "midcom-serveattachmentguid-{$attobj->guid}/{$attobj->name}), "; } }
/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_emailimport($handler_id, array $args, array &$data) { //Content-Type midcom::get()->skip_page_style = true; midcom::get('cache')->content->content_type('text/plain'); //Make sure we have the components we use and the Mail_mimeDecode package if (!class_exists('org_openpsa_mail_decoder')) { throw new midcom_error('org.openpsa.mail decoder could not be loaded.'); } if (!class_exists('Mail_mimeDecode')) { throw new midcom_error('Cannot decode attachments, aborting.'); } //Make sure the message_source is POSTed if (!array_key_exists('message_source', $_POST) || empty($_POST['message_source'])) { throw new midcom_error('_POST[\'message_source\'] not present or empty.'); } $decoder = new org_openpsa_mail_decoder(); $decoder->mime_decode($_POST['message_source']); //Parse email addresses $regex = '/<?([a-zA-Z0-9_.-]+?@[a-zA-Z0-9_.-]+)>?[ ,]?/'; $emails = array(); if (preg_match_all($regex, $decoder->headers['To'], $matches_to)) { foreach ($matches_to[1] as $email) { //Each address only once $emails[$email] = $email; } } if (preg_match_all($regex, $decoder->headers['Cc'], $matches_cc)) { foreach ($matches_cc[1] as $email) { //Each address only once $emails[$email] = $email; } } $from = false; if (preg_match_all($regex, $decoder->headers['From'], $matches_from)) { foreach ($matches_from[1] as $email) { //Each address only once $emails[$email] = $email; //It's unlikely that we'd get multiple matches in From, but we use the latest $from = $email; } } midcom::get('auth')->request_sudo(); //TODO: Create wikinote $wikipage = new net_nemein_wiki_wikipage(); $wikipage->topic = $this->_topic->id; //PONDER: add from, to & subject into the body ?? $wikipage->content = $decoder->body; $title_format = $this->_config->get('emailimport_title_format'); $wikipage->title = sprintf($title_format, $decoder->subject, $from, strftime('%x', time())); //Check for duplicate title(s) $qb = net_nemein_wiki_wikipage::new_query_builder(); $qb->add_constraint('topic', '=', $wikipage->topic); $qb->add_constraint('title', 'LIKE', $wikipage->title . '%'); $results = $qb->execute_unchecked(); if (($found = count($results)) > 0) { foreach ($results as $foundpage) { if ($foundpage->content == $wikipage->content) { //Content exact duplicate, abort import debug_print_r("duplicate content with page '{$wikipage->title}", $wikipage->content); throw new midcom_error('Duplicate content with an existing page with similar title.'); } } //In theory this should be recursive but we'll leave it at this for now $wikipage->title .= ' ' . ($found + 1); } //Figure out author $author = $this->emailimport_find_person($from); $wikipage->author = $author->id; if (!$wikipage->author) { //Default to first user in the db $qb = midcom_db_person::new_query_builder(); $qb->add_constraint('username', '<>', ''); $results = $qb->execute_unchecked(); if (empty($results)) { //No users found throw new midcom_error('Cannot set any author for the wikipage'); } $wikipage->author = $results[0]->id; } if (!$wikipage->create()) { throw new midcom_error('wikipage->create returned failure, errstr: ' . midcom_connection::get_error_string()); } //Mark as email $wikipage->parameter('net.nemein.wiki:emailimport', 'is_email', time()); $embeds_added = false; $attachments_added = false; foreach ($decoder->attachments as $att) { debug_add("processing attachment {$att['name']}"); $attobj = $wikipage->create_attachment($att['name'], $att['name'], $att['mimetype']); if (!$attobj) { //Could not create attachment debug_add("Could not create attachment '{$att['name']}', errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR); continue; } $fp = @$attobj->open('w'); if (!$fp) { //Could not open for writing, clean up and continue debug_add("Could not open attachment {$attobj->guid} for writing, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR); $attobj->delete(); continue; } if (!fwrite($fp, $att['content'], strlen($att['content']))) { //Could not write, clean up and continue debug_add("Error when writing attachment {$attobj->guid}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR); fclose($fp); $attobj->delete(); continue; } fclose($fp); if (isset($att['part']) && isset($att['part']->headers) && isset($att['part']->headers['content-id'])) { //Attachment is embed, add tag to end of note if (!$embeds_added) { $wikipage->content .= "\n\n"; $embeds_added = true; } $wikipage->content .= "![{$attobj->title}](" . midcom_connection::get_url('self') . "midcom-serveattachmentguid-{$attobj->guid}/{$attobj->name})\n\n"; } else { //Add normal attachments as links to end of note if (!$attachments_added) { //We hope the client handles these so that embeds come first and attachments then so we can avoid double pass over this array $wikipage->content .= "\n\n"; $attachments_added = true; } $wikipage->content .= "[{$attobj->title}](" . midcom_connection::get_url('self') . "midcom-serveattachmentguid-{$attobj->guid}/{$attobj->name}), "; } } if ($embeds_added || $attachments_added) { $wikipage->update(); } // Store recipients of the email to the page for possible later use reset($emails); foreach ($emails as $email) { $wikipage->parameter('net.nemein.wiki:emailimport_recipients', $email, time()); debug_add("Processing email address {$email} for related-to links"); $person = $this->emailimport_find_person($email); if (!$person) { $group = $this->emailimport_find_group($email); if (!$group) { debug_add("Could not find person or group for email {$email}, cannot link, storing email for future reference", MIDCOM_LOG_WARN); $wikipage->parameter('net.nemein.wiki:emailimport_notlinked', $email, time()); continue; } continue; } } midcom::get('auth')->drop_sudo(); }
/** * Binds the a toolbar to a DBA object. This will append a number of globally available * toolbar options. For example, expect Metadata- and Version Control-related options * to be added. * * This call is available through convenience functions throughout the framework: The * toolbar main class has a mapping for it (midcom_helper_toolbar::bind_to($object)) * and object toolbars created by this service will automatically be bound to the * specified object. * * Repeated bind calls are intercepted, you can only bind a toolbar to a single object. * * @see midcom_helper_toolbar::bind_to() * @see create_object_toolbar() * @param &$toolbar */ function bind_toolbar_to_object(&$toolbar, &$object) { if (array_key_exists('midcom_services_toolbars_bound_to_object', $toolbar->customdata)) { // We already processed this toolbar, skipping further adds. return; } else { $toolbar->customdata['midcom_services_toolbars_bound_to_object'] = true; } $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); if (!$prefix) { debug_add("Toolbar for object {$object->guid} was called before topic prefix was available, skipping global items.", MIDCOM_LOG_WARN); return; } $reflector = new midcom_helper_reflector($object); $this->_view_toolbar_label = $reflector->get_class_label(); if ($GLOBALS['midcom_config']['metadata_approval'] && $object->can_do('midcom:approve')) { $metadata = midcom_helper_metadata::retrieve($object); if ($metadata && $metadata->is_approved()) { $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "{$prefix}__ais/folder/unapprove/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('unapprove', 'midcom'), MIDCOM_TOOLBAR_HELPTEXT => midcom::get('i18n')->get_string('approved', 'midcom'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/page-approved.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('guid' => $object->guid, 'return_to' => $_SERVER['REQUEST_URI']), MIDCOM_TOOLBAR_ACCESSKEY => 'u')); } else { $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "{$prefix}__ais/folder/approve/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('approve', 'midcom'), MIDCOM_TOOLBAR_HELPTEXT => midcom::get('i18n')->get_string('unapproved', 'midcom'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/page-notapproved.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('guid' => $object->guid, 'return_to' => $_SERVER['REQUEST_URI']), MIDCOM_TOOLBAR_ACCESSKEY => 'a')); } } if ($object->can_do('midgard:update')) { $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "{$prefix}__ais/folder/metadata/{$object->guid}/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('edit metadata', 'midcom.admin.folder'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/metadata.png', MIDCOM_TOOLBAR_ACCESSKEY => 'm')); $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "{$prefix}__ais/folder/move/{$object->guid}/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('move', 'midcom.admin.folder'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/save-as.png', MIDCOM_TOOLBAR_ENABLED => is_a($object, 'midcom_db_article'))); $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => midcom_connection::get_url('self') . "__mfa/asgard/object/open/{$object->guid}/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('manage object', 'midgard.admin.asgard'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/properties.png', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard.admin.asgard:access', null, 'midgard_admin_asgard_plugin', 'midgard.admin.asgard') && midcom::get('auth')->can_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin'))); } if ($GLOBALS['midcom_config']['midcom_services_rcs_enable'] && $object->can_do('midgard:update') && $object->_use_rcs) { $toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "{$prefix}__ais/rcs/{$object->guid}/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('show history', 'no.bergfald.rcs'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/history.png', MIDCOM_TOOLBAR_ACCESSKEY => 'v')); } }
/** * Include all text/css attachments of current style to MidCOM headers */ function add_database_head_elements() { static $called = false; if ($called) { return; } $style = $this->get_style(); $mc = midcom_db_attachment::new_collector('parentguid', $style->guid); $mc->add_constraint('mimetype', '=', 'text/css'); $attachments = $mc->get_values('name'); foreach ($attachments as $filename) { // TODO: Support media types midcom::get('head')->add_stylesheet(midcom_connection::get_url('self') . "midcom-serveattachmentguid-{$guid}/{$filename}"); } $called = true; }
<?php $auth = midcom::get('auth'); $i18n = midcom::get('i18n'); if ($auth->user) { $siteconf = org_openpsa_core_siteconfig::get_instance(); if ($user_url = $siteconf->get_node_full_url('org.openpsa.user')) { $person_string = '<a href="' . $user_url . 'view/' . $auth->user->guid . '/">' . $auth->user->name . "</a>"; } else { $person_string = $auth->user->name; } echo "<ul>\n"; echo " <li class=\"user\">" . $person_string . "</li>\n"; echo " <li class=\"logout\"><a href=\"" . midcom_connection::get_url('self') . "midcom-logout-\"><img src=\"" . MIDCOM_STATIC_URL . "/stock-icons/16x16/exit.png\" title=\"" . $i18n->get_string('logout', 'midcom') . "\" alt=\"" . $i18n->get_string('logout', 'midcom') . "\" /></a></li>\n"; echo " <li class=\"midgard\"><img src=\"" . MIDCOM_STATIC_URL . "/stock-icons/logos/midgard-16x16.png\" alt=\"X\" id=\"org_openpsa_toolbar_trigger\" /></li>\n"; echo "</ul>\n"; }
/** * Object display * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. * @return boolean Indicating success. */ public function _handler_delete($handler_id, array $args, array &$data) { $this->_load_object($args[0]); $this->_object->require_do('midgard:delete'); midcom::get('auth')->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin'); $type = $this->_object->__mgdschema_class_name__; $relocate_url = $type; $cancel_url = "__mfa/asgard/object/{$this->_request_data['default_mode']}/{$this->_object->guid}/"; $class_extends = $this->_config->get('class_extends'); if (is_array($class_extends) && array_key_exists($type, $class_extends)) { $relocate_url = $class_extends[$type]; } // Redirect person deletion to user management if (is_a($this->_object, 'midcom_db_person')) { $relocate_url = "../asgard_midcom.admin.user/"; $cancel_url = "__mfa/asgard_midcom.admin.user/edit/{$args[0]}/"; } $this->_prepare_request_data(); $this->_load_schemadb(); $this->_datamanager = new midcom_helper_datamanager2_datamanager($this->_schemadb); $this->_datamanager->set_schema('object'); if (!$this->_datamanager->set_storage($this->_object)) { throw new midcom_error("Failed to create a DM2 instance for object {$this->_object->guid}."); } if (array_key_exists('midgard_admin_asgard_deleteok', $_REQUEST)) { // Deletion confirmed. $parent = $this->_object->get_parent(); if (array_key_exists('midgard_admin_asgard_disablercs', $_REQUEST)) { $this->_object->_use_rcs = false; } if (!$this->_object->delete_tree()) { throw new midcom_error("Failed to delete object {$args[0]}, last Midgard error was: " . midcom_connection::get_error_string()); } if (is_a($this->_object, 'midcom_db_style') || is_a($this->_object, 'midcom_db_element')) { mgd_cache_invalidate(); } // Update the index $indexer = midcom::get('indexer'); $indexer->delete($this->_object->guid); if ($parent) { return new midcom_response_relocate(midcom_connection::get_url('self') . "__mfa/asgard/object/{$data['default_mode']}/{$parent->guid}/"); } return new midcom_response_relocate(midcom_connection::get_url('self') . "__mfa/asgard/" . $relocate_url); } if (array_key_exists('midgard_admin_asgard_deletecancel', $_REQUEST)) { // Redirect to default object mode page. return new midcom_response_relocate($cancel_url); } midgard_admin_asgard_plugin::bind_to_object($this->_object, $handler_id, $data); // Add Thickbox midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/midgard.admin.asgard/object_browser.js'); midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/jQuery/thickbox/jquery-thickbox-3.1.pack.js'); $this->add_stylesheet(MIDCOM_STATIC_URL . '/jQuery/thickbox/thickbox.css', 'screen'); midcom::get('head')->add_jscript('var tb_pathToImage = "' . MIDCOM_STATIC_URL . '/jQuery/thickbox/loadingAnimation.gif"'); // Add jQuery file for the checkbox operations midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/midgard.admin.asgard/jquery-copytree.js'); midcom::get('head')->add_jscript('jQuery(document).ready(function(){jQuery("#midgard_admin_asgard_copytree").tree_checker();})'); }
$pos = $_COOKIE['midcom_services_toolbars_position']; $pos = explode('_', $pos); $x = $pos[0]; $y = $pos[1]; } break; case 'session': $session = new midcom_services_session('midcom.services.toolbars'); $x = $session->get('position_x'); $y = $session->get('position_y'); break; } echo "{$x},{$y}"; _midcom_stop_request(); } // Interface for storing the toolbar position switch ($GLOBALS['midcom_config']['toolbars_position_storagemode']) { case 'parameter': $person = new midcom_db_person(midcom::get('auth')->user); $person->set_parameter('midcom.services.toolbars', 'position_x', $_REQUEST['position_x']); $person->set_parameter('midcom.services.toolbars', 'position_y', $_REQUEST['position_y']); break; case 'cookie': _midcom_setcookie('midcom_services_toolbars_position', $_REQUEST['position_x'] . '_' . $_REQUEST['position_y'], time() + 30 * 24 * 3600, midcom_connection::get_url('self')); break; case 'session': $session = new midcom_services_session('midcom.services.toolbars'); $session->set('position_x', $_REQUEST['position_x']); $session->set('position_y', $_REQUEST['position_y']); break; }
/** * Renders the UI for the currently registered filters */ public function render() { foreach ($this->_filters as $filter) { $url = midcom_connection::get_url('uri'); $filter->render($url); } }
public static function get_widget_config($type) { $handler_url = midcom_connection::get_url('self') . 'midcom-exec-midcom.helper.datamanager2/autocomplete_handler.php'; $widget_config = midcom_baseclasses_components_configuration::get('midcom.helper.datamanager2', 'config')->get('clever_classes'); $config = $widget_config[$type]; $config['handler_url'] = $handler_url; return $config; }
</select> <input type="submit" name="midgard_type_change" class="submit" value="<?php echo midcom::get('i18n')->get_string('go', 'midgard.admin.asgard'); ?> " /> </p> </form> <script type="text/javascript"> // <![CDATA[ jQuery('#midgard_admin_asgard_navigation_form input[type="submit"]').css({display:'none'}); jQuery('#midgard_admin_asgard_navigation_chooser').change(function() { if (!this.value) { window.location = '<?php echo midcom_connection::get_url('self') . '__mfa/asgard/'; ?> '; } else { window.location = '<?php echo midcom_connection::get_url('self') . '__mfa/asgard/'; ?> ' + jQuery(this).attr('value') + '/'; } }); // ]]> </script>
<div class="grouplogo"> <a href="<?php echo midcom_connection::get_url('self'); ?> "><img src="<?php echo MIDCOM_STATIC_URL; ?> /org.openpsa.core/openpsa-small.png" alt="OpenPSA" title="OpenPSA" /></a> </div>
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.') !== false) { echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; } $pref_found = false; if ($width = midgard_admin_asgard_plugin::get_preference('offset')) { $navigation_width = $width - 40; $content_offset = $width + 2; $pref_found = true; } // JavasScript libraries required by Asgard midcom::get('head')->add_jsfile(MIDCOM_JQUERY_UI_URL . '/ui/jquery.ui.core.min.js'); midcom::get('head')->add_jsfile(MIDCOM_JQUERY_UI_URL . '/ui/jquery.ui.widget.min.js'); midcom::get('head')->add_jsfile(MIDCOM_JQUERY_UI_URL . '/ui/jquery.ui.mouse.min.js'); midcom::get('head')->add_jsfile(MIDCOM_JQUERY_UI_URL . '/ui/jquery.ui.draggable.min.js'); midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/midgard.admin.asgard/resize.js'); midcom::get('head')->add_jscript("var MIDGARD_ROOT = '" . midcom_connection::get_url('self') . "';"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo midcom::get('i18n')->get_current_language(); ?> " lang="<?php echo midcom::get('i18n')->get_current_language(); ?> "> <head> <title><?php echo midcom_core_context::get()->get_key(MIDCOM_CONTEXT_PAGETITLE); ?> (<?php
/** * Return full URL that was given to the parser */ public function get_url() { return midcom_connection::get_url('self') . "{$this->url}"; }
/** * Get the URL where the topic links to * * @param array &$data Request data * @return String containing redirection URL */ public static function topic_links_to(&$data) { $config =& $data['config']; switch ($data['config']->get('redirection_type')) { case 'node': $nap = new midcom_helper_nav(); $id = $data['config']->get('redirection_node'); if (is_string($id)) { try { $topic = new midcom_db_topic($id); $id = $topic->id; } catch (midcom_error $e) { $e->log(); break; } } $node = $nap->get_node($id); // Node not found, fall through to configuration if (!$node) { break; } return $node[MIDCOM_NAV_FULLURL]; case 'subnode': $nap = new midcom_helper_nav(); $nodes = $nap->list_nodes($nap->get_current_node()); // Subnodes not found, fall through to configuration if (count($nodes) == 0) { break; } // Redirect to first node $node = $nap->get_node($nodes[0]); return $node[MIDCOM_NAV_FULLURL]; case 'permalink': $url = midcom::get('permalinks')->resolve_permalink($data['config']->get('redirection_guid')); if ($url) { return $url; } case 'url': if ($data['config']->get('redirection_url') != '') { $url = $data['config']->get('redirection_url'); // Support varying host prefixes if (strpos($url, '__PREFIX__') !== false) { $url = str_replace('__PREFIX__', midcom_connection::get_url('self'), $url); } return $url; } // Otherwise fall-through to config } $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); return "{$prefix}config/"; }
/** * This function holds the cache hit check mechanism. It searches the requested * URL in the cache database. If found, it checks, whether the cache page has * expired. If not, the cached page is delivered to the client and processing * ends. In all other cases this method simply returns. * * The midcom-cache URL methods are handled before checking for a cache hit. * * Also, any HTTP POST request will automatically circumvent the cache so that * any component can process the request. It will set no_cache automatically * to avoid any cache pages being overwritten by, for example, search results. * * Note, that HTTP GET is <b>not</b> checked this way, as GET requests can be * safely distinguished by their URL. */ private function _check_hit() { foreach (midcom_connection::get_url('argv') as $arg) { switch ($arg) { case "midcom-cache-invalidate": case "midcom-cache-nocache": case "midcom-cache-stats": // Don't cache these. debug_add("X-MidCOM-cache: " . $arg . " uncached"); return; } } // Check for POST variables, if any is found, go for no_cache. if (count($_POST) > 0) { debug_add('POST variables have been found, setting no_cache and not checking for a hit.'); $this->no_cache(); return; } // Check for uncached operation if ($this->_uncached) { debug_add("Uncached mode"); return; } // Check that we have cache for the identifier $this->_meta_cache->open(); $request_id = $this->generate_request_identifier(0); if (!$this->_meta_cache->exists($request_id)) { debug_add("MISS {$request_id}"); // We have no information about content cached for this request $this->_meta_cache->close(); return; } debug_add("HIT {$request_id}"); // Load metadata for the content identifier connected to current request $content_id = $this->_meta_cache->get($request_id); if (!$this->_meta_cache->exists($content_id)) { debug_add("MISS meta_cache {$content_id}"); // Content cache data is missing $this->_meta_cache->close(); return; } $data = $this->_meta_cache->get($content_id); if (isset($data['expires']) && !is_null($data['expires'])) { if ($data['expires'] < time()) { $this->_meta_cache->close(); debug_add('Current page is in cache, but has expired on ' . gmdate('c', $data['expires']), MIDCOM_LOG_INFO); return; } } $this->_meta_cache->close(); if (!isset($data['last_modified'])) { debug_add('Current page is in cache, but has insufficient information', MIDCOM_LOG_INFO); return; } debug_add("X-MidCOM-meta-cache: HIT {$content_id}"); // Check If-Modified-Since and If-None-Match, do content output only if // we have a not modified match. if (!$this->_check_not_modified($data['last_modified'], $data['etag'], $data['sent_headers'])) { $this->_data_cache->open(); if (!$this->_data_cache->exists($content_id)) { $this->_data_cache->close(); debug_add("Current page is in not in the data cache, possible ghost read.", MIDCOM_LOG_WARN); return; } debug_add("HIT {$content_id}"); $content = $this->_data_cache->get($content_id); $this->_data_cache->close(); foreach ($data['sent_headers'] as $header) { _midcom_header($header); } echo $content; } _midcom_stop_request(); }
?> </h1> <p> <?php echo $data['l10n']->get('you can import simple lists of email addresses here'); ?> . <?php echo $data['l10n']->get('you can also write the addresses to the text field'); ?> . </p> <form enctype="multipart/form-data" action="<?php echo midcom_connection::get_url('uri'); ?> " method="post" class="datamanager datamanager2"> <label for="org_openpsa_directmarketing_import_upload"> <span class="field_text"><?php echo $data['l10n']->get('file to import'); ?> </span> <input type="file" class="fileselector" name="org_openpsa_directmarketing_import_upload" id="org_openpsa_directmarketing_import_upload" /> </label> <label for="org_openpsa_directmarketing_import_textarea"> <span class="field_text"><?php echo $data['l10n']->get('email addresses'); ?> </span> <textarea class="longtext" name="org_openpsa_directmarketing_import_textarea" id="org_openpsa_directmarketing_import_textarea" cols="40" rows="20"></textarea>
/** * Get snippet link. A small helper for generating link for the requested schemadb * * @param String $schemadb * @return String Link tag to the loaded object */ private function _get_snippet_link($path) { if (!is_string($path)) { return false; } $snippet = new midgard_snippet(); try { $snippet->get_by_path($path); if ($snippet->guid) { return "<a href=\"" . midcom_connection::get_url('self') . "__mfa/asgard/object/edit/{$snippet->guid}/\">{$path}</a>"; } } catch (Exception $e) { } return $path; }
/** * Include a theme element */ public static function include_element($name) { static $style = null; if (is_array($name)) { $element = $name[1]; } else { $element = $name; } switch ($element) { case 'title': return $GLOBALS['midcom_config']['midcom_site_title']; case 'content': return '<(content)>'; default: $element_file = OPENPSA2_THEME_ROOT . $GLOBALS['midcom_config']['theme'] . '/style' . midcom_connection::get_url('page_style') . "/{$element}.php"; if (!file_exists($element_file)) { if ($element == 'ROOT') { /* If we don't have a ROOT element, go to content directly. style-init or style-finish * can load the page style (under mgd1, this might also be done with the * midgard style engine as well) */ return '<(content)>'; } return ''; } $value = file_get_contents($element_file); return preg_replace_callback("/<\\(([a-zA-Z0-9 _-]+)\\)>/", array('midcom_helper_misc', 'include_element'), $value); } }
private function _add_linked_field($key) { $linked_type = $this->_reflector->get_link_name($key); $linked_type_reflector = midcom_helper_reflector::get($linked_type); $field_type = $this->_reflector->get_midgard_type($key); if ($key == 'up') { $field_label = sprintf($this->_l10n->get('under %s'), midgard_admin_asgard_plugin::get_type_label($linked_type)); } else { $type_label = midgard_admin_asgard_plugin::get_type_label($linked_type); if (substr($type_label, 0, strlen($key)) == $key) { // Handle abbreviations like "lang" for "language" $field_label = $type_label; } else { if ($key == $type_label) { $field_label = $key; } else { $ref = midcom_helper_reflector::get($this->_object); $component_l10n = $ref->get_component_l10n(); $field_label = sprintf($this->_l10n->get('%s (%s)'), $component_l10n->get($key), $type_label); } } } // Get the chooser widgets switch ($field_type) { case MGD_TYPE_UINT: case MGD_TYPE_STRING: case MGD_TYPE_GUID: $class = midcom::get('dbclassloader')->get_midcom_class_name_for_mgdschema_object($linked_type); if (!$class) { break; } $component = midcom::get('dbclassloader')->get_component_for_class($linked_type); $this->_schemadb['object']->append_field($key, array('title' => $field_label, 'storage' => $key, 'type' => 'select', 'type_config' => array('require_corresponding_option' => false, 'options' => array(), 'allow_other' => true, 'allow_multiple' => false), 'widget' => 'chooser', 'widget_config' => array('class' => $class, 'component' => $component, 'titlefield' => $linked_type_reflector->get_label_property(), 'id_field' => $this->_reflector->get_link_target($key), 'searchfields' => $linked_type_reflector->get_search_properties(), 'result_headers' => $this->_get_result_headers($linked_type_reflector), 'orders' => array(), 'creation_mode_enabled' => true, 'creation_handler' => midcom_connection::get_url('self') . "__mfa/asgard/object/create/chooser/{$linked_type}/", 'creation_default_key' => $linked_type_reflector->get_label_property(), 'generate_path_for' => midcom_helper_reflector::get_name_property($this->_object)))); break; } }