How to integrate newtinymce + elfinder extension in Yii? - tinymce

I wanted to integrate elFinder with TinyMCE. More specifically, make it available as a button somewhere on TinyMCE (like inside insert picture dialog).
What I have done so far:
1. have newtinymce, elfinder extensions under protected/extensions folder. (The author said integrating these two would be cleaner in code)
2. have ElfinderController, TinyMceController as described on extension page.
3. inside protected/config/main.php component secion:
'widgetFactory'=>array(
'widgets'=>array(
'TinyMce'=>array(
'language'=>'en',
'settings'=>array(
'language' => 'en',
'theme' => "advanced",
'skin' => 'o2k7',
'plugins' => "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",
// Theme options
'theme_advanced_buttons1' => "removeformat,pagebreak,visualchars,visualaid,|,insertlayer,moveforward,movebackward,absolute,styleprops,attribs,|,undo,redo,search,replace,cleanup,print,preview,save,newdocument",
'theme_advanced_buttons2' => "pastetext,pasteword,|,hr,blockquote,|,bullist,numlist,outdent,indent,justifyleft,justifycenter,justifyright,justifyfull,ltr,rtl,formatselect",//copy,cut,paste,
'theme_advanced_buttons3' => "nonbreaking,sub,sup,charmap,|,bold,italic,underline,strikethrough,forecolor,backcolor,fontsizeselect,fontselect",
'theme_advanced_buttons4' => "tablecontrols,|,link,unlink,anchor,|,image,media",
'theme_advanced_toolbar_location' => "top",
'theme_advanced_toolbar_align' => "right",
'theme_advanced_statusbar_location' => "bottom",
'theme_advanced_resizing' => true,
'relative_urls' => false,
'spellchecker_languages' => null,
'fileManager'=>array(
'class' => 'ext.elFinder.TinyMceElFinder',
'connectorRoute'=>'elfinder/connector',
),
)
)
)
),
4. in view file:
<?php
$this->widget('ext.tinymce.TinyMce', array(
'model' => $model,
'attribute' => 'content',
'compressorRoute' => 'tinyMce/compressor',
'htmlOptions' => array(
'rows' => 6,
'cols' => 60,
),
)); ?>
This gives me the TinyMCE editor without elFinder window as a button on TinyMCE somewhere (like inside insert picture dialog).
When I add the following inside view file, it gives me an elFinder area directly where I put the code.
<?php $this->widget('ext.elFinder.ServerFileInput', array(
'model' => $model,
'attribute' => 'content',
'connectorRoute' => 'elfinder/connector',
)
);?>
I guess this means elFinder is working. But I don't want it as a separate widget for a field, rather I want it to be part of TinyMCE as stated at the top.
What else do I need to integrate them?

It was a onfiguration problem. fileManager property was not a child of settings, but a sibling.
So config/main.php part should be something like:
'widgetFactory'=>array(
'widgets'=>array(
'TinyMce'=>array(
'language'=>'en',
'settings'=>array(...),
'fileManager'=>array(
'class' => 'ext.elFinder.TinyMceElFinder',
'connectorRoute'=>'elfinder/connector',
),

Related

TYPO3 TCA: Add CSS class selection to inputLink

I'm trying to add a CSS class selection in a TCA inputLink Field. I was able to create the selection in the RTE Editor and now I want to be able to select the same CSS classes in TCA link input fields.
Here is my current code:
'link' => [
'exclude' => 1,
'label' => 'foo label',
'config' => [
'type' => 'input',
'renderType' => 'inputLink',
'size' => 50,
'max' => 1024,
'eval' => 'trim',
'fieldControl' => [
'linkPopup' => [
'options' => [
'title' => 'foo title',
'class' => [
'valuePicker' => [
'mode' => 'blank',
'items' => [
['button', 'Button Style'],
],
],
],
],
],
],
'softref' => 'typolink',
],
],
I couldn't find anything in the TCA Docs. I thought I would give it a try with the LinkPopup --> options --> class. But (as expected) nothing happens.
How am I able to define such a selection dropdown in the link input field?
I'm using TYPO3 LTS 11.
Not sure if you have configured, what you are describing...
A valuePicker can be placed next to an input field of RenderTypes default, colorpicker, inputLink (-> TCAref). The class field in the linkPopup is a simple (hardcoded) form field without a defined renderType or other TCA configuration (Code insight).
There are only a few options for configuring a linkpopup (-> TCAref):
pid
allowedExtensions
blindLinkFields
blindLinkOptions
Setting a prefilled (not selectable) class seems to be possible via TCAMAIN.linkHandler-options (-> LinkBrowser-API). I found an example in an issue of EXT:bootstrap_package.

How can we add new fields in a new tab in user setting in TYPO3

How can we add new fields in a new tab in user setting in TYPO3 version 8.7?
Our problem is the creation of a new tab.
I can add new fields to personal data tab in user setting, but I need to create new fields into a new tab.
For backend admin user setting I added a new tab, but for user setting I want to try this. I have an extension and since the installation of the extension it will add-on.
I tried to create new tab in fe_user.php.
Previously I tried to change ext_tables.php, but that is not working at all.
// Add some fields to FE Users table to show TCA fields definitions
// USAGE: TCA Reference > $GLOBALS['TCA'] array reference >
// ['columns'][fieldname]['config'] / TYPE: "select"
$temporaryColumns = array (
'tx_examples_options' => array (
'exclude' => 1,
'label' => 'tx_examples_options',
'config' => array (
'type' => 'select',
'showitem' => array (
array('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:fe_users.tx_examples_options.I.0', '1'),
array('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:fe_users.tx_examples_options.I.1', '2'),
array('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:fe_users.tx_examples_options.I.2', '--div--'),
array('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:fe_users.tx_examples_options.I.3', '3'),
),
'size' => 1,
'maxitems' => 1,
)
),
'tx_examples_special' => array (
'exclude' => 1,
'label' => 'tx_examples_special',
'config' => array (
'type' => 'user',
'size' => '30',
'userFunc' => 'Documentation\\Examples\\Userfuncs\\Tca->specialField',
'parameters' => array(
'color' => 'blue'
)
)
),
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'fe_users',
$temporaryColumns
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'fe_users',
'--div--;newtab,tx_examples_options, tx_examples_special'
);
When I changed into file ext_tables.php
$GLOBALS['TYPO3_USER_SETTINGS']['columns']['copy_directory'] = array(
'label' => 'Alternative directory for saving copies',
'type' => 'text',
'table' => 'be_users',
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToUserSettings('copy_directory','after:lang');
then it's showing in "personal data" tab but I want new tab in user setting for non-admin user.
In general your code looks fine.
But you are in the wrong file!
Avoid ext_tables.php if possible.
If you change anything to the TCA you should do it in Configuration/TCA/ for new tables and Configuration/TCA/Overrides for enhancing existing tables.
Use filenames according to the table you are modifying.
In your case all the code should be located in Configuration/TCA/Overrides/fe_users.php.
And be sure you clear all caches if you develop anything with TCA!

zend addElements form onchange select

I try to add dinamically a form input Elemnt on onchange of select element.
I have this code:
$this->addElement('select', 'nationality', array(
'multiOptions' => array('CH' => 'Choose','IT' => 'Italy', 'other' => 'Other'),
'required' => true,
'label' => 'Nation',
'filters' => array('StringTrim'),
'onChange' => '???'
));
I try to paste my new element instead "???"
$this->addElement('select', 'nationality', array(
'multiOptions' => array('CH' => 'Choose','IT' => 'Italy', 'other' => 'Other'),
'required' => true,
'label' => 'Nation',
'filters' => array('StringTrim'),
'onChange' => '$this->addElement(
'text', 'codice_fiscale', array(
'required' => true,
'label' => 'Codice fiscale',
'required' => true
))'
));
I know is not correct, but I dont' found any documentation about it.
How can I add an element onchange select value?
Thanks in advance
I would approach the problem in a different way, if it's possible for you:
javascript functions to call on the onChange. It would be syntax correct (and, as you said, what you wrote is not correct, it's going to be printed out entirely on the onChange attribute, not interpreted through php).
so, i would write
'onChange' => 'addElement()'
and then declare the javascript function which handles new elements. Or, you can prepare the elements before (if you have a fixed number), and show / hide them. It may be convenient if you don't have much elements, but if they're too many, just add through javascript the needed one.
PseudoCode Javascript
function addElement()
{
// add your element here, or show / hide it
}
As far as I saw from my experience and similar cases
(Zend_form_element_select onchange in zend framework,
Zend Form: onchange select load another view content)
you won't escape from Javascript if you want to handle the "onChange"

How do I allow html tags in label for Zend form element using addElement()?

I am brand new to Zend and I've been given a project to make adjustments on. I'd like to add html to the labels for my form elements but I can't seem to get it right.
Here's what I have:
$this->addElement('text', 'school_name', array(
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 150)),
),
'required' => true,
'label' => 'Name* :<img src="picture.png">,
'size' => '90',
));
As is, of course, the <img src="picture.png"> text gets escaped and the whole string is displayed.
I've read that I need to use 'escape' => false in some capacity but I can't figure out where/how to use it in my specific case.
Any help would be great. Thanks!
After calling addElement fetch the label's decorator and change the escape setting:
$form->getElement('school_name')->getDecorator('label')->setOption('escape', false);
If you use this type of label a lot, you should consider writing a custom decorator.
You can also use the disable_html_escape in 'label_options' when adding an element to the form:
$this->add(array(
....
'options' => array(
'label' => '<span class="required">Name</span>,
'label_options' => array(
'disable_html_escape' => true,
)
),
...
));
Credit to Théo Bouveret's post 'Button content in ZF2 forms' for the answer.

Permanently show block in Moodle?

Is there a way to permanently show a block within Moodle? I am working on configuring a theme, and I wanted to know if there's a way to ensure that a block is visible no matter which page you're on.
One solution should be to add a new block region.
In your theme directory, in config.php file, modify the layout option and add your new region to all your used layouts:
$THEME->layouts = array(
'base' => array(
'file' => 'admin.php',
'regions' => array('your-region'),
'defaultregion' => 'your-region',
),
'standard' => array(
'file' => 'admin.php',
'regions' => array('your-region', 'side-post'),
'defaultregion' => 'your-region',
),
// The site home page.
'frontpage' => array(
'file' => 'general.php',
'regions' => array('tools-menu', 'side-post'),
'defaultregion' => 'tools-menu',
'defaultregion' => 'tools-menu',
),
'course' => array(
'file' => 'general.php',
'regions' => array('your-region'),
'defaultregion' => 'your-region',
'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true),
),
etc...
Then you edit all your layout files theme/your_theme/layout/*.php and add this line where you want your block to appear:
echo $OUTPUT->blocks_for_region('your-region');
Now, you will have to add your block to this region for all page type, simply execute this sql in you database:
INSERT INTO `mdl_block_instances` (
`id` ,
`blockname` ,
`parentcontextid` ,
`showinsubcontexts` ,
`pagetypepattern` ,
`subpagepattern` ,
`defaultregion` ,
`defaultweight` ,
`configdata`
)
VALUES ( NULL , 'your_block_name', '1', '1', '*', NULL, 'your-region', '0', NULL );