Beispiel #1
0
/**
 * Disables the unsupported eAccelerator caching method, replacing it with the
 * "file" caching method.
 *
 * @return  void
 *
 * @since   3.2
 */
function admin_postinstall_eaccelerator_action()
{
    $prev = new JConfig();
    $prev = JArrayHelper::fromObject($prev);
    $data = array('cacheHandler' => 'file');
    $data = array_merge($prev, $data);
    $config = new Registry('config');
    $config->loadArray($data);
    jimport('joomla.filesystem.path');
    jimport('joomla.filesystem.file');
    // Set the configuration file path.
    $file = JPATH_CONFIGURATION . '/configuration.php';
    // Get the new FTP credentials.
    $ftp = JClientHelper::getCredentials('ftp', true);
    // Attempt to make the file writeable if using FTP.
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'));
    }
    // Attempt to write the configuration file as a PHP class named JConfig.
    $configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
    if (!JFile::write($file, $configuration)) {
        JFactory::getApplication()->enqueueMessage(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error');
        return;
    }
    // Attempt to make the file unwriteable if using FTP.
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'));
    }
}
Beispiel #2
0
 function save($data)
 {
     // Get the previous configuration.
     if (is_object($data)) {
         $data = JArrayHelper::fromObject($data);
     }
     $prev = JTheFactoryHelper::getConfig();
     $prev = JArrayHelper::fromObject($prev);
     $data = array_merge($prev, $data);
     $configfile = JTheFactoryAdminHelper::getConfigFile();
     $config = new JRegistry('config');
     $config->loadArray($data);
     jimport('joomla.filesystem.path');
     jimport('joomla.filesystem.file');
     jimport('joomla.client.helper');
     // Get the new FTP credentials.
     $ftp = JClientHelper::getCredentials('ftp', true);
     // Attempt to make the file writeable if using FTP.
     if (!$ftp['enabled'] && JPath::isOwner($configfile) && !JPath::setPermissions($configfile, '0644')) {
         JError::raiseNotice(101, JText::_('FACTORY_SETTINGS_FILE_IS_NOT_WRITABLE'));
     }
     // Attempt to write the configuration file as a PHP class named JConfig.
     $configString = $config->toString('PHP', array('class' => ucfirst(APP_PREFIX) . "Config", 'closingtag' => false));
     if (!JFile::write($configfile, $configString)) {
         JError::raiseWarning(101, JText::_('FACTORY_SETTINGS_FILE_WRITE_FAILED'));
         return false;
     }
     // Attempt to make the file unwriteable if using FTP.
     if (!$ftp['enabled'] && JPath::isOwner($configfile) && !JPath::setPermissions($configfile, '0444')) {
         JError::raiseNotice(101, JText::_('FACTORY_SETTINGS_FILE_IS_NOT_WRITABLE'));
     }
     return true;
 }
Beispiel #3
0
 /**
  * shows the data formatted for the table view
  * @param string data
  * @param object all the data in the tables current row
  * @return string formatted value
  */
 function renderTableData($data, $oAllRowsData)
 {
     $str = '';
     $params =& $this->getParams();
     $w = $params->get('fb_gm_table_mapwidth');
     $h = $params->get('fb_gm_table_mapheight');
     $z = $params->get('fb_gm_table_zoomlevel');
     if (strstr($data, GROUPSPLITTER)) {
         $data = explode(GROUPSPLITTER, $data);
         foreach ($data as $d) {
             if ($params->get('fb_gm_staticmap_tableview')) {
                 $str .= $this->_staticMap($d, $w, $h);
             } else {
                 if ($params->get('fb_gm_staticmap_tableview_type_coords', 'num') == 'dms') {
                     $str .= $this->_dmsformat($d);
                 } else {
                     $str .= $this->_microformat($d);
                 }
             }
         }
     } else {
         if ($params->get('fb_gm_staticmap_tableview')) {
             $str .= $this->_staticMap($data, $w, $h, $z, 0, true, JArrayHelper::fromObject($oAllRowsData));
         } else {
             if ($params->get('fb_gm_staticmap_tableview_type_coords', 'num') == 'dms') {
                 $str .= $this->_dmsformat($data);
             } else {
                 $str .= $this->_microformat($data);
             }
         }
     }
     return $str;
 }
Beispiel #4
0
	/**
	 * @access private
	 *
	 * @param string data
	 * @param object all the data in the tables current row
	 * @return string formatted value
	 */

	function _renderListData($data, $oAllRowsData)
	{
		//$data = explode(GROUPSPLITTER2, $data);
		$data = FabrikWorker::JSONtoData($data, true);
		$listModel = $this->getlistModel();
		$params = $this->getParams();
		if (is_array($data)) {
			if (count($data) == 1) { $data[1] = $data[0];}
			if (empty($data[1]) && empty($data[0])) {
				return '';
			}
			$target = $params->get('link_target', '');
			if ($listModel->getOutPutFormat() != 'rss') {
				if (empty($data[1])) {
					$link = $data[0];
				}
				else {
					$smart_link = $params->get('link_smart_link', false);
					if ($smart_link || $target == 'mediabox') {
						$smarts = $this->_getSmartLinkType( $data[1]);
						$link = "<a href=\"" . $data[1] . "\" rel=\"lightbox[" . $smarts['type'] . " " . $smarts['width'] . " " . $smarts['height'] . "]\">" . $data[0] . "</a>";
					}
					else {
						$link = "<a href=\"" . $data[1] . "\" target=\"" .$target . "\">" . $data[0] . "</a>";
					}
				}
			} else {
				$link = $data[1];
			}
			$w = new FabrikWorker();
			$link = $listModel->parseMessageForRowHolder($link, JArrayHelper::fromObject($oAllRowsData));
			return $link;
		}
		return $data;
	}
Beispiel #5
0
 public function edit($key = null, $urlVar = null)
 {
     $app = JFactory::getApplication();
     $recordId = $app->input->getInt('id', 0);
     $response = array('status' => 1, 'error' => false, 'error_message' => '', 'message' => '', 'object' => array());
     try {
         parent::edit($key, $urlVar);
     } catch (Exception $e) {
         $response['status'] = 0;
         $response['error'] = true;
         $response['error_message'] = $e->getMessage();
         echo json_encode($response);
         $app->close();
     }
     $model = $this->getModel();
     $item = $model->getItem($recordId);
     if (empty($item) || empty($item->id)) {
         $response['status'] = 0;
         $response['error'] = true;
         $response['error_message'] = JText::_('COM_DJREVIEWS_ERROR_REVIEW_NOT_EXIST');
     } else {
         $response['object'] = JArrayHelper::fromObject($item, true);
     }
     echo json_encode($response);
     $app->close();
 }
Beispiel #6
0
 /**
  *  Displays the form
  * @param string $tpl   
  */
 public function _displayForm($tpl)
 {
     JHtml::_('behavior.formvalidation');
     $db = JFactory::getDBO();
     $uri = JFactory::getURI();
     $user = JFactory::getUser();
     $form = $this->get('Form');
     $lists = array();
     $editor = JFactory::getEditor();
     //get the item
     $item = $this->get('item');
     //Get Versions
     $model = $this->getModel();
     $archive = strtolower($item->name);
     $item->files = $model->getFiles($archive);
     if (!version_compare(JVERSION, '3.0', 'lt')) {
         $form->bind(JArrayHelper::fromObject($item));
     } else {
         $form->bind($item);
     }
     $isNew = $item->id < 1;
     // Edit or Create?
     if ($isNew) {
         // initialise new record
         $item->published = 1;
     }
     $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published);
     $this->form = $form;
     $this->lists = $lists;
     $this->item = $item;
     $this->isNew = $isNew;
     parent::display($tpl);
 }
Beispiel #7
0
 /**
  *  Displays the form
  * @param string $tpl   
  */
 public function _displayForm($tpl)
 {
     jimport('joomla.form.formvalidator');
     JHTML::stylesheet('fields.css', 'administrator/components/com_szavazasok/assets/');
     $db =& JFactory::getDBO();
     $uri =& JFactory::getURI();
     $user =& JFactory::getUser();
     $form = $this->get('Form');
     $lists = array();
     $editor =& JFactory::getEditor();
     //get the item
     $item =& $this->get('item');
     if (!version_compare(JVERSION, '3.0', 'lt')) {
         $form->bind(JArrayHelper::fromObject($item));
     } else {
         $form->bind($item);
     }
     $isNew = $item->id < 1;
     // Edit or Create?
     if ($isNew) {
         // initialise new record
         $item->published = 1;
     }
     $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published);
     $this->assign('form', $form);
     $this->assignRef('lists', $lists);
     $this->assignRef('editor', $editor);
     $this->assignRef('item', $item);
     $this->assignRef('isNew', $isNew);
     parent::display($tpl);
 }
Beispiel #8
0
 /**
  * Method to get the HTML output for specific fields
  **/
 function getFieldHTML($field, $showRequired = '&nbsp; *')
 {
     $fieldType = strtolower($field->type);
     if (is_array($field)) {
         jimport('joomla.utilities.arrayhelper');
         $field = JArrayHelper::toObject($field);
     }
     CFactory::load('libraries' . DS . 'fields', $fieldType);
     $class = 'CFields' . ucfirst($fieldType);
     if (is_object($field->options)) {
         $field->options = JArrayHelper::fromObject($field->options);
     }
     // Clean the options
     if (!empty($field->options) && !is_array($field->options)) {
         array_walk($field->options, array('JString', 'trim'));
     }
     // Escape the field name
     $field->name = $this->escape($field->name);
     if (!isset($field->value)) {
         $field->value = '';
     }
     if (class_exists($class)) {
         $object = new $class();
         if (method_exists($object, 'getFieldHTML')) {
             $html = $object->getFieldHTML($field, $showRequired);
             return $html;
         }
     }
     return JText::sprintf('CC UNKNOWN USER PROFILE TYPE', $class, $fieldType);
 }
Beispiel #9
0
 /**
  * Can the row be edited
  *
  * @param   object  $params     plugin params
  * @param   object  $listModel  list model
  * @param   object  $row        current row to test
  *
  * @return boolean
  */
 public function onCanEdit($params, $listModel, $row)
 {
     // If $row is null, we were called from the table's canEdit() in a per-table rather than per-row context,
     // and we don't have an opinion on per-table edit permissions, so just return true.
     if (is_null($row) || is_null($row[0])) {
         return true;
     }
     if (is_array($row[0])) {
         $data = JArrayHelper::toObject($row[0]);
     } else {
         $data = $row[0];
     }
     $field = str_replace('.', '___', $params->get('caneditrow_field'));
     // If they provided some PHP to eval, we ignore the other settings and just run their code
     $caneditrow_eval = $params->get('caneditrow_eval', '');
     // $$$ rob if no can edit field selected in admin return true
     if (trim($field) == '' && trim($caneditrow_eval) == '') {
         return true;
     }
     if (!empty($caneditrow_eval)) {
         $w = new FabrikWorker();
         $data = JArrayHelper::fromObject($data);
         $caneditrow_eval = $w->parseMessageForPlaceHolder($caneditrow_eval, $data);
         $caneditrow_eval = @eval($caneditrow_eval);
         FabrikWorker::logEval($caneditrow_eval, 'Caught exception on eval in can edit row : %s');
         return $caneditrow_eval;
     } else {
         // No PHP given, so just do a simple match on the specified element and value settings.
         if ($params->get('caneditrow_useraw', '0') == '1') {
             $field .= '_raw';
         }
         $value = $params->get('caneditrow_value');
         return $data->{$field} == $value;
     }
 }
Beispiel #10
0
 /**
  * Shows the data formatted for the list view
  *
  * @param   string  $data      elements data
  * @param   object  &$thisRow  all the data in the lists current row
  *
  * @return  string	formatted value
  */
 public function renderListData($data, &$thisRow)
 {
     $listModel = $this->getListModel();
     $params = $this->getParams();
     $w = $params->get('fb_gm_table_mapwidth');
     $h = $params->get('fb_gm_table_mapheight');
     $z = $params->get('fb_gm_table_zoomlevel');
     $data = FabrikWorker::JSONtoData($data, true);
     foreach ($data as $i => &$d) {
         if ($params->get('fb_gm_staticmap_tableview')) {
             $d = $this->_staticMap($d, $w, $h, null, $i, true, JArrayHelper::fromObject($thisRow));
         }
         if ($params->get('icon_folder') == '1') {
             // $$$ rob was returning here but that stoped us being able to use links and icons together
             $d = $this->_replaceWithIcons($d, 'list', $listModel->getTmpl());
         } else {
             if (!$params->get('fb_gm_staticmap_tableview')) {
                 $d = $params->get('fb_gm_staticmap_tableview_type_coords', 'num') == 'dms' ? $this->_dmsformat($d) : $this->_microformat($d);
             }
         }
         $d = $this->rollover($d, $thisRow, 'list');
         $d = $listModel->_addLink($d, $this, $thisRow, $i);
     }
     return $this->renderListDataFinal($data);
 }
Beispiel #11
0
 /**
  * Read list
  *
  * @param   object  $data  $limitStart, $limit, $filterSearch,
  *                         $filters, $ordering, $orderingDirection, $language
  *
  * @return  array
  */
 public function readList($data)
 {
     // We are setting the operation of the webservice to Read
     $this->setOperation('read');
     $dataGet = $this->webservice->options->get('dataGet', array());
     if (is_object($dataGet)) {
         $dataGet = JArrayHelper::fromObject($dataGet);
     }
     $dataGet['list']['limitstart'] = isset($data->limitStart) ? (int) $data->limitStart : 0;
     $dataGet['list']['limit'] = isset($data->limit) ? (int) $data->limit : 20;
     $dataGet['filter']['search'] = isset($data->filterSearch) ? (string) $data->filterSearch : '';
     $filters = RApiHalHelper::getFilterFields($this->webservice->configuration->operations->read->list, true);
     foreach ($filters as $filter) {
         $dataGet['filter'][$filter] = isset($data->filters->{$filter}) ? $data->filters->{$filter} : '';
     }
     $dataGet['list']['ordering'] = isset($data->ordering) ? (string) $data->ordering : '';
     $dataGet['list']['direction'] = isset($data->orderingDirection) ? (string) $data->orderingDirection : '';
     // Handle different language switch
     $this->setLanguage(isset($data->language) ? (string) $data->language : '');
     $this->webservice->options->set('dataGet', $dataGet);
     $this->webservice->options->set('task', '');
     $this->webservice->options->set('filterOutResourcesGroups', array('_links', '_messages'));
     $this->webservice->options->set('filterResourcesSpecific', 'listItem');
     $this->webservice->execute();
     $arr = $this->webservice->hal->toArray();
     $outputResources = RApiSoapHelper::getOutputResources($this->webservice->configuration->operations->read->list, 'listItem', true);
     if ($arr['_embedded'] && $arr['_embedded']['item']) {
         $response = RApiSoapHelper::selectListResources($outputResources, $arr['_embedded']['item']);
     } else {
         $response = array();
     }
     $final = new stdClass();
     $final->list = $response;
     return $final;
 }
Beispiel #12
0
 /**
  * create the pivot data
  * @return array of objects - first being the headings, subsequent the data
  */
 public function getPivot()
 {
     $model = $this->formModel->getTableModel();
     $params =& $model->getParams();
     $val = FabrikString::safeColName($params->get('pivot_value', ''));
     $xCol = FabrikString::safeColName($params->get('pivot_xcol', ''));
     $yCol = FabrikString::safeColName($params->get('pivot_ycol', ''));
     $db =& $model->getDb();
     $table =& $model->getTable();
     $join = $model->_buildQueryJoin();
     $where = $model->_buildQueryWhere();
     $db->setQuery("SELECT DISTINCT {$yCol} FROM {$table->db_table_name}");
     $yCols = $db->loadResultArray();
     $query = "select name,\n";
     $data = array();
     foreach ($yCols as $c) {
         $data[] = "SUM({$val}*(1-abs(sign(" . $yCol . "-" . $c . ")))) as exam" . $c . "\n";
     }
     $query .= implode(",", $data);
     $query .= "\nFROM " . $table->db_table_name . " {$join} {$where} group by {$xCol}";
     $db->setQuery($query);
     $data = $db->loadObjectList();
     $headings = JArrayHelper::toObject(array_keys(JArrayHelper::fromObject($data[0])));
     array_unshift($data, $headings);
     return $data;
 }
Beispiel #13
0
 function _loadConfig()
 {
     $jconf = new JConfig();
     $jconf->password = '******';
     $jconf->ftp_pass = '******';
     $jconf->secret = '*******';
     $this->data['Joomla Configuration'] = JArrayHelper::fromObject($jconf);
 }
Beispiel #14
0
 /**
  * shows the data formatted for the table view
  * @param string data
  * @param object all the data in the tables current row
  * @return string formatted value
  */
 function renderTableData($data, $oAllRowsData)
 {
     $fullName = $this->_getQRElement()->getFullName();
     $data = $oAllRowsData->{$fullName};
     $data = $this->_getQRElement()->getQRValue($data, JArrayHelper::fromObject($oAllRowsData));
     $data = $this->_renderTableData($data);
     return parent::renderTableData($data, $oAllRowsData);
 }
Beispiel #15
0
 /**
  * process the plugin, called when form is submitted
  *
  * @param object $params
  * @param object form
  */
 function onAfterProcess($params, &$formModel)
 {
     $this->formModel = $formModel;
     $emailData = $this->getEmailData();
     $post = JRequest::get('post');
     if (!array_key_exists('fabrik_mailchimp_signup', $post)) {
         return;
     }
     $listId = $params->get('mailchimp_listid');
     $apiKey = $params->get('mailchimp_apikey');
     if ($apiKey == '') {
         JError::raiseNotice(500, 'Mailchimp: no api key specified');
         return;
     }
     if ($listId == '') {
         JError::raiseNotice(500, 'Mailchimp: no list id specified');
         return;
     }
     $api = new MCAPI($params->get('mailchimp_apikey'));
     $opts = array();
     $emailKey = $formModel->getElement($params->get('mailchimp_email'), true)->getFullName();
     $firstNameKey = $formModel->getElement($params->get('mailchimp_firstname'), true)->getFullName();
     if ($params->get('mailchimp_lastname') !== '') {
         $lastNameKey = $formModel->getElement($params->get('mailchimp_lastname'), true)->getFullName();
         $lname = $formModel->_formDataWithTableName[$lastNameKey];
         $opts['LNAME'] = $lname;
     }
     $email = $formModel->_formDataWithTableName[$emailKey];
     $fname = $formModel->_formDataWithTableName[$firstNameKey];
     $opts['FNAME'] = $fname;
     $w = new FabrikWorker();
     $groupOpts = json_decode($params->get('mailchimp_groupopts', "[]"));
     if (!empty($groupOpts)) {
         foreach ($groupOpts as $groupOpt) {
             $groups = array();
             if (isset($groupOpt->groups)) {
                 $groupOpt->groups = $w->parseMessageForPlaceHolder($groupOpt->groups, $emailData);
                 $groups[] = JArrayHelper::fromObject($groupOpt);
                 //array('name'=>'Your Interests:', 'groups'=>'Bananas,Apples')
             }
         }
         $opts['GROUPINGS'] = $groups;
     }
     // By default this sends a confirmation email - you will not see new members
     // until the link contained in it is clicked!
     $emailType = $params->get('mailchimp_email_type', 'html');
     $doubleOptin = (bool) $params->get('mailchimp_double_optin', true);
     $updateExisting = (bool) $params->get('mailchimp_update_existing');
     $retval = $api->listSubscribe($listId, $email, $opts, $emailType, $doubleOptin, $updateExisting);
     if ($api->errorCode) {
         $formModel->_arErrors['mailchimp_error'] = true;
         JError::raiseNotice(500, $api->errorCode . ':' . $api->errorMessage);
         return false;
     } else {
         return true;
     }
 }
Beispiel #16
0
	/**
	 * do the plugin action
	 * @return number of records updated
	 */

	function process(&$data)
	{
		$app = JFactory::getApplication();
		jimport('joomla.mail.helper');
		$params = $this->getParams();
		$msg = $params->get('message');
		$to = $params->get('to');
		$w = new FabrikWorker();
		$MailFrom = $app->getCfg('mailfrom');
		$FromName = $app->getCfg('fromname');
		$subject = $params->get('subject', 'Fabrik cron job');
		$eval = $params->get('cronemail-eval');
		$condition = $params->get('cronemail_condition', '');
		$updates = array();
		foreach ($data as $group) {
			if (is_array($group)) {
				foreach ($group as $row) {
					if (!empty($condition)) {
						$this_condition = $w->parseMessageForPlaceHolder($condition, $row);
						if (eval($this_condition === false)) {
							continue;
						}
					}
					$row = JArrayHelper::fromObject($row);
					$thisto = $w->parseMessageForPlaceHolder($to, $row);
					if (JMailHelper::isEmailAddress($thisto)) {
						$thismsg = $w->parseMessageForPlaceHolder($msg, $row);
						if ($eval) {
							$thismsg = eval($thismsg);
						}
						$thissubject = $w->parseMessageForPlaceHolder($subject, $row);
						$res = JUTility::sendMail( $MailFrom, $FromName, $thisto, $thissubject, $thismsg, true);
					}
					$updates[] = $row['__pk_val'];

				}
			}
		}
		$field = $params->get('cronemail-updatefield');
		if (!empty( $updates) && trim($field ) != '') {
			//do any update found
			$listModel = JModel::getInstance('list', 'FabrikFEModel');
			$listModel->setId($params->get('table'));
			$table = $listModel->getTable();

			$connection = $params->get('connection');
			$field = $params->get('cronemail-updatefield');
			$value = $params->get('cronemail-updatefield-value');

			$field = str_replace("___", ".", $field);
			$query = "UPDATE $table->db_table_name set $field = " . $fabrikDb->Quote($value) . " WHERE $table->db_primary_key IN (" . implode(',', $updates) . ")";
			$fabrikDb = $listModel->getDb();
			$fabrikDb->setQuery($query);
			$fabrikDb->query();
		}
		return count($updates);
	}
Beispiel #17
0
 /**
  * display a json object representing the table data.
  */
 function display()
 {
     $model = $this->getModel();
     $model->setId(JRequest::getInt('listid'));
     $table = $model->getTable();
     $params = $model->getParams();
     //$this->assign('emptyDataMessage', $this->get('EmptyDataMsg'));
     $rowid = JRequest::getInt('rowid');
     list($this->headings, $groupHeadings, $this->headingClass, $this->cellClass) = $this->get('Headings');
     $data = $model->render();
     $this->assign('emptyDataMessage', $this->get('EmptyDataMsg'));
     $nav = $model->getPagination();
     $form = $model->getFormModel();
     $c = 0;
     foreach ($data as $groupk => $group) {
         foreach ($group as $i => $x) {
             $o = new stdClass();
             if (is_object($data[$groupk])) {
                 $o->data = JArrayHelper::fromObject($data[$groupk]);
             } else {
                 $o->data = $data[$groupk][$i];
             }
             $o->cursor = $i + $nav->limitstart;
             $o->total = $nav->total;
             $o->id = 'list_' . $model->getRenderContext() . '_row_' . @$o->data->__pk_val;
             $o->class = 'fabrik_row oddRow' . $c;
             if (is_object($data[$groupk])) {
                 $data[$groupk] = $o;
             } else {
                 $data[$groupk][$i] = $o;
             }
             $c = 1 - $c;
         }
     }
     $groups = $form->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         $elementModels = $groupModel->getPublishedElements();
         foreach ($elementModels as $elementModel) {
             $elementModel->setContext($groupModel, $form, $model);
             $elementModel->setRowClass($data);
         }
     }
     // $$$ hugh - heading[3] doesn't exist any more?  Trying [0] instead.
     $d = array('id' => $table->id, 'listRef' => JRequest::getVar('listref'), 'rowid' => $rowid, 'model' => 'list', 'data' => $data, 'headings' => $this->headings, 'formid' => $model->getTable()->form_id, 'lastInsertedRow' => JFactory::getSession()->get('lastInsertedRow', 'test'));
     $d['nav'] = $nav->getProperties();
     $d['htmlnav'] = $params->get('show-table-nav', 1) ? $nav->getListFooter($model->getId(), $this->getTmpl()) : '';
     $d['calculations'] = $model->getCalculations();
     // $$$ hugh - see if we have a message to include, set by a list plugin
     $context = 'com_fabrik.list' . $model->getRenderContext() . '.msg';
     $session = JFactory::getSession();
     if ($session->has($context)) {
         $d['msg'] = $session->get($context);
         $session->clear($context);
     }
     echo json_encode($d);
 }
Beispiel #18
0
 /**
  * Empties the state
  *
  * @return unknown_type
  */
 public function emptyState()
 {
     $state = JArrayHelper::fromObject($this->getState());
     foreach ($state as $key => $value) {
         if (substr($key, '0', '1') != '_') {
             $this->setState($key, '');
         }
     }
     return $this->getState();
 }
Beispiel #19
0
 /**
  * Method to get the Component
  *
  * @access public
  * @return object item
  */
 public function getItem()
 {
     static $instance;
     if ($instance) {
         return $instance;
     }
     $item =& $this->getTable();
     $params = json_decode($item->params);
     $item->load($this->_id);
     $item->params = new JObject();
     $item->params->setProperties(JArrayHelper::fromObject($params));
     $instance = $item;
     return $instance;
 }
Beispiel #20
0
 /**
  * Short cut for getting the element's filter value
  *
  * @param   int  $elementId  Element id
  *
  * @since   3.0.7
  *
  * @return  string
  */
 public static function filterValue($elementId)
 {
     $app = JFactory::getApplication();
     $pluginManager = FabrikWorker::getPluginManager();
     $model = $pluginManager->getElementPlugin($elementId);
     $listModel = $model->getListModel();
     $listid = $listModel->getId();
     $key = 'com_fabrik.list' . $listid . '_com_fabrik_' . $listid . '.filter';
     $filters = JArrayHelper::fromObject($app->getUserState($key));
     $elementIds = (array) JArrayHelper::getValue($filters, 'elementid', array());
     $index = array_search($elementId, $elementIds);
     $value = $filters['value'][$index];
     return $value;
 }
Beispiel #21
0
 function display()
 {
     jimport('joomla.form.form');
     $form = JForm::getInstance('config', $this->formxml);
     $cfg = JTheFactoryHelper::getConfig();
     $data = JArrayHelper::fromObject($cfg);
     $form->bind($data);
     $groups = JTheFactoryConfigHelper::getFieldGroups($this->formxml);
     JTheFactoryEventsHelper::triggerEvent('onDisplaySettings', array($form, $groups, $data));
     $view = $this->getView('settings');
     $view->assignRef('groups', $groups);
     $view->assignRef('form', $form);
     $view->assignRef('formxml', $this->formxml);
     $view->display();
 }
Beispiel #22
0
 /**
  * get html form fields for a plugin (filled with
  * current element's plugin data
  * @param string $plugin
  * @return string html form fields
  */
 function getPluginHTML($plugin = null)
 {
     $item = $this->getItem();
     if (is_null($plugin)) {
         $plugin = $item->plugin;
     }
     JPluginHelper::importPlugin('fabrik_cron');
     $pluginManager = JModel::getInstance('Pluginmanager', 'FabrikFEModel');
     if ($plugin == '') {
         $str = JText::_('COM_FABRIK_SELECT_A_PLUGIN');
     } else {
         $plugin = $pluginManager->getPlugIn($plugin, 'Cron');
         $str = $plugin->onRenderAdminSettings(JArrayHelper::fromObject($item));
     }
     return $str;
 }
 /**
  * Method to get an ojbect.
  *
  * @param	integer	The id of the object to get.
  *
  * @return	mixed	Object on success, false on failure.
  */
 public function &getData($id = null)
 {
     if ($this->_item === null) {
         $this->_item = false;
         if (empty($id)) {
             $id = $this->getState('comment.id');
         }
         // Get a level row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         if ($table->load($id)) {
             // Check published state.
             if ($published = $this->getState('filter.published')) {
                 if ($table->state != $published) {
                     return $this->_item;
                 }
             }
             // Convert the JTable to a clean JObject.
             $properties = $table->getProperties(1);
             $this->_item = JArrayHelper::toObject($properties, 'JObject');
         } elseif ($error = $table->getError()) {
             $this->setError($error);
         }
     }
     if (isset($this->_item->poiid) && $this->_item->poiid != '') {
         if (is_object($this->_item->poiid)) {
             $this->_item->poiid = JArrayHelper::fromObject($this->_item->poiid);
         }
         $values = is_array($this->_item->poiid) ? $this->_item->poiid : explode(',', $this->_item->poiid);
         $textValue = array();
         foreach ($values as $value) {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('title')->from('`#__citybranding_pois`')->where('id = ' . $db->quote($db->escape($value)));
             $db->setQuery($query);
             $results = $db->loadObject();
             if ($results) {
                 $textValue[] = $results->title;
             }
         }
         $this->_item->poiid = !empty($textValue) ? implode(', ', $textValue) : $this->_item->poiid;
     }
     if (isset($this->_item->created_by)) {
         $this->_item->created_by_name = JFactory::getUser($this->_item->created_by)->name;
     }
     return $this->_item;
 }
Beispiel #24
0
 /**
  * Display a json object representing the table data.
  *
  * @return  void
  */
 public function display()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $model = JModelLegacy::getInstance('List', 'FabrikFEModel');
     $model->setId($input->getInt('listid'));
     $this->setModel($model, true);
     $item = $model->getTable();
     $params = $model->getParams();
     $model->render();
     $this->emptyDataMessage = $params->get('empty_data_msg');
     $rowid = $input->getString('rowid', '', 'string');
     list($this->headings, $groupHeadings, $this->headingClass, $this->cellClass) = $this->get('Headings');
     $data = $model->getData();
     $nav = $model->getPagination();
     $c = 0;
     foreach ($data as $groupk => $group) {
         foreach ($group as $i => $x) {
             $o = new stdClass();
             if (is_object($data[$groupk])) {
                 $o->data = JArrayHelper::fromObject($data[$groupk]);
             } else {
                 $o->data = $data[$groupk][$i];
             }
             $o->cursor = $i + $nav->limitstart;
             $o->total = $nav->total;
             $o->id = 'list_' . $item->id . '_row_' . @$o->data->__pk_val;
             $o->class = "fabrik_row oddRow" . $c;
             if (is_object($data[$groupk])) {
                 $data[$groupk] = $o;
             } else {
                 $data[$groupk][$i] = $o;
             }
             $c = 1 - $c;
         }
     }
     // $$$ hugh - heading[3] doesn't exist any more?  Trying [0] instead.
     $d = array('id' => $item->id, 'rowid' => $rowid, 'model' => 'list', 'data' => $data, 'headings' => $this->headings, 'formid' => $model->getTable()->form_id, 'lastInsertedRow' => JFactory::getSession()->get('lastInsertedRow', 'test'));
     $d['nav'] = $nav->getProperties();
     $d['htmlnav'] = $params->get('show-table-nav', 1) ? $nav->getListFooter($model->getId(), $this->getTmpl()) : '';
     $d['calculations'] = $model->getCalculations();
     $msg = $app->getMessageQueue();
     if (!empty($msg)) {
         $d['msg'] = $msg[0]['message'];
     }
     echo json_encode($d);
 }
Beispiel #25
0
 /**
  * @access private
  *
  * @param string data
  * @param object all the data in the tables current row
  * @return string formatted value
  */
 function _renderTableData($data, $oAllRowsData, $repeatCounter)
 {
     $data = explode(GROUPSPLITTER2, $data);
     $tableModel =& $this->getTableModel();
     $params =& $this->getParams();
     $watch_element = str_replace('.', '___', $params->get('fabrikweather_watch'));
     $watch_element_raw = $watch_element . '_raw';
     if (array_key_exists($watch_element_raw, $oAllRowsData)) {
         if (!empty($oAllRowsData->{$watch_element_raw})) {
             $watch = $oAllRowsData->{$watch_element_raw};
             $watch = explode(GROUPSPLITTER, $watch);
             $watch = $watch[$repeatCounter];
         }
     }
     $html = $this->_render($watch, JArrayHelper::fromObject($oAllRowsData), 'table', $repeatCounter);
     return $html;
 }
Beispiel #26
0
 private function _getDefault()
 {
     if (!isset($this->value[0])) {
         return array();
     }
     if (is_string($this->value[0])) {
         $files = JTable::getInstance('Files', 'CobaltTable');
         return $files->getFiles($this->value, 'filename');
     }
     if (is_object($this->value[0])) {
         foreach ($this->value as $key => $value) {
             $def[$key] = JArrayHelper::fromObject($value);
         }
         return $def;
     }
     return array();
 }
 /**
  * Method to get the configuration data.
  *
  * This method will load the global configuration data straight from
  * JConfig. If configuration data has been saved in the session, that
  * data will be merged into the original data, overwriting it.
  *
  * @return	array  An array containg all global config data.
  *
  * @since	1.6
  */
 public function getData()
 {
     // Get the config data.
     $config = new JConfig();
     $data = JArrayHelper::fromObject($config);
     // Prime the asset_id for the rules.
     $data['asset_id'] = 1;
     // Get the text filter data
     $params = JComponentHelper::getParams('com_config');
     // Check for data in the session.
     $temp = JFactory::getApplication()->getUserState('com_config.config.global.data');
     // Merge in the session data.
     if (!empty($temp)) {
         $data = array_merge($data, $temp);
     }
     return $data;
 }
Beispiel #28
0
 /**
  * Method to get an ojbect.
  *
  * @param	integer	The id of the object to get.
  *
  * @return	mixed	Object on success, false on failure.
  */
 public function &getData($id = null)
 {
     if ($this->_item === null) {
         $this->_item = false;
         if (empty($id)) {
             $id = $this->getState('files.id');
         }
         // Get a level row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         if ($table->load($id)) {
             // Check published state.
             if ($published = $this->getState('filter.published')) {
                 if ($table->state != $published) {
                     return $this->_item;
                 }
             }
             // Convert the JTable to a clean JObject.
             $properties = $table->getProperties(1);
             $this->_item = JArrayHelper::toObject($properties, 'JObject');
         } elseif ($error = $table->getError()) {
             $this->setError($error);
         }
     }
     if (isset($this->_item->created_by)) {
         $this->_item->created_by_name = JFactory::getUser($this->_item->created_by)->name;
     }
     if (isset($this->_item->whatbanner) && $this->_item->whatbanner != '') {
         if (is_object($this->_item->whatbanner)) {
             $this->_item->whatbanner = JArrayHelper::fromObject($this->_item->whatbanner);
         }
         $values = is_array($this->_item->whatbanner) ? $this->_item->whatbanner : explode(',', $this->_item->whatbanner);
         $textValue = array();
         foreach ($values as $value) {
             $db = JFactory::getDbo();
             $query = "SELECT alias \r\nFROM  #__banners WHERE alias LIKE '" . $value . "'";
             $db->setQuery($query);
             $results = $db->loadObject();
             if ($results) {
                 $textValue[] = $results->alias;
             }
         }
         $this->_item->whatbanner = !empty($textValue) ? implode(', ', $textValue) : $this->_item->whatbanner;
     }
     return $this->_item;
 }
Beispiel #29
0
 /**
  * Get a value from a nested array
  *
  * @param   array   $array         Data to search
  * @param   string  $key           Search key, use key.dot.format to get nested value
  * @param   string  $default       Default value if key not found
  * @param   bool    $allowObjects  Should objects found in $array be converted into arrays
  *
  * @return  mixed
  */
 public static function getNestedValue($array, $key, $default = null, $allowObjects = false)
 {
     $keys = explode('.', $key);
     foreach ($keys as $key) {
         if (is_object($array) && $allowObjects) {
             $array = JArrayHelper::fromObject($array);
         }
         if (!is_array($array)) {
             return $default;
         }
         if (array_key_exists($key, $array)) {
             $array = $array[$key];
         } else {
             return $default;
         }
     }
     return $array;
 }
 protected function __save($data, $dataInsert)
 {
     if ($dataInsert && count($dataInsert)) {
         $registry = new JRegistry();
         if ($data && !empty($data) && isset($data->media) && !is_object($data->media)) {
             // Process data
             $registry->loadString($data->media);
             if ($registry->get($this->getName())) {
                 $old_data = JArrayHelper::fromObject($registry->get($this->getName()));
                 $dataInsert = array_merge($old_data, $dataInsert);
             }
         }
         // Store data to database
         $registry->set($this->getName(), $dataInsert);
         $data->media = $registry->toString();
         $data->store();
     }
 }