Пример #1
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;
     }
 }
Пример #2
0
 /**
  * Method to get an ojbect.
  *
  * @param	integer	The id of the object to get.
  *
  * @return	mixed	Object on success, false on failure. FIGYELEM!!! alternativák tömb is!!!!!
  */
 public function &getItem($id = null)
 {
     $db = JFactory::getDBO();
     if ($this->_item === null) {
         $this->_item = false;
         if (empty($id)) {
             $id = $this->getState('alternativak.id');
         }
         // Get a level row instance.
         $table = JTable::getInstance('Alternativak', 'Table');
         // Attempt to load the row.
         if ($id == null | $id == 0) {
             // rekord init felvitelhez
             $user = JFactory::getUser();
             $this->_item = new stdclass();
             $this->_item->id = 0;
             $this->_item->megnevezes = '';
             $this->_item->leiras = '';
             $this->_item->temakor_id = JRequest::getVar('temakor', 0);
             $this->_item->szavazas_id = JRequest::getVar('szavazas', 0);
             $this->_item->letrehozo = $user->id;
             $this->_item->letrehozva = date('Y-m-d H:i:s');
         } else {
             if ($table->load($id)) {
                 // Convert the JTable to a clean JObject.
                 $this->_item = JArrayHelper::toObject($table->getProperties(1), 'JObject');
             } else {
                 if ($error = $table->getError()) {
                     $this->setError($error);
                 }
             }
         }
     }
     return $this->_item;
 }
Пример #3
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('user.id');
         }
         // Get a level row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         if ($table !== false && $table->load($id)) {
             $user = JFactory::getUser();
             $id = $table->id;
             $canEdit = $user->authorise('core.edit', 'com_db8download') || $user->authorise('core.create', 'com_db8download');
             if (!$canEdit && $user->authorise('core.edit.own', 'com_db8download')) {
                 $canEdit = $user->id == $table->created_by;
             }
             if (!$canEdit) {
                 throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 500);
             }
             // 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');
         }
     }
     return $this->_item;
 }
Пример #4
0
 /**
  * Method to get a single record.
  *
  * @param     integer $pk   The id of the primary key.
  * @return    mixed   $item   Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? (int) $pk : (int) $this->getState($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties(1);
     $item = JArrayHelper::toObject($properties, 'JObject');
     // Convert attributes to JRegistry params
     $item->params = new JRegistry();
     $item->params->loadString($item->attribs);
     $item->attribs = $item->params->toArray();
     // Get the attachments
     $item->attachment = array();
     if (PFApplicationHelper::exists('com_pfrepo')) {
         $attachments = $this->getInstance('Attachments', 'PFrepoModel');
         $item->attachment = $attachments->getItems('com_pfforum.topic', $item->id);
     }
     // Get the labels
     $model_labels = $this->getInstance('Labels', 'PFModel');
     $item->labels = $model_labels->getConnections('com_pfforum.topic', $item->id);
     return $item;
 }
Пример #5
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 &getItem($id = null)
 {
     if ($this->_item === null) {
         $this->_item = false;
         if (empty($id)) {
             $id = $this->getState('weblink.id');
         }
         // Get a level row instance.
         $table = JTable::getInstance('Weblink', 'WeblinksTable');
         // 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');
         } else {
             if ($error = $table->getError()) {
                 $this->setError($error);
             }
         }
     }
     return $this->_item;
 }
Пример #6
0
 /**
  * Method to get a single record.
  *
  * @param     integer    $pk      The id of the primary key.
  * @return    mixed      $item    Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties(1);
     $item = JArrayHelper::toObject($properties, 'JObject');
     // Convert attributes to JRegistry params
     $item->params = new JRegistry();
     $item->params->loadString($item->attribs);
     $item->attribs = $item->params->toArray();
     // Convert seconds back to minutes
     if ($item->log_time > 0) {
         $item->log_time = round($item->log_time / 60);
     }
     return $item;
 }
Пример #7
0
 function emailFriend()
 {
     JRequest::checkToken() or jexit('Invalid Token');
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_member.php';
     $app = JFactory::getApplication();
     if (JobBoardHelper::verifyHumans()) {
         if (!JobBoardMemberHelper::matchHumanCode(JRequest::getString('human_ver', ''))) {
             $post = JArrayHelper::toObject(JRequest::get('post'));
             $post->errors = 1;
             if (isset($post->human_ver)) {
                 unset($post->human_ver);
             }
             $app->setUserState('com_jobboard.sfields', $post);
             $app->redirect(JRoute::_('index.php?option=com_jobboard&view=share&errors=1&job_id=' . $post->job_id . '&Itemid=' . JRequest::getInt('Itemid')), JText::_('COM_JOBBOARD_FORM_CAPTCHA_FAILMSG'), 'error');
             return;
         }
     }
     $message = new JObject();
     $message->job_id = JRequest::getVar('job_id', '', '', 'int');
     $catid = JRequest::getVar('catid', '', '', 'int');
     $message->job_title = JRequest::getVar('job_title', '', '', 'string');
     $message->job_city = JRequest::getVar('job_city', '', '', 'string');
     $message->personal_message = JRequest::getVar('personal_message', '', '', 'string');
     $uri =& JURI::getInstance();
     $message->link = $uri->getScheme() . '://' . $uri->getHost() . JRequest::getVar('job_path', '', '', 'string');
     $fields_valid = $this->validateFields();
     $message->sender_email = $fields_valid->sender_email;
     $message->sender_name = $fields_valid->sender_name;
     $message->rec_emails = $fields_valid->rec_emails;
     if ($fields_valid->errors === true) {
         $errmsg = $fields_valid->errmsg . '</ul>';
         $app->setUserState('sfields', $message);
         $link = JRoute::_('index.php?option=com_jobboard&view=share&errors=1&job_id=' . $message->job_id . '&Itemid=' . $itemid);
         $this->setRedirect($link, $errmsg, '');
         return;
     } else {
         if (stristr($message->rec_emails, ',') === TRUE) {
             $rec_emailarray = explode(',', $message->rec_emails);
             foreach ($rec_emailarray as $email_recipient) {
                 $this->sendEmail($message, trim($email_recipient));
             }
         } else {
             $this->sendEmail($message, trim($message->rec_emails));
         }
         $mesgModel =& $this->getModel('Message');
         $saved = $mesgModel->saveMessage($message);
         if ($saved) {
             $msg = '&nbsp;' . JText::_('SEND_MSG_SUCCESS');
             $link = JRoute::_('index.php?option=com_jobboard&view=job&id=' . $message->job_id, false);
             $this->setRedirect($link, $msg, '');
             return;
         } else {
             $msg = '&nbsp;' . JText::_('ERR_WAIT');
             $link = JRoute::_('index.php?option=com_jobboard&view=job&id=' . $message->job_id, false);
             $this->setRedirect($link, $msg, '');
             return;
         }
     }
     parent::display();
 }
 public function __construct(JDocumentHTML $template)
 {
     if (!$template instanceof JDocumentHTML) {
         return false;
     }
     $this->_template = $template;
     $this->_params = $template->params;
     $menu = JFactory::getApplication()->getMenu();
     $activeMenu = $menu->getActive();
     //merge menu params with template params
     jimport('joomla.utilities.arrayhelper');
     $params = array_merge($activeMenu->params->toArray(), $this->_params->toArray());
     $this->params = JArrayHelper::toObject($params, 'JRegistry');
     // check for position
     $this->show_top = $template->countModules('top');
     $this->show_top_left = $template->countModules('top-left');
     $this->show_top_center = $template->countModules('top-center');
     $this->show_top_right = $template->countModules('top-right');
     $this->show_user1 = $template->countModules('user1');
     $this->show_user2 = $template->countModules('user2');
     $this->show_user3 = $template->countModules('user3');
     $this->show_content_header = $template->countModules('content-header');
     $this->show_content_footer = $template->countModules('content-footer');
     $this->show_left = $template->countModules('left');
     $this->show_right = $template->countModules('right');
     $this->show_bottom_left = $template->countModules('bottom-left');
     $this->show_bottom_center = $template->countModules('bottom-center');
     $this->show_bottom_right = $template->countModules('bottom-right');
     $this->show_bottom = $template->countModules('bottom');
     $this->show_bottom_socials = $template->countModules('bottom-socials');
     $this->show_footer = $template->countModules('footer');
 }
Пример #9
0
 /**
  * Event method that runs on content preparation
  *
  * @param   JForm    $form  The form object
  * @param   integer  $data  The form data
  *
  * @return bool
  */
 public function onContentPrepareForm($form, $data)
 {
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     $name = $form->getName();
     if (!in_array($name, array('com_content.article'))) {
         return true;
     }
     $include_categories = $this->params->get('include_categories');
     if (empty($include_categories)) {
         return true;
     }
     if (empty($data)) {
         $input = JFactory::getApplication()->input;
         $data = (object) $input->post->get('jform', array(), 'array');
     }
     if (is_array($data)) {
         jimport('joomla.utilities.arrayhelper');
         $data = JArrayHelper::toObject($data);
     }
     if (empty($data->catid)) {
         return true;
     }
     if (!in_array($data->catid, $include_categories)) {
         return true;
     }
     JForm::addFormPath(__DIR__ . '/form');
     $form->loadFile('form');
     if (!empty($data->id)) {
         $data = $this->loadTest($data);
     }
     return true;
 }
Пример #10
0
 /**
  * Method to get a single record.
  *
  * @param	integer	The id of the primary key.
  *
  * @return	mixed	Object on success, false on failure.
  */
 public function &getItem($pk = null)
 {
     // Initialise variables.
     $pk = !empty($pk) ? $pk : (int) $this->getState('user.id');
     $false = false;
     // Get a row instance.
     $table =& $this->getTable();
     // Attempt to load the row.
     $return = $table->load($pk);
     // Check for a table object error.
     if ($return === false && $table->getError()) {
         $this->setError($table->getError());
         return $false;
     }
     // Prime required properties.
     if (empty($table->id)) {
         // Prepare data for a new record.
     }
     // Convert to the JObject before adding other data.
     $value = JArrayHelper::toObject($table->getProperties(1), 'JObject');
     $value->profile = new JObject();
     // Get the dispatcher and load the users plugins.
     $dispatcher =& JDispatcher::getInstance();
     JPluginHelper::importPlugin('user');
     // Trigger the data preparation event.
     $results = $dispatcher->trigger('onPrepareUserProfileData', array($table->id, &$value));
     // Convert the params field to an array.
     $registry = new JRegistry();
     $registry->loadJSON($value->params);
     $value->params = $registry->toArray();
     return $value;
 }
Пример #11
0
 /**
  * Decorate the J2Store product information with its related Fabrik record
  *
  * @param $product
  *
  * @return object
  */
 private function getFabrikItem(&$product)
 {
     list($component, $listId) = explode('.', $product->product_source);
     $key = $listId . '.' . $product->product_source_id;
     static $sets;
     if (!is_array($sets)) {
         $sets = array();
     }
     if (!isset($sets[$key])) {
         JModelLegacy::addIncludePath(COM_FABRIK_FRONTEND . '/models', 'FabrikFEModel');
         /** @var FabrikFEModelList $listModel */
         $listModel = JModelLegacy::getInstance('List', 'FabrikFEModel');
         $listModel->setId($listId);
         $formModel = $listModel->getFormModel();
         $formModel->setRowId($product->product_source_id);
         $row = $formModel->getData();
         $params = $formModel->getParams();
         $index = array_search('j2store', (array) $params->get('plugins', array(), 'array'));
         $w = new FabrikWorker();
         $plugIn = FabrikWorker::getPluginManager()->loadPlugIn('j2store', 'form');
         // Set params relative to plugin render order
         $plugInParams = $plugIn->setParams($params, $index);
         $context = new stdClass();
         $context->title = $w->parseMessageForPlaceHolder($plugInParams->get('j2store_product_name'), $row);
         $context->published = $w->parseMessageForPlaceHolder($plugInParams->get('j2store_enabled'), $row);
         $objectRow = JArrayHelper::toObject($row);
         $context->viewLink = $listModel->viewDetailsLink($objectRow);
         $context->editLink = $listModel->editLink($objectRow);
         $context->id = $objectRow->__pk_val;
         $sets[$key] = $context;
     }
     //echo "<pre>";print_r($sets);echo "</pre>";
     return $sets[$key];
 }
Пример #12
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('vistamapa.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');
         }
     }
     $this->_item->nom_entidad = JText::_('COM_MAPA_MAPVENEZUELA_NOM_ENTIDAD_OPTION_' . $this->_item->nom_entidad);
     $this->_item->col_entidad = JText::_('COM_MAPA_MAPVENEZUELA_COL_ENTIDAD_OPTION_' . $this->_item->col_entidad);
     return $this->_item;
 }
Пример #13
0
 /**
  * @param null $pk
  * @return array|mixed|object
  * @throws Exception
  */
 public function getItem($pk = NULL)
 {
     $id = JFactory::getApplication()->input->get('id', NULL, 'INT');
     //判断$id 是否存在 存在调用数据库 不存在为$item 赋空值
     if ($id) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('*')->from($db->quoteName('#__gasmanagement'))->where($db->quoteName('id') . "=" . $db->quote($id));
         $db->setQuery($query);
         try {
             $item = $db->loadObject();
         } catch (Exception $e) {
             $this->setError($e->getMessage());
         }
         if (!$item) {
             $item = array('id' => '', 'name' => '', 'brand' => '', 'standard' => '');
             $item = JArrayHelper::toObject($item, 'JObject');
         }
         return $item;
     } else {
         $item = array('id' => '', 'name' => '', 'brand' => '', 'standard' => '');
         $item = JArrayHelper::toObject($item, 'JObject');
         return $item;
     }
 }
Пример #14
0
 function _exportCSV($ids)
 {
     header('Content-Description: File Transfer');
     header('Content-Type: application/vnd.ms-excel');
     header('Content-disposition: attachment; filename="users.csv"');
     $model = CFactory::getModel('Profile');
     $lang =& JFactory::getLanguage();
     $lang->load('com_community', JPATH_ROOT);
     foreach ($ids as $id) {
         $user = CFactory::getUser($id);
         $profile = $model->getEditableProfile($id, $user->getProfileType());
         $profileType = JTable::getInstance('MultiProfile', 'CTable');
         $profileType->load($user->getProfileType());
         echo $user->id . ',' . $profileType->getName() . ',' . $user->name . ',' . $user->username . ',' . $user->email . ',' . $user->getThumbAvatar() . ',' . $user->getAvatar() . ',' . $user->getKarmaPoint() . ',';
         echo $user->registerDate . ',' . $user->lastvisitDate . ',' . $user->block . ',' . $user->getStatus() . ',' . $user->getViewCount() . ',' . $user->getAlias() . ',' . $user->getFriendCount();
         foreach ($profile['fields'] as $group => $groupFields) {
             foreach ($groupFields as $field) {
                 $field = JArrayHelper::toObject($field);
                 $field->value = $field->value;
                 echo $field->value . ",";
             }
         }
         echo "\r\n";
     }
     exit;
 }
Пример #15
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 &getItem($id = null)
 {
     if ($this->_item === null) {
         $this->_item = false;
         if (empty($id)) {
             $id = $this->getState('temakorok.id');
         }
         // Get a level row instance.
         $table = JTable::getInstance('Temakorok', 'Table');
         // Attempt to load the row.
         if ($table->load($id)) {
             // Convert the JTable to a clean JObject.
             $this->_item = JArrayHelper::toObject($table->getProperties(1), 'JObject');
             $db = JFactory::getDBO();
             $db->setQuery('select * from #__beallitasok where id = (10+' . $id . ')');
             $res = $db->loadObject();
             if ($res) {
                 $this->_item->json = $res->json;
             } else {
                 $this->_item->json = '{}';
             }
         } else {
             if ($error = $table->getError()) {
                 $this->setError($error);
             }
         }
     }
     return $this->_item;
 }
Пример #16
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('einsatzbericht.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);
             //$properties[test]= 'testvalue';print_r ($properties);
             $this->_item = JArrayHelper::toObject($properties, 'JObject');
         } elseif ($error = $table->getError()) {
             $this->setError($error);
         }
     }
     return $this->_item;
 }
Пример #17
0
 protected function preprocessForm(\JForm $form, $data, $group = 'content')
 {
     // if no data, grab the posted form data.
     if (!$data instanceof JObject) {
         $data = JFactory::getApplication()->input->get('jform', $data, 'array');
         $data = JArrayHelper::toObject($data);
     }
     $params = new JRegistry();
     $params->loadArray($data->params);
     if ($params->get('discovery.url')) {
         $plugin = $params->get('discovery.type');
         $language = JFactory::getLanguage();
         $language->load('plg_harvest_' . $plugin);
         $path = JPATH_ROOT . '/plugins/harvest/' . $plugin . '/forms/harvest.xml';
         $form->loadFile($path, false);
         foreach (JPluginHelper::getPlugin('ingest') as $plugin) {
             $language->load('plg_ingest_' . $plugin->name);
             $path = JPATH_ROOT . '/plugins/ingest/' . $plugin->name . '/forms/ingest.xml';
             $form->loadFile($path, false);
         }
         $form->removeField('originating_url');
         $form->removeField('harvester');
         // hide the run_once value (users cannot set it after discovery)
         $form->setFieldAttribute("run_once", 'type', 'hidden');
         $form->setFieldAttribute("run_once", 'class', '');
     } else {
         $form->removeField('state');
         $form->removeField('harvested');
         $form->removeField('url', 'params.discovery');
         $form->removeField('type', 'params.discovery');
     }
     parent::preprocessForm($form, $data, $group);
 }
 /**
  * Method to get a single record.
  *
  * @param     integer    The id of the primary key.
  * @return    mixed      Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? (int) $pk : (int) $this->getState($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties(1);
     $item = JArrayHelper::toObject($properties, 'JObject');
     // Convert attributes to JRegistry params
     $item->params = new JRegistry();
     $item->params->loadString($item->attribs);
     $item->attribs = $item->params->toArray();
     // Get the author name
     $query = $this->_db->getQuery(true);
     $query->select('name')->from('#__users')->where('id = ' . (int) $item->created_by);
     $this->_db->setQuery($query);
     $item->author_name = $this->_db->loadResult();
     return $item;
 }
Пример #19
0
 /**
  * Method to get an record ojbect.
  * @param    integer    The id of the object to get.
  * @return    mixed    Object on success, false on failure.
  */
 public function getItem($id)
 {
     $fn = '';
     $fv = '';
     $error = '';
     JTable::addIncludePath(JPATH_COMPONENT . DS . 'models' . DS . 'tables');
     $table = JTable::getInstance(ucfirst($this->name), 'Table');
     if ($id == 0) {
         // init new record for insert
         $this->_item = new stdClass();
         foreach ($table as $fn => $fv) {
             $this->_item->{$fn} = '';
         }
         $this->_item->id = 0;
     } else {
         $this->_item = false;
         if ($table->load($id)) {
             $this->_item = JArrayHelper::toObject($table->getProperties(1), 'JObject');
         } else {
             if ($error = $table->getError()) {
                 $this->setError($error);
             }
         }
     }
     return $this->_item;
 }
Пример #20
0
 /**
  * Method to get a single record.
  *
  * @param	integer	The id of the primary key.
  *
  * @return	mixed	Object on success, false on failure.
  */
 public function &getItem($pk = null)
 {
     static $cache = null;
     // Initialise variables.
     $pk = !empty($pk) ? $pk : (int) $this->getState('comment.id');
     $false = false;
     if (empty($cache)) {
         $cache = array();
     }
     if (empty($cache[$pk])) {
         // Get a row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return $false;
         }
         // Prime required properties.
         if (empty($table->id)) {
             // Prepare data for a new record.
         }
         // Convert to the JObject before adding other data.
         $cache[$pk] = JArrayHelper::toObject($table->getProperties(1), 'JObject');
     }
     return $cache[$pk];
 }
Пример #21
0
 /**
  * Method to get a single record.
  *
  * @param    integer    The id of the primary key.
  *
  * @return    mixed    Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     // Initialise variables.
     $pk = !empty($pk) ? $pk : (int) $this->getState('sitemap.id');
     $false = false;
     // Get a row instance.
     $table = $this->getTable();
     // Attempt to load the row.
     $return = $table->load($pk);
     // Check for a table object error.
     if ($return === false && $table->getError()) {
         $this->setError($table->getError());
         return $false;
     }
     // Prime required properties.
     if (empty($table->id)) {
         // Prepare data for a new record.
     }
     // Convert to the JObject before adding other data.
     $value = $table->getProperties(1);
     $value = JArrayHelper::toObject($value, 'JObject');
     // Convert the params field to an array.
     $registry = new JRegistry();
     $registry->loadJSON($table->attribs);
     $value->attribs = $registry->toArray();
     return $value;
 }
Пример #22
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;
 }
 /**
  * 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('sliderpublico.id');
         }
         // Get a level row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         if ($table->load($id)) {
             $user = JFactory::getUser();
             $id = $table->id;
             $canEdit = $user->authorise('core.edit', 'com_somosmaestros') || $user->authorise('core.create', 'com_somosmaestros');
             if (!$canEdit && $user->authorise('core.edit.own', 'com_somosmaestros')) {
                 $canEdit = $user->id == $table->created_by;
             }
             if (!$canEdit) {
                 JError::raiseError('500', JText::_('JERROR_ALERTNOAUTHOR'));
             }
             // 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);
         }
     }
     return $this->_item;
 }
Пример #24
0
 /**
  * Method to get the field input.
  *
  * @return  string    The field input.
  */
 protected function getInput()
 {
     $attributes = '';
     if ($v = (string) $this->element['onchange']) {
         $attributes .= ' onchange="' . $v . '"';
     }
     $params = JComponentHelper::getParams('com_localise');
     $reference = $params->get('reference', 'en-GB');
     $admin = JLanguage::getKnownLanguages(LOCALISEPATH_ADMINISTRATOR);
     $site = JLanguage::getKnownLanguages(LOCALISEPATH_SITE);
     if (JFolder::exists(LOCALISEPATH_INSTALLATION)) {
         $install = JLanguage::getKnownLanguages(LOCALISEPATH_INSTALLATION);
     } else {
         $install = array();
     }
     $languages = array_merge($admin, $site, $install);
     $attributes .= ' class="' . (string) $this->element['class'] . ($this->value == $reference ? ' iconlist-16-reference"' : '"');
     foreach ($languages as $i => $language) {
         $languages[$i] = JArrayHelper::toObject($language);
     }
     JArrayHelper::sortObjects($languages, 'name');
     $options = array();
     foreach ($this->element->children() as $option) {
         $options[] = JHtml::_('select.option', $option->attributes('value'), JText::_(trim($option)), array('option.attr' => 'attributes', 'attr' => ''));
     }
     foreach ($languages as $language) {
         $options[] = JHtml::_('select.option', $language->tag, $language->name, array('option.attr' => 'attributes', 'attr' => 'class="' . ($language->tag == $reference ? 'iconlist-16-reference" title="' . JText::_('COM_LOCALISE_TOOLTIP_FIELD_LANGUAGE_REFERENCE') . '"' : '"')));
     }
     $return = JHtml::_('select.genericlist', $options, $this->name, array('id' => $this->id, 'list.select' => $this->value, 'option.attr' => 'attributes', 'list.attr' => $attributes));
     return $return;
 }
Пример #25
0
 public function getItem($pk = null)
 {
     // Initialise variables.
     $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties(1);
     $item = JArrayHelper::toObject($properties, 'JObject');
     $item->title = htmlspecialchars(strip_tags($item->title));
     if (property_exists($item, 'params')) {
         $registry = new JRegistry();
         $registry->loadString($item->params);
         $item->params = $registry->toArray();
     }
     if ($item) {
         $arr = str_replace('[', '', $item->value);
         $arr = str_replace(']', '', $arr);
         if (preg_match('/.*\\},{\\.*?/s', $arr, $match)) {
             //var_dump($match);
             $values = str_replace('},', '}///', $arr);
             $values = explode('///', $values);
         } else {
             $values = (array) $arr;
         }
         //            $artOptFields   = $this -> _checkArticleFields($item -> id);
         if (count($values) > 0) {
             $list = array();
             $i = 0;
             foreach ($values as $value) {
                 $list[$i] = new stdClass();
                 $param = new JRegistry($value);
                 $list[$i]->type = $item->type;
                 if (!empty($item->default_value)) {
                     $list[$i]->default_value = explode(',', $item->default_value);
                 } else {
                     $list[$i]->default_value = array();
                 }
                 $list[$i]->name = $param->get('name');
                 $list[$i]->value = $param->get('value');
                 $list[$i]->target = $param->get('target');
                 $list[$i]->editor = $param->get('editor');
                 $list[$i]->image = $param->get('image');
                 $list[$i]->ordering = $param->get('ordering');
                 $i++;
             }
             $item->defvalue = $list;
         }
         $item->groups = $this->getGroups();
     }
     return $item;
 }
Пример #26
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);
 }
Пример #27
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('address.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 = JFactory::getUser($this->_item->created_by)->name;
     }
     return $this->_item;
 }
Пример #28
0
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties(1);
     $item = JArrayHelper::toObject($properties, 'JObject');
     if (!is_array($item->items)) {
         if (isset($item->id)) {
             $this->_db->setQuery('SELECT * FROM #__djc2_order_items WHERE order_id=\'' . $item->id . '\'');
             $item->items = $this->_db->loadObjectList();
         } else {
             $item->items = array();
         }
     }
     if (property_exists($item, 'params')) {
         $registry = new JRegistry();
         $registry->loadString($item->params);
         $item->params = $registry->toArray();
     }
     return $item;
 }
Пример #29
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties(1);
     $item = JArrayHelper::toObject($properties, 'JObject');
     if (property_exists($item, 'params')) {
         $registry = new JRegistry();
         $registry->loadString($item->params);
         $item->params = $registry->toArray();
     }
     if (property_exists($item, 'order_params')) {
         $registry = new JRegistry();
         $registry->loadString($item->order_params);
         $item->order_params = $registry->toArray();
     }
     return $item;
 }
Пример #30
0
 /**
  * Method to get request data.
  *
  * @param   integer  $itemId  The id of the request.
  *
  * @return  mixed  Request item data object on success, false on failure.
  */
 public function getItem($itemId = null)
 {
     $itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('request.id');
     // Get a row instance.
     $table = $this->getTable();
     // Attempt to load the row.
     $return = $table->load($itemId);
     // Check for a table object error.
     if ($return === false && $table->getError()) {
         $this->setError($table->getError());
         return false;
     }
     $properties = $table->getProperties(1);
     $value = JArrayHelper::toObject($properties, 'JObject');
     $value->similar_q = $value->similar_text ? 1 : 0;
     // Convert body field to array.
     $registry = new JRegistry();
     $registry->loadString($value->body);
     $value->body = $registry->toArray();
     // Convert special field to array.
     $registry = new JRegistry();
     $registry->loadString($value->special);
     $value->special = $registry->toArray();
     // Convert payment field to array.
     $registry = new JRegistry();
     $registry->loadString($value->payment);
     $value->payment = $registry->toArray();
     $value->profile = $this->getProfile();
     return $value;
 }