本文整理汇总了PHP中FlexicontentFields::loadFieldConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentFields::loadFieldConfig方法的具体用法?PHP FlexicontentFields::loadFieldConfig怎么用?PHP FlexicontentFields::loadFieldConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentFields
的用法示例。
在下文中一共展示了FlexicontentFields::loadFieldConfig方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($tpl = null)
{
$user = JFactory::getUser();
$dispatcher = JDispatcher::getInstance();
// Initialize some variables
$item =& $this->get('Item');
$params =& $item->parameters;
$fields =& $this->get('Extrafields');
$tags =& $item->tags;
$categories =& $item->categories;
$favourites = $item->favourites;
$favoured = $item->favoured;
// process the new plugins
JPluginHelper::importPlugin('content', 'image');
if (!FLEXI_J16GE) {
$dispatcher->trigger('onPrepareContent', array(&$item, &$params, 0));
} else {
$dispatcher->trigger('onContentPrepare', array('com_content.article', &$item, &$params, 0));
}
$document = JFactory::getDocument();
// set document information
$document->setTitle($item->title);
$document->setName($item->alias);
$document->setDescription($item->metadesc);
$document->setMetaData('keywords', $item->metakey);
// prepare header lines
$document->setHeader($this->_getHeaderText($item, $params));
$pdf_format_fields = trim($params->get("pdf_format_fields"));
$pdf_format_fields = !$pdf_format_fields ? array() : preg_split("/[\\s]*,[\\s]*/", $pdf_format_fields);
$methodnames = array();
foreach ($pdf_format_fields as $pdf_format_field) {
@(list($fieldname, $methodname) = preg_split("/[\\s]*:[\\s]*/", $pdf_format_field));
$methodnames[$fieldname] = empty($methodname) ? 'display' : $methodname;
}
// IF no fields set then just print the item's description text
if (!count($pdf_format_fields)) {
echo $item->text;
return;
}
foreach ($fields as $field) {
if (!isset($methodnames[$field->name])) {
continue;
}
if ($field->iscore) {
FlexicontentFields::loadFieldConfig($field, $item);
//$results = $dispatcher->trigger('onDisplayCoreFieldValue', array( &$field, $item, &$params, $tags, $categories, $favourites, $favoured ));
FLEXIUtilities::call_FC_Field_Func('core', 'onDisplayCoreFieldValue', array(&$field, $item, &$params, $tags, $categories, $favourites, $favoured));
} else {
//$results = $dispatcher->trigger('onDisplayFieldValue', array( &$field, $item ));
FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item));
}
if (@$field->display) {
echo '<b>' . $field->label . '</b>: ';
echo $field->display . '<br /><br />';
}
}
}
示例2: replaceFieldValue
static function replaceFieldValue(&$field, &$item, $variable, $varname, &$cacheable = false)
{
static $parsed = array();
static $d;
static $c;
// Parse field variable if not already parsed
if (!isset($parsed[$field->id][$varname])) {
$parsed[$field->id][$varname] = true;
$result = preg_match_all("/\\{\\{([a-zA-Z_0-9]+)(##)?([0-9]+)?(##)?([a-zA-Z_0-9]+)?\\}\\}/", $variable, $field_matches);
if ($result) {
$d[$field->id][$varname]['fulltxt'] = $field_matches[0];
$d[$field->id][$varname]['fieldname'] = $field_matches[1];
$d[$field->id][$varname]['valueno'] = $field_matches[3];
$d[$field->id][$varname]['propname'] = $field_matches[5];
} else {
$d[$field->id][$varname]['fulltxt'] = array();
$d[$field->id][$varname]['valueno'] = false;
}
$result = preg_match_all("/\\{\\{(item->)([a-zA-Z_0-9]+)\\}\\}/", $variable, $field_matches);
if ($result) {
$c[$field->id][$varname]['fulltxt'] = $field_matches[0];
$c[$field->id][$varname]['propname'] = $field_matches[2];
} else {
$c[$field->id][$varname]['fulltxt'] = array();
}
if (!count($d[$field->id][$varname]['fulltxt']) && !count($c[$field->id][$varname]['fulltxt'])) {
$cacheable = true;
}
}
// Replace variable
foreach ($d[$field->id][$varname]['fulltxt'] as $i => $fulltxt) {
$fieldname = $d[$field->id][$varname]['fieldname'][$i];
$valueno = $d[$field->id][$varname]['valueno'][$i] ? (int) $d[$field->id][$varname]['valueno'][$i] : 0;
$propname = $d[$field->id][$varname]['propname'][$i] ? $d[$field->id][$varname]['propname'][$i] : '';
$fieldid = @$item->fields[$fieldname]->id;
$value = @$item->fieldvalues[$fieldid][$valueno];
if (!$fieldid) {
$value = 'Field with name: ' . $fieldname . ' not found';
$variable = str_replace($fulltxt, $value, $variable);
continue;
}
$is_indexable = $propname && preg_match("/^_([a-zA-Z_0-9]+)_\$/", $propname, $prop_matches) && ($propname = $prop_matches[1]);
if ($fieldid <= 14) {
if ($fieldid == 13) {
$value = @$item->categories[$valueno]->{$propname};
} else {
if ($fieldid == 14) {
$value = @$item->tags[$valueno]->{$propname};
}
}
} else {
if ($is_indexable) {
if ($propname != 'value') {
$extra_props = $propname != 'text' ? array($propname) : array();
// this will work only if field has a single extra property
$extra_props = array();
if (!isset($item->fields[$fieldname]->parameters)) {
FlexicontentFields::loadFieldConfig($item->fields[$fieldname], $item);
}
$elements = FlexicontentFields::indexedField_getElements($item->fields[$fieldname], $item, $extra_props);
$value = @$elements[$value]->{$propname};
}
} else {
if ($propname) {
$value = @unserialize($value);
$value = @$value[$propname];
}
}
}
$variable = str_replace($fulltxt, $value, $variable);
//echo "<pre>"; print_r($item->fieldvalues[$fieldid]); echo "</pre>"; echo "Replaced $fulltxt with ITEM field VALUE: $value <br>";
}
// Replace variable
foreach ($c[$field->id][$varname]['fulltxt'] as $i => $fulltxt) {
$propname = $c[$field->id][$varname]['propname'][$i];
if (!isset($item->{$propname})) {
$value = 'Item property with name: ' . $propname . ' not found';
$variable = str_replace($fulltxt, $value, $variable);
continue;
}
$value = $item->{$propname};
$variable = str_replace($fulltxt, $value, $variable);
//echo "<pre>"; echo "</pre>"; echo "Replaced $fulltxt with ITEM property VALUE: $value <br>";
}
// Return variable after all replacements
return $variable;
}
示例3: getCascadedField
function getCascadedField()
{
$field_id = JRequest::getInt('field_id', 0);
$item_id = JRequest::getInt('item_id', 0);
$valgrps = JRequest::getVar('valgrps', '');
$valindex = JRequest::getVar('valindex', 0);
// Load field
$_fields = FlexicontentFields::getFieldsByIds(array($field_id), array($item_id));
$field = $_fields[$field_id];
$field->item_id = $item_id;
$field->valgrps = $valgrps;
$field->valindex = $valindex;
// Load item
$item = JTable::getInstance($_type = 'flexicontent_items', $_prefix = '', $_config = array());
$item->load($item_id);
// Get field configuration
FlexicontentFields::loadFieldConfig($field, $item);
// Get field values
//$_fieldvalues = FlexicontentFields::getFieldValsById(array($field_id), array($item_id));
$field->value = null;
//isset($_fieldvalues[$item_id][$field_id]) ? $_fieldvalues[$item_id][$field_id] : array();
// Render field
$field->isAjax = 1;
$this->onDisplayField($field, $item);
// Output the field
echo $field->html;
exit;
}
示例4: getRatingResolution
function getRatingResolution()
{
if ($this->_rating_resolution) {
return $this->_rating_resolution;
}
$this->_db->setQuery('SELECT * FROM #__flexicontent_fields WHERE field_type="voting"');
$field = $this->_db->loadObject();
$item = JTable::getInstance($type = 'flexicontent_items', $prefix = '', $config = array());
//$item->load( $id );
FlexicontentFields::loadFieldConfig($field, $item);
$rating_resolution = (int) $field->parameters->get('rating_resolution', 5);
$rating_resolution = $rating_resolution >= 5 ? $rating_resolution : 5;
$rating_resolution = $rating_resolution <= 100 ? $rating_resolution : 100;
$this->_rating_resolution = $rating_resolution;
}
示例5: _displayForm
//.........这里部分代码省略.........
} else {
JError::raiseError(403, $msg);
}
}
}
}
}
// *****************************************************************************
// Get (CORE & CUSTOM) fields and their VERSIONED values and then
// (a) Apply Content Type Customization to CORE fields (label, description, etc)
// (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField'
// *****************************************************************************
// Check if saving an item that translates an original content in site's default language
$site_default = substr(flexicontent_html::getSiteDefaultLang(), 0, 2);
$is_content_default_lang = $site_default == substr($item->language, 0, 2);
//$modify_untraslatable_values = $enable_translation_groups && !$is_content_default_lang; // && $item->lang_parent_id && $item->lang_parent_id!=$item->id;
if ($print_logging_info) {
$start_microtime = microtime(true);
}
$fields = $this->get('Extrafields');
$item->fields =& $fields;
if ($print_logging_info) {
$fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
}
if ($print_logging_info) {
$start_microtime = microtime(true);
}
$jcustom = $app->getUserState('com_flexicontent.edit.item.custom');
//print_r($jcustom);
foreach ($fields as $field) {
// a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description
// NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations
if ($field->iscore) {
FlexicontentFields::loadFieldConfig($field, $item);
}
// b. Create field 's editing HTML (the form field)
// NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow)
if (!$field->iscore) {
if (isset($jcustom[$field->name])) {
$field->value = array();
foreach ($jcustom[$field->name] as $i => $_val) {
$field->value[$i] = $_val;
}
}
$is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id);
if ($is_editable) {
FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item));
if ($field->untranslatable) {
$field->html = '<div class="alert alert-info fc-small fc-iblock">' . JText::_('FLEXI_FIELD_VALUE_IS_NON_TRANSLATABLE') . '</div>' . "\n" . $field->html;
}
} else {
if ($field->valueseditable == 1) {
$field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>';
} else {
if ($field->valueseditable == 2) {
FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item));
$field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>' . "\n" . $field->display;
} else {
if ($field->valueseditable == 3) {
FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item));
$field->html = $field->display;
} else {
if ($field->valueseditable == 4) {
$field->html = '';
$field->formhidden = 4;
}
示例6: display
//.........这里部分代码省略.........
// Add modal layout editing
// ************************
if ($perms['cantemplates']) {
JToolBarHelper::divider();
if (!$isnew || $item->version) {
flexicontent_html::addToolBarButton('FLEXI_EDIT_LAYOUT', $btn_name = 'apply_ajax', $full_js = "var url = jQuery(this).attr('data-href'); fc_showDialog(url, 'fc_modal_popup_container'); return false;", $msg_alert = '', $msg_confirm = '', $btn_task = 'items.apply_ajax', $extra_js = '', $btn_list = false, $btn_menu = true, $btn_confirm = false, $btn_class = "btn-info" . $tip_class, $btn_icon = "icon-pencil", 'data-placement="bottom" data-href="index.php?option=com_flexicontent&view=template&type=items&tmpl=component&ismodal=1&folder=' . $item->itemparams->get('ilayout', $tparams->get('ilayout', 'default')) . '" title="Edit the display layout of this item. <br/><br/>Note: this layout maybe assigned to content types or other items, thus changing it will effect them too"');
}
}
// Check if saving an item that translates an original content in site's default language
$site_default = substr(flexicontent_html::getSiteDefaultLang(), 0, 2);
$is_content_default_lang = $site_default == substr($item->language, 0, 2);
// *****************************************************************************
// Get (CORE & CUSTOM) fields and their VERSIONED values and then
// (a) Apply Content Type Customization to CORE fields (label, description, etc)
// (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField'
// *****************************************************************************
if ($print_logging_info) {
$start_microtime = microtime(true);
}
$fields = $this->get('Extrafields');
$item->fields =& $fields;
if ($print_logging_info) {
$fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
}
if ($print_logging_info) {
$start_microtime = microtime(true);
}
$jcustom = $app->getUserState('com_flexicontent.edit.item.custom');
//print_r($jcustom);
foreach ($fields as $field) {
// a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description
// NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations
if ($field->iscore) {
FlexicontentFields::loadFieldConfig($field, $item);
}
// b. Create field 's editing HTML (the form field)
// NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow)
if (!$field->iscore) {
if (isset($jcustom[$field->name])) {
$field->value = array();
foreach ($jcustom[$field->name] as $i => $_val) {
$field->value[$i] = $_val;
}
}
$is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id);
if ($is_editable) {
FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item));
if ($field->untranslatable) {
$field->html = (!isset($field->html) ? '<div class="fc-mssg-inline fc-warning" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_PLEASE_PUBLISH_THIS_PLUGIN') . '</div><div class="clear"></div>' : '') . '<div class="alert alert-info fc-small fc-iblock" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_FIELD_VALUE_IS_NON_TRANSLATABLE') . '</div>' . "\n" . (isset($field->html) ? '<div class="clear"></div>' . $field->html : '');
}
} else {
if ($field->valueseditable == 1) {
$field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>';
} else {
if ($field->valueseditable == 2) {
FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item));
$field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>' . "\n" . $field->display;
} else {
if ($field->valueseditable == 3) {
FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item));
$field->html = $field->display;
} else {
if ($field->valueseditable == 4) {
$field->html = '';
$field->formhidden = 4;
}
示例7: getvotes
/**
* Method to fetch the votes
*
* @since 1.5
*/
function getvotes()
{
$id = JRequest::getInt('id', 0);
$model = $this->getModel('item');
$votes = $model->getvotes($id);
$db = JFactory::getDBO();
$db->setQuery('SELECT * FROM #__flexicontent_fields WHERE field_type="voting"');
$field = $db->loadObject();
$item = JTable::getInstance($type = 'flexicontent_items', $prefix = '', $config = array());
$item->load($id);
FlexicontentFields::loadFieldConfig($field, $item);
$rating_resolution = (int) $field->parameters->get('rating_resolution', 5);
$rating_resolution = $rating_resolution >= 5 ? $rating_resolution : 5;
$rating_resolution = $rating_resolution <= 100 ? $rating_resolution : 100;
@ob_end_clean();
if ($votes) {
$score = round((int) $votes[0]->rating_sum / (int) $votes[0]->rating_count * (100 / $rating_resolution), 2);
$vote = (int) $votes[0]->rating_count > 1 ? (int) $votes[0]->rating_count . ' ' . JText::_('FLEXI_VOTES') : (int) $votes[0]->rating_count . ' ' . JText::_('FLEXI_VOTE');
echo $score . '% | ' . $vote;
} else {
echo JText::_('FLEXI_NOT_RATED_YET');
}
exit;
}
示例8: getList
//.........这里部分代码省略.........
}
}
$lists[$ord]['featured'][$i] = new stdClass();
$lists[$ord]['featured'][$i]->_row = $row;
$lists[$ord]['featured'][$i]->id = $row->id;
$lists[$ord]['featured'][$i]->is_active_item = $isflexi_itemview && $row->id == $active_item_id;
//date
if ($display_date_feat == 1) {
$dateformat = JText::_($params->get('date_format_feat', 'DATE_FORMAT_LC3'));
if ($dateformat == JText::_('custom')) {
$dateformat = $params->get('custom_date_format_feat', JText::_('DATE_FORMAT_LC3'));
}
$date_fields_feat = $params->get('date_fields_feat', array('created'));
$date_fields_feat = !is_array($date_fields_feat) ? array($date_fields_feat) : $date_fields_feat;
$lists[$ord]['featured'][$i]->date_created = "";
if (in_array('created', $date_fields_feat)) {
// Created
$lists[$ord]['featured'][$i]->date_created .= $params->get('date_label_feat', 1) ? '<span class="date_label_feat">' . JText::_('FLEXI_DATE_CREATED') . '</span> ' : '';
$lists[$ord]['featured'][$i]->date_created .= '<span class="date_value_feat">' . JHTML::_('date', $row->created, $dateformat) . '</span>';
}
$lists[$ord]['featured'][$i]->date_modified = "";
if (in_array('modified', $date_fields_feat)) {
// Modified
$lists[$ord]['featured'][$i]->date_modified .= $params->get('date_label_feat', 1) ? '<span class="date_label_feat">' . JText::_('FLEXI_DATE_MODIFIED') . '</span> ' : '';
$modified_date = $row->modified != $db->getNullDate() ? JHTML::_('date', $row->modified, $dateformat) : JText::_('FLEXI_DATE_NEVER');
$lists[$ord]['featured'][$i]->date_modified .= '<span class="date_value_feat">' . $modified_date . '</span>';
}
}
$lists[$ord]['featured'][$i]->image_rendered = $thumb_rendered;
$lists[$ord]['featured'][$i]->image = $thumb;
$lists[$ord]['featured'][$i]->hits = $row->hits;
$lists[$ord]['featured'][$i]->hits_rendered = '';
if ($display_hits_feat && $has_access_hits) {
FlexicontentFields::loadFieldConfig($hitsfield, $row);
$lists[$ord]['featured'][$i]->hits_rendered .= $params->get('hits_label_feat') ? '<span class="hits_label_feat">' . JText::_($hitsfield->label) . '</span> ' : '';
$lists[$ord]['featured'][$i]->hits_rendered .= $hits_icon;
$lists[$ord]['featured'][$i]->hits_rendered .= ' (' . $row->hits . (!$params->get('hits_label_feat') ? ' ' . JTEXT::_('FLEXI_HITS_L') : '') . ')';
}
$lists[$ord]['featured'][$i]->voting = '';
if ($display_voting_feat && $has_access_voting) {
FlexicontentFields::loadFieldConfig($votingfield, $row);
$lists[$ord]['featured'][$i]->voting .= $params->get('voting_label_feat') ? '<span class="voting_label_feat">' . JText::_($votingfield->label) . '</span> ' : '';
$lists[$ord]['featured'][$i]->voting .= '<div class="voting_value_feat">' . flexicontent_html::ItemVoteDisplay($votingfield, $row->id, $row->rating_sum, $row->rating_count, 'main', '', $params->get('vote_stars_feat', 1), $params->get('allow_vote_feat', 0), $params->get('vote_counter_feat', 1), !$params->get('voting_label_feat')) . '</div>';
}
if ($display_comments_feat) {
$lists[$ord]['featured'][$i]->comments = $row->comments_total;
$lists[$ord]['featured'][$i]->comments_rendered = $params->get('comments_label_feat') ? '<span class="comments_label_feat">' . JText::_('FLEXI_COMMENTS') . '</span> ' : '';
$lists[$ord]['featured'][$i]->comments_rendered .= $comments_icon;
$lists[$ord]['featured'][$i]->comments_rendered .= ' (' . $row->comments_total . (!$params->get('comments_label_feat') ? ' ' . JTEXT::_('FLEXI_COMMENTS_L') : '') . ')';
}
$lists[$ord]['featured'][$i]->catid = $row->catid;
$lists[$ord]['featured'][$i]->itemcats = explode(",", $row->itemcats);
$lists[$ord]['featured'][$i]->link = JRoute::_(FlexicontentHelperRoute::getItemRoute($row->slug, $row->categoryslug, $forced_itemid, $row) . ($method_curlang == 1 ? "&lang=" . substr($row->language, 0, 2) : ""));
$lists[$ord]['featured'][$i]->title = strlen($row->title) > $cuttitle_feat ? JString::substr($row->title, 0, $cuttitle_feat) . '...' : $row->title;
$lists[$ord]['featured'][$i]->alias = $row->alias;
$lists[$ord]['featured'][$i]->fulltitle = $row->title;
$lists[$ord]['featured'][$i]->text = $mod_do_stripcat_feat ? flexicontent_html::striptagsandcut($row->introtext, $mod_cut_text_feat) : $row->introtext;
$lists[$ord]['featured'][$i]->typename = $row->typename;
$lists[$ord]['featured'][$i]->access = $row->access;
$lists[$ord]['featured'][$i]->featured = 1;
if ($use_fields_feat && @$row->fields && $fields_feat) {
$lists[$ord]['featured'][$i]->fields = array();
foreach ($fields_feat as $field) {
if (!isset($row->fields[$field])) {
continue;
}
示例9: translateFieldValues
function translateFieldValues(&$fields, &$row, $lang_from, $lang_to)
{
// Translate 'text' TYPE fields
$fieldnames_arr = array();
$fieldvalues_arr = array();
foreach ($fields as $field_index => $field) {
if ($field->field_type != 'text') {
continue;
}
$fieldnames_arr[] = 'field_value' . $field_index;
$translatable_obj = new stdClass();
$translatable_obj->originalValue = $field->value;
$translatable_obj->noTranslate = false;
$fieldvalues_arr[] = $translatable_obj;
}
if (count($fieldvalues_arr)) {
$result = autoTranslator::translateItem($fieldnames_arr, $fieldvalues_arr, $lang_from, $lang_to);
if (intval($result)) {
foreach ($fieldnames_arr as $index => $fieldname) {
$field_index = str_replace('field_value', '', $fieldname);
$fields[$field_index]->value = $fieldvalues_arr[$index]->translationValue;
}
}
}
// Translate 'textarea' TYPE fields
$fieldnames_arr = array();
$fieldvalues_arr = array();
foreach ($fields as $field_index => $field) {
if ($field->field_type != 'textarea' && $field->field_type != 'maintext') {
continue;
}
if (!is_array($field->value)) {
$field->value = array($field->value);
}
// Load field parameters
FlexicontentFields::loadFieldConfig($field, $row);
// Parse fulltext field into tabs to avoid destroying them during translation
FLEXIUtilities::call_FC_Field_Func('textarea', 'parseTabs', array(&$field, &$row));
$dti =& $field->tab_info;
if (!$field->tabs_detected) {
$fieldnames_arr[] = $field->name;
$translatable_obj = new stdClass();
$translatable_obj->originalValue = $field->value[0];
$translatable_obj->noTranslate = false;
$fieldvalues_arr[] = $translatable_obj;
} else {
// BEFORE tabs
$fieldnames_arr[] = 'beforetabs';
$translatable_obj = new stdClass();
$translatable_obj->originalValue = $dti->beforetabs;
$translatable_obj->noTranslate = false;
$fieldvalues_arr[] = $translatable_obj;
// AFTER tabs
$fieldnames_arr[] = 'aftertabs';
$translatable_obj = new stdClass();
$translatable_obj->originalValue = $dti->aftertabs;
$translatable_obj->noTranslate = false;
$fieldvalues_arr[] = $translatable_obj;
// TAB titles
foreach ($dti->tab_titles as $i => $tab_title) {
$fieldnames_arr[] = 'tab_titles_' . $i;
$translatable_obj = new stdClass();
$translatable_obj->originalValue = $tab_title;
$translatable_obj->noTranslate = false;
$fieldvalues_arr[] = $translatable_obj;
}
// TAB contents
foreach ($dti->tab_contents as $i => $tab_content) {
$fieldnames_arr[] = 'tab_contents_' . $i;
$translatable_obj = new stdClass();
$translatable_obj->originalValue = $tab_content;
$translatable_obj->noTranslate = false;
$fieldvalues_arr[] = $translatable_obj;
}
}
// Do Google Translation
unset($translated_parts);
if (count($fieldvalues_arr)) {
$result = autoTranslator::translateItem($fieldnames_arr, $fieldvalues_arr, $lang_from, $lang_to);
if (intval($result)) {
$translated_parts = new stdClass();
foreach ($fieldnames_arr as $index => $fieldname) {
$translated_parts->{$fieldname} = $fieldvalues_arr[$index]->translationValue;
}
}
}
//echo "<pre>"; print_r($translated_parts);
// Reconstruct field value out of the translated tabs code and assign it back to the field
if (isset($translated_parts)) {
if (!$field->tabs_detected) {
$fields[$field_index]->value = $translated_parts->{$field->name};
} else {
$translated_value = $translated_parts->beforetabs;
$translated_value .= $dti->tabs_start;
foreach ($dti->tab_titles as $i => $tab_title) {
$translated_value .= str_replace($tab_title, $translated_parts->{'tab_titles_' . $i}, $dti->tab_startings[$i]);
$translated_value .= $translated_parts->{'tab_contents_' . $i};
$translated_value .= $dti->tab_endings[$i];
}
$translated_value .= $dti->tabs_end;
//.........这里部分代码省略.........
示例10: ajaxvote
/**
* Method for voting (ajax)
*
* @TODO move the query part to the item model
* @access public
* @since 1.5
*/
public function ajaxvote()
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$db = JFactory::getDBO();
$session = JFactory::getSession();
$cparams = JComponentHelper::getParams('com_flexicontent');
$no_ajax = JRequest::getInt('no_ajax');
$user_rating = JRequest::getInt('user_rating');
$cid = JRequest::getInt('cid');
$xid = JRequest::getVar('xid');
// Compatibility in case the voting originates from joomla's voting plugin
if ($no_ajax && !$cid) {
$cid = JRequest::getInt('id');
// Joomla 's content plugin uses 'id' HTTP request variable
}
// *******************************************************************
// Check for invalid xid (according to voting field/type configuration
// *******************************************************************
$xid = empty($xid) ? 'main' : $xid;
$int_xid = (int) $xid;
if ($xid != 'main' && !$int_xid) {
// Rare/unreachable voting ERROR
$error = "ajaxvote(): invalid xid '" . $xid . "' was given";
// Set responce
if ($no_ajax) {
$app->enqueueMessage($error, 'notice');
return;
} else {
$result = new stdClass();
$result->percentage = '';
$result->htmlrating = '';
$error = '
<div class="fc-mssg fc-warning fc-nobgimage">
<button type="button" class="close" data-dismiss="alert">×</button>
' . $error . '
</div>';
if ($int_xid) {
$result->message = $error;
} else {
$result->message_main = $error;
}
echo json_encode($result);
jexit();
}
}
// ******************************
// Get voting field configuration
// ******************************
$db->setQuery('SELECT * FROM #__flexicontent_fields WHERE field_type="voting"');
$field = $db->loadObject();
$item = JTable::getInstance($type = 'flexicontent_items', $prefix = '', $config = array());
$item->load($cid);
FlexicontentFields::loadFieldConfig($field, $item);
$rating_resolution = (int) $field->parameters->get('rating_resolution', 5);
$rating_resolution = $rating_resolution >= 5 ? $rating_resolution : 5;
$rating_resolution = $rating_resolution <= 100 ? $rating_resolution : 100;
$min_rating = 1;
$max_rating = $rating_resolution;
$main_counter = (int) $field->parameters->get('main_counter', 1);
$extra_counter = (int) $field->parameters->get('extra_counter', 1);
$main_counter_show_label = (int) $field->parameters->get('main_counter_show_label', 1);
$extra_counter_show_label = (int) $field->parameters->get('extra_counter_show_label', 1);
$main_counter_show_percentage = (int) $field->parameters->get('main_counter_show_percentage', 0);
$extra_counter_show_percentage = (int) $field->parameters->get('extra_counter_show_percentage', 0);
// *****************************************************
// Find if user has the ACCESS level required for voting
// *****************************************************
$aid_arr = JAccess::getAuthorisedViewLevels($user->id);
$acclvl = (int) $field->parameters->get('submit_acclvl', 1);
$has_acclvl = in_array($acclvl, $aid_arr);
// *********************************
// Create no access Redirect Message
// *********************************
if (!$has_acclvl) {
$logged_no_acc_msg = $field->parameters->get('logged_no_acc_msg', '');
$guest_no_acc_msg = $field->parameters->get('guest_no_acc_msg', '');
$no_acc_msg = $user->id ? $logged_no_acc_msg : $guest_no_acc_msg;
$no_acc_msg = $no_acc_msg ? JText::_($no_acc_msg) : '';
// Message not set create a Default Message
if (!$no_acc_msg) {
// Find name of required Access Level
$acclvl_name = '';
if ($acclvl) {
$db->setQuery('SELECT title FROM #__viewlevels as level WHERE level.id=' . $acclvl);
$acclvl_name = $db->loadResult();
if (!$acclvl_name) {
$acclvl_name = "Access Level: " . $acclvl . " not found/was deleted";
}
}
$no_acc_msg = JText::sprintf('FLEXI_NO_ACCESS_TO_VOTE', $acclvl_name);
}
}
//.........这里部分代码省略.........
示例11: ajaxvote
/**
* Method for voting (ajax)
*
* @TODO move the query part to the item model
* @access public
* @since 1.5
*/
public function ajaxvote()
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$db = JFactory::getDBO();
$session = JFactory::getSession();
$cparams = JComponentHelper::getParams( 'com_flexicontent' );
$no_ajax = JRequest::getInt('no_ajax');
$user_rating = JRequest::getInt('user_rating');
$cid = JRequest::getInt('cid');
$xid = JRequest::getVar('xid');
// Compatibility in case the voting originates from joomla's voting plugin
if ($no_ajax) {
// Joomla 's content plugin uses 'id' HTTP request variable
$cid = JRequest::getInt('id');
}
// ******************************
// Get voting field configuration
// ******************************
$db->setQuery('SELECT * FROM #__flexicontent_fields WHERE field_type="voting"');
$field = $db->loadObject();
$item = JTable::getInstance( $type = 'flexicontent_items', $prefix = '', $config = array() );
$item->load( $cid );
FlexicontentFields::loadFieldConfig($field, $item);
$rating_resolution = (int)$field->parameters->get('rating_resolution', 5);
$rating_resolution = $rating_resolution >= 5 ? $rating_resolution : 5;
$rating_resolution = $rating_resolution <= 100 ? $rating_resolution : 100;
$min_rating = 1;
$max_rating = $rating_resolution;
// *****************************************************
// Find if user has the ACCESS level required for voting
// *****************************************************
if (!FLEXI_J16GE) $aid = (int) $user->get('aid');
else $aid_arr = JAccess::getAuthorisedViewLevels($user->id);
$acclvl = (int) $field->parameters->get('submit_acclvl', FLEXI_J16GE ? 1 : 0);
$has_acclvl = FLEXI_J16GE ? in_array($acclvl, $aid_arr) : $acclvl <= $aid;
// *********************************
// Create no access Redirect Message
// *********************************
if ( !$has_acclvl )
{
$logged_no_acc_msg = $field->parameters->get('logged_no_acc_msg', '');
$guest_no_acc_msg = $field->parameters->get('guest_no_acc_msg', '');
$no_acc_msg = $user->id ? $logged_no_acc_msg : $guest_no_acc_msg;
$no_acc_msg = $no_acc_msg ? JText::_($no_acc_msg) : '';
// Message not set create a Default Message
if ( !$no_acc_msg )
{
// Find name of required Access Level
if (FLEXI_J16GE) {
$acclvl_name = '';
if ($acclvl) {
$db->setQuery('SELECT title FROM #__viewlevels as level WHERE level.id='.$acclvl);
$acclvl_name = $db->loadResult();
if ( !$acclvl_name ) $acclvl_name = "Access Level: ".$acclvl." not found/was deleted";
}
} else {
$acclvl_names = array(0=>'Public', 1=>'Registered', 2=>'Special');
$acclvl_name = $acclvl_names[$acclvl];
}
$no_acc_msg = JText::sprintf( 'FLEXI_NO_ACCESS_TO_VOTE' , $acclvl_name);
}
}
// ****************************************************
// NO voting Access OR rating is NOT within valid range
// ****************************************************
if ( !$has_acclvl || ($user_rating < $min_rating && $user_rating > $max_rating) )
{
// Voting REJECTED, avoid setting BAR percentage and HTML rating text ... someone else may have voted for the item ...
$result = new stdClass();
$result->percentage = '';
$result->htmlrating = '';
$result->html = !$has_acclvl ? $no_acc_msg : JText::sprintf( 'FLEXI_VOTING_OUT_OF_RANGE', $min_rating, $max_rating);
// Set responce
if ($no_ajax) {
//.........这里部分代码省略.........
示例12: getVotingResolution
function getVotingResolution($id = 0)
{
static $rating_resolution = array();
$id = $id ? $id : $this->_id;
if (empty($rating_resolution[$id])) {
$this->_db->setQuery('SELECT * FROM #__flexicontent_fields WHERE field_type="voting"');
$field = $this->_db->loadObject();
$item = JTable::getInstance($type = 'flexicontent_items', $prefix = '', $config = array());
$item->load($id);
FlexicontentFields::loadFieldConfig($field, $item);
$_rating_resolution = (int) $field->parameters->get('rating_resolution', 5);
$_rating_resolution = $_rating_resolution >= 5 ? $_rating_resolution : 5;
$_rating_resolution = $_rating_resolution <= 100 ? $_rating_resolution : 100;
$rating_resolution[$id] = $_rating_resolution;
}
return $rating_resolution[$id];
}
示例13: display
//.........这里部分代码省略.........
JToolBarHelper::cancel('items.cancel');
} else {
JToolBarHelper::apply();
if (!$isnew || $item->version) {
JToolBarHelper::save();
}
if (!$isnew || $item->version) {
JToolBarHelper::custom('saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false);
}
JToolBarHelper::cancel();
}
// Check if saving an item that translates an original content in site's default language
$is_content_default_lang = substr(flexicontent_html::getSiteDefaultLang(), 0, 2) == substr($item->language, 0, 2);
$modify_untraslatable_values = $enable_translation_groups && !$is_content_default_lang && $item->lang_parent_id && $item->lang_parent_id != $item->id;
// *****************************************************************************
// Get (CORE & CUSTOM) fields and their VERSIONED values and then
// (a) Apply Content Type Customization to CORE fields (label, description, etc)
// (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField'
// *****************************************************************************
if ($print_logging_info) {
$start_microtime = microtime(true);
}
$fields = $this->get('Extrafields');
if ($print_logging_info) {
$fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
}
if ($print_logging_info) {
$start_microtime = microtime(true);
}
foreach ($fields as $field) {
// a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description
// NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations
if ($field->iscore) {
FlexicontentFields::loadFieldConfig($field, $item);
}
// b. Create field 's editing HTML (the form field)
// NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow)
if (!$field->iscore) {
if (FLEXI_J16GE) {
$is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id);
} else {
if (FLEXI_ACCESS && $user->gid < 25) {
$is_editable = !$field->valueseditable || FAccess::checkAllContentAccess('com_content', 'submit', 'users', $user->gmid, 'field', $field->id);
} else {
$is_editable = 1;
}
}
if (!$is_editable) {
$field->html = '<div class="fc-mssg fc-warning">' . JText::_('FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>';
} else {
if ($modify_untraslatable_values && $field->untranslatable) {
$field->html = '<div class="fc-mssg fc-note">' . JText::_('FLEXI_FIELD_VALUE_IS_UNTRANSLATABLE') . '</div>';
} else {
FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item));
}
}
}
// c. Create main text field, via calling the display function of the textarea field (will also check for tabs)
if ($field->field_type == 'maintext') {
if (isset($item->item_translations)) {
$shortcode = substr($item->language, 0, 2);
foreach ($item->item_translations as $lang_id => $t) {
if ($shortcode == $t->shortcode) {
continue;
}
$field->name = array('jfdata', $t->shortcode, 'text');
示例14: _displayForm
//.........这里部分代码省略.........
if ($new_typeid) {
$params->merge($tparams);
}
// Apply type configuration if it type is set
if ($menu) {
$params->merge($menu_params);
}
// Apply menu configuration if it menu is set, to override type configuration
} else {
$params = $item->parameters;
}
// Check if saving an item that translates an original content in site's default language
$is_content_default_lang = substr(flexicontent_html::getSiteDefaultLang(), 0, 2) == substr($item->language, 0, 2);
$modify_untraslatable_values = $enable_translation_groups && !$is_content_default_lang && $item->lang_parent_id && $item->lang_parent_id != $item->id;
// *****************************************************************************
// Get (CORE & CUSTOM) fields and their VERSIONED values and then
// (a) Apply Content Type Customization to CORE fields (label, description, etc)
// (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField'
// *****************************************************************************
if ($print_logging_info) {
$start_microtime = microtime(true);
}
$fields = $this->get('Extrafields');
if ($print_logging_info) {
$fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
}
if ($print_logging_info) {
$start_microtime = microtime(true);
}
foreach ($fields as $field) {
// a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description
// NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations
if ($field->iscore) {
FlexicontentFields::loadFieldConfig($field, $item);
}
// b. Create field 's editing HTML (the form field)
// NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow)
if (!$field->iscore) {
if (FLEXI_J16GE) {
$is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id);
} else {
if (FLEXI_ACCESS && $user->gid < 25) {
$is_editable = !$field->valueseditable || FAccess::checkAllContentAccess('com_content', 'submit', 'users', $user->gmid, 'field', $field->id);
} else {
$is_editable = 1;
}
}
if (!$is_editable) {
$field->html = '<div class="fc-mssg fc-warning">' . JText::_('FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>';
} else {
if ($modify_untraslatable_values && $field->untranslatable) {
$field->html = '<div class="fc-mssg fc-note">' . JText::_('FLEXI_FIELD_VALUE_IS_UNTRANSLATABLE') . '</div>';
} else {
FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item));
}
}
}
// c. Create main text field, via calling the display function of the textarea field (will also check for tabs)
if ($field->field_type == 'maintext') {
if (isset($item->item_translations)) {
$shortcode = substr($item->language, 0, 2);
foreach ($item->item_translations as $lang_id => $t) {
if ($shortcode == $t->shortcode) {
continue;
}
$field->name = array('jfdata', $t->shortcode, 'text');