Wordpress WP_editor() HTML formatting - php

I'm working today on an Wordpress plugin with the beautiful WP_Editor()
But this editor doesn't format their HTML, every time i add some html text with the editor and save it correctly as an posts in the database, is everything fine. but when i post this html string data to my WP_Editor() it messed it up.
Is their an solution to get the right format to view html in the wp_editor?
thanks a lot!
P.s. my code:
$settings_desc = array(
'textarea_name' => 'description',
'mode' => 'specific_textareas',
'editor_selector' => 'theEditor',
'width' => '100%',
'theme' => 'advanced',
'skin' => 'wp_theme',
'theme_advanced_buttons1' => 'bold,italic,strikethrough,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,|,link,unlink,wp_more,|,spellchecker,fullscreen,wp_adv',
'theme_advanced_buttons2' => 'formatselect,underline,justifyfull,forecolor,|,pastetext,pasteword,removeformat,|,media,charmap,|,outdent,indent,|,undo,redo,wp_help',
'theme_advanced_buttons3' => '',
'theme_advanced_buttons4' => '',
'language' => 'de',
'spellchecker_languages' => 'English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,+German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv',
'theme_advanced_toolbar_location' => 'top',
'theme_advanced_toolbar_align' => 'left',
'theme_advanced_statusbar_location' => 'bottom',
'theme_advanced_resizing' => true,
'theme_advanced_resize_horizontal' => false,
'dialog_type' => 'modal',
'relative_urls' => false,
'remove_script_host' => false,
'convert_urls' => false,
'apply_source_formatting' => false,
'remove_linebreaks' => true,
'gecko_spellcheck' => true,
'entities' => '38,amp,60,lt,62,gt',
'accessibility_focus' => true,
'tabfocus_elements' => 'major-publishing-actions',
'media_strict' => false,
'paste_remove_styles' => true,
'paste_remove_spans' => true,
'paste_strip_class_attributes' => 'all',
'wpeditimage_disable_captions' => false,
'plugins' => 'safari,inlinepopups,spellchecker,paste,wordpress,media,fullscreen,wpeditimage,wpgallery,tabfocus',
);

Related

ZF2 Add custom attribute to option in a select form element

I would like to add a custom HTML attribute to an option of a select in a Zend Framework 2 Form.
This is my (partial) code from my Form class:
$this->add(array(
'name' => 'lieuRemplissage',
'type' => 'Select',
'attributes' => array(
'class' => 'form-control',
),
'options' => array(
'label' => _('Lieu pré-enregistré'),
),
));
I populate my options values in my controller like this :
$form = new \Vente\Form\Vente;
foreach($this->getAdminLieuDeVenteTable()->fetchAll() as $lieu) {
$optionsLieu[$lieu->getId()] = $lieu->getNom();
}
$form->get('lieuRemplissage')->setValueOptions($optionsLieu);
But now, for each option I want to add an html attribute to all select options but with a different value for each one.
Is there a way do achieve that in ZF2 ?
Thanks.
Yes this is possible with ZF2
You pass in the attributes within the option value. The value should be in array format:
//example in view:
$select=new \Zend\Form\Element\Select('test');
$select->setValueOptions(
[
['attributes'=>['data-key'=>'value'],'value'=>'myValue','label'=>'myLabel']
]
);
echo $this->formselect($select);
prints:
<select name="test"><option value="myValue" data-key="value">myLabel</option></select>
EDIT:
The attributes you provide must be valid HTML attributes you cannot put any random key/value pairs.
For example data-* is fine as are the following :
protected $validGlobalAttributes = array(
'accesskey' => true,
'class' => true,
'contenteditable' => true,
'contextmenu' => true,
'dir' => true,
'draggable' => true,
'dropzone' => true,
'hidden' => true,
'id' => true,
'lang' => true,
'onabort' => true,
'onblur' => true,
'oncanplay' => true,
'oncanplaythrough' => true,
'onchange' => true,
'onclick' => true,
'oncontextmenu' => true,
'ondblclick' => true,
'ondrag' => true,
'ondragend' => true,
'ondragenter' => true,
'ondragleave' => true,
'ondragover' => true,
'ondragstart' => true,
'ondrop' => true,
'ondurationchange' => true,
'onemptied' => true,
'onended' => true,
'onerror' => true,
'onfocus' => true,
'oninput' => true,
'oninvalid' => true,
'onkeydown' => true,
'onkeypress' => true,
'onkeyup' => true,
'onload' => true,
'onloadeddata' => true,
'onloadedmetadata' => true,
'onloadstart' => true,
'onmousedown' => true,
'onmousemove' => true,
'onmouseout' => true,
'onmouseover' => true,
'onmouseup' => true,
'onmousewheel' => true,
'onpause' => true,
'onplay' => true,
'onplaying' => true,
'onprogress' => true,
'onratechange' => true,
'onreadystatechange' => true,
'onreset' => true,
'onscroll' => true,
'onseeked' => true,
'onseeking' => true,
'onselect' => true,
'onshow' => true,
'onstalled' => true,
'onsubmit' => true,
'onsuspend' => true,
'ontimeupdate' => true,
'onvolumechange' => true,
'onwaiting' => true,
'role' => true,
'aria-labelled-by' => true,
'aria-described-by' => true,
'spellcheck' => true,
'style' => true,
'tabindex' => true,
'title' => true,
'xml:base' => true,
'xml:lang' => true,
'xml:space' => true,
);
I just figured this out and wanted to share here since I saw this question while I was searching for the same question. Should give the same result with the suggested way but directly using options' attributes in form class; especially useful if passing data object to form construct to populate options like me.
$this->add(array(
'name' => 'lieuRemplissage',
'type' => 'Select',
'attributes' => array(
'class' => 'form-control',
),
'options' => array(
'label' => _('Lieu pré-enregistré'),
'value' => 123
'attributes' => array(
'data-key' => 'value_for_data_attribute_goes_here',
),
),
));

Orange HRM 3.1 leave list customization

In orangehrm3.1 I want to customize view leave request page. If leave request day is greater than 3 I need to hide Actions list box for supervisor.
How do I do this?
Currently editing in LeaveListConfigurationFactory.php
$leaveRequestService = new LeaveRequestService();
$header7->populateFromArray(array(
'name' => 'Actions',
'width' => '10%',
'isSortable' => false,
'isExportable' => false,
'elementType' => 'leaveListAction',
'textAlignmentStyle' => 'left',
'elementProperty' => array(
'classPattern' => 'select_action quotaSelect',
'defaultOption' => array('label' => 'Select Action', 'value' => ''),
'hideIfEmpty' => true,
'options' => array($leaveRequestService, 'getLeaveRequestActions', array(self::RECORD, self::$loggedInEmpNumber)),
'namePattern' => 'select_leave_action_{id}',
'idPattern' => 'select_leave_action_{id}',
'hasHiddenField' => true,
'hiddenFieldName' => '{eimId}-{leaveTypeId}',
'hiddenFieldId' => '{eimId}-{leaveTypeId}',
'hiddenFieldValueGetter' => 'getNumberOfDays',
'hiddenFieldClass' => 'quotaHolder',
'placeholderGetters' => array(
'id' => 'getId',
'eimId' => 'getEmpNumber',
'leaveTypeId' => 'getLeaveTypeId'
),
),
));

CJuiDatepicker hide on select

I'm trying to force the CJuiDatepicker to hide after I select the date. Nothing works. How could I achieve it?
Here's my actual code:
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model' => $model,
'attribute' => 'confirmStart',
'options' => array(
'format' => 'yyyy-mm-dd',
'showButtonPanel' => false,
'onSelect' => 'js:function() {
$("#Projects_confirmStart").datepicker("hide");
}
',
),
));
It is working fine in my test Yii app. Check your program with mozilla firebug. You may get error in console when you select the date. May be your datepicker functionality is effecting by some other plugins/scripts.
This work for me.
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model' => $model,
'attribute' => 'fechaAdq',
'language' => 'es',
'i18nScriptFile' => 'jquery-ui-i18n.min.js',
'htmlOptions' => array(
'id' => 'FMAIDetalleAdq_fechaAdq',
'size' => '10', * *'onChange' => 'jQuery("#FMAIDetalleAdq_fechaAdq").datepicker("hide")' * *
) ,
'defaultOptions' => array(
'showOn' => 'focus',
'showOtherMonths' => true,
'selectOtherMonths' => true,
'changeMonth' => true,
'changeYear' => true,
'showButtonPanel' => true,
) ,
'options' => array(
'showAnim' => 'fold',
'format' => 'dd-mm-yyyy',
'language' => 'es',
) ,
) , true);

How add time to datepicker in backend magento

I'am using magento 1.7.2 and I want to add date attribute with time which saves date as well as time in database for that product.
i had tried this code to add new attribute using mysql-setup file in my module.
$setup->addAttribute('catalog_product', 'new_date', array(
'group' => 'General',
'input' => 'date',
'type' => 'datetime',
'label' => 'New Date',
'backend' => 'eav/entity_attribute_backend_datetime',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'searchable' => 1,
'filterable' => 1,
'comparable' => 1,
'visible_on_front' => 1,
'visible_in_advanced_search' => 0,
'is_html_allowed_on_front' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
but this gives me only date to select not time.
Please help me.
Thanks.
Try this for backend (any admin panel form):
$fieldset->addField('your_column_name', 'date',array(
'name' => 'image_link', /* should match with your table column name where the data should be inserted */
'time' => true,
'class' => 'required-entry',
'required' => true,
'format' => $this->escDates(),
'label' => Mage::helper('featuredpopup')->__('From:'),
'image' => $this->getSkinUrl('images/grid-cal.gif')
));
in format u can write directly 'yyyy-MM-dd HH:mm:ss' or one more method like
private function escDates() {
return 'yyyy-MM-dd HH:mm:ss';
}
Hopes this gives u an idea.
Try these (works on Magento 1.8):
$this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'test_date_time', array(
'input' => 'datetime',
'type' => 'datetime',
'time' => true,
'label' => 'Date&Time',
'visible' => true,
'required' => false,
'user_defined' => true,
'visible_on_front' => true,
'backend' => 'eav/entity_attribute_backend_time_created',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL
));
Hello check app/code/local/Magik/Popup/Block/Adminhtml/Popup/Edit/Tab/Form.php
Add below code
$dateFormatIso=Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$fieldset->addField("text_name", "date", array(
"name" => "text_name",
"label" => Mage::helper("modelname")->__("Start Date"),
"title" => Mage::helper("modelname")->__("Start Date"),
"image" => $this->getSkinUrl('images/grid-cal.gif'),
"input_format" => Varien_Date::DATE_INTERNAL_FORMAT,
"format" => $dateFormatIso,
"time" => false,
"value" => "textstart",
));
when creating a custom attribute you just need to add
'input'=> 'datetime' instead of 'input'=> 'date'

make magento custom attribute filterable

Is there a way to make a custom magento product attribute filterable through a setup file and resource file?
I can create the attribute, I can even set the group it goes into but w/out manually going into the admin and adjusting the filterable option on the attribute, I can't get it to be set to filterable (especially filterable - I've tried w/ true/false and 0,1,2). I've tried adjust about every option that makes sense.
ie:
app/code/local/Company/Module/Model/Resource/Eav/Mysql4/Setup.php
public function getDefaultEntities()
{
return array(
'catalog_product' => array(
'entity_model' => 'catalog/product',
'attribute_model' => 'catalog/resource_eav_attribute',
'table' => 'catalog/product',
'additional_attribute_table' => 'catalog/eav_attribute',
'entity_attribute_collection' => 'catalog/product_attribute
'attributes' => array(
'attribute_name' => array(
'group' => 'Attribute Set Group',
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Attribute Label',
'input' => 'select',
'class' => '',
'source' => 'eav/entity_attribu
'global' => Mage_Catalog_Model_
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => false,
'searchable' => true,
'filterable' => 1,
'comparable' => false,
'visible_on_front' => true,
'visible_in_advanced_search' => true,
'used_in_product_listing' => true,
'used_for_sort_by' => true,
'unique' => false,
),
),
),
);
}
app/code/local/Company/Module/Model/sql/module_setup/mysql4-install-0.1.0.php
$this->installEntities();
You can add an attribute in the following way:
module_name\sql\machinesearch_setup
Create one SQL setup file like this in your module.
<?php
$installer = $this;
$data= array (
'attribute_set' => 'Default',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'label' => 'Year',
'input' => 'multiselect',
'type' => 'text',
'default_value_text' => 'varchar',
'unique' => false,
'required' => false,
'visible' => true,
'searchable'=> true,
'visible_in_advanced_search' => true,
'html_allowed_on_front' => true,
'comparable' => false,
'backend_type' => 'varchar',
'backend' => 'eav/entity_attribute_backend_array',
'group' => 'General',
'user_defined' => true,
);
$installer->addAttribute('catalog_product','mmy_year',$data);
$data= array
(
'attribute_set' => 'Default',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'label' => 'Make',
'input' => 'multiselect',
'type' => 'text',
'default_value_text' => 'varchar',
'unique'=> false,
'required'=> false,
'visible' => true,
'searchable'=> true,
'visible_in_advanced_search'=> true,
'html_allowed_on_front' => true,
'comparable'=> false,
'backend_type' => 'varchar',
'backend'=> 'eav/entity_attribute_backend_array',
'group' => 'General',
'user_defined'=> true,
);
$installer->addAttribute('catalog_product','mmy_make',$data);
$data= array (
'attribute_set' => 'Default',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'label' => 'Model',
'input' => 'multiselect',
'type' => 'text',
'default_value_text' => 'varchar',
'unique' => false,
'required' => false,
'visible' => true,
'searchable' => true,
'visible_in_advanced_search' => true,
'html_allowed_on_front' => true,
'comparable' => false,
'backend_type' => 'varchar',
'backend' => 'eav/entity_attribute_backend_array',
'group' => 'General',
'user_defined' => true,
);
$installer->addAttribute('catalog_product','mmy_model',$data);
$installer->endSetup();
?>

Categories