can't use css file zf2 (Zend\View\HelperPluginManager::get was unable to fetch or create an instance for inlineStyle) - zend-framework

I have a css and js files, i want to use it and call it from controller, for js these lines work perfectly:
$serverUrl = $this->baseUrl();
$headScript = $this->getServiceLocator()->get('viewhelpermanager')->get('inlineScript');
$headScript->appendFile($serverUrl . '/assets/js/file.js');
But for css when i use these lines :
$serverUrl = $this->baseUrl();
$headScript = $this->getServiceLocator()->get('viewhelpermanager')->get('inlineStyle');
$headScript->appendFile($serverUrl . '/assets/js/file.css');
i have this error:
Zend\View\HelperPluginManager::get was unable to fetch or create an instance for inlineStyle

Try to use “headLink” instead of “inlineStyle”.

Related

Add node CATEGORIES to vcard with perl module "vCard::AddressBook"

I do not find a possibility to add nodes like CATEGORIES or ORG to a vcard object when using the perl module vCard::AddressBook (https://metacpan.org/pod/vCard::AddressBook).
The output should look like this:
BEGIN:VCARD
VERSION:4.0
...
N:Doe;John;;;
...
ORG:Organization_01;
CATEGORIES:Cat_01
...
END:VCARD
When I use the following code:
use vCard::AddressBook;
my $address_book = vCard::AddressBook->new();
my $vcard = $address_book->add_vcard;
$vcard->given_names(['John']);
$vcard->family_names(['Doe']);
$vcard->categories(['Cat_01']); ## DOES NOT WORK
my $file = $address_book->as_file('file.vcf');
I get the following error:
Can't locate object method "categories" via package "vCard" at tmp2.pl line 6.
What is the best way to get other nodes like CATEGORIES in my vcard file?
BTW: RFC6350 defines it... https://www.rfc-editor.org/rfc/rfc6350#section-6.7.1
There is https://metacpan.org/pod/Text::vCard::Precisely which seems to be more compliant with RFC6350:
use Text::vCard::Precisely;
my $vcard = Text::vCard::Precisely->new( version => '4.0' );
$vcard->n(['John','Doe']);
$vcard->categories([qw/Cat_01 Cat_02 Cat_03/]);
print $vcard->as_string();
prints:
BEGIN:VCARD
VERSION:4.0
N:John;Doe;;;
CATEGORIES:Cat_01,Cat_02,Cat_03
END:VCARD

Save a file in a flask-wtf form to MongoDB's GridFS

I'm using the flask-user extension (https://flask-user.readthedocs.io/) along with the mongoengine adapter and flask-wtf to create an HTML form that'll accept several files (images, mp4). The goal is to directly store those files in MongoDB using GridFS but I can't get it to work without storing the image locally on the flask server first...
Here's my non-working code:
#bp.route('/video1', methods=['GET', 'POST'])
#login_required
def video1():
video1Form = Video1Form()
if request.method == 'POST' and video1Form.validate_on_submit():
newVideo1 = Video1(
slogan = video1Form.slogan.data,
objectif = video1Form.objectif.data,
stat1 = video1Form.stat1.data,
stat2 = video1Form.stat2.data
)
name = secure_filename(str(current_user.id) + "__" + "logo.png")
fh = open(video1Form.logo.data, 'rb')
newVideo1.logo.put(fh, filename=name, content_type = "image/jpeg")
newVideo1.save()
return redirect(url_for('video.download'))
if video1Form.errors:
flash(video1Form.errors, 'alert-danger')
return render_template('video/video1.html', video1Form=video1Form)
`
I get the following error on:
[...]File "/home/lucaspierru/Documents/IKADA/sos_sponsors/app/video/routes.py", line 35, in video1
fh = open(video1Form.logo.data, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'name_of_the_uploaded_file.ext'
Is it possible to point directly to the file's content and not just get the filename without saving it to the server first ?
I found my mistake:
I forgot to add the enctype="multipart/form-data" attribute to my HTML <form> tag and apparently it is needed to properly upload files, otherwise they'll be considered as text data.

imagick error: 'unable to open image' image upload

I get the following error when trying to process uploaded images with imagick.
Fatal error: Uncaught exception 'ImagickException' with message 'unable to open image `9eK59iu.jpg': No such file or directory # error/blob.c/OpenBlob/2644' in D:\PATH\upload.php on line 77
The code looks like this:
<?php
$new_folder_name = "D:/PATH/content";
mkdir("$new_folder_name",0700);
$tmp_img = $_FILES["upload_file"]["tmp_name"];
$img = new Imagick($tmp_img);
$img->thumbnailImage(100 , 100 , TRUE);
$img->writeImage($new_folder_name);
?>
Without imagick the image upload works just fine.
Only imagick won't open the image given to $_FILES
I also tried to open the image with imagick, after move_uploaded_file, like this:
<?php
$extension = pathinfo($upload_file_name, PATHINFO_EXTENSION);
$new_upload_file_name = rand(00000, 99999).".".$extension;
$new_folder_name = "D:/PATH/content".time();
mkdir("$new_folder_name",0700);
$path_to_file = $new_folder_name."/".$new_upload_file_name;
move_uploaded_file($_FILES["upload_file"]["tmp_name"],$path_to_file);
$img = new Imagick($path_to_file);
$img->thumbnailImage(100 , 100 , TRUE);
$img->writeImage($new_folder_name);
?>
neither works.. :-(
Any suggestion?
Read the file upload docs. The server-side temporary filename assigned by PHP to store the uploaded file in ['tmp_name'] in the $_FILES array. You're trying to use the client-side user-provided ['name'], which DOES NOT exist anywhere on your server.
$tmp_img = $_FILES["upload_file"]["tmp_name"];
^^^^
You are also simply assuming that the upload has succeed. That is NOT a good thing. Never EVER assume success with dealing with remote resources (web apis, file uploads, database operations, etc...). ALWAYS check for errors:
if ($_FILES['upload_file']['error'] !== UPLOAD_ERR_OK) {
die("Upload failed with error code " . $_FILES['upload_file']['error']);
}

Change epydoc's favicon - how to?

Everything is in the question :
How would I do to change epydoc's generated html pages favicon ?
Note : I saw how to customize the css content, but nothing about customizing output html files...
Many thanks.
Ok, so after a littel brainstorming (with myself), I found a way :
Since we can inject some html using --navlink option to epydoc (initially designed to customize project's link in the navigation bar), I used a javascript trick to add the following dynamically in the tag of the document.
Here is the javascript code :
var link = parent.document.createElement('link');
link.id = 'dynamic-favicon';
link.type = 'image/png';
link.rel = 'shortcut icon';
link.href = '../logo-fav.png'; parent.document.head.appendChild(link);
parent.document.head = parent.document.head ||
parent.document.getElementsByTagName('head')[0];
And here is the full epydoc command line :
epydoc -v --name "My Project" -o ./html \
--css epydoc.css --url http://www.my-project.org --inheritance listed \
--graph all --no-private --docformat epytext \
--navlink "<img src=\"../logo.png\" style=\"margin:10px;\" />
<script>
var link = parent.document.createElement('link');
link.id = 'dynamic-favicon';
link.type = 'image/png';
link.rel = 'shortcut icon';
link.href = '../logo-fav.png';
parent.document.head.appendChild(link);
parent.document.head = parent.document.head || parent.document.getElementsByTagName('head')[0];
</script>
" \
my_py_module
This can be used to customize the whole documentation, but is still hacky. Still strange that their is no way to use some templates in such a mature tool like epydoc...

Using Soap in magento

I'm trying to follow the information about how to use soap in magento, but always get same message in error.log
If any one experience something similar, that could give me some tip, it will be welcome.
"PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.site.com/index.php/api/?wsdl' : failed to load external entity "http://www.site.com/index.php/api/?wsdl"\n in /var/www/test.php on line 1"
$client = new SoapClient('http://www.site.com/api/?wsdl');
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'somestuff.method');
$result = $client->call($session, 'somestuff.method', 'arg1');
$result = $client->call($session, 'somestuff.method', array('arg1', 'arg2', 'arg3'));
$result = $client->multiCall($session, array(
array('somestuff.method'),
array('somestuff.method', 'arg1'),
array('somestuff.method', array('arg1', 'arg2'))
));
// If you don't need the session anymore
$client->endSession($session);
where you have www.site.com in your SOAP code, replace it with localhost or whatever the correct URL is for your server. You'll also need to replace somestuff.method with real objects and methods as per the Magento documentation