How to properly load DoctrineExtensions in Bisna? - php

I am trying to load some doctrine extensions but I get all sort of errors. So far this is what I have
In my ini:
autoloaderNamespaces[] = "DoctrineExtensions"
resources.doctrine.classLoader.loaderClass = "Doctrine\Common\ClassLoader"
resources.doctrine.classLoader.loaderFile = "Doctrine/Common/ClassLoader.php"
resources.doctrine.classLoader.loaders.DoctrineExtensions_Paginate.namespace = "DoctrineExtensions\Paginate"
resources.doctrine.classLoader.loaders.DoctrineExtensions_Paginate.includePath = APPLICATION_PATH '/../library/Doctrine/DoctrineExtensions/Paginate/'
And in one of my controllers:
$count = Paginate::getTotalQueryResults($query); // Step 1
$paginateQuery = Paginate::getPaginateQuery($query, $offset, $limitPerPage); // Step 2 and 3
$result = $paginateQuery->getResult();
And this is the error:
Warning: include_once(DoctrineExtensions/Paginate.php): failed to open stream: No such file or directory

Try something simple
//include class loader first
//make sure this is correct
$doctrine_root=APPLICATION_PATH. '/../library/Doctrine';
require_once $doctrine_root.'/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine',$doctrine_root);
$classLoader->register();
user Doctrine\DoctrineExtensions\Paginate;
Then try reset of the code
$count = Paginate::getTotalQueryResults($query); // Step 1
// Step 2 and 3
$paginateQuery = Paginate::getPaginateQuery($query, $offset, $limitPerPage);
$result = $paginateQuery->getResult();
let me know how this works
cheers :)
Note : I haven't tested this code at my end

I suggest you try this plugin: beberlei / DoctrineExtensions
And here are the details on how to integrate it into your project: README
I do not think you can do so for as the developer has built the extensions! :S
In order to use the autoload for the class Paginate, the class should have been called DoctrineExtensions_Paginate_Paginate.
Good Luck!

Related

PHP Fatal error: Class 'SmartySecurity' not found

Been pulling my hair for 2 hours on this Smarty 2.6 to Smarty 3.1 upgrade task for that old website. The reason is that the host is now PHP 7 only. No more PHP 5. I thought it would be a 1 hour deal, but it's quickly turning into a nightmare. I remember using Smarty back in 2005 and I've never used it ever again, but today, nearly 15 years later, this monstrosity of a template engine is haunting me back!
Here's the init PHP file's contents:
<?php
#Load Smarty library
#require_once("php/Smarty-2.6.26/libs/Smarty.class.php");
#require_once("php/smarty-3.1.34/libs/Smarty.class.php");
require_once("php/smarty-3.1.34/libs/SmartyBC.class.php");
require_once("php/smarty-3.1.34/libs/sysplugins/smarty_security.php");
class class_init extends SmartyBC {
function __construct(){
#Init
parent::__construct();
#Directories
$this->template_dir = "skin/".SKIN."/public/";
$this->compile_dir = "skin/".SKIN."/compile/";
$this->config_dir = "skin/".SKIN."/config/";
$this->cache_dir = "skin/".SKIN."/cache/";
#Caching
$this->caching = (boolean)SMARTY_CACHING;
$this->cache_lifetime = (int)SMARTY_CACHE_LIFETIME;
$this->debugging = true;
}
function is_cached($str_tpl, $cache_id = NULL, $compile_id = NULL){
return $this->isCached($str_tpl, $cache_id, $compile_id);
}
}
class MySecurity extends SmartySecurity {
public $secure_dir = array('/home/lesclownsducarro/public_html/');
public function __construct(Smarty $smarty){
parent::__construct($smarty);
}
}
?>
Here's the controller file's contents:
require_once("./php/class/init.php");
$_ENV['class_init'] = new class_init();
$securityPolicy = new Smarty_Security($_ENV['class_init']);
$securityPolicy->php_handling = \Smarty::PHP_ALLOW;
$_ENV['class_init']->enableSecurity($securityPolicy);
Getting a completely blank page and the error_log simply states:
[30-Dec-2019 22:22:40 UTC] PHP Fatal error: Class 'SmartySecurity' not found in /home/xxxxx/public_html/php/class/init.php on line 32
FOR BACKWARDS COMPATIBILITY, I need to use SmartyBC because the template is including PHP files all over the place. inb4 yes I know, and this is not my website.
Any ideas ?
DOH. Welp, I'm just too tired, it seems.
It should obviously be: $securityPolicy = new Smarty_Security($_ENV['class_init']);
...with the underscore. I don't know, I copy/pasted the example from smarty.net without paying any attention at all. "new SmartySecurity" as seen here: https://www.smarty.net/forums/viewtopic.php?p=72741
JFC.

PHP: Class not detected?

For some reason, when I try running my php script,
Fatal error: Class 'GeoTools\LatLngCollection' not found in ...
However, I have the classes in the same directory. Namely, I am using https://github.com/jkoreska/RouteboxerPHP
and I have all the scripts in the same directory.
Can someone tell me what I'm doing wrong?
Current script:
$points = [
[48.167, 17.104],
[48.399, 17.586],
[48.908, 18.049],
[49.22253, 18.734436],
[48.728115, 21.255798],
];
$collection = new GeoTools\LatLngCollection($points);
$boxer = new GeoTools\RouteBoxer();
//calculate boxes with 10km distance from the line between points
$boxes = $boxer->box(points, $distance = 10);
//boxes now contain an array of LatLngBounds
//literally have to return string that is printed to STDOUT
print $boxes
?>
When you write GeoTools\LatLngCollection then GeoTools is not the directory, but the namespace of the class LatLngCollection. However, the linked sourcecode defines no namespace at all, and by the way, no class named LatLngCollection. So what you most likely need to do is
require_once(__DIR__ . '/RouteBoxer.class.php');
$points = ...;
$collection = array();
array_push($collection, new LatLng(48.167, 17.104);
array_push($collection, new LatLng(48.399, 17.586);
/...
$boxer = new RouteBoxer();
//...
require includes a file. So I assume that you saved the classes in file "RouteBoxer.class.php" like it is in GitHub.

Uncaught exception 'Zend_Cache_Exception' with message 'cache_dir must be a directory'

I am new to Zend and I have to work on previously done project to add some functionality.
Below are the cache specifications in application.ini file.
cache.frontend.type = Core
cache.frontend.options.lifetime = 7200
cache.frontend.options.automatic_serialization = true
cache.frontend.options.cache_id_prefix = proj_name
cache.frontend.options.cache = true
cache.backend.type = Memcached
cache.backend.options.servers.1.host = 127.0.0.1
cache.backend.options.servers.1.port = 11211
cache.backend.options.servers.1.persistent = true
cache.backend.options.servers.1.weight = 1
cache.backend.options.servers.1.timeout = 5
cache.backend.options.servers.1.retry_interval = 15
logsdb.params.dbname = dataLink
I have installed memcache and it works fine. But the following error occurs when I want to start project.
Uncaught exception 'Zend_Cache_Exception' with message 'cache_dir must be a directory'
I tried to find some answers in google but none of the solutions worked. Please help me with this. I work on WAMP 2.1
Not sure, but if you use an "new" version of Zend Framework (1.8+?), than you have to use
CacheManager in your application.ini to setup the cache.
For memcache it should look like this:
resources.cachemanager.myache.frontend.name = Core
resources.cachemanager.mycache.frontend.options.automatic_serialization = On
resources.cachemanager.mycache.backend.name = Memcached
resources.cachemanager.mycache.backend.options.servers.1.host =
resources.cachemanager.mycache.backend.options.servers.1.port = 1
resources.cachemanager.mycache.backend.options.servers.2.host =
resources.cachemanager.mycache.backend.options.servers.2.port =
And somewhere in your Controller to get the Cache:
$cacheManager = $this->getInvokeArg('bootstrap')->getResource('cachemanager');
$myCache = $cacheManager->getCache('mycache');
Or anyhwhere in your code (i dont like this way)
$cacheManager = Zend_Controller_Front::getInstance()
->getParam('bootstrap')
->getResource('cachemanager');
$myCache = $cacheManager->getCache('mycache');

Ebay Trading API ReturnPolicyType

I'm trying to create a script to add items to my test ebay account. But I've hit a problem I'm not sure if I have the wrong file set? but it doesn't seem to match up to the documentation (or I'm reading it wrong).
The file set I have is PHP Toolkit with 527 Support. There is also PHP Toolkit with 515 Support. Both from https://www.x.com/developers/ebay/php-accelerator-toolkit-ebay-trading-api-edition
I've found this great script through another question on stack overflow
https://github.com/iloveitaly/ebay-php/blob/master/eBayCommon.php
And I've been looking at the online help files here: http://developer.ebay.com/devzone/xml/docs/WebHelp/wwhelp/wwhimpl/js/html/wwhelp.htm
Here is the error I'm getting: PHP Fatal error: Class 'ReturnPolicyType' not found
The way I understand it is that there should be a file for each "Type" there is one for CategoryType and AmountType but no file for ReturnPolicyType. And no reference to it any any of the files I have.. am I looking at this totally wrongly?
require_once '../EbatNs/EbatNs_ServiceProxy.php';
require_once '../EbatNs/EbatNs_Logger.php';
require_once '../EbatNs/VerifyAddItemRequestType.php';
require_once '../EbatNs/AddItemRequestType.php';
require_once '../EbatNs/ItemType.php';
require_once '../EbatNs/ItemConditionCodeType.php';
require_once '../EbatNs/GetMyeBaySellingRequestType.php';
require_once '../EbatNs/GetMyeBaySellingResponseType.php';
require_once '../EbatNs/GetItemRequestType.php';
$session = new EbatNs_Session('config/ebay.config.php');
$cs = new EbatNs_ServiceProxy($session);
$cs->_logger = new EbatNs_Logger();
$req = new VerifyAddItemRequestType();
$item = new ItemType();
$item->BuyItNowPrice;
$item->Description = 'test ��� � <b>Some bold text</b>';
$item->ListingDuration = 'Days_7';
$item->Title = '��� test-titel';
$item->Currency = 'EUR';
$item->ListingType = 'Chinese';
$item->Quantity = 1;
$item->StartPrice = new AmountType();
$item->StartPrice->setTypeValue('1.0');
$item->StartPrice->setTypeAttribute('currencyID', 'EUR');
$item->Country = 'GB';
$item->Location = '-- not given --';
$item->ConditionID = '1';
$item->PrimaryCategory = new CategoryType();
$item->PrimaryCategory->CategoryID = 11450;
$returnPolicy = new ReturnPolicyType();
$returnPolicy->setRefundOption($sellerConfig['refund']['option']);
$returnPolicy->setRefund($sellerConfig['refund']['option']);
$returnPolicy->setReturnsWithinOption($sellerConfig['refund']['within']);
$returnPolicy->setReturnsWithin($sellerConfig['refund']['within']);
$returnPolicy->setReturnsAcceptedOption($sellerConfig['refund']['returns']);
$returnPolicy->setReturnsAccepted($sellerConfig['refund']['returns']);
$returnPolicy->setDescription($sellerConfig['refund']['description']);
$returnPolicy->setShippingCostPaidByOption($sellerConfig['refund']['paidby']);
$returnPolicy->setShippingCostPaidBy($sellerConfig['refund']['paidby']);
$item->ReturnPolicy = $returnPolicy;
$item->Site = 'UK';
$item->ShipToLocations[]="Europe";
$item->PaymentMethods[] = 'PayPal';
$item->PayPalEmailAddress = 'paypal#intradesys.com';
$req->Item = $item;
$res = $cs->VerifyAddItem($req);
?>
You're going to have to get a newer toolkit. ReturnPolicy was added 3 1/2 years ago in 581.
Also, the lowest supported schema is now 629. I would recommend using as new of a toolkit as you can find. It looks like eBay hasn't updated their PHP page in a while, so you should go directly to the toolkit developer website to see what they have there.
Hope this helps!

Issues installing CKeditor in Kohana (v2)

I'm attempting to install CKeditor on Kohana 2. I've dropped the ckeditor folder into libraries/ and put ckeditor.php alongside the ckeditor folder in libraries/. I'm trying to call ckeditor in my controller with the following:
$this->ckeditor = new Ckeditor('FCKEDITOR1');
$this->ckeditor->BasePath = 'application/libraries/ckeditor/';
$this->ckeditor->value = 'This is some <strong>sample text</strong>.' ;
$this->ckeditor->create();
I'm getting the following error and having a hard time solving it:
Fatal error: Call to undefined method
CKEditor::create() in
[path redacted]/app-admin/controllers/blog.php
on line 18
well its simple: there is no such function in the CKEditor class.
also found this in comments:
* Example 1: get the code creating %CKEditor instance and print it on a page with the "echo" function.
* $CKEditor = new CKEditor();
* $CKEditor->returnOutput = true;
* $code = $CKEditor->editor("editor1", "<p>Initial value.</p>");
* echo "<p>Editor 1:</p>";
* echo $code;

Categories