Beispiel #1
0
	function import($filename)
	{
		global $errors, $errmode;

		// import crossreferences
		$this->xscripts     =
		$this->xpieces      =
		// old package backlinks
		$this->oldscripts   =
		$this->oldpieces    =
		// insert trace
		$this->scripts      =
		$this->pieces       =
		$this->forms        =
		$this->elements     =
		$this->menus        =
		// misc
		$this->warnings     = array();
		$this->pubmenus     = 0;

		if ($errmode=='log') {
			$this->saveErrors = $errors;
			$errors = array();
		} // if

		$ok = parent::import($filename);

		if (!$ok) {
			
			// fail case
			$this->rollback();
			if ($errmode=='log') {
				if (count($this->saveErrors)) $errors = array_merge($this->saveErrors, $errors);
				$errors[] = BFText::_('COM_BREEZINGFORMS_INSTALLER').': '.$this->error;
			} // if
		} else {
			// success case
			if ($this->pubmenus>0) updateComponentMenus();
			$id = $this->getText(0, 'pkgid');
			if ($id != '') {
				relinkScripts($this->oldscripts);
				relinkPieces($this->oldpieces);
				savePackage(
					$id,
					$this->getText(0, 'name'),
					$this->getText(0, 'title'),
					$this->getText(0, 'version'),
					$this->getText(0, 'creationDate'),
					$this->getText(0, 'author'),
					$this->getText(0, 'authorEmail'),
					$this->getText(0, 'authorUrl'),
					$this->getText(0, 'description'),
					$this->getText(0, 'copyright')
				);
			} // if
		} // if
		return $ok;
	} // import
 function import($filename)
 {
     global $errors, $errmode;
     // import crossreferences
     $this->xscripts = $this->xpieces = $this->oldscripts = $this->oldpieces = $this->scripts = $this->pieces = $this->forms = $this->elements = $this->menus = $this->warnings = array();
     $this->pubmenus = 0;
     if ($errmode == 'log') {
         $this->saveErrors = $errors;
         $errors = array();
     }
     // if
     $ok = parent::import($filename);
     if (!$ok) {
         // fail case
         $this->rollback();
         if ($errmode == 'log') {
             if (count($this->saveErrors)) {
                 $errors = array_merge($this->saveErrors, $errors);
             }
             $errors[] = BFText::_('COM_BREEZINGFORMS_INSTALLER') . ': ' . $this->error;
         }
         // if
     } else {
         // success case
         if ($this->pubmenus > 0) {
             updateComponentMenus();
         }
         $id = $this->getText(0, 'pkgid');
         if ($id != '') {
             relinkScripts($this->oldscripts);
             relinkPieces($this->oldpieces);
             savePackage($id, $this->getText(0, 'name'), $this->getText(0, 'title'), $this->getText(0, 'version'), $this->getText(0, 'creationDate'), $this->getText(0, 'author'), $this->getText(0, 'authorEmail'), $this->getText(0, 'authorUrl'), $this->getText(0, 'description'), $this->getText(0, 'copyright'));
         }
         // if
         require_once JPATH_SITE . '/administrator/components/com_breezingforms/admin/quickmode.class.php';
         require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php';
         require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php';
         foreach ($this->forms as $form_id) {
             JFactory::getDBO()->setQuery("Select template_areas, template_code_processed, template_code From #__facileforms_forms Where id = " . intval($form_id));
             $row = JFactory::getDBO()->loadObject();
             if (trim($row->template_code) != '') {
                 $areas = Zend_Json::decode(bf_b64dec($row->template_areas));
                 $i = 0;
                 foreach ($areas as $area) {
                     $j = 0;
                     foreach ($area['elements'] as $element) {
                         $areas[$i]['elements'][$j]['dbId'] = 0;
                         $j++;
                     }
                     $i++;
                 }
                 $template_areas = Zend_Json::encode($areas);
                 $template_code = $row->template_code;
                 if ($row->template_code_processed == 'QuickMode') {
                     $dataObject = Zend_Json::decode(bf_b64dec($row->template_code));
                     $this->resetQuickModeDbId($dataObject);
                     $template_code = bf_b64enc(Zend_Json::encode($dataObject));
                 }
                 JFactory::getDBO()->setQuery("Update #__facileforms_forms Set template_code = " . JFactory::getDBO()->Quote($template_code) . ", template_areas = " . JFactory::getDBO()->Quote($template_areas) . " Where id = " . intval($form_id));
                 JFactory::getDBO()->query();
                 if ($row && $row->template_code_processed == 'QuickMode') {
                     $quickMode = new QuickMode();
                     $quickMode->save($form_id, Zend_Json::decode(bf_b64dec($template_code)));
                 }
             }
         }
     }
     // if
     return $ok;
 }