/** * Retrieve a custom field form * * @since 4.0 * @access public * @param string * @return */ public function getForm() { // Get the field id $id = $this->input->get('id', 0, 'int'); // Get the field type $type = $this->input->get('type', '', 'cmd'); if (!$type) { return $this->ajax->reject(); } $field = EB::table('Field'); $field->load($id); // Get the form $form = EB::fields()->get($type)->admin($field); return $this->ajax->resolve($form); }
/** * Retrieves the custom fields * * @since 4.0 * @access public * @param string * @return */ public function getCustomFields($id) { $db = EB::db(); $query = 'SELECT a.* FROM ' . $db->quoteName('#__easyblog_fields') . ' AS a'; $query .= ' INNER JOIN ' . $db->quoteName('#__easyblog_category_fields_groups') . ' AS b'; $query .= ' ON a.' . $db->quoteName('group_id') . '= b.' . $db->quoteName('group_id'); $query .= ' WHERE b.' . $db->quoteName('category_id') . '=' . $db->Quote($id); $query .= ' AND a.' . $db->quoteName('state') . '=' . $db->Quote(1); $db->setQuery($query); $result = $db->loadObjectList(); if (!$result) { return $result; } // Get the fields library $lib = EB::fields(); // Initialize the default value $fields = array(); foreach ($result as $row) { $field = EB::table('Field'); $field->bind($row); $fields[] = $field; } return $fields; }
/** * Indexes a post on the site * * @since 5.0 * @access public * @param FinderIndexerResult The item to index * @param string The item's format * @return void */ protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled if (!$this->exists()) { return; } // Build the necessary route and path information. $item->url = 'index.php?option=com_easyblog&view=entry&id=' . $item->id; $item->route = EBR::getRoutedURL($item->url, false, true); // Remove any /administrator/ segments from the url since the indexer could be executed from the back end $item->route = $this->removeAdminSegment($item->route); // Get the content path $item->path = FinderIndexerHelper::getContentPath($item->route); // If there is access defined, just set it to 2 which is special privileges. if (!$item->access || $item->access == 0) { $item->access = 1; } else { if ($item->access > 0) { $item->access = 2; } } // Load up the post item $post = EB::post(); $post->load($item->id); // Get the intro text of the content $item->summary = $post->getIntro(); // Get the contents $item->body = $post->getContent('entry', false); // If the post is password protected, we do not want to display the contents if ($post->isPasswordProtected()) { $item->summary = JText::_('PLG_FINDER_EASYBLOG_PASSWORD_PROTECTED'); } else { // we want to get custom fields values. $fields = $post->getCustomFields(); $fieldlib = EB::fields(); $customfields = array(); if ($fields) { foreach ($fields as $field) { if ($field->group->hasValues($post)) { foreach ($field->fields as $customField) { $eachField = $fieldlib->get($customField->type); $customfields[] = $eachField->text($customField, $post); } } } $customfieldvalues = implode(' ', $customfields); $item->body = $item->body . ' ' . $customfieldvalues; } } // Add the author's meta data $item->metaauthor = !empty($item->created_by_alias) ? $item->created_by_alias : $item->author; $item->author = !empty($item->created_by_alias) ? $item->created_by_alias : $item->author; // If the post has an image, use it $image = $post->getImage('thumbnail', false, true); // If there's no image, try to scan the contents for an image to be used if (!$image && $post->isLegacy()) { $image = EB::string()->getImage($item->body); } // If we still can't locate any images, use the placeholder image if (!$image) { $image = EB::getPlaceholderImage(); } $registry = new JRegistry(); $registry->set('image', $image); $item->params = $registry; // Add the meta-data processing instructions. $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'EasyBlog'); // Add the author taxonomy data. if (!empty($item->author) || !empty($item->created_by_alias)) { $item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author); } // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. if (empty($item->language)) { $item->language = '*'; } $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // For Joomla 3.0, the indexer is assigned to the property // Index the item. if (EB::isJoomla30()) { return $this->indexer->index($item); } return FinderIndexer::index($item); }
/** * Displays the new group form * * @since 4.0 * @access public * @param string * @return */ public function form($tpl = null) { $this->checkAccess('easyblog.manage.fields'); $id = $this->input->get('id', 0, 'int'); // Get the field table $field = EB::table('Field'); $field->load($id); if (!$id) { $title = 'COM_EASYBLOG_FIELDS_CREATE_TITLE'; } else { $title = 'COM_EASYBLOG_FIELDS_EDIT_TITLE'; } // Set page details $this->setHeading($title, '', 'fa-list-alt'); JToolBarHelper::title(JText::_($title), 'fields'); JToolbarHelper::apply('fields.apply'); JToolbarHelper::save('fields.save'); JToolbarHelper::save2new('fields.savenew'); JToolBarHelper::cancel('fields.cancel'); // Get the fieldsgroup model $model = EB::model('Fields'); $groups = $model->getGroups(); if (!$groups) { return parent::display('fields/form.nogroups'); } // Get the custom fields library $fields = EB::fields()->getItems(); // Get the current active field form $form = ''; if ($field->id) { $form = EB::fields()->get($field->type)->admin($field); } $this->set('fields', $fields); $this->set('form', $form); $this->set('field', $field); $this->set('groups', $groups); parent::display('fields/form'); }
/** * Retrieves the form * * @since 4.0 * @access public * @param string * @return */ public function getForm(EasyBlogPost $post, $elementName = 'fields') { $fields = EB::fields(); $field = $fields->get($this->type); $field->setFormElement($elementName); return $field->form($post, $this); }