Ejemplo n.º 1
0
	function display($tpl = null) {
			$db = JFactory::getDBO();
		if ( $virtuemart_media_id = vRequest::getInt('virtuemart_media_id') ) {
			//$db = JFactory::getDBO();
			$query='SELECT `file_url`,`file_title` FROM `#__virtuemart_medias` where `virtuemart_media_id`='.$virtuemart_media_id;
			$db->setQuery( $query );
			$json = $db->loadObject();
			if (isset($json->file_url)) {
				$json->file_url = JURI::root().$json->file_url;
				$json->msg =  'OK';
				echo json_encode($json);
			} else {
				$json->msg =  '<b>'.vmText::_('COM_VIRTUEMART_NO_IMAGE_SET').'</b>';
				echo json_encode($json);
			}
		}
		elseif ( $custom_jplugin_id = vRequest::getInt('custom_jplugin_id') ) {

			$table = '#__extensions';
			$ext_id = 'extension_id';

			$q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `' . $ext_id . '` = "'.$custom_jplugin_id.'"';
			$db ->setQuery($q);
			$this->jCustom = $db ->loadObject();

			$customModel = VmModel::getModel('custom');
			$this->custom = $customModel -> getCustom();

			// Get the payment XML.
			$formFile	= JPath::clean( VMPATH_ROOT .DS. 'plugins' .DS. 'vmcustom' .DS . $this->jCustom->element . DS . $this->jCustom->element . '.xml');
			if (file_exists($formFile)){
				VmConfig::loadJLang('plg_vmpsplugin', false);
				if (!class_exists('vmPlugin')) require(VMPATH_PLUGINLIBS . DS . 'vmplugin.php');
				$filename = 'plg_vmcustom_' .  $this->jCustom->element;
				vmPlugin::loadJLang($filename,'vmcustom',$this->jCustom->element);

				$this->custom = VmModel::getModel('custom')->getCustom();
				$varsToPush = vmPlugin::getVarsToPushByXML($formFile,'customForm');
				$this->custom->form = JForm::getInstance($this->jCustom->element, $formFile, array(),false, '//vmconfig | //config[not(//vmconfig)]');
				$this->custom->params = new stdClass();

				foreach($varsToPush as $k => $field){
					if(strpos($k,'_')!=0){
						$this->custom->params->$k = $field[0];
					}
				}
				$this->custom->form->bind($this->custom->getProperties());
				$form = $this->custom->form;
				include(VMPATH_ADMIN.DS.'fields'.DS.'formrenderer.php');
				echo '<input type="hidden" value="'.$this->jCustom->element.'" name="custom_value">';
			} else {
				$this->custom->form = null;
				VmConfig::$echoDebug = 1;
				vmdebug ('File does not exist '.$formFile);
			}
		}
		jExit();
	}
Ejemplo n.º 2
0
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     if ($field = vRequest::getVar('field')) {
         if (strpos($field, 'plugin') !== false) {
             JForm::addFieldPath(JPATH_VM_ADMINISTRATOR . DS . 'fields');
             $table = '#__extensions';
             $field = substr($field, 6);
             $q = 'SELECT `params`,`element`,`type` FROM `' . $table . '` WHERE `element` = "' . $field . '"';
             $db->setQuery($q);
             $this->userField = $db->loadObject();
             //$this->userField->element = substr($this->userField->type, 6);
             if (!class_exists('vmPlugin')) {
                 require JPATH_VM_PLUGINS . DS . 'vmplugin.php';
             }
             vmPlugin::loadJLang('plg_vmuserfield_' . $this->userField->element, 'vmuserfield', $this->userField->element);
             $path = JPATH_ROOT . DS . 'plugins' . DS . 'vmuserfield' . DS . $this->userField->element . DS . $this->userField->element . '.xml';
             // Get the payment XML.
             $formFile = JPath::clean($path);
             if (file_exists($formFile)) {
                 if (!class_exists('VmConfig')) {
                     require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
                 }
                 if (!class_exists('VmTable')) {
                     require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtable.php';
                 }
                 $this->userField->form = JForm::getInstance($this->userField->element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]');
                 $this->userField->params = new stdClass();
                 $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'customForm');
                 /*
                 					$this->userField->params->userfield_params = $this->userField->params;
                 					VmTable::bindParameterable($this->userField->params,'userfield_params',$varsToPush);*/
                 if (empty($this->userField->userfield_params)) {
                     $this->userField->userfield_params = '';
                 }
                 $this->userField->params->userfield_params = $this->userField->userfield_params;
                 VmTable::bindParameterable($this->userField->params, 'userfield_params', $varsToPush);
                 $this->userField->form->bind($this->userField);
             } else {
                 $this->userField->form = false;
                 vmdebug('renderUserfieldPlugin could not find xml for ' . $this->userField->type . ' at ' . $path);
             }
             //vmdebug('renderUserfieldPlugin ',$this->userField->form);
             if ($this->userField->form) {
                 $form = $this->userField->form;
                 ob_start();
                 include JPATH_VM_ADMINISTRATOR . DS . 'fields' . DS . 'formrenderer.php';
                 $body = ob_get_contents();
                 ob_end_clean();
                 echo $body;
             }
         }
     }
     jExit();
 }
Ejemplo n.º 3
0
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     if ($virtuemart_media_id = JRequest::getInt('virtuemart_media_id')) {
         //$db = JFactory::getDBO();
         $query = 'SELECT `file_url`,`file_title` FROM `#__virtuemart_medias` where `virtuemart_media_id`=' . $virtuemart_media_id;
         $db->setQuery($query);
         $json = $db->loadObject();
         if (isset($json->file_url)) {
             $json->file_url = JURI::root() . $json->file_url;
             $json->msg = 'OK';
             echo json_encode($json);
         } else {
             $json->msg = '<b>' . JText::_('COM_VIRTUEMART_NO_IMAGE_SET') . '</b>';
             echo json_encode($json);
         }
     } elseif ($custom_jplugin_id = JRequest::getInt('custom_jplugin_id')) {
         if (JVM_VERSION === 1) {
             $table = '#__plugins';
             $ext_id = 'id';
         } else {
             $table = '#__extensions';
             $ext_id = 'extension_id';
         }
         $q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `' . $ext_id . '` = "' . $custom_jplugin_id . '"';
         $db->setQuery($q);
         $this->plugin = $db->loadObject();
         if (!class_exists('vmParameters')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'parameterparser.php';
         }
         $parameters = new vmParameters($this->plugin->params, $this->plugin->element, 'plugin', 'vmcustom');
         if (!class_exists('vmPlugin')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'plugins' . DS . 'vmplugin.php';
         }
         $filename = 'plg_vmcustom_' . $this->plugin->element;
         vmPlugin::loadJLang($filename, 'vmcustom', $this->plugin->element);
         echo $parameters->render();
         echo '<input type="hidden" value="' . $this->plugin->element . '" name="custom_value">';
         jExit();
     }
     jExit();
 }
Ejemplo n.º 4
0
 function renderInstalledCustomPlugins($selected)
 {
     $db = JFactory::getDBO();
     $table = '#__extensions';
     $enable = 'enabled';
     $ext_id = 'extension_id';
     //$q = 'SELECT * FROM `'.$table.'` WHERE `folder` = "vmcustom" AND `'.$enable.'`="1" ';
     $q = 'SELECT * FROM `' . $table . '` WHERE `folder` = "vmcustom" ';
     $db->setQuery($q);
     $results = $db->loadAssocList($ext_id);
     if (!class_exists('vmPlugin')) {
         require VMPATH_ADMIN . DS . 'plugins' . DS . 'vmplugin.php';
     }
     foreach ($results as $result) {
         //$filename = 'plg_' .strtolower ( $result['name']).'.sys';
         //$lang->load($filename, JPATH_ADMINISTRATOR);
         $filename = 'plg_' . strtolower($result['name']) . '.sys';
         vmPlugin::loadJLang($filename, 'vmcustom', $result['name']);
     }
     return VmHTML::select('custom_jplugin_id', $results, $selected, "", $ext_id, 'name');
     //return JHtml::_('select.genericlist', $result, 'custom_jplugin_id', null, $ext_id, 'name', $selected);
 }