示例#1
0
 protected function getEditor()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/classes/editor.php';
     $config = JFactory::getConfig();
     $K2Editor = K2Editor::getInstance($config->get('editor'));
     $init = 'function () {' . $K2Editor->init() . '}';
     $setContent = 'function (name, content) {' . $K2Editor->setContent('REPLACE_NAME', 'REPLACE_CONTENT') . '}';
     $getContent = 'function (name) {' . $K2Editor->getContent('REPLACE_NAME') . '}';
     $save = 'function (name) {' . $K2Editor->save('REPLACE_NAME') . '}';
     $js = '{init : ' . $init . ', setContent : ' . $setContent . ', getContent : ' . $getContent . ', save : ' . $save . '}';
     $js = JString::str_ireplace("'REPLACE_NAME'", 'name', $js);
     $js = JString::str_ireplace('"REPLACE_NAME"', 'name', $js);
     $js = JString::str_ireplace('REPLACE_NAME', 'name', $js);
     $js = JString::str_ireplace("'REPLACE_CONTENT'", 'content', $js);
     $js = JString::str_ireplace('"REPLACE_CONTENT"', 'content', $js);
     $js = JString::str_ireplace('REPLACE_CONTENT', 'content', $js);
     $K2Editor->display('text', '', '100%', '300', '40', '5');
     return $js;
 }
示例#2
0
 /**
  * Hook for children views to allow them attach fields to the form object.
  * Children views usually should override this method.
  *
  * @return void
  */
 protected function setFormFields(&$_form, $row)
 {
     $language = JFactory::getLanguage();
     $language->load('', JPATH_ADMINISTRATOR);
     $language->load('com_users', JPATH_ADMINISTRATOR);
     // Import JForm
     jimport('joomla.form.form');
     // Determine form name and path
     $formName = 'K2' . ucfirst($this->getName()) . 'Form';
     $formPath = JPATH_ADMINISTRATOR . '/components/com_users/models/forms/user.xml';
     // Convert JRegistry instances to plain object so JForm can bind them
     if ($row->id) {
         $row->params = $row->params->toObject();
     }
     // Get the form instance
     $form = JForm::getInstance($formName, $formPath);
     // Bind values
     $form->bind($row);
     $form->setValue('password', null);
     $form->setValue('password2', null);
     // Attach the JForm fields to the form
     foreach ($form->getFieldsets() as $fieldset) {
         $array = array();
         foreach ($form->getFieldset($fieldset->name) as $field) {
             $tmp = new stdClass();
             $tmp->label = $field->label;
             $tmp->input = $field->input;
             $array[$field->name] = $tmp;
         }
         $name = $fieldset->name;
         $_form->{$name} = $array;
     }
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models');
     $model = JModelLegacy::getInstance('User', 'UsersModel');
     if ($row->id) {
         $assignedGroups = $model->getAssignedGroups($row->id);
     } else {
         $assignedGroups = null;
     }
     $_form->groups = JHtml::_('access.usergroups', 'groups', $assignedGroups, true);
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/helpers/html.php';
     $_form->gender = K2HelperHTML::gender('gender', $row->gender);
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/helpers/extrafields.php';
     $_form->extraFields = K2HelperExtraFields::getUserExtraFieldsGroups($row->extra_fields);
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/classes/editor.php';
     $config = JFactory::getConfig();
     $editor = K2Editor::getInstance($config->get('editor'));
     $_form->description = $editor->display('description', $row->description, '100%', '300', '40', '5');
 }
示例#3
0
<?php

/**
 * @version		3.0.0
 * @package		K2
 * @author		JoomlaWorks http://www.joomlaworks.net
 * @copyright	Copyright (c) 2006 - 2014 JoomlaWorks Ltd. All rights reserved.
 * @license		GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */
// no direct access
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR . '/components/com_k2/classes/editor.php';
$config = JFactory::getConfig();
$editor = K2Editor::getInstance($config->get('editor'));
?>

<?php 
if ($field->get('editor')) {
    ?>
	<?php 
    echo $editor->display($field->get('prefix') . '[value]', $field->get('value'), '100%', '300', (int) $field->get('rows', '10'), (int) $field->get('columns', '40'));
    ?>
	<script type="text/javascript">
	K2Editor.init();
	</script>
<?php 
} else {
    ?>
	<textarea rows="<?php 
    echo (int) $field->get('rows', '10');
    ?>
示例#4
0
 protected function setFormFields(&$form, $row)
 {
     $form->state = K2HelperHTML::state('state', $row->state, false, true, 'radio', true);
     $form->language = K2HelperHTML::language('language', $row->language);
     $form->access = JHtml::_('access.level', 'access', $row->access, '', false);
     $form->category = K2HelperHTML::categories('catid', $row->catid, 'K2_SELECT_CATEGORY');
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/classes/editor.php';
     $config = JFactory::getConfig();
     $editor = K2Editor::getInstance($config->get('editor'));
     $params = JComponentHelper::getParams('com_k2');
     if ($params->get('mergeEditors')) {
         $value = trim($row->fulltext) != '' ? $row->introtext . '<hr id="system-readmore" />' . $row->fulltext : $row->introtext;
         $form->text = $editor->display('text', $value, '100%', '300', '40', '5');
     } else {
         $form->introtext = $editor->display('introtext', $row->introtext, '100%', '300', '40', '5', array('readmore'));
         $form->fulltext = $editor->display('fulltext', $row->fulltext, '100%', '300', '40', '5', array('readmore'));
     }
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/helpers/extrafields.php';
     $form->extraFields = K2HelperExtraFields::getItemExtraFieldsGroups($row->catid, $row->extra_fields);
     $form->mediaProviders = K2HelperHtml::mediaProviders();
     // Associations
     $associations = new stdClass();
     $associations->enabled = JLanguageAssociations::isEnabled();
     $associations->languages = array();
     if ($associations->enabled) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         foreach ($languages as $tag => $language) {
             if (empty($row->language) || $tag != $row->language) {
                 $lang = new stdClass();
                 $lang->title = $language->title;
                 $lang->code = $language->lang_code;
                 $lang->associated = new stdClass();
                 $lang->associated->title = '';
                 $lang->associated->id = '';
                 if (isset($row->associations) && is_array($row->associations) && isset($row->associations[$language->lang_code])) {
                     $associated = $row->associations[$language->lang_code];
                     $lang->associated->title = $associated->title;
                     $lang->associated->id = (int) $associated->id;
                 }
                 $associations->languages[] = $lang;
             }
         }
     }
     $form->associations = $associations;
 }
示例#5
0
 protected function setFormFields(&$form, $row)
 {
     $form->state = K2HelperHTML::state('state', $row->state, false, true, 'radio', true);
     $form->language = K2HelperHTML::language('language', $row->language);
     $form->access = JHtml::_('access.level', 'access', $row->access, '', false);
     $form->parent = K2HelperHTML::categories('parent_id', $row->parent_id, 'K2_NONE', $row->id);
     $form->inheritance = K2HelperHTML::categories('inheritance', $row->inheritance, 'K2_NONE', $row->id, '', false, 'id', true);
     $form->template = K2HelperHTML::template('template', $row->template);
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/classes/editor.php';
     $config = JFactory::getConfig();
     $editor = K2Editor::getInstance($config->get('editor'));
     $form->description = $editor->display('description', $row->description, '100%', '300', '40', '5');
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/helpers/extrafields.php';
     $form->extraFields = K2HelperExtraFields::getCategoryExtraFieldsGroups($row->extra_fields);
     // Associations
     $associations = new stdClass();
     $associations->enabled = JLanguageAssociations::isEnabled();
     $associations->languages = array();
     if ($associations->enabled) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         foreach ($languages as $tag => $language) {
             if (empty($row->language) || $tag != $row->language) {
                 $lang = new stdClass();
                 $lang->title = $language->title;
                 $lang->code = $language->lang_code;
                 $lang->associated = new stdClass();
                 $lang->associated->title = '';
                 $lang->associated->id = '';
                 if (isset($row->associations) && is_array($row->associations) && isset($row->associations[$language->lang_code])) {
                     $associated = $row->associations[$language->lang_code];
                     $lang->associated->title = $associated->title;
                     $lang->associated->id = (int) $associated->id;
                 }
                 $associations->languages[] = $lang;
             }
         }
     }
     $form->associations = $associations;
 }