/** * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return mixed A string if successful, otherwise a Error object. * * @since 1.6 */ public function display($tpl = null) { try { $this->item = $this->get('Item'); } catch (Exception $e) { $app = JFactory::getApplication(); $app->enqueueMessage($e->getMessage(), 'error'); return false; } $paramsList = $this->item->getProperties(); unset($paramsList['xml']); $paramsList = json_encode($paramsList); return $paramsList; }
/** * Tests getting the properties of the object. * * @group JObject * @covers JObject::getProperties * @return void */ public function testGetProperties() { $this->object = new JObject( array( '_privateproperty1' => 'valuep1', 'property1' => 'value1', 'property2' => 5 ) ); $this->assertEquals( array( '_errors' => array(), '_privateproperty1' => 'valuep1', 'property1' => 'value1', 'property2' => 5 ), $this->object->getProperties(false), 'Should get all properties, including private ones' ); $this->assertEquals( array( 'property1' => 'value1', 'property2' => 5 ), $this->object->getProperties(), 'Should get all public properties' ); }
public static function readXML($params) { $temppath = JPATH_BASE . DS . "cache/mod_bps_kiyoh/"; if (!is_dir($temppath)) { mkdir($temppath); } $xmlUrl = $params->get('xmlUrl', ''); $cacheTime = (int) $params->get('cacheTime', 480) * 60; $filename = md5($xmlUrl . $params->toString()); $tempfile = $temppath . $filename; if (file_exists($tempfile)) { $mtime = filemtime($tempfile); if (time() - $mtime < $cacheTime) { $aXmlData = unserialize(file_get_contents($tempfile)); return $aXmlData; } } if (!($oXml = simplexml_load_file($xmlUrl))) { echo 'Geen xml geladen'; return false; } $oXmlInfo = new JObject(); $oXmlInfo->set('naam', (string) $oXml->company->name); $oXmlInfo->set('kiyohLink', (string) $oXml->company->url); $oXmlInfo->set('total_score', (double) $oXml->company->total_score); $oXmlInfo->set('total_reviews', (int) $oXml->company->total_reviews); $oXmlInfo->set('total_views', (int) $oXml->company->total_views); $aReviews = array(); $iReviewCount = 0; foreach ($oXml->review_list->review as $oReview) { $oReviewInfo = new JObject(); $oReviewInfo->set('naam', (string) $oReview->customer->name); $oReviewInfo->set('place', (string) $oReview->customer->place); $oReviewInfo->set('date', JHtml::_('date', (string) $oReview->customer->date, '%d %b')); $oReviewInfo->set('dateRaw', JHtml::_('date', (string) $oReview->customer->date, '%Y-%m-%d')); $oReviewInfo->set('total_score', (int) $oReview->total_score); $oReviewInfo->set('recommendation', (string) $oReview->recommendation); $oReviewInfo->set('positive', (string) $oReview->positive); $oReviewInfo->set('negative', (string) $oReview->negative); $iReviewCount++; if ($params->get('reviewOnly', false) && ($oReviewInfo->positive == '' && $oReviewInfo->negative == '')) { continue; } $aReviews[] = $oReviewInfo->getProperties(); } $oXmlInfo->set('reviewCount', $iReviewCount); $oXmlInfo->set('aReviews', $aReviews); $aXmlData = $oXmlInfo->getProperties(); //in file zetten $file = fopen($tempfile, 'w'); fwrite($file, serialize($aXmlData)); fclose($file); // print_r_pre($aXmlData); // print_r_pre($oXml->review_list); return $aXmlData; }
/** * Make sure that the data contains CamelCase properties * * @param mixed $data Data to sanitize * * @return JObject */ protected function sanitizeConstructorData($data) { $data = new JObject($data); $properties = $data->getProperties(); $sanitizeData = new JObject(); foreach ($properties as $property => $value) { $sanitizeData->set(NenoHelper::convertDatabaseColumnNameToPropertyName($property), $value); } return $sanitizeData; }
/** * Gets the appropriate values from the request * * @return unknown_type */ function _getState() { $state = new JObject(); foreach ($state->getProperties() as $key => $value) { $new_value = JRequest::getVar($key); $value_exists = array_key_exists($key, JRequest::get('post')); if ($value_exists && !empty($key)) { $state->{$key} = $new_value; } } return $state; }
/** * Gets the appropriate values from the request * * @return JObject */ function _getState() { $state = new JObject(); $state->file = ''; $state->uploaded_file = ''; $state->uploaded_images_zip_file = ''; $state->uploaded_files_zip_file = ''; foreach ($state->getProperties() as $key => $value) { $new_value = JRequest::getVar($key); $value_exists = array_key_exists($key, $_POST); if ($value_exists && !empty($key)) { $state->{$key} = $new_value; } } return $state; }
/** * Gets the appropriate values from the request * * return JObject */ function _getState() { $input = JFactory::getApplication()->input; $state = new JObject(); $state->file = ''; $state->uploaded_file = ''; $state->uploaded_images_zip_file = ''; $state->uploaded_files_zip_file = ''; foreach ($state->getProperties() as $key => $value) { $new_value = $input->get($key); $value_exists = array_key_exists($key, $_POST); if ($value_exists && !empty($key)) { $state->{$key} = $new_value; } } return $state; }
/** * Gets the appropriate values from the request * * @return unknown_type */ function _getState() { $state = new JObject(); $state->host = ''; $state->user = ''; $state->password = ''; $state->database = ''; $state->prefix = 'jos_'; $state->vm_prefix = 'vm_'; $state->driver = 'mysql'; $state->port = '3306'; $state->external_site_url = ''; foreach ($state->getProperties() as $key => $value) { $new_value = JRequest::getVar($key); $value_exists = array_key_exists($key, $_POST); if ($value_exists && !empty($key)) { $state->{$key} = $new_value; } } return $state; }
public function register(InputInterface $input, OutputInterface $output) { $app = Bootstrapper::getApplication($this->target_dir); ob_start(); // build the record. $data = new \JObject(); $data->name = $this->extension; $data->type = $this->type; $data->element = $this->extension; $data->client_id = $input->getOption('client_id'); $data->enabled = $input->getOption('enabled'); $data->position = $input->getOption('position'); $element = $input->getOption('element'); if (strlen($element)) { $data->element = $element; } // special case for plugin, naming and folder. if ($this->type == 'plugin') { // set the default folder for plugins only. $data->folder = $input->getOption('folder') ? $input->getOption('folder') : 'system'; // special case for the plugins only. if (substr($data->element, 0, 4) == 'plg_') { $data->element = substr($data->element, 4); } } if ($this->type == 'template') { if (substr($data->name, 0, 4) == 'tpl_') { $data->name = substr($data->name, 4); $data->element = substr($data->element, 4); } } //need to be sure that a prefix is provided for components and modules if (($this->type == "component" || $this->type == "module") && strpos($data->element, '_') === false) { $prefix = array_search($this->type, $this->typeMap); $data->element = $prefix . $this->extension; } // get the #__extensions model and table require_once JPATH_ADMINISTRATOR . '/components/com_installer/models/extension.php'; $model = new \InstallerModel(); $table = $model->getTable('extension', 'JTable'); // restrict on same name and type $unique = array('name' => $data->name, 'type' => $data->type); // does the extension exist? if (!$table->load($unique)) { if ($table->save($data->getProperties())) { if (array_key_exists($this->type, $this->exceptions)) { $this->handleExceptions($output, $app, $data, $this->type); } $output->writeln("<info>Your extension registered as a '{$this->type}', with extension_id: {$table->extension_id}</info>"); } else { $output->writeln("<info>" . $table->getError() . "</info>"); } } else { $output->writeln("<error>{$this->extension} {$this->type}: That extension already exists.</error>"); } ob_end_clean(); }
/** * Gets the appropriate values from the request * * @return unknown_type */ function _getState() { $app = JFactory::getApplication(); $state = new JObject(); $state->host = ''; $state->user = ''; $state->password = ''; $state->database = ''; $state->prefix = ''; $state->driver = 'mysql'; $state->port = '3306'; foreach ($state->getProperties() as $key => $value) { $new_value = $app->input->get($key); $value_exists = array_key_exists($key, $_POST); if ($value_exists && !empty($key)) { $state->{$key} = $new_value; } } return $state; }
/** * Gets the appropriate values from the request * * @return unknown_type */ function _getState() { $app = JFactory::getApplication(); $state = new JObject(); foreach ($state->getProperties() as $key => $value) { //$new_value = JRequest::getVar( $key ); $new_value = $app->input->get($key); $post = $app->input->get($_POST); $value_exists = array_key_exists($key, $post); if ($value_exists && !empty($key)) { $state->{$key} = $new_value; } } return $state; }