TYPO3 6.2x extBase RTE parse - fluid

I want to parse RTE content in TYPO3 6.2.9 extBase. I have tried:
$cObj = GeneralUtility::makeInstance('tslib_cObj');
$parseContent= $cObj->parseFunc($content, array(), '< lib.parseFunc_RTE');
$parseContent=\TYPO3\CMS\Frontend\Plugin\AbstractPlugin::pi_RTEcssText($content);
$cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
parseContent= $cObj->parseFunc($content, array(), '< lib.parseFunc_RTE' );
screenshot of the resulting html
How can I parse RTE content?

$Cobj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_cObj');
$htmloutput= $Cobj->parseFunc($myquerywithcontentvariable , array(), '< lib.parseFunc_RTE');
And of course Also use defaultExtras' => 'richtext:rte_transform[flag=rte_enabled|mode=ts_css] in your TCA file

Here is the function for the same
private function formatHtml($value) {
$contentObject = GeneralUtility::makeInstance(TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
$content = $contentObject->parseFunc($value, array(), '< lib.parseFunc_RTE');
return $content;
}

Alongwith RTE option enableRichText="1" please append this option as well defaultExtras="richtext:rte_transform[flag=rte_enabled|mode=ts_css]"
This might help :)

$parseProcObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
$parseProcObj->parseFunc($value, array(), '< lib.parseFunc_RTE')

Related

Email Template goes as Raw Html using Swiftmailer Symfony2

Hi I am sending email templates to email as followas:
//here $emailBody is a twig template with html.
$mailBody = $this->templating->render('test/template/layout.html.twig', array(
'mailBody' => $mailBody
));
$tmp = $this->mailer->createMessage();
$tmp->setSubject(trim($emailSubject));
$tmp->setFrom('test#gmail.com');
$tmp->setTo($somnerecipeient);
$tmp->setBody($emailBody, 'text/html');
$sent = $this->mailer->send($tmp);
So when I am geting email my inbox its comes like raw html.Even content-type is already set text/html as:
$tmp->setBody($emailBody, 'text/html');
What could be the issue, Please assist
Thanks advance
You should be using renderView and you spelled the content as $mailBody instead of $emailBody. So change like so:
$emailBody = $this->templating->renderView('test/template/layout.html.twig', array(
'mailBody' => $mailBody
));
Can you try that and see if it resolves the issue.

Shopify API Updating Fulfillments

I am writing a private app in Shopify with PHP. I have been able to get most of the other access to the json data, however, I am having trouble with Fulfillments - specifically updating a single line-item.
I am using the api-skeleton (phpish)?
Here is my code (the process as described seems so simple):
$orderid = "1350520065";
$itemid = "2338134657";
$quantity = 1;
$arguments = array(
'fulfillment' => array(
'tracking_number' => null,
'notify_customer' => true,
'line_items' => array(array('id' => $itemid, 'quantity' => 1))
)
);
$response = $shopify('POST /admin/orders/' . $orderid . '/fulfillments.json', $arguments);
I am getting [line_items] => Required parameter missing or invalid.
Any help would be appreciated.
Skip the line items unless you are doing a partial fulfillment. If you are, then obviously you need a quantity. You forgot that it seems, hence your error of missing parameter.
Add a header 'Content-Type:application/json' to your POST. That worked for me.

BOX-API upload file form

i'm trying to upload a file in BOX_API with php and Zend framework. But i'm missing somethin. It's the first time that i use an interface like this o i've read the manual. But it is confusig for me. My question are two:
-First, why do you have to pass to the post call only the name of the file and not the whole file with the right header for file upload? File upload in a form is not like passing the name of the file through a post call;
-secondly and consequently, do i have to make a form for file upload or simply a textarea where to write the name of the file to be passed to the BOX-API?
UPDATE:
This is the code of my upload form:
$form = new Zend_Form;
$form->setAction('/imball-reagens/public/upload')
->setMethod('post');
$file = new Zend_Form_Element_File('file');
$file->setLabel('Choose a file to upload:');
$file->addValidator('alnum');
$file->setRequired(true);
$form->addElement($file);
$access_token = new Zend_Form_Element_Hidden(array('name' => 'access_token', 'value' => $result->access_token));
$form->addElement($access_token);
$refresh_token = new Zend_Form_Element_Hidden(array('name' => 'refresh_token', 'value' => $result->refresh_token));
$form->addElement($refresh_token);
$form->addElement('submit', 'upload', array('label' => 'Upload File'));
echo $form;
And this s the POST cal to the box API which comes after the form:
$access_token= $this->getRequest()->getParam('access_token');
$client = new Zend_Http_Client('https://upload.box.com/api/2.0/files/content');
$client->setMethod(Zend_Http_Client::POST);
$client->setHeaders('Authorization: Bearer '.$access_token);
$data = $_FILES["file"]["name"];
$client->setParameterPost(array(
'filename' => '#'.$data,
'parent_id' => '0'
));
$response = $client->request()->getBody();
$this->view->response= $response;
$result = json_decode($response);
The error it throws is below:
{"type":"error","status":400,"code":"invalid_request_parameters","help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Invalid input parameters in request","request_id":"172518183652dcf2a16af73"}
Tricky to debug without seeing all of the code, but in the bit you pasted it looks like you are passing $_FILES["file"]["name"] to the API - this only contains the original name of the file which was uploaded by the user - you need to pass the location to the file on the server which is sending the data to the Box API client so that it can grab it and send it to the Box server - this should be stored in $_FILES["file"]["tmp_name"].
I would recommend changing the code to this and trying again:
$access_token= $this->getRequest()->getParam('access_token');
$client = new Zend_Http_Client('https://upload.box.com/api/2.0/files/content');
$client->setMethod(Zend_Http_Client::POST);
$client->setHeaders('Authorization: Bearer '.$access_token);
$data = $_FILES["file"]["tmp_name"];
$client->setParameterPost(array(
'parent_id' => '0'
));
$client->setFileUpload($data, 'filename');
$response = $client->request()->getBody();
$this->view->response= $response;
$result = json_decode($response);

how to add static elements to yii dropDownList?

echo $form->dropDownList(
$model,'categoryId',
CHtml::listData(Category::model()->findAllBySql(
'SELECT * from category where isnull(parent_id)'),
'id', 'name'),
array(
'empty'=>Yii::t('fim','Search All'),
Yii::t('fim','Jobs'),
Yii::t('fim','Training'),
Yii::t('fim','Events'),
Yii::t('fim','News')
)
);
Jobs, Training, Events and News are not appearing.
How can/should we build this, in order to add those values to the select box ?
Thanks
You cannot add static elements by using the $htmlOptions parameter. Here is how I do it:
$data = CHtml::listData(Category::model()->findAllBySql(
'SELECT * from category where isnull(parent_id)'),
'id', 'name');
// Add extra options here: I am actually prepending with this syntax,
// but you are free to append or interleave instead. Array keys are the values.
$static = array(
'jobs' => Yii::t('fim','Jobs'),
'training' => Yii::t('fim','Training'),
'events' => Yii::t('fim','Events'),
'news' => Yii::t('fim','News'),
);
echo $form->dropDownList(
$model,
'categoryId',
$static + $data,
array('empty'=>Yii::t('fim','Search All')));
For me, what i did is i added jquery code, i append an html option
$("#categoryId").append("<option value='0'>Additional Field</option>");
its less complicated and it works for me

Symfony file upload - "Array" stored in database instead of the actual filename

I'm using Symfony 1.4.4 and Doctrine and I need to upload an image on the server.
I've done that hundreds of times without any problem but this time something weird happens : instead of the filename being stored in the database, I find the string "Array".
Here's what I'm doing:
In my Form:
$this->useFields(array('filename'));
$this->embedI18n(sfConfig::get('app_cultures'));
$this->widgetSchema['filename'] = new sfWidgetFormInputFileEditable(array(
'file_src' => '/uploads/flash/'.$this->getObject()->getFilename(),
'is_image' => true,
'edit_mode' => !$this->isNew(),
'template' => '<div id="">%file%</div><div id=""><h3 class="">change picture</h3>%input%</div>',
));
$this->setValidator['filename'] = new sfValidatorFile(array(
'mime_types' => 'web_images',
'path' => sfConfig::get('sf_upload_dir').'/flash',
));
In my action:
public function executeIndex( sfWebRequest $request )
{
$this->flashContents = $this->page->getFlashContents();
$flash = new FlashContent();
$this->flashForm = new FlashContentForm($flash);
$this->processFlashContentForm($request, $this->flashForm);
}
protected function processFlashContentForm($request, $form)
{
if ( $form->isSubmitted( $request ) ) {
$form->bind( $request->getParameter( $form->getName() ), $request->getFiles( $form->getName() ) );
if ( $form->isValid() ) {
$form->save();
$this->getUser()->setFlash( 'notice', $form->isNew() ? 'Added.' : 'Updated.' );
$this->redirect( '#home' );
}
}
}
Before binding my parameters, everything's fine, $request->getFiles($form->getName()) returns my files.
But afterwards, $form->getValue('filename') returns the string "Array".
Did it happen to any of you guys or do you see anything wrong with my code?
Edit: I added the fact that I'm embedding another form, which may be the problem (see Form code above).
Alright, I got it. I wasn't properly declaring my validator.
What i should've done is:
$this->setValidator('filename', new sfValidatorFile(array(
'mime_types' => 'web_images',
'path' => sfConfig::get('sf_upload_dir').'/flash',
)));
Silly mistake, I hope that will help those who have the same problem.
Alternatively you can use;
$this->validatorSchema['filename']
in place of;
$this->setValidator['filename']