How define a unique "plugins" path to all apps in 1.3? - php

In 1.2 i used:
$pluginPaths = array(CAKE_CORE_INCLUDE_PATH . DS. 'vendors' . DS.
'plugins' . DS);
But.. in 1.3 we have the new plugins path, and i believe thats not
necessary the $pluginsPaths manual declaration if i have:
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
//define('CAKE_CORE_INCLUDE_PATH', ROOT);
define('CAKE_CORE_INCLUDE_PATH', $_SERVER['DOCUMENT_ROOT'] . DS .
"libs2");
}
I saved my plugin inside the "plugins path"...
But i have not sucess in:
var $components = 'Plugin.Component';
Anyone can help me?
Thanks, Celso.

Probably you need this.

Related

Overwrite block core file without custom module in Magento

I just want to know if I can create Product block in local code pool (i.e. \app\code\local\Mage\Catalog\Block\Product.php) without making my custom module just place this single file?
If so, will this local code pool block call or the core one call? If it would be the local one, please let me know why.
If you copy a code/core file to the code/local repository, the core file will be overwritten by the local file.
This is because of the include path order to load system files specified in app/Mage.php:
$paths = array();
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
$paths[] = BP . DS . 'lib';
So in your case the system will search for the Product.php in following order:
app/code/local/Mage/Catalog/Block/Product.php
app/code/community/Mage/Catalog/Block/Product.php
app/code/core/Mage/Catalog/Block/Product.php
lib/Mage/Catalog/Block/Product.php
If the system cannot find any of these files, it will throw an error.

defined('SITE_ROOT') ? null - Error including file in Wordpress

i am new on wordpress and i am trying to merge a website with wordpress as a theme which contains its own php files and folders " forms, includes, ajax and others .. "
i am using this to define and call a path on my files
defined('SITE_ROOT') ? null : define('SITE_ROOT', DS . 'home' .DS . 'sitename' . DS . 'public_html');
when i tried to do this in wordpress , it doesnt work , so i typed the full path like this
defined('SITE_ROOT') ? null : define('SITE_ROOT', DS . 'home' .DS . 'sitename' . DS . 'public_html' . DS . 'wordpress' . DS . 'wp-content' . DS . 'themes' . DS . 'citation');
it works locally! .. i tried to upload it online and i changed the path to
defined('SITE_ROOT') ? null : define('SITE_ROOT', 'c:' .DS . 'wamp' . DS . 'www' . DS . 'wordpress' . DS . 'wp-content' . DS . 'themes' . DS . 'citation');
but it doesnt work.
after searching i found an absolute path for wordpress folder , then i tried it locally and it works!
defined('SITE_ROOT') ? null : define('SITE_ROOT', ABSPATH . DS . 'wp-content' . DS . 'themes' . DS . 'citation');
i tried it online but it doesnt work again ..
any one can help ?
You may use this syntax:
defined("SITE_ROOT") || define("SITE_ROOT", "provide url here");
But this is not the solution, just a nice shortcut for defining a constant, anyways, you don't need to do this, WorrdPress has TEMPLATEPATH, instead and also WordPress provided so any helper functions for this kind of things and one of those:
// Prints http://www.example.com/home/wp/wp-content/themes/yourThrme
echo get_bloginfo('template_url');
Or use
// prints http://www.example.com/home/wp/wp-content/themes/yourThrme
bloginfo('template_url');
Also, worth checking these available functions. Check WordPress Integration with other Website.

Php copy() is not working properly

I'm trying to copy my uploaded file to another directory called img folder with following code. But it doesn't work properly. I don't know why ? can you help me plz ?
php Code:
if($image["name"] != "")
{
//$path = PATH . DS . "uploads" . DS . "products" . DS . $id;
$path = "../../uploads" . DS . "products" . DS . $id;
$path2 = "img";
if(!is_dir($path))
{
mkdir($path);
}
chmod($path, 0755);
//move_uploaded_file($image["tmp_name"], $path . DS . $image["name"]);
move_uploaded_file($image["tmp_name"], $path . DS .
$uploadImage);//exit;
copy($uploadImage, $path2);
}
Following error message show:
Warning: copy(249.jpg) [function.copy]: failed to open stream: No such file or directory in...
The copy() function needs the full file path for the source file; you're just passing the filename, not the path.
As things stand, it's looking in the current folder for the file, not finding it, and throwing the error as a result.
From the previous line of code, it looks like your full path should be $path . DS . $uploadImage, so the copy command should look like this:
copy($path . DS . $uploadImage, $path2);
hope that helps.
Your copy function is wrong...
copy($uploadImage, $path2);
As Spudley answer says, you have to use the full path of the image. Also, $path2 is a directory. You have to give a name for the new copy of the image.
So, your copy function would be as follows:
copy($path . DS . $uploadImage, $path2. DS . $uploadImage);
Try it and let us know.

Zend Framework - How to Properly set Include Path?

I'm trying to install TheStudio application which was apparently written using Zend Framework. My test server is running Ubuntu 12.04 and my application directory is stored in /home
My error log is stating
PHP Fatal error: require_once(): Failed opening required 'usr/share/php/libzend-frameworkphp/Zend/Loader/Autoloader.php'
(include_path='.:../library:../application/db:../application/models:../application/utils:../application/views/helpers:../application') in /home/application/config/config.php on line 22
Line 22 of config.php states:
require_once '/usr/share/php/libzend-framework-php/Zend/Loader/Autoloader.php';
The include path is as follows:
define('PS', PATH_SEPARATOR);
define('DS', DIRECTORY_SEPARATOR);
define('ROOT_DIR', dirname('home'));
// Modify include path
$paths = '.' . PS . '..' . DS . 'library'
. PS . '..' . DS . 'application' . DS . 'db'
. PS . '..' . DS . 'application' . DS . 'models'
. PS . '..' . DS . 'application' . DS . 'utils'
. PS . '..' . DS . 'application' . DS . 'views' . DS . 'helpers'
. PS . '..' . DS . 'application';
ini_set("include_path", $paths);
How should I modify the path statement to target the files located in /home directory? Are there other adjustments that should be made in order to resolve the above error?
/usr/share/php/libzend-frameworkphp is the default installation path for the Zend Framework Ubuntu package, so it seems this application is assuming that will be there. sudo apt-get install zend-framework should solve that problem.
I would say it's bad practice to include the full path on a require_once call, and there are way too many include paths being defined on your third code example (which I assume is from the app?).

Define absolute path for files

I have the following include files..
require_once ("config.php");
require_once ("functions.php");
require_once ("session.php");
I want to define absolute paths for my include files. I have tried with the following code and no luck..
can you please help to define an appropriate absolute path, so that require_once as expected.
defined('DS') ? null : define('DS',DIRECTORY_SEPARATOR);
defined('SITE_ROOT') ? null: define('SITE_ROOT',DS.'PHP_Files'. DS . 'phpsandbox'. DS.'my_mat'. DS.'my_test');
defined('LIB_PATH')?null:define('LIB_PATH',SITE_ROOT.DS.'includes');
require_once(LIB_PATH.DS."config.php");
require_once(LIB_PATH.DS."functions.php");
require_once(LIB_PATH.DS."session.php");
These 3 include files in my system are stored in J:\PHP_Files\phpsandbox\my_mat\my_test\includes.
Thanks in advance!
Ok, so I think what you are looking for is the actual system file path. To get that you can echo
dirname( __FILE__ );
You can do this in any file that you want and it will display the system file path relative to your file. For me it's something like this:
/home2/myusername/public_html/project_name/includes/config.php
so if you are interested in the "project_name" folder you should have something like this:
defined("SITE_ROOT") ? null : define("SITE_ROOT", DS . "home2" . DS . "myusername" . DS . "public_html" . DS . "project_name" );
Then if you are looking for the "includes" folder which will be your library you should have something like this:
defined("LIB_PATH") ? null : define("LIB_PATH", SITE_ROOT . DS . "includes" );
Hope this helps. I had the exact same problem and this worked for me.
Cheers, Mihai Popa
Try including your LIB_PATH in your include path.
set_include_path(LIB_PATH . DS . PATH_SEPARATOR . get_include_path());
require_once(dirname(__FILE__).DS."config.php");
require_once(dirname(__FILE__).DS."functions.php");
require_once(dirname(__FILE__).DS."session.php");
check it out , i think it's good
You need realpath function. Also, you can get all files included by get_included_files that returns array of absolute paths of files you've included at the moment function's got called.
defined('DS') or define('DS',DIRECTORY_SEPARATOR);
$disk_label = '';
if (PHP_OS == 'WINNT') {
if (FALSE !== ($pos = strpos(__FILE__, ':'))) {
$disk_label = substr(__FILE__, 0,$pos+1);
}
}
defined('SITE_ROOT') or define('SITE_ROOT', $disk_label.DS.'PHP_Files'. DS . 'phpsandbox'. DS.'my_mat'. DS.'my_test');
defined('LIB_PATH') or define('LIB_PATH',SITE_ROOT.DS.'includes');
require_once(LIB_PATH.DS."config.php");
require_once(LIB_PATH.DS."functions.php");
require_once(LIB_PATH.DS."session.php");

Categories