Yiic message translation failing - yii

I'm trying to prep translation for a module. my config.php is just a copy from the framework, modified 'languages' for just 'fr'.
Here's my config.php file
return array(
'language'=>'en',
'sourcePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'messagePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'messages',
'languages'=>array('fr'),
'fileTypes'=>array('php'),
'overwrite'=>true,
'exclude'=>array(
'.svn',
'.gitignore',
'/i18n/data',
'/messages',
),
);
The command runs properly, and I get this kind of output:
Extracting messages from <MyProject>/protected/modules/admin/views/significantEvent/view.php...
...
Extracting messages from <MyProject>/protected/modules/admin/views/projectProgress/update.php...
But that's it. Nothing is changed anywhere, there's no new files, nothing was edited. It seems like the command didn't do anything but read all the files and tell me where to translate. What am I doing wrong?

You will probably have to edit your messages/config.php file so it includes the contents of the module.
set the sourcepath part of the array to
'sourcePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..',
And set the 'exclude' part to
'exclude' => array(
'.svn',
'.gitignore',
'/assets',
'/css',
'/images',
'/js',
'/yii',
'.htaccess',
'index.php',
'index-test.php'
)

Related

Shopware 6 Product variation image upload issue using API

I have tried to upload images for the different variations as like below with generating media_id in laravel.
str_replace('-', '', Str::uuid()->toString());
The above code is creating a random string and with the help of that some of the images are uploading but some are not.
$urlArr = array('url' => $url);
$parts = pathinfo($url);
$params = array('extension' => $parts['extension'],'fileName' => $parts['filename'] . '__' . md5(time()),);
$uploadImage = $shopware6HelperObj->post('_action/media/' . $mediaId . '/upload', $urlArr, $params, $accessToken);
Above is the process of upload variation images but somehow some of the products of variations are uploading while some are not.
Can you please suggest where is the issue and lake in the code?

Drupal 8 - Absolute url in content

I'm migrating my website from dev environment to production environment so the absolute path url entered in CkEditor, Content or fields by users won't work on the domain.
What can I do?
Database can be huge so I'm looking for something else than search and replace in a 40 mo sql file.
I'm on Drupal 8 with mysql
You can simply find which tables/fields in db contain your absolute urls you want to replace. And then replace it in mysql. Here is an example:
$fields_to_update = [
['table' => 'field_data_body', 'field' => 'body_value'],
['table' => 'field_data_body', 'field' => 'body_summary'],
['table' => 'field_data_field_account_notes', 'field' => 'field_account_notes_value'],
['table' => 'field_data_field_extra_text', 'field' => 'field_extra_text_value'],
];
foreach ($fields_to_update as $item) {
$table = $item['table'];
$field = $item['field'];
db_query("UPDATE {$table} SET $field = REPLACE($field, 'http://www.example.com/', :new_name) WHERE $field LIKE BINARY '%http://www.example.com/%'", array(':new_name' => '/'));
}
hope it helps

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.

Set Upload Folder when using FAL in TCA

Is it possible when using FAL, to set the upload destination folder directly in the TCA column? My configuration looks like this at the moment:
'images_outdoor' => Array (
'exclude' => 1,
'label' => 'Outdoor: ',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('images_outdoor', Array (
'appearance' => Array (
'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference'
),
'minitems' => 1,
'maxitems' => 6,
), $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),
),
I have such columns in different TCAs and want their images to be saved in different folders. So a standard folder setting doesn't work here.
I know this one is old but here is a answer.
There are no supported way for TYPO3 6.2, but in the new TYPO3 7.6 LTS it should be possible to register a hook in your ext_localconf.php file, add this:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['getDefaultUploadFolder'][] = 'VendorName\ExtensionName\Hooks\BackendUserAuthentication->getDefaultUploadFolder'
Create the file Classes/Hooks/BackendUserAuthentication.php and write something like this:
<?php
namespace VendorName\ExtensionName\Hooks;
classe BackendUserAuthentication {
public function getDefaultUploadFolder(Array $params, \TYPO3\CMS\Core\Authentication\BackendUserAuthentication $backendUserAuthentication) {
// Do what you wants here and return a object of \TYPO3\CMS\Core\Resource\Folder
}
}
The params array will contain this:
$_params = array(
'uploadFolder' => $uploadFolder, // The current \TYPO3\CMS\Core\Resource\Folder object, properly 1:/user_upload/
'pid' => $pid, // Page id
'table' => $table, // The table name
'field' => $field, // The field name
);
Now use the table and field name to change the upload folder - good look :)

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);