public function generate($page)
 {
     $full_generate = true;
     $devkit = null;
     $output = null;
     if ($this->_Parent->isLoggedIn()) {
         ####
         # Delegate: FrontendDevKitResolve
         # Description: Allows a devkit object to be specified, and stop continued execution:
         # Global: Yes
         $this->ExtensionManager->notifyMembers('FrontendDevKitResolve', '/frontend/', array('full_generate' => &$full_generate, 'devkit' => &$devkit));
     }
     $this->_Parent->Profiler->sample('Page creation process started');
     $this->_page = $page;
     $this->__buildPage($full_generate);
     if ($full_generate) {
         ####
         # Delegate: FrontendOutputPreGenerate
         # Description: Immediately before generating the page. Provided with the page object, XML and XSLT
         # Global: Yes
         $this->ExtensionManager->notifyMembers('FrontendOutputPreGenerate', '/frontend/', array('page' => &$this, 'xml' => $this->_xml, 'xsl' => $this->_xsl));
         if (is_null($devkit)) {
             if (@in_array('XML', $this->_pageData['type']) || @in_array('xml', $this->_pageData['type'])) {
                 $this->addHeaderToPage('Content-Type', 'text/xml; charset=utf-8');
             } else {
                 $this->addHeaderToPage('Content-Type', 'text/html; charset=utf-8');
             }
             if (@in_array('404', $this->_pageData['type'])) {
                 $this->addHeaderToPage('HTTP/1.0 404 Not Found');
             } elseif (@in_array('403', $this->_pageData['type'])) {
                 $this->addHeaderToPage('HTTP/1.0 403 Forbidden');
             }
         }
         $output = parent::generate();
         ####
         # Delegate: FrontendOutputPostGenerate
         # Description: Immediately after generating the page. Provided with string containing page source
         # Global: Yes
         $this->ExtensionManager->notifyMembers('FrontendOutputPostGenerate', '/frontend/', array('output' => &$output));
         $this->_Parent->Profiler->sample('XSLT Transformation', PROFILE_LAP);
         if (is_null($devkit) && !$output) {
             $errstr = NULL;
             while (list($key, $val) = $this->Proc->getError()) {
                 $errstr .= 'Line: ' . $val['line'] . ' - ' . $val['message'] . self::CRLF;
             }
             $this->_Parent->customError(E_USER_ERROR, NULL, trim($errstr), true, false, 'xslt-error', array('proc' => clone $this->Proc));
         }
         $this->_Parent->Profiler->sample('Page creation complete');
     }
     if (!is_null($devkit)) {
         $devkit->prepare($this, $this->_pageData, $this->_xml, $this->_param, $output);
         return $devkit->generate();
     }
     ## EVENT DETAILS IN SOURCE
     if ($this->_Parent->isLoggedIn() && $this->_Parent->Configuration->get('display_event_xml_in_source', 'public') == 'yes') {
         $output .= self::CRLF . '<!-- ' . self::CRLF . $this->_events_xml->generate(true) . ' -->';
     }
     return $output;
 }
 public function generate($page, $mode = self::FRONTEND_OUTPUT_NORMAL)
 {
     $this->_Parent->Profiler->sample('Page creation process started');
     $this->_page = $page;
     $this->__buildPage();
     if ($mode == self::FRONTEND_OUTPUT_NORMAL) {
         if (@in_array('XML', $this->_pageData['type']) || @in_array('xml', $this->_pageData['type'])) {
             $this->addHeaderToPage('Content-Type', 'text/xml; charset=utf-8');
         } else {
             $this->addHeaderToPage('Content-Type', 'text/html; charset=utf-8');
         }
         if (@in_array('404', $this->_pageData['type'])) {
             $this->addHeaderToPage('HTTP/1.0 404 Not Found');
         } elseif (@in_array('403', $this->_pageData['type'])) {
             $this->addHeaderToPage('HTTP/1.0 403 Forbidden');
         }
     }
     ####
     # Delegate: FrontendOutputPreGenerate
     # Description: Immediately before generating the page. Provided with the page object, XML and XSLT
     # Global: Yes
     $this->ExtensionManager->notifyMembers('FrontendOutputPreGenerate', '/frontend/', array('page' => &$this, 'xml' => $this->_xml, 'xsl' => $this->_xsl));
     $output = parent::generate();
     ####
     # Delegate: FrontendOutputPostGenerate
     # Description: Immediately after generating the page. Provided with string containing page source
     # Global: Yes
     $this->ExtensionManager->notifyMembers('FrontendOutputPostGenerate', '/frontend/', array('output' => &$output));
     $this->_Parent->Profiler->sample('XSLT Transformation', PROFILE_LAP);
     if ($mode == self::FRONTEND_OUTPUT_NORMAL && !$output) {
         $errstr = NULL;
         while (list($key, $val) = $this->Proc->getError()) {
             $errstr .= 'Line: ' . $val['line'] . ' - ' . $val['message'] . self::CRLF;
         }
         $this->_Parent->customError(E_USER_ERROR, NULL, trim($errstr), true, false, 'xslt-error', array('proc' => clone $this->Proc));
     }
     $this->_Parent->Profiler->sample('Page creation complete');
     ## DEBUG
     if ($mode == self::FRONTEND_OUTPUT_DEBUG) {
         include_once TOOLKIT . '/class.debugpage.php';
         $debug = new DebugPage();
         $output = $debug->generate($this->_pageData, $this->_xml, @file_get_contents($this->_pageData['filelocation']), $output, $this->_param);
         ## PROFILE
     } elseif ($mode == self::FRONTEND_OUTPUT_PROFILE) {
         include_once TOOLKIT . '/class.profilepage.php';
         $profile = new ProfilePage();
         $output = $profile->generate($this->_pageData, $this->_Parent->Profiler, $this->_Parent->Database);
     }
     ## EVENT DETAILS IN SOURCE
     if ($this->_Parent->isLoggedIn() && $this->_Parent->Configuration->get('display_event_xml_in_source', 'public') == 'yes') {
         $output .= self::CRLF . '<!-- ' . self::CRLF . $this->_events_xml->generate(true) . ' -->';
     }
     return $output;
 }
 /**
  * This function is called immediately from the Frontend class passing the current
  * URL for generation. Generate will resolve the URL to the specific page in the Symphony
  * and then execute all events and datasources registered to this page so that it can
  * be rendered. A number of delegates are fired during stages of execution for extensions
  * to hook into.
  *
  * @uses FrontendDevKitResolve
  * @uses FrontendOutputPreGenerate
  * @uses FrontendPreRenderHeaders
  * @uses FrontendOutputPostGenerate
  * @see __buildPage()
  * @param string $page
  * The URL of the current page that is being Rendered as returned by getCurrentPage
  * @return string
  * The page source after the XSLT has transformed this page's XML. This would be
  * exactly the same as the 'view-source' from your browser
  */
 public function generate($page)
 {
     $full_generate = true;
     $devkit = null;
     $output = null;
     if ($this->is_logged_in) {
         /**
          * Allows a devkit object to be specified, and stop continued execution:
          *
          * @delegate FrontendDevKitResolve
          * @param string $context
          * '/frontend/'
          * @param boolean $full_generate
          *  Whether this page will be completely generated (ie. invoke the XSLT transform)
          *  or not, by default this is true. Passed by reference
          * @param mixed $devkit
          *  Allows a devkit to register to this page
          */
         Symphony::ExtensionManager()->notifyMembers('FrontendDevKitResolve', '/frontend/', array('full_generate' => &$full_generate, 'devkit' => &$devkit));
     }
     Symphony::Profiler()->sample('Page creation process started');
     $this->_page = $page;
     $this->__buildPage();
     if ($full_generate) {
         /**
          * Immediately before generating the page. Provided with the page object, XML and XSLT
          * @delegate FrontendOutputPreGenerate
          * @param string $context
          * '/frontend/'
          * @param FrontendPage $page
          *  This FrontendPage object, by reference
          * @param string $xml
          *  This pages XML, including the Parameters, Datasource and Event XML, by reference
          * @param string $xsl
          *  This pages XSLT
          */
         Symphony::ExtensionManager()->notifyMembers('FrontendOutputPreGenerate', '/frontend/', array('page' => &$this, 'xml' => &$this->_xml, 'xsl' => $this->_xsl));
         if (is_null($devkit)) {
             if (General::in_iarray('XML', $this->_pageData['type'])) {
                 $this->addHeaderToPage('Content-Type', 'text/xml; charset=utf-8');
             } else {
                 if (General::in_iarray('JSON', $this->_pageData['type'])) {
                     $this->addHeaderToPage('Content-Type', 'application/json; charset=utf-8');
                 } else {
                     $this->addHeaderToPage('Content-Type', 'text/html; charset=utf-8');
                 }
             }
             if (in_array('404', $this->_pageData['type'])) {
                 $this->addHeaderToPage('Status', '404 Not Found', 404);
             } elseif (in_array('403', $this->_pageData['type'])) {
                 $this->addHeaderToPage('Status', '403 Forbidden', 403);
             }
         }
         /**
          * This is just prior to the page headers being rendered, and is suitable for changing them
          * @delegate FrontendPreRenderHeaders
          * @param string $context
          * '/frontend/'
          */
         Symphony::ExtensionManager()->notifyMembers('FrontendPreRenderHeaders', '/frontend/');
         $output = parent::generate();
         /**
          * Immediately after generating the page. Provided with string containing page source
          * @delegate FrontendOutputPostGenerate
          * @param string $context
          * '/frontend/'
          * @param string $output
          *  The generated output of this page, ie. a string of HTML, passed by reference
          */
         Symphony::ExtensionManager()->notifyMembers('FrontendOutputPostGenerate', '/frontend/', array('output' => &$output));
         Symphony::Profiler()->sample('XSLT Transformation', PROFILE_LAP);
         if (is_null($devkit) && !$output) {
             $errstr = NULL;
             while (list($key, $val) = $this->Proc->getError()) {
                 $errstr .= 'Line: ' . $val['line'] . ' - ' . $val['message'] . PHP_EOL;
             }
             GenericExceptionHandler::$enabled = true;
             throw new SymphonyErrorPage(trim($errstr), NULL, 'xslt', array('proc' => clone $this->Proc));
         }
         Symphony::Profiler()->sample('Page creation complete');
     }
     if (!is_null($devkit)) {
         $devkit->prepare($this, $this->_pageData, $this->_xml, $this->_param, $output);
         return $devkit->build();
     }
     // Display the Event Results in the page source if the user is logged
     // into Symphony, the page is not JSON and if it is enabled in the
     // configuration.
     if ($this->is_logged_in && !General::in_iarray('JSON', $this->_pageData['type']) && Symphony::Configuration()->get('display_event_xml_in_source', 'public') == 'yes') {
         $output .= PHP_EOL . '<!-- ' . PHP_EOL . $this->_events_xml->generate(true) . ' -->';
     }
     return $output;
 }
Esempio n. 4
0
 /**
  * This function is called immediately from the Frontend class passing the current
  * URL for generation. Generate will resolve the URL to the specific page in the Symphony
  * and then execute all events and datasources registered to this page so that it can
  * be rendered. A number of delegates are fired during stages of execution for extensions
  * to hook into.
  *
  * @uses FrontendDevKitResolve
  * @uses FrontendOutputPreGenerate
  * @uses FrontendPreRenderHeaders
  * @uses FrontendOutputPostGenerate
  * @see __buildPage()
  * @param string $page
  * The URL of the current page that is being Rendered as returned by getCurrentPage
  * @return string
  * The page source after the XSLT has transformed this page's XML. This would be
  * exactly the same as the 'view-source' from your browser
  */
 public function generate($page = null)
 {
     $full_generate = true;
     $devkit = null;
     $output = null;
     $this->addHeaderToPage('Cache-Control', 'no-cache, must-revalidate, max-age=0');
     $this->addHeaderToPage('Expires', 'Mon, 12 Dec 1982 06:14:00 GMT');
     $this->addHeaderToPage('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT');
     $this->addHeaderToPage('Pragma', 'no-cache');
     if ($this->is_logged_in) {
         /**
          * Allows a devkit object to be specified, and stop continued execution:
          *
          * @delegate FrontendDevKitResolve
          * @param string $context
          * '/frontend/'
          * @param boolean $full_generate
          *  Whether this page will be completely generated (ie. invoke the XSLT transform)
          *  or not, by default this is true. Passed by reference
          * @param mixed $devkit
          *  Allows a devkit to register to this page
          */
         Symphony::ExtensionManager()->notifyMembers('FrontendDevKitResolve', '/frontend/', array('full_generate' => &$full_generate, 'devkit' => &$devkit));
     }
     Symphony::Profiler()->sample('Page creation process started');
     $this->_page = $page;
     $this->__buildPage();
     if ($full_generate) {
         /**
          * Immediately before generating the page. Provided with the page object, XML and XSLT
          * @delegate FrontendOutputPreGenerate
          * @param string $context
          * '/frontend/'
          * @param FrontendPage $page
          *  This FrontendPage object, by reference
          * @param string $xml
          *  This pages XML, including the Parameters, Datasource and Event XML, by reference
          * @param string $xsl
          *  This pages XSLT, by reference
          */
         Symphony::ExtensionManager()->notifyMembers('FrontendOutputPreGenerate', '/frontend/', array('page' => &$this, 'xml' => &$this->_xml, 'xsl' => &$this->_xsl));
         if (is_null($devkit)) {
             if (General::in_iarray('XML', $this->_pageData['type'])) {
                 $this->addHeaderToPage('Content-Type', 'text/xml; charset=utf-8');
             } else {
                 if (General::in_iarray('JSON', $this->_pageData['type'])) {
                     $this->addHeaderToPage('Content-Type', 'application/json; charset=utf-8');
                 } else {
                     $this->addHeaderToPage('Content-Type', 'text/html; charset=utf-8');
                 }
             }
             if (in_array('404', $this->_pageData['type'])) {
                 $this->setHttpStatus(self::HTTP_STATUS_NOT_FOUND);
             } else {
                 if (in_array('403', $this->_pageData['type'])) {
                     $this->setHttpStatus(self::HTTP_STATUS_FORBIDDEN);
                 }
             }
         }
         /**
          * This is just prior to the page headers being rendered, and is suitable for changing them
          * @delegate FrontendPreRenderHeaders
          * @param string $context
          * '/frontend/'
          */
         Symphony::ExtensionManager()->notifyMembers('FrontendPreRenderHeaders', '/frontend/');
         $backup_param = $this->_param;
         $this->_param['current-query-string'] = General::wrapInCDATA($this->_param['current-query-string']);
         $output = parent::generate();
         $this->_param = $backup_param;
         /**
          * Immediately after generating the page. Provided with string containing page source
          * @delegate FrontendOutputPostGenerate
          * @param string $context
          * '/frontend/'
          * @param string $output
          *  The generated output of this page, ie. a string of HTML, passed by reference
          */
         Symphony::ExtensionManager()->notifyMembers('FrontendOutputPostGenerate', '/frontend/', array('output' => &$output));
         Symphony::Profiler()->sample('XSLT Transformation', PROFILE_LAP);
         if (is_null($devkit) && !$output) {
             $errstr = NULL;
             while (list($key, $val) = $this->Proc->getError()) {
                 $errstr .= 'Line: ' . $val['line'] . ' - ' . $val['message'] . PHP_EOL;
             }
             Frontend::instance()->throwCustomError(trim($errstr), __('XSLT Processing Error'), Page::HTTP_STATUS_ERROR, 'xslt', array('proc' => clone $this->Proc));
         }
         Symphony::Profiler()->sample('Page creation complete');
     }
     if (!is_null($devkit)) {
         $devkit->prepare($this, $this->_pageData, $this->_xml, $this->_param, $output);
         return $devkit->build();
     }
     // Display the Event Results in the page source if the user is logged
     // into Symphony, the page is not JSON and if it is enabled in the
     // configuration.
     if ($this->is_logged_in && !General::in_iarray('JSON', $this->_pageData['type']) && Symphony::Configuration()->get('display_event_xml_in_source', 'public') == 'yes') {
         $output .= PHP_EOL . '<!-- ' . PHP_EOL . $this->_events_xml->generate(true) . ' -->';
     }
     return $output;
 }
Esempio n. 5
0
 private function __importStep2Page()
 {
     // Store the CSV data in the cache table, so the CSV file will not be stored on the server
     $cache = new Cacheable(Symphony::Database());
     // Get the nodes provided by this CSV file:
     $csv = new parseCSV();
     $csv->auto($_FILES['csv-file']['tmp_name']);
     $cache->write('importcsv', serialize($csv), 60 * 60 * 24);
     // Store for one day
     $sectionID = $_POST['section'];
     // Generate the XML:
     $xml = new XMLElement('data', null, array('section-id' => $sectionID));
     // Get the fields of this section:
     $fieldsNode = new XMLElement('fields');
     $sm = new SectionManager($this);
     $section = $sm->fetch($sectionID);
     $fields = $section->fetchFields();
     foreach ($fields as $field) {
         $fieldsNode->appendChild(new XMLElement('field', $field->get('label'), array('id' => $field->get('id'))));
     }
     $xml->appendChild($fieldsNode);
     $csvNode = new XMLElement('csv');
     foreach ($csv->titles as $key) {
         $csvNode->appendChild(new XMLElement('key', $key));
     }
     $xml->appendChild($csvNode);
     // Generate the HTML:
     $xslt = new XSLTPage();
     $xslt->setXML($xml->generate());
     $xslt->setXSL(EXTENSIONS . '/importcsv/content/step2.xsl', true);
     $this->Form->setValue($xslt->generate());
 }