Passbook: line breaks in PKBarcodeFormatQR - passbook

I'm trying to build a wallet card included a VCF contact in the QR Code.
I got an issue with the line breaks, that are mandatory in VCF contact format.
I included my VCF String like this (build in PHP):
'barcodes' => [
0 => [
'format' => 'PKBarcodeFormatQR',
'message' => "$vCard",
'messageEncoding' => 'iso-8859-1',
],
],
And the generated QRCode included this string:
BEGIN:VCARD\nVERSION:3.0\nREV:2022-09-16T16:29:50Z\nN;CHARSET=utf-8:[...]END:VCARD\n
As you cas see, there is some \n instead of line breaks.
I need something like this:
BEGIN:VCARD
VERSION:3.0
REV:2022-09-16T16:29:50Z
N;CHARSET=utf-8:[...]
END:VCARD
Do you know how I can replace all \n with line breaks ?
Note: Everything working fine since iOS 16. I don't know what Apple changed in Wallet...

Related

Typo3 External importer is not mapping extended news fields

Using cobwebch/external_import and after extendig tx_news_domain_model_news with custom fields I try to map on import those. But the new created fields are not getting recognized by mapper.
my config which relays in TCA/Overrides/tx_news_domain_model_news.php and looks as it follows
$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['link_external']['external'] = [ 'news' => [ 'field' => 'tx_newsrundbrief_ext_link' ], ];
I'm using version 5.1
What I'm missing in this case?

How to display PDF file on yii2

I have a audit table and audit_report field.Field type is text .I saved pdf files into folder and saved name to database.I tried to display the pdf on view page. but the box with image sign only getting. I could display jpeg and png files nicely.How to display PDF on view page of yii2 framework.
This would work,
return Yii::$app->response->sendFile($completePath, $filename, ['inline'=>true]);
Input the function with third param as array of value 'inline'=>true to open the file within the browser window.
See the documentation here sendFile()
You could add a button that opens the file in a new tab, but make it link to an action in your controller that returns the file instead of the direct path to the file:
In your view:
<?= Html::a('PDF', [
'controller/pdf',
'id' => $model->id,
], [
'class' => 'btn btn-primary',
'target' => '_blank',
]); ?>
In your controller:
public function actionPdf($id) {
$model = ModelClass::findOne($id);
// This will need to be the path relative to the root of your app.
$filePath = '/your/file/path';
// Might need to change '#app' for another alias
$completePath = Yii::getAlias('#app'.$filePath.'/'.$model->fileName);
return Yii::$app->response->sendFile($completePath, $model->fileName);
}
Aliases - Key Concepts - The Definitive Guide to Yii 2.0
Although the question has been answered there is one thing that needs to be addressed if you have the file content/stream instead of the file path, like for instance you are using Dropbox API and you receive a stream from the API and want to display that file instead of forcing the browser to download.
For this case you can use the sendContentAsFile when attempting to display the PDF file in the browser you will need to specify the mimeType option too along with the "inline"=>true because the default mimeType value is set to application/octet-stream which is used to download a file and to display inline in browser you need to change it to application/pdf.
return Yii::$app->response->sendContentAsFile(
$fileContent,
$filename,
['inline' => true, 'mimeType' => 'application/pdf']
);

Yii The view file does not exist - where do mail layouts go

I am using basic template but have adapted the advanced user password reset functionality, for some reason I can't get it to find the mail layouts.
So in \mail\layouts I have
- passwordResetToken-html.php
- passwordResteToken-text.php
In web.php I have
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => 'app\mail\layouts',
...
The advanced template uses
'viewPath' => '#common/mail',
But as i'm using basic template, its not in the common/mail folder.
In sendMail function in PasswordResetRequestForm.php i have
return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])
...
However getting error
The view file does not exist: app\mail\layouts\passwordResetToken-html.php
I know this is going to be something small but for the life of me i cannot see it
Removed the 'viewPath' of config, as the doc don't use it.
So it works.

What is the correct place to set the Default Namespace for a Multiple Module project created with Phalcon DevTools?

I just started looking about Phalcon this week, I'm trying to create a multiple module application with the dev tools.
The result of running phalcon project <name> multiple only creates one module ('frontend') and it works fine. However, when I add a second module (by copying the frontend one and changing the namespace to \Backend , I couldn't get to the Backend\IndexController class.
After reading the doc page about mutiple module applications and looking at the samples (https://github.com/phalcon/mvc/tree/master/multiple and https://github.com/phalcon/mvc/tree/master/multiple-volt) and an old question on the Google group (sorry, can't post more than 2 links since I'm new on StackOverflow), I've ended commenting this this line on the services.php file:
$router->setDefaultNamespace("MyL\Frontend\Controllers"); //project name is MyL
and adding the following on the setServices of my backend/Module.php file:
$di->set('dispatcher', function() {
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace("MyL\Backend\Controllers");
return $dispatcher;
});
and the something similar on the frontend/Module.php
It works with these modifications, but my question is: is this the best way to do it, or is there a better way?
Thanks in advance!
You need to register your modules in your app like so:
$app = new \Phalcon\Mvc\Application();
$app->registerModules(
[
'frontend' => [
'className' => 'MyL\Frontend\Controllers',
'path' => '../apps/frontend/Module.php'
],
'backend' => [
'className' => 'MyL\Backend\Controllers',
'path' => '../apps/backend/Module.php'
],
]
);
Make sure that you have the Module.php ready also for each module
Here is a simple way to split frontend and backend in Phalcon project without modules:
https://github.com/borzov/phalcon-templates

Using Elfinder extension in Yii

I need to use a file manager in pop up which comes on a button click. I am using Yii extension elfinder. I am finding it hard to understand the way of using it. I downloaded the code from bitbucket, put it inside my application in the folder extension. I try to test it using new controller, named it elfcontroller and put the following code (got from the website)
class ElfinderController extends CController
{
public function actions()
{
return array(
'connector' => array(
'class' => 'ext.elFinder.ElFinderConnectorAction',
'settings' => array(
'root' => Yii::getPathOfAlias('webroot') . '/uploads/',
'URL' => Yii::app()->baseUrl . '/uploads/',
'rootAlias' => 'Home',
'mimeDetect' => 'none'
)
),
);
}
}
and i created one more function for rendering the index page(i want the file manager to be in this page)
in the view i wrote the following code
$model = new xxxmodel();
$this->widget('ext.elFinder.ElFinderWidget', array(
'model' => $model,
'attribute' => 'serverFile',
'connectorRoute' => 'admin/elfinder/connector',
)
);
and i included a div for containing it
But i am getting the following error
Alias "ext.elFinder.ElFinderWidget" is invalid. Make sure it points to an existing PHP file and the file is readable.
i tried to include alias in config/main.php
I know i am messing some where with the folder structure
here is the path i am using the extension
C:\xampp\htdocs\project\protected\extensions\ext.elfinder
I returned empty after google searches, can any one please explain me how to use this extension to place the code exactly where it is needed to be?
In general the extensions folder already has the ext alias, so you don't need to set an alias for it.
Then the extension itself should be placed in the extensions folder, somewhat like : project/extensions/extension-name/ . In your case it should be: project\extensions\elFinder , and keep the rest of your code same, i.e continue referring to extension like:
ext.elFinder.ElFinderWidget