How to configure OpenAds in CakePHP? - cakephp

I want to use OpenAds in CakePHP, how can I install it? I put the OpenAds folder in my vendors folder and tried to change the URL in the Router but it did not work.

I think you need to do a lot more than that.
You should place the OpenAds folder in /webroot to start with.
Then you probably want to create a small Helper or Element that can give you the right invocation codes for OpenAds. You should analyse the invocation codes OpenAds gives you and create a Helper that can fill in the blanks like zone ids and so on.

Related

Processing.js - Listing files from sketch directory

I'm new here, so hello everyone!
I wrote a few things in Processing language and now I need to switch to Processing.js. I need to write an app that first scans the sketch folder to prepare a list of provided files. And what was straightforward in Processing is not in PJS.
I'm currently searching the web but I only found solutions for classic Processing. I know that JavaScript has restrictions and in general can't access the user-side files, but is there any way to list the sketch-itself files?
The only way that comes to my mind is to list them on server side via PHP and generate the .pde file dynamically depending on the sketch folder. But the catch is to not use any other language.
Thanks in advance for help!
Processing.js running on a website can only get information that URLs can provide it, and since there are no "dir listings" on the web, it can't grab dir listing content for a URL for you work with. However, depending on what you really want to do, there might be a way to make it work without resorting to PHP.
Assuming you have your Pjs page running on www.example.org/index.html, and you want to list content for www.example.org/sketch/, one option is to simply have a file www.example.org/sketch/list.txt containing all the filenames that the sketch can access, and simply grab that with a
String[] fileNames = loadStrings("./sketch/list.txt")
instruction.
If you can give an example of what you mean with "I need to write an app that first scans the sketch folder to prepare a list of provided files", a more specific solution is probably possible (i.e., what are the files, what does the user need them for, etc)

Share controllers, models and views in multisite CakePHP 2.3 installation

I'm creating a CakePHP 2.3 advanced installation (several apps -websites- that share one same lib folder where all of cake's core files are located). This works without any problems, I just edit the core.php file in the Config folder for each app so it knows where to find cake's files. The file system looks something like:
[root]
[cake-core-files]
[websites]
[website-1]
[app]
[plugins]
[vendors]
[website-2]
...
[website-N]
These different apps are in fact different in some things (they are different websites) but at the same time there's many things that are common to all of them (for example some models, controllers, functions...). What I would like to do, if possible, is to have those apps also share a bunch of controllers, models, etc so I can put them in one place, instead of replicating them now for each app.
I've seen the concept of vendors and plugins in CakePHP (I actually use plugins in those websites, but from the /app/plugins folder), but I'm not sure if that would work in my case, or how I would set that up. I guess the idea would be to have another folder (for example [shared_objects]) at the same level of [cake-core-files] and [websites], but I don't know how I would have to configure cake to do that or how to call those objects from each app.
Any ideas?
EDIT
Based on the comments/responses below I'm trying to do this using the App:build() function in the bootstrap.php, but I can't get it to work. This is what I've done:
Added a new folder where I want to put the stuff to share between all apps:
[root]
[cake-core-files]
[shared-stuff] --> NEW FOLDER
[Model]
[Config]
[websites]
[website-1]
etc...
Placed the model User.php inside the new folder [shared-stuff/Model]
Added this line in the bootstrap:
App::build(array('Model' => array('/path/to/shared-stuff/Model')));
Deleted the model User.php from its original location [website-1/app/Model]
After this steps, it seems to work, the model User.php is loaded correctly from the [shared-stuff] folder (I've tested that printing App::objects('Model');, the User model is listed). However, it actually doesn't work, when I call that model from the UsersController in the login() function, the login doesn't work (although I don't receive any kind of error, even with debug set to 2).
This model uses a database configuration different from the default one (the users table is located in a different database than the default one). I don't know if this matters.
One thing is for sure, if I leave the same exact User.php model in its original location ( [website-1/app/Model]) it all works fine, including the login, so it's a problem with how I try to configure all this sharing stuff, not the model itself.
Any ideas what am I doing wrong?
I think it could be useful to share some controller/model between multiple websites, and do it without a plugin: Using shared controller/model lets you to overwrite it if needed. It should happen simply copying the controller/model in the website's correct folder and the system should use it instead of the shared one!
EDIT: Wonderful, it works, but i think there is a little error in cake's official documentation: All paths should be terminated with a Directory separator! In the cakephp book there aren't trailing slash. Add it to your App::build path and everything will work perfectly!
You can have plugins in the core Plugins/ dir
[root]
[lib]
[Cake]
[Plugins]
[Available]
[To]
[All]
[website-1] // the 'app' dir -> https://github.com/cakephp/cakephp/tree/master/app
[plugins]
[vendors]
[website-2] // you can have many of them named anything, 'app' is just one.
...
[website-N]
This folder specifically will make the plugins available to any app using the cake lib
EG:
Look at this. Copy app to website-1, repeat till website-n.

How can i copy my Magento files

I had an assignment in magento. I installed magento without sample data. I completed assignment tast in default magento setting. now i want to send this solution to my teacher. which files i should copy and send him so that it will work fine.
please help me..
Send to him whatever files created or edited, keep the folder structure the same as from the installation folder of Magento.
Best option would be to archive the whole Magento folder and make a dump of the database.
Put those 2 files together and upload them to some cyberlocker like mediafire or something.
If you added attributes you will need to provide with the database (unless you have written a module with an install script that automatically makes the changes.)
Give that link to your teacher ;)
PS: You could always just contact your teacher and ask him how he wants to have your solution.

How can I predict links in box.net?

I'm a new user on box.net site and I've uploaded A LOT of .zip files that I want to use in my project.
The problem is that, normally, the share link is something like: box.net/1.zip .. so I can predict that the 100th file will be box.net/100.zip ... but this is not the case in box.net..
I cant obviously copy every files link manually since what I uploaded and need is ~1000 small .zip files and copying each files link will take ages.
So is there a way to fix this?
We recently released a new feature, where you can give your share a custom name. See the blog entry for more details on how to use it.
Right now, we have not exposed an API to set these custom links, but that will be coming soon.

CakePHP include external php file in plugin

I'm making a main app in CakePHP 1.3.10 that has a couple of plugins. In one of them, I need to use a very big array ($array_test) populated "manually".
The way I have it now (which works perfectly) is that I declare the array in the controller of the plugin that I want to use it in (plugin1_home_controller.php for example), doing something like var $array_test = array(1,2,3,4,5...), and I can access it perfectly from the views in that controller.
The thing is that I would prefer having the array declared somewhere else in the plugin, since it's too big, and then load it when I need it.
So I'm trying to create a array_test.php file with the array declared in it, put in /app/plugins/plugin1/webroot/php/array_test.php, and then load it from the view using include "/php/array_test.php" (I also tried include "/plugin1/php/array_test.php" as the CakeBook says in the plugins assets section), but none of them work.
How can I get the right path? Or is there any good alternative to what I want to do? Thank you so much in advance!
If your plugin is in the app's directory use:
APP_PATH.'plugins'.DS.'plugin1'.DS.'webroot'.DS.'php'.DS.'array_test.php'
If your plugin is installed in the common cake directory:
CORE_PATH.'plugins'.DS.'plugin1'.DS.'webroot'.DS.'php'.DS.'array_test.php'

Resources