How can I install a yii extension, making it available to my whole web application? - yii

Recently I decided to study php and I discovered yii framework. At first glance it seemed very easy to work with it but now I am struggling to configure my web application for installing an extension to work with Enums. I downloaded this extension from their web site and I put it within extensions folder. The issue is that I am not able to call the subclasses that I created in my code. I created a few classes that extend from this superclass (extension).
Which configuration I must do to make this extension class, available to my web application code?
As I said I just put that extension class in my extensions folder and I am just instantiating them, inside controller's methods. When I run the code I see the same error message no matter any configuration I make:
include (xxx.php): failed to open stream: No such file or directory
If anyone does want to know more about this extension this is the page that shows some information about that.
http://www.yiiframework.com/extension/enum/

in config/main.php you should add your extension details in the components array, something like:
return array(
// 'preload'=>array('xyz',...),
'components'=>array(
'xyz'=>array(
'class'=>'ext.xyz.XyzClass',
'property1'=>'value1',
'property2'=>'value2',
),
// other component configurations
),
);
where xyz is an extension
or just put it in the extensions folder and import it by Yii::import('application.extensions.extensionname.*');

Related

how to use vue.js offline?

Hi I received a web project with all already implemented CSS js HTML code, directories, project structure etc.
I have to make changes in view.js but I don’t always have internet access on the move so is there a way to continue this project locally without changing my project structure?
I already have an existing web project whose file contains
-an HTML page
-a CSS file
-a js file
Place in their folders respectively
I want to use view.js on this project
The problem I don’t always have internet access when I’m on the move.
So how do I use seen?
Knowing that:
CDN is a script placed in HTML requiring a connection to run view
-Vue CLI is a package that allows to generate a new project view "certainly out of competition"
But I should start over
Because the directory structure and already predefined what doesn’t suit me.
How does it work?
How to just add view and continue the project without zero spread?
I already installed node.js (npm) on my pc if its can help .
"-- IN BRIEF:
If you still don’t understand
Imagine being entrusted with a web project all made HTML CSS JS already configure etc...
And you must use VUE to make changes
knowing that on the move you don’t always have the connection
How do you do that?
Assuming (I can't tell 100% from your description) that it is an un-compiled implementation that uses the CDN, you can easily handle this by copying the vue library locally and update the html to use the local version instead of the CDN.
if you need to keep the html, you could use a browser plugin like requestly but there are many others. There you can select the url that goes to the cdn and replace it with the local one.
Another option for chromium-based browsers is to use local overrides. Picture upload is not working currently, so can't include a picture, but the option is available through the sources tab in the developer tools. You need to enable overrides, select a folder, then you can select the resource that you want to serve from local override.

Dropwizard serve external images directory

I have a dropwizard API app and I want one endpoint where I can run the call and also upload and image, these images have to be saved in a directory and then served through the same application context.
Is it possible with dropwizard? I can only find static assets bundles.
There is similar question already: Can DropWizard serve assets from outside the jar file?
The above module is mentioned in the third party modules list of dropwizard. There is also official modules list. These two lists are hard to find maybe because the main documentation doesn't reference them.
There is also dropwizard-file-assets which seems new. I don't know which module will work best for your case. Both are based on dropwizard's AssetServlet
If you don't like them you could use it as example how to implement your own. I suspect that the resource caching part may not be appropriate for your use case if someone replace the same resource name with new content: https://github.com/dirkraft/dropwizard-file-assets/blob/master/src/main/java/com/github/dirkraft/dropwizard/fileassets/FileAssetServlet.java#L129-L141
Edit: This is simple project that I've made using dropwizard-configurable-assets-bundle. Follow the instructions in the README.md. I think it is doing exactly what you want: put some files in a directory somewhere on the file system (outside the project source code) and serve them if they exist.

ESAPI custom property files

Ok, so I've been researching ESAPI for awhile now and trying to determnine how to create custom ESAPI and validator.properties files that override those found in my ESAPI jar. How do I accomplish this? I know it looks in 4 places (reference: ESAPI properties file in Tomcat, ESAPI docs) when trying to load, obviously loading via the classpath works but it's loading the default property values. I can get my custom properties to load when I put them in my home directory but that isn't very helpful.
Is there a way to get ESAPI to load my custom properties files when they are in my main projects directory?
Did you try to use
-Dorg.owasp.esapi.resources=PATH_TO_FOLDER
JVM option?

How to get the file upload button to show in the EditMe extension

I'm using the ExtEditMe extension in my project with the following configuration:
$this->widget('ext.editMe.widgets.ExtEditMe',
array(
'model'=>$model,
'attribute'=>'Text',
'ckeConfig'=>array('enableTabKeyTools'=>true,'enterMode'=>2),
'height'=>'500',
'width'=>'100%',
'filebrowserImageBrowseUrl'=>'/protected/extensions/kcfinder/browse.php?type=files',
'filebrowserImageUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserBrowseUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files'
)
);
For some reason the file upload button isn't showing in the tool bar. Is there something else I need to add?
Questions too much for a comment. Could you check the following:
Check the permissions for the assets folder. Need to be writable by your
httpd (example apache:apache or apache:www-data)
EditMe should be inside the protected/extensions/ folder
Change your widget call to:
$this->widget('application.extensions.editme.widgets.ExtEditMe',
(used full path)
Check if kcfinder/config.php says: 'disabled' => false,
Also, there may be a need to put kcfinder in the root of the webapp. See this example with CKeditor.
The following comes from the CKEDITOR docs:
This button will be hidden by default (hidden:true). The filebrowser plugin looks for all elements with the filebrowser attribute and unhides them if appropriate configuration setting is available (filebrowserBrowseUrl/filebrowserUploadUrl).
Which could mean your config settings for the filebrowser plugin are not correct. You should try the following:
KCFinder (your filebrowser plugin) is not a yii extension as far as I know, so move the kcfinder folder to the root folder (or any other folder outside of the protected folder).
Change the paths to the KCFinder files. I recommend using yii's Yii::app()->baseUrl to make sure you're getting the correct paths:
'filebrowserImageBrowseUrl'=>Yii::app()->baseUrl.'/kcfinder/browse.php?type=files',
'filebrowserImageUploadUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files',
'filebrowserBrowseUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files',
'filebrowserUploadUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files'
Hope that helps.
'filebrowserImageBrowseUrl'=>'/protected/extensions/kcfinder/browse.php?type=files',
'filebrowserImageUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserBrowseUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files'
These URLs will be passed to the Javascript initiator of the extension, and they will be requested from there, so you can copy them and try requesting them from the browser to see if they are working (I'm almost sure they won't work).
One way you can work this out, is by creating a controller and includes these PHP files there, then make these URLs refer to the controller you created. Hope it helps.

Unable to find nib named error when trying to load nib from within a framework

I've got a 'Main app' and a 'Helper app' (sandboxed, if that matters) that share a private framework including some resources, nib files, sound files etc.
The framework gets called and used by both apps without issues. However from within in the Framework code I have a NSViewController that loads a nib file which is included in its resource folder. This seems to work as long as its called by the 'Main app'. Doing the same with the Helper app (a login item) however does not work and fails with an "Unable to find nib named" error.
The actual 'Framework' is copied to the Main app's 'Frameworks' directory and I use a #rpath in the helper app to find the framework: #executable_path/../../../../Frameworks
This setup seems to work just fine however at runtime it seems the frameworks code tries to find the named Resource under the helper app's Resource folder and not under the Framework's resource folder. Is there a setting or some flag that I can set in xcode to make the framework's always look under the exact path where the framework's executable/library is installed?
It seems the only solution is to copy the framework to the 'Helper' app as well. Resources otherwise do not get loaded if the framework was just a symbolic link to the actual framework placed inside the main app.
What you can do is making your Framework dynamic or shared like described here Dynamic Library Programming Topics
Though it is a bit of a complex process, but a very nice feature.
What else can help you?
Perhaps editing the Library Search Paths or the Framework Search Paths under your Build Settings in Xcode. there you can specify additional search paths to look for.
Even though, I would not copy the Framework to the Main app's dir. I would leave it in one place on your disk, add them to your project (Main and helper) and add the specified search path.
By the way: How is your framework implemented? Is it a folder, is it compiled, or is it only code files?