示例#1
0
 /**
  * Iterate over all articles and create index record using the datamanager indexer
  * method.
  */
 public function _on_reindex($topic, $config, &$indexer)
 {
     if (is_null($config->get('symlink_topic')) && !$config->get('disable_indexing')) {
         $qb = midcom::get('dbfactory')->new_query_builder('midcom_db_article');
         $qb->add_constraint('topic', '=', $topic->id);
         $result = $qb->execute();
         if ($result) {
             $schemadb = midcom_helper_datamanager2_schema::load_database($config->get('schemadb'));
             $datamanager = new midcom_helper_datamanager2_datamanager($schemadb);
             if (!$datamanager) {
                 debug_add('Warning, failed to create a datamanager instance with this schemapath:' . $config->get('schemadb'), MIDCOM_LOG_WARN);
                 continue;
             }
             foreach ($result as $article) {
                 if (!$datamanager->autoset_storage($article)) {
                     debug_add("Warning, failed to initialize datamanager for Article {$article->id}. Skipping it.", MIDCOM_LOG_WARN);
                     continue;
                 }
                 net_nehmer_blog_viewer::index($datamanager, $indexer, $topic);
             }
         }
     } elseif (is_null($config->get('symlink_topic')) && !$config->get('disable_search')) {
         debug_add("The topic {$topic->id} is is not to be indexed, skipping indexing.");
     } else {
         debug_add("The topic {$topic->id} is symlinked to another topic, skipping indexing.");
     }
     return true;
 }
示例#2
0
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_list($handler_id, array &$data)
 {
     if ($handler_id == 'mycontacts_xml') {
         $schemadb_person = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_person'));
         $datamanager = new midcom_helper_datamanager2_datamanager($schemadb_person);
         $xml = '<contacts></contacts>';
         $simplexml = simplexml_load_string($xml);
         foreach ($data['mycontacts'] as $person) {
             $contact = $simplexml->addChild('contact');
             $contact->addAttribute('guid', $person->guid);
             $datamanager->autoset_storage($person);
             $person_data = $datamanager->get_content_xml();
             foreach ($person_data as $key => $value) {
                 $contact->addChild($key, $value);
             }
             $mc = midcom_db_member::new_collector('uid', $person->id);
             $memberships = $mc->get_values('gid');
             $qb = org_openpsa_contacts_group_dba::new_query_builder();
             $qb->add_constraint('gid', 'IN', $memberships);
             $qb->add_constraint('orgOpenpsaObtype', '>', org_openpsa_contacts_list_dba::MYCONTACTS);
             $organisations = $qb->execute();
             foreach ($organisations as $organisation) {
                 $contact->addChild('company', str_replace('&', '&amp;', ${$organisation}->get_label()));
             }
         }
         echo $simplexml->asXml();
     } else {
         midcom_show_style("show-mycontacts-header");
         foreach ($data['mycontacts'] as $person) {
             $data['person'] = $person;
             midcom_show_style("show-mycontacts-item");
         }
         midcom_show_style("show-mycontacts-footer");
     }
 }
示例#3
0
 public function prepare_document(midcom_services_indexer_document &$document, midcom_helper_datamanager2_datamanager $dm)
 {
     $document->title = $dm->storage->object->get_label();
     if (is_a($dm->storage->object, 'org_openpsa_projects_task_dba')) {
         $values = $dm->get_content_csv();
         $document->abstract = $values['start'] . ' - ' . $values['end'] . ', ' . $this->_l10n->get($values['status']);
         $document->abstract .= ' ' . substr($values['description'], 0, 200);
     }
 }
示例#4
0
 /**
  * Loads the DM2 view of an object.
  *
  * @param midcom_baseclasses_components_handler &$handler The handler from which we were called
  * @param midcom_core_dbaobject &$object The object to display
  * @return array The get_content_html output for the requested object
  */
 public static function get_view_controller(midcom_helper_datamanager2_interfaces_view &$handler, &$object)
 {
     $schemadb = $handler->load_schemadb();
     $datamanager = new midcom_helper_datamanager2_datamanager($schemadb);
     $datamanager->set_schema($handler->get_schema_name());
     if (!$datamanager->set_storage($object)) {
         throw new midcom_error("Failed to create a DM2 instance for object {$object->guid}.");
     }
     return $datamanager;
 }
示例#5
0
文件: delete.php 项目: nemein/openpsa
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_delete($handler_id, array &$data)
 {
     $this->_request_data['wikipage_view'] = $this->_datamanager->get_content_html();
     // Replace wikiwords
     if (array_key_exists('content', $this->_request_data['wikipage_view'])) {
         $parser = new net_nemein_wiki_parser($this->_page);
         $this->_request_data['wikipage_view']['content'] = $parser->get_markdown($this->_request_data['wikipage_view']['content']);
     }
     midcom_show_style('view-wikipage-delete');
 }
示例#6
0
 public function test_autoset_storage()
 {
     $filename = 'file:/../test/midcom/helper/datamanager2/__files/schemadb_invoice.inc';
     $schemadb = midcom_helper_datamanager2_schema::load_database($filename);
     $dm = new midcom_helper_datamanager2_datamanager($schemadb);
     $invoice = $this->create_object('org_openpsa_invoices_invoice_dba');
     $this->assertTrue($dm->autoset_storage($invoice));
     $this->assertEquals('default', $dm->schema_name);
     $this->assertTrue(is_a($dm->storage, 'midcom_helper_datamanager2_storage_midgard'));
     $this->assertTrue($dm->autoset_storage($dm->storage));
     $this->assertEquals('default', $dm->schema_name);
 }
示例#7
0
文件: pdf.php 项目: nemein/openpsa
 /**
  * @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_pdf($handler_id, array $args, array &$data)
 {
     $this->_invoice = new org_openpsa_invoices_invoice_dba($args[0]);
     $this->_request_data['invoice_url'] = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "invoice/" . $this->_invoice->guid . "/";
     //check for manually uploaded pdf-file & if user wants to replace it
     if (array_key_exists('cancel', $_POST)) {
         return new midcom_response_relocate($this->_request_data['invoice_url']);
     } else {
         if (array_key_exists('save', $_POST)) {
             $this->_update_attachment = true;
         } else {
             $data['confirmation_message'] = 'current pdf file was manually uploaded shall it be replaced ?';
             // load schema & datamanager to get attachment
             $schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb'));
             $this->_datamanager = new midcom_helper_datamanager2_datamanager($schemadb);
             if (!$this->_datamanager->autoset_storage($this->_invoice)) {
                 throw new midcom_error("Failed to create a DM2 instance for object {$this->_invoice->guid}.");
             }
             if ($this->_invoice->sent) {
                 $data['confirmation_message'] = 'invoice has already been sent. should it be replaced?';
             } else {
                 if (!empty($this->_datamanager->types['pdf_file']->attachments)) {
                     foreach ($this->_datamanager->types['pdf_file']->attachments as $attachment) {
                         $checksum = $attachment->get_parameter('org.openpsa.invoices', 'auto_generated');
                         // check if auto generated parameter is same as md5 in current-file
                         // if not the file was manually uploaded
                         if ($checksum) {
                             $blob = new midgard_blob($attachment->__object);
                             // check if md5 sum equals the one saved in auto_generated
                             if ($checksum == md5_file($blob->get_path())) {
                                 $this->_update_attachment = true;
                             }
                         }
                     }
                 } else {
                     $this->_update_attachment = true;
                 }
             }
         }
     }
     if ($this->_update_attachment) {
         $this->_request_data['billing_data'] = $this->_invoice->get_billing_data();
         if (self::render_and_attach_pdf($this->_invoice)) {
             midcom::get('uimessages')->add($this->_l10n->get($this->_component), $this->_l10n->get('pdf created'));
         } else {
             midcom::get('uimessages')->add($this->_l10n->get($this->_component), $this->_l10n->get('pdf creation failed') . ': ' . midcom_connection::get_error_string(), 'error');
         }
         return new midcom_response_relocate($this->_request_data["invoice_url"]);
     }
 }
示例#8
0
文件: view.php 项目: nemein/openpsa
 /**
  * Display the comment list and the submit-comment form.
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 function _show_comments($handler_id, array &$data)
 {
     midcom_show_style('comments-header');
     if ($this->_comments) {
         midcom_show_style('comments-start');
         foreach ($this->_comments as $comment) {
             $this->_display_datamanager->autoset_storage($comment);
             $data['comment'] = $comment;
             $data['comment_toolbar'] = $this->_master->_populate_post_toolbar($comment);
             midcom_show_style('comments-item');
             if (midcom::get('auth')->admin || midcom::get('auth')->user && $comment->can_do('midgard:delete')) {
                 midcom_show_style('comments-admintoolbar');
             }
         }
         midcom_show_style('comments-end');
     } else {
         midcom_show_style('comments-nonefound');
     }
     if (midcom::get('auth')->user || $this->_config->get('allow_anonymous')) {
         midcom_show_style('post-comment');
     } else {
         midcom_show_style('post-denied');
     }
     midcom_show_style('comments-footer');
 }
示例#9
0
文件: feed.php 项目: nemein/openpsa
 /**
  * Displays the feed
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_feed($handler_id, array &$data)
 {
     $data['feedcreator'] =& $this->_feed;
     // Add each article now.
     if ($this->_articles) {
         foreach ($this->_articles as $article) {
             $this->_datamanager->autoset_storage($article);
             $data['article'] =& $article;
             $data['datamanager'] =& $this->_datamanager;
             midcom_show_style('feeds-item');
         }
     }
     switch ($handler_id) {
         case 'feed-rss2':
         case 'feed-category-rss2':
             echo $this->_feed->createFeed('RSS2.0');
             break;
         case 'feed-rss1':
             echo $this->_feed->createFeed('RSS1.0');
             break;
         case 'feed-rss091':
             echo $this->_feed->createFeed('RSS0.91');
             break;
         case 'feed-atom':
             echo $this->_feed->createFeed('ATOM');
             break;
     }
 }
示例#10
0
 /**
  * Sets the current datamanager instance to the storage object given, which may either
  * be a MidCOM DBA object (which is encapsulated by a midgard datamanager storage instance).
  *
  * You must load a schema database before actually
  *
  * @param object &$storage A reference to either an initialized datamanager, an initialized
  *     storage backend or to a DBA compatible class instance.
  * @param string $schema This is an optional schema name that should be used to edit the
  *     storage object. If it is null, the controller will try to autodetect the schema
  *     to use by using the datamanager's autoset_storage interface.
  */
 function set_storage(&$storage, $schema = null)
 {
     if (count($this->schemadb) == 0) {
         throw new midcom_error('You cannot set a storage object for a DM2 controller object without loading a schema database previously.');
     }
     if ($storage instanceof midcom_helper_datamanager2_datamanager) {
         $this->datamanager = $storage;
     } else {
         if ($storage instanceof midcom_helper_datamanager2_storage || midcom::get('dbclassloader')->is_midcom_db_object($storage)) {
             $this->datamanager = new midcom_helper_datamanager2_datamanager($this->schemadb);
             if ($schema === null) {
                 if (!$this->datamanager->autoset_storage($storage)) {
                     debug_print_r('We got this storage object:', $storage);
                     throw new midcom_error('Failed to automatically create a datamanager instance for a storage object or a MidCOM type. See the debug level log for more information.');
                 }
             } else {
                 if (!$this->datamanager->set_schema($schema)) {
                     debug_add("Tried to set the schema {$schema}");
                     debug_print_r('We got this storage object:', $storage);
                     throw new midcom_error('Failed to set the autocreated datamanager\'s schema. See the debug level log for more information.');
                 }
                 if (!$this->datamanager->set_storage($storage)) {
                     debug_add("Tried to set the schema {$schema}");
                     debug_print_r('We got this storage object:', $storage);
                     throw new midcom_error('Failed to set the autocreated datamanager\'s storage object. See the debug level log for more information.');
                 }
             }
         } else {
             debug_print_r('Storage object passed was:', $storage);
             throw new midcom_error('You must pass either a datamanager subclass, an initialized storage encapsulation or a MidCOM DBA object');
         }
     }
 }
示例#11
0
文件: view.php 项目: nemein/openpsa
 /**
  * Internal helper, loads the datamanager for the current article. Any error triggers a 500.
  */
 private function _load_datamanager()
 {
     $this->_datamanager = new midcom_helper_datamanager2_datamanager($this->_request_data['schemadb']);
     if (!$this->_datamanager->autoset_storage($this->_article)) {
         throw new midcom_error("Failed to create a DM2 instance for article {$this->_article->id}.");
     }
 }
示例#12
0
 /**
  * Phase for composing a message
  *
  * @param String $handler_id    Name of the request handler
  * @param array $args           Variable arguments
  * @param array &$data          Public request data, passed by reference
  */
 public function _handler_compose($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->request_sudo();
     //Load message
     $data['message'] = new org_openpsa_directmarketing_campaign_message_dba($args[0]);
     $data['campaign'] = new org_openpsa_directmarketing_campaign_dba($data['message']->campaign);
     $this->set_active_leaf('campaign_' . $data['campaign']->id);
     $this->_load_datamanager();
     $this->_datamanager->autoset_storage($data['message']);
     $data['message_obj'] =& $data['message'];
     $data['message_dm'] =& $this->_datamanager;
     if ($handler_id === 'compose4person') {
         $data['person'] = new org_openpsa_contacts_person_dba($args[1]);
         $qb = org_openpsa_directmarketing_campaign_member_dba::new_query_builder();
         $qb->add_constraint('person', '=', $this->_request_data['person']->id);
         $memberships = $qb->execute();
         if (empty($memberships)) {
             $data['member'] = new org_openpsa_directmarketing_campaign_member_dba();
             $data['member']->person = $data['person']->id;
             $data['member']->campaign = $data['message']->campaign;
         } else {
             $data['member'] = $memberships[0];
         }
     }
     $data['message_array'] = $this->_datamanager->get_content_raw();
     if (!array_key_exists('content', $data['message_array'])) {
         throw new midcom_error('"content" not defined in schema');
     }
     //Substyle handling
     @debug_add("\$data['message_array']['substyle']='{$data['message_array']['substyle']}'");
     if (array_key_exists('substyle', $data['message_array']) && !empty($data['message_array']['substyle']) && !preg_match('/^builtin:/', $data['message_array']['substyle'])) {
         debug_add("Appending substyle {$data['message_array']['substyle']}");
         midcom::get('style')->append_substyle($data['message_array']['substyle']);
     }
     //This isn't necessary for dynamic-loading, but is nice for "preview".
     midcom::get()->skip_page_style = true;
     debug_add('message type: ' . $data['message_obj']->orgOpenpsaObtype);
     switch ($data['message_obj']->orgOpenpsaObtype) {
         case org_openpsa_directmarketing_campaign_message_dba::EMAIL_TEXT:
         case org_openpsa_directmarketing_campaign_message_dba::SMS:
             debug_add('Forcing content type: text/plain');
             midcom::get('cache')->content->content_type('text/plain');
             break;
             //TODO: Other content type overrides ?
     }
     midcom::get('auth')->drop_sudo();
 }
示例#13
0
文件: view.php 项目: nemein/openpsa
 /**
  * Shows the loaded article.
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_view($handler_id, array &$data)
 {
     if ($this->_config->get('enable_ajax_editing')) {
         // For AJAX handling it is the controller that renders everything
         $this->_request_data['view_article'] = $this->_request_data['controller']->get_content_html();
     } else {
         $this->_request_data['view_article'] = $this->_datamanager->get_content_html();
     }
     midcom_show_style('view');
 }
示例#14
0
文件: view.php 项目: nemein/openpsa
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_whatlinks($handler_id, array &$data)
 {
     if ($this->_controller) {
         $data['wikipage_view'] = $this->_controller->get_content_html();
     } else {
         $data['wikipage_view'] = $this->_datamanager->get_content_html();
     }
     // Replace wikiwords
     $parser = new net_nemein_wiki_parser($this->_page);
     $data['wikipage_view']['content'] = $parser->get_markdown($data['wikipage_view']['content']);
     midcom_show_style('view-wikipage-whatlinks');
 }
示例#15
0
文件: manage.php 项目: nemein/openpsa
 /**
  * Shows the object to delete.
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_delete($handler_id, array &$data)
 {
     $data['view_object'] = $this->_datamanager->get_content_html();
     midcom_show_style('midgard_admin_asgard_header');
     midcom_show_style('midgard_admin_asgard_middle');
     // Initialize the tree
     $data['tree'] = new midgard_admin_asgard_copytree($this->_object, $data);
     $data['tree']->copy_tree = false;
     $data['tree']->inputs = false;
     midcom_show_style('midgard_admin_asgard_object_delete');
     midcom_show_style('midgard_admin_asgard_footer');
 }
示例#16
0
 /**
  * Iterate over all wiki pages and create index record using the datamanager2 indexer
  * method.
  */
 public function _on_reindex($topic, $config, &$indexer)
 {
     $qb = net_nemein_wiki_wikipage::new_query_builder();
     $qb->add_constraint('topic', '=', $topic->id);
     $result = $qb->execute();
     if ($result) {
         $schemadb = midcom_helper_datamanager2_schema::load_database($config->get('schemadb'));
         $datamanager = new midcom_helper_datamanager2_datamanager($schemadb);
         if (!$datamanager) {
             debug_add('Warning, failed to create a datamanager instance with this schemapath:' . $config->get('schemadb'), MIDCOM_LOG_WARN);
             continue;
         }
         foreach ($result as $wikipage) {
             if (!$datamanager->autoset_storage($wikipage)) {
                 debug_add("Warning, failed to initialize datamanager for Wiki page {$wikipage->id}. Skipping it.", MIDCOM_LOG_WARN);
                 continue;
             }
             net_nemein_wiki_viewer::index($datamanager, $indexer, $topic);
         }
     }
     return true;
 }
示例#17
0
文件: index.php 项目: nemein/openpsa
 /**
  * Displays the index page
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_index($handler_id, array &$data)
 {
     $data['index_fulltext'] = $this->_config->get('index_fulltext');
     if ($this->_config->get('ajax_comments_enable')) {
         $comments_node = $this->_seek_comments();
         if ($comments_node) {
             $this->_request_data['ajax_comments_enable'] = true;
             $this->_request_data['base_ajax_comments_url'] = $comments_node[MIDCOM_NAV_RELATIVEURL] . "comment/";
         }
     }
     midcom_show_style('index-start');
     if ($this->_config->get('comments_enable')) {
         $this->_request_data['comments_enable'] = true;
     }
     if ($this->_articles) {
         $total_count = count($this->_articles);
         $data['article_count'] = $total_count;
         $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
         foreach ($this->_articles as $article_counter => $article) {
             if (!$this->_datamanager->autoset_storage($article)) {
                 debug_add("The datamanager for article {$article->id} could not be initialized, skipping it.");
                 debug_print_r('Object was:', $article);
                 continue;
             }
             $data['article'] =& $article;
             $data['article_counter'] = $article_counter;
             $arg = $article->name ? $article->name : $article->guid;
             if ($this->_config->get('view_in_url')) {
                 $data['local_view_url'] = "{$prefix}view/{$arg}/";
             } else {
                 $data['local_view_url'] = "{$prefix}{$arg}/";
             }
             if ($this->_config->get('link_to_external_url') && !empty($article->url)) {
                 $data['view_url'] = $article->url;
             } else {
                 $data['view_url'] = $data['local_view_url'];
             }
             if ($article->topic === $this->_content_topic->id) {
                 $data['linked'] = false;
             } else {
                 $data['linked'] = true;
                 $nap = new midcom_helper_nav();
                 $data['node'] = $nap->get_node($article->topic);
             }
             midcom_show_style('index-item', array($article->guid));
         }
     } else {
         midcom_show_style('index-empty');
     }
     midcom_show_style('index-end');
 }
示例#18
0
 /**
  * Displays the feed
  *
  * @param mixed $handler_id The ID of the handler.
  * @param mixed &$data The local request data.
  */
 function _show_rss($handler_id, &$data)
 {
     $data['feedcreator'] =& $this->_feed;
     // Add each event now.
     if ($this->_events) {
         foreach ($this->_events as $event) {
             $this->_datamanager->autoset_storage($event);
             $data['event'] =& $event;
             $data['datamanager'] =& $this->_datamanager;
             midcom_show_style('feeds-item');
         }
     }
     echo $this->_feed->createFeed('RSS2.0');
 }
示例#19
0
 /**
  * Displays the archive.
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_list($handler_id, array &$data)
 {
     // FIXME: For some reason the config topic is lost between _handle and _show phases
     $this->_config->store_from_object($this->_topic, $this->_component);
     midcom_show_style('archive-list-start');
     if ($this->_articles) {
         $data['index_fulltext'] = $this->_config->get('index_fulltext');
         if ($this->_config->get('comments_enable')) {
             midcom::get('componentloader')->load_graceful('net.nehmer.comments');
             $data['comments_enable'] = true;
         }
         $total_count = count($this->_articles);
         $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
         foreach ($this->_articles as $article_counter => $article) {
             if (!$this->_datamanager->autoset_storage($article)) {
                 debug_add("The datamanager for article {$article->id} could not be initialized, skipping it.");
                 debug_print_r('Object was:', $article);
                 continue;
             }
             $data['article'] =& $article;
             $data['article_counter'] = $article_counter;
             $data['article_count'] = $total_count;
             $arg = $article->name ? $article->name : $article->guid;
             if ($this->_config->get('view_in_url')) {
                 $data['local_view_url'] = "{$prefix}view/{$arg}/";
             } else {
                 $data['local_view_url'] = "{$prefix}{$arg}/";
             }
             if ($this->_config->get('link_to_external_url') && !empty($article->url)) {
                 $data['view_url'] = $article->url;
             } else {
                 $data['view_url'] = $data['local_view_url'];
             }
             if ($article->topic === $this->_content_topic->id) {
                 $data['linked'] = false;
             } else {
                 $data['linked'] = true;
                 $nap = new midcom_helper_nav();
                 $data['node'] = $nap->get_node($article->topic);
             }
             midcom_show_style('archive-list-item');
         }
     } else {
         midcom_show_style('archive-list-empty');
     }
     midcom_show_style('archive-list-end');
 }
示例#20
0
文件: view.php 项目: nemein/openpsa
 /**
  * Handle the single event view
  *
  * @param String $handler_id    Name of the request handler
  * @param array $args           Variable arguments
  * @param array &$data          Public request data, passed by reference
  */
 public function _handler_event($handler_id, array $args, array &$data)
 {
     // We're using a popup here
     midcom::get()->skip_page_style = true;
     // Get the requested event object
     $this->_request_data['event'] = new org_openpsa_calendar_event_dba($args[0]);
     // Muck schema on private events
     if (!$this->_request_data['event']->can_do('org.openpsa.calendar:read')) {
         foreach ($this->_datamanager->_schemadb as $schemaname => $schema) {
             foreach ($this->_datamanager->_schemadb[$schemaname]->fields as $fieldname => $field) {
                 switch ($fieldname) {
                     case 'title':
                     case 'start':
                     case 'end':
                         break;
                     default:
                         $this->_datamanager->_schemadb[$schemaname]->fields[$fieldname]['hidden'] = true;
                 }
             }
         }
     }
     // Load the event to datamanager
     if (!$this->_datamanager->autoset_storage($data['event'])) {
         throw new midcom_error('Failed to load the event in datamanager');
     }
     // Reload parent if needed
     if (array_key_exists('reload', $_GET)) {
         midcom::get('head')->add_jsonload('window.opener.location.reload();');
     }
     // Add toolbar items
     if ($this->_request_data['view'] == 'default') {
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'event/edit/' . $this->_request_data['event']->guid . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $data['event']->can_do('midgard:update'), MIDCOM_TOOLBAR_ACCESSKEY => 'e'));
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'event/delete/' . $this->_request_data['event']->guid . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $data['event']->can_do('midgard:delete')));
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'javascript:window.print()', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('print'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/printer.png', MIDCOM_TOOLBAR_OPTIONS => array('rel' => 'directlink')));
         $relatedto_button_settings = null;
         if (midcom::get('auth')->user) {
             $user = midcom::get('auth')->user->get_storage();
             $relatedto_button_settings = array('wikinote' => array('node' => false, 'wikiword' => str_replace('/', '-', sprintf($this->_l10n->get($this->_config->get('wiki_title_skeleton')), $this->_request_data['event']->title, strftime('%x'), $user->name))));
         }
         org_openpsa_relatedto_plugin::common_node_toolbar_buttons($this->_view_toolbar, $this->_request_data['event'], $this->_component, $relatedto_button_settings);
     }
 }
示例#21
0
文件: admin.php 项目: nemein/openpsa
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 function _show_moderate($handler_id, array &$data)
 {
     midcom_show_style('admin-start');
     if ($this->_comments) {
         midcom_show_style('admin-comments-start');
         foreach ($this->_comments as $comment) {
             $this->_display_datamanager->autoset_storage($comment);
             $data['comment'] =& $comment;
             $data['comment_toolbar'] = $this->_master->_populate_post_toolbar($comment);
             midcom_show_style('admin-comments-item');
             if (midcom::get('auth')->admin || midcom::get('auth')->user && $comment->can_do('midgard:delete')) {
                 midcom_show_style('admin-comments-admintoolbar');
             }
         }
         midcom_show_style('admin-comments-end');
     } else {
         midcom_show_style('comments-nonefound');
     }
     midcom_show_style('admin-list-end');
     midcom_show_style('admin-end');
 }
示例#22
0
文件: admin.php 项目: nemein/openpsa
 /**
  * Shows the loaded deliverable.
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_delete($handler_id, array &$data)
 {
     $data['deliverable_view'] = $this->_datamanager->get_content_html();
     midcom_show_style('show-deliverable-delete');
 }
示例#23
0
文件: view.php 项目: nemein/openpsa
 /**
  * Shows the loaded contact.
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_view($handler_id, array &$data)
 {
     $data['contact_view'] = $this->_datamanager->get_content_html();
     midcom_show_style('show-person');
 }
示例#24
0
 /**
  * Sets given object as storage object for DM2
  */
 function set_dm_storage(&$object)
 {
     return $this->_datamanager->set_storage($object);
 }
示例#25
0
文件: client.php 项目: nemein/openpsa
 private function _process_query($name, $qb, $schemadb)
 {
     $results = $qb->execute();
     if (empty($results)) {
         return array();
     }
     $documents = array();
     $datamanager = new midcom_helper_datamanager2_datamanager($schemadb);
     foreach ($results as $object) {
         if (!$datamanager->autoset_storage($object)) {
             debug_add("Warning, failed to initialize datamanager for object {$object->id}. See debug log for details.", MIDCOM_LOG_WARN);
             debug_print_r('Object dump:', $object);
             continue;
         }
         $documents[] = $this->_create_document($datamanager);
     }
     return $documents;
 }
示例#26
0
文件: admin.php 项目: nemein/openpsa
 /**
  * Shows the loaded message.
  */
 public function _show_delete($handler_id, array &$data)
 {
     $data['view_message'] = $this->_datamanager->get_content_html();
     midcom_show_style('show-message-delete');
 }
示例#27
0
 /**
  * This helper function goes over the topic and loads all available objects for displaying
  * in the autoindex.
  *
  * It will populate the request data key 'create_urls' as well. See the view handler for
  * further details.
  *
  * The computed array has the following keys:
  *
  * - string name: The name of the object.
  * - string url: The full URL to the object.
  * - string size: The formatted size of the document. This is only populated for attachments.
  * - string desc: The object title/description.
  * - string type: The MIME Type of the object.
  * - string lastmod: The localized last modified date.
  *
  * @return Array Autoindex objects as outlined above
  */
 private function _load_autoindex_data()
 {
     $view = array();
     $datamanager = new midcom_helper_datamanager2_datamanager($this->_request_data['schemadb']);
     $qb = midcom_db_article::new_query_builder();
     $sort_order = 'ASC';
     $sort_property = $this->_config->get('sort_order');
     if (strpos($sort_property, 'reverse ') === 0) {
         $sort_order = 'DESC';
         $sort_property = substr($sort_property, strlen('reverse '));
     }
     if (strpos($sort_property, 'metadata.') === false) {
         $article = new midgard_article();
         if (!property_exists($article, $sort_property)) {
             $sort_property = 'metadata.' . $sort_property;
         }
     }
     $qb->add_order($sort_property, $sort_order);
     $qb->add_order('title');
     $qb->add_order('name');
     // Include the article links to the indexes if enabled
     if ($this->_config->get('enable_article_links')) {
         $mc = net_nehmer_static_link_dba::new_collector('topic', $this->_content_topic->id);
         $mc->add_constraint('topic', '=', $this->_content_topic->id);
         $links = $mc->get_values('article');
         $qb->begin_group('OR');
         if (count($links) > 0) {
             $qb->add_constraint('id', 'IN', $links);
         }
         $qb->add_constraint('topic', '=', $this->_content_topic->id);
         $qb->end_group();
     } else {
         $qb->add_constraint('topic', '=', $this->_content_topic->id);
     }
     $result = $qb->execute();
     foreach ($result as $article) {
         if (!$datamanager->autoset_storage($article)) {
             debug_add("The datamanager for article {$article->id} could not be initialized, skipping it.");
             debug_print_r('Object was:', $article);
             continue;
         }
         $this->_process_datamanager($datamanager, $article, $view);
     }
     return $view;
 }
示例#28
0
        <label>
            URL/path
            <input type="text" name="address" value="/tmp/__PRODUCT_CODE__.jpg" />
        </label>
        <input type="submit" value="Import images" />
    </form>
    <?php 
} else {
    midcom::get()->disable_limits();
    // Import product images
    $qb = org_openpsa_products_product_dba::new_query_builder();
    $qb->add_constraint('code', '<>', '');
    $products = $qb->execute();
    $schemadb = midcom_baseclasses_components_configuration::get('org.openpsa.products', 'config')->get('schemadb_product');
    $schema = midcom_helper_datamanager2_schema::load_database($schema);
    $datamanager = new midcom_helper_datamanager2_datamanager($schema);
    foreach ($products as $product) {
        // Get old image
        $image = file_get_contents(str_replace('__PRODUCT_CODE__', $product->code, $_POST['address']));
        if (empty($image)) {
            continue;
        }
        // Save image to a temp file
        $tmp_name = tempnam($GLOBALS['midcom_config']['midcom_tempdir'], 'org_openpsa_products_product_oldimage_');
        $fp = fopen($tmp_name, 'w');
        if (!fwrite($fp, $image)) {
            //Could not write, clean up and continue
            echo "Error when writing file {$tmp_name}";
            fclose($fp);
            continue;
        }
示例#29
0
文件: edit.php 项目: nemein/openpsa
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_edit($handler_id, array &$data)
 {
     $data['controller'] =& $this->_controller;
     $data['preview_mode'] = $this->_preview;
     if ($this->_preview) {
         // Populate preview page with values from form
         $data['preview_page'] = $this->_page;
         foreach ($this->_controller->datamanager->schema->fields as $name => $type_definition) {
             if (!is_a($this->_controller->datamanager->types[$name], 'midcom_helper_datamanager2_type_text')) {
                 // Skip fields of other types
                 continue;
             }
             switch ($type_definition['storage']) {
                 case 'parameter':
                 case 'configuration':
                 case 'metadata':
                     // Skip
                     continue;
                 default:
                     $location = $type_definition['storage']['location'];
             }
             $data['preview_page']->{$location} = $this->_controller->datamanager->types[$name]->convert_to_storage();
         }
         // Load DM for rendering the page
         $datamanager = new midcom_helper_datamanager2_datamanager($this->_schemadb);
         $datamanager->autoset_storage($data['preview_page']);
         $data['wikipage_view'] = $datamanager->get_content_html();
         $data['wikipage'] =& $data['preview_page'];
         $data['autogenerate_toc'] = false;
         $data['display_related_to'] = false;
         // Replace wikiwords
         // TODO: We should somehow make DM2 do this so it would also work in AJAX previews
         $parser = new net_nemein_wiki_parser($data['preview_page']);
         $data['wikipage_view']['content'] = $parser->get_markdown($data['wikipage_view']['content']);
     }
     midcom_show_style('view-wikipage-edit');
 }
示例#30
0
文件: admin.php 项目: nemein/openpsa
 /**
  * The delete handler.
  *
  * @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_delete($handler_id, array $args, array &$data)
 {
     $this->_hour_report = new org_openpsa_projects_hour_report_dba($args[0]);
     $this->_hour_report->require_do('midgard:delete');
     if (array_key_exists('org_openpsa_expenses_deleteok', $_REQUEST)) {
         // Deletion confirmed.
         if (!$this->_hour_report->delete()) {
             throw new midcom_error("Failed to delete hour report {$args[0]}, last Midgard error was: " . midcom_connection::get_error_string());
         }
         // Delete ok, relocating to welcome.
         return new midcom_response_relocate('');
     }
     if (array_key_exists('org_openpsa_expenses_deletecancel', $_REQUEST)) {
         // Redirect to view page.
         return new midcom_response_relocate('');
     }
     $this->_load_schemadb();
     $dm = new midcom_helper_datamanager2_datamanager($this->_schemadb);
     $dm->autoset_storage($this->_hour_report);
     $data['datamanager'] =& $dm;
     $this->_update_breadcrumb_line($handler_id);
     $this->_view_toolbar->bind_to($this->_hour_report);
     midcom::get('metadata')->set_request_metadata($this->_hour_report->metadata->revised, $this->_hour_report->guid);
 }