Changeset 11872
- Timestamp:
- 08/30/07 15:37:53 (1 year ago)
- Files:
-
- trunk/midcom/midcom.core/midcom.php (modified) (1 diff)
- trunk/midcom/midcom.core/midcom/application.php (modified) (20 diffs)
- trunk/midcom/midcom.core/midcom/core/service/implementation/urlparsertopic.php (modified) (4 diffs)
- trunk/midcom/midcom.core/midcom/helper/_styleloader.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midcom.core/midcom.php
r11859 r11872 129 129 130 130 // Helpers and First-Generation services 131 require('midcom/helper/urlparser.php');132 131 require('midcom/helper/_componentloader.php'); 133 132 require('midcom/helper/_styleloader.php'); trunk/midcom/midcom.core/midcom/application.php
r11868 r11872 405 405 * 406 406 * Initialize the Application class. Sets all private variables to a predefined 407 * state. $ topic should be set to the midcom root-topicGUID.407 * state. $node should be set to the midcom root-node GUID. 408 408 * $prefix can be a prefix, which is appended to get_midgard()->self (i.e. the 409 409 * Midgard Page URL). This may be needed when MidCOM is run by wrapper. … … 431 431 432 432 // Initialize Root Topic 433 $root_ topic= new midcom_db_topic($GLOBALS['midcom_config']['midcom_root_topic_guid']);434 if ( ! $root_ topic435 || !$root_ topic->guid)433 $root_node = new midcom_db_topic($GLOBALS['midcom_config']['midcom_root_topic_guid']); 434 if ( ! $root_node 435 || !$root_node->guid) 436 436 { 437 437 if (mgd_errno() == MGD_ERR_ACCESS_DENIED) … … 443 443 { 444 444 $this->generate_error(MIDCOM_ERRCRIT, 445 "Unable to load root topicwith GUID='{$GLOBALS['midcom_config']['midcom_root_topic_guid']}'.<br />" .445 "Unable to load root node with GUID='{$GLOBALS['midcom_config']['midcom_root_topic_guid']}'.<br />" . 446 446 "This is fatal, aborting. See the MidCOM log file for details.<br />" . 447 447 'Last Midgard Error was: ' . mgd_errstr()); … … 451 451 452 452 // Initialize Context Storage 453 $this->_currentcontext = $this->_create_context(0, $root_ topic);453 $this->_currentcontext = $this->_create_context(0, $root_node); 454 454 455 455 // Populate browser information … … 607 607 * the URL $url and executes it as if it was used as primary component. 608 608 * Additional configuration parameters can be appended through the parameter 609 * $config. Specifying a topic id will let the parser work on a different topic 610 * tree than usual. The default "null" stays within the current topic tree. It 611 * will return the Context ID on success, false on failure, generate-error will 612 * be used to generate an appropriate error message. 609 * $config. 613 610 * 614 611 * This is only possible if the system is in the Page-Style output phase. It … … 620 617 * the following exceptions: 621 618 * 622 * - The Topic with the ID $topicid is used as a root topic instead of the623 * normal root topic. This is required to be able to administrate another624 * Topic Tree as the AIS does.625 619 * - This function can (and usually will be) called during the content output phase 626 620 * of the system. 627 621 * - A call to generate_error will result in an regular error page output if 628 622 * we still are in the code-init phase. 629 * - The parameter urlparser_prefix is there to let the parser know that we are630 * operating under a different environment. $midgard->self is not a good start631 * anymore. This is needed to provide an accurate anchor prefix in the632 * component context. If this parameter is omitted, it is set to the633 * anchor_prefix of the calling component.634 623 * 635 624 * Example code, executed on a sites Homepage, it will load the newsticker from 636 * the given URL and display it using a substyle of the topicstyle that is assinged625 * the given URL and display it using a substyle of the node style that is assinged 637 626 * to the loaded one: 638 627 * … … 706 695 707 696 // Parser Init: Generate arguments and instantinate it. 708 $topic = $this->get_context_data(MIDCOM_CONTEXT_ROOTTOPIC);709 697 $this->_parser = $this->serviceloader->load('midcom_core_service_urlparser'); 710 698 $argv = $this->_parser->tokenize($url); … … 793 781 * will report an error, depending on the situation. 794 782 * 795 * Details: The logic will traverse the topic tree and for each topicit will load783 * Details: The logic will traverse the node tree and for each node it will load 796 784 * the component that is responsible for it. This component gets the chance to 797 785 * acceppt the request (this is encaspulated in the _checkobject call), which is … … 803 791 * If the parsing process doesn't find any component that declares to be able to 804 792 * handle the request, an HTTP 404 - Not Found error is triggered. 805 *806 * If no topic is found, it tries to serve a topic attachment as a last resort,807 * it uses the last valid topic as container object.808 *809 * This method has legacy ViewerGroups parameter support since version 1.3. If810 * a ViewerGroup parameter domain is detected at a given topic, and the user does811 * not have the appropriate permissions, it will fire an HTTP 401 Unauthorized812 * error. If no ViewerGroups parameter domain is there, no error will be fired.813 *814 * Two types of attachments will be processed and delivered automatically:815 * Topic-Attachments and explicit attachments requested through the816 * midcom-serveattachment... URL methods.817 793 * 818 794 * @access private … … 930 906 $object = $this->_parser->get_current_object(); 931 907 932 if (!is_ a($object,'midcom_db_topic'))908 if (!is_object($object)) 933 909 { 934 debug_add("Root topicmissing.", MIDCOM_LOG_ERROR);935 $this->generate_error(MIDCOM_ERRCRIT, "Root topicmissing.");910 debug_add("Root node missing.", MIDCOM_LOG_ERROR); 911 $this->generate_error(MIDCOM_ERRCRIT, "Root node missing."); 936 912 } 937 913 … … 940 916 if (!$path) 941 917 { 942 debug_add("No component defined for this Topic.", MIDCOM_LOG_ERROR);943 $this->generate_error(MIDCOM_ERRCRIT, "No component defined for this Topic.");918 debug_add("No component defined for this node.", MIDCOM_LOG_ERROR); 919 $this->generate_error(MIDCOM_ERRCRIT, "No component defined for this node."); 944 920 } 945 921 … … 949 925 // If so, execute it, if not, continue. 950 926 951 if ($this->_checkobject($object)) { 927 if ($this->_checkobject($object)) 928 { 952 929 $this->_status = MIDCOM_STATUS_HANDLE; 953 930 954 // Strip all midcom-*-* URL Parameters out of the prefix.955 956 931 $prefix = $this->_parser->get_url(); 957 $prefix = preg_replace ("|midcom-[^-]*-[^/]*/|i","",$prefix); 958 932 959 933 // Initialize context 960 934 $this->_context[$this->_currentcontext][MIDCOM_CONTEXT_ANCHORPREFIX] = $prefix; … … 975 949 if (! $success) 976 950 { 977 // We couldn't fetch a topicdue to access restrictions.951 // We couldn't fetch a node due to access restrictions. 978 952 if (mgd_errno() == MGD_ERR_ACCESS_DENIED) 979 953 { … … 1038 1012 * according to the error code and -string of the component in question. 1039 1013 * 1040 * @param string $path Override the component set in the topic (used mainly for AIS). 1041 * @access private 1042 */ 1043 private function _handle($path = NULL) 1014 * @access private 1015 */ 1016 private function _handle() 1044 1017 { 1045 1018 debug_push_class(__CLASS__, __FUNCTION__); 1046 1019 1047 $opath = $this->get_context_data(MIDCOM_CONTEXT_COMPONENT); 1048 if (!isset($path)) $path = $opath; 1020 $path = $this->get_context_data(MIDCOM_CONTEXT_COMPONENT); 1049 1021 1050 1022 if ($this->get_context_data(MIDCOM_CONTEXT_REQUESTTYPE) != MIDCOM_REQUEST_CONTENT) … … 1122 1094 * accordingly, both on the configure and on the can_handle run. 1123 1095 * 1124 * @param MidgardTopic $object The topicthat is currently being tested.1096 * @param MidgardTopic $object The node that is currently being tested. 1125 1097 * @return bool Indication, wether a component can handle a request. 1126 1098 * @access private … … 1177 1149 * parameter domain has to be used. 1178 1150 * 1179 * @param Midgard Topic $object The topicfrom which to load the configuration.1151 * @param MidgardObject $object The node from which to load the configuration. 1180 1152 * @return midcom_helper_configuration Reference to the newly constructed configuration object. 1181 1153 * @access private … … 1392 1364 * currently uses different context IDs. The problem is, that this is not 100% 1393 1365 * efficient: If you instantinate two different NAP Classes in different contexts 1394 * both referring to the same root topic, you will get two different instances.1366 * both referring to the same root node, you will get two different instances. 1395 1367 * 1396 1368 * If the system has not completed the can_handle phase, this method fails and … … 1420 1392 1421 1393 return $this->_context[$contextid][MIDCOM_CONTEXT_NAP]; 1422 }1423 1424 /**1425 * @deprecated This function is discouraged in favor of the component context since 2.0.01426 *1427 * Return a copy of the topic that is handling the request.1428 *1429 * If the system is in the output phase (midcom_application::codeinit is false),1430 * this function returns a copy of the topic, that is being output, for example1431 * for the usage of the NAP System.1432 *1433 * If the system is not in the output phase, this method simply returns false.1434 *1435 * <b>Note:</b> This is equivalent to requesting the context key1436 * MIDCOM_CONTEXT_CONTENTTOPIC1437 *1438 * @return MidgardTopic The topic being output.1439 * @see midcom_application::get_context_data()1440 */1441 function get_content_topic() {1442 return $this->get_context_data(MIDCOM_CONTEXT_CONTENTTOPIC);1443 1394 } 1444 1395 … … 1877 1828 * 1878 1829 * @param int id Explicitly specify the ID for context creation (used during construction), this parameter is usually omitted. 1879 * @param midcom_db_topic Root topicof the context1830 * @param MidgardObject Root node of the context 1880 1831 * @return int The ID of the newly created component. 1881 1832 * @access private 1882 1833 */ 1883 private function _create_context($id = null, $ topic= null)1834 private function _create_context($id = null, $node = null) 1884 1835 { 1885 1836 if (is_null($id)) … … 1890 1841 $this->_context[$id][MIDCOM_CONTEXT_ANCHORPREFIX] = ''; 1891 1842 $this->_context[$id][MIDCOM_CONTEXT_REQUESTTYPE] = MIDCOM_REQUEST_CONTENT; 1892 $this->_context[$id][MIDCOM_CONTEXT_ROOTTOPIC] = $ topic;1843 $this->_context[$id][MIDCOM_CONTEXT_ROOTTOPIC] = $node; 1893 1844 $this->_context[$id][MIDCOM_CONTEXT_CONTENTTOPIC] = null; 1894 1845 $this->_context[$id][MIDCOM_CONTEXT_COMPONENT] = null; trunk/midcom/midcom.core/midcom/core/service/implementation/urlparsertopic.php
r11868 r11872 19 19 private $root_topic = null; 20 20 private $current_object = null; 21 22 private $url = ''; 21 23 22 24 public function __construct() … … 84 86 85 87 $this->current_object = $this->root_topic; 88 $this->url = ''; 86 89 } 87 90 … … 129 132 $this->argc -= 1; 130 133 array_shift ($this->argv); 134 135 $this->url .= $this->current_object->name . '/'; 131 136 132 137 return $this->current_object; … … 183 188 public function get_url() 184 189 { 185 return implode('/', $this->argv_original) . '/';190 return '/' . $this->url; 186 191 } 187 192 } trunk/midcom/midcom.core/midcom/helper/_styleloader.php
r11816 r11872 744 744 debug_add("entering context $context", MIDCOM_LOG_DEBUG); 745 745 746 $this->_topic = $_MIDCOM->get_conte nt_topic();746 $this->_topic = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_CONTENTTOPIC); 747 747 748 748 $_st = $this->_getComponentStyle($this->_topic); … … 781 781 // get our topic again 782 782 // FIXME: does this have to be above _getComponentStyle($this->_topic) ?? 783 $this->_topic = $_MIDCOM->get_conte nt_topic();783 $this->_topic = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_CONTENTTOPIC); 784 784 785 785 $this->_snippetdir = $this->_getComponentSnippetdir($this->_topic);
