CakePHP 1.3.3 Broken Pagination Sort Options
Posted by Timothy on Aug 1, 2011 in PHP, Programming
Working with CakePHP v1.3.3 and the Pagination helper I discovered that the Direction option for the Sort method sort of goes ignored— or more like over-written with whatever value CakePHP decides to use. I’m not happy with my hack, but I need this functionality today. I’m also not too fond of having to hack-up source code when upgrades will be involved because I have to keep porting forward my patches. So anyhow. Here’s what I’m trying to do.
In my view, I’d like to have sort options such as, Most Recent, Most Viewed, Longest Video, Shortest Video. I’ve tried hard-coding the URL for the Paginator to use, this didn’t work well with some of the search options. I tried to be crafty with $this->here, $this->action and $this->name. I figured it’d be best to let the Paginator deal with it. So I dug up the documentation on $this->Paginator->sort(); Set ‘direction’=>’desc’, and the generated link wasn’t in Descending order. :-S Here’s what I found.
$dir = isset($options['direction']) ? $options['direction'] : 'asc';
unset($options['direction']);
$sortKey = $this->sortKey($options['model']);
$defaultModel = $this->defaultModel();
$isSorted = (
$sortKey === $key ||
$sortKey === $defaultModel . '.' . $key ||
$key === $defaultModel . '.' . $sortKey
);
if ($isSorted) {....}
I changed it to check for the Direction option.
$dir = isset($options['direction']) ? $options['direction'] : 'asc';
//unset($options['direction']);
$isSorted = false;
if (!isset($options['direction']))
{
$sortKey = $this->sortKey($options['model']);
$defaultModel = $this->defaultModel();
$isSorted = (
$sortKey === $key ||
$sortKey === $defaultModel . '.' . $key ||
$key === $defaultModel . '.' . $sortKey
);
}
if ($isSorted) {....}
Seems to work with all my other pagination throughout the site. I haven’t tested it heavily, but it appears to work.
Read MoreUsing CakePHP with Plesk 10
Posted by Timothy on Jul 12, 2011 in PHP, Programming
If you haven’t already figured it out, you can’t just unarchive CakePHP and drop it into your httpdocs folder under Plesk. There’s some minor changes you need to make before Plesk plays nicely with CakePHP.
First think that needs to be done is to create a vhost.conf file in /var/www/vhosts/domain.com/conf/ directory that contains the following
<Directory /var/www/vhosts/domain.com> php_admin_flag engine on php_admin_value open_basedir none </Directory>
After you’ve done that, you’ll need to run the Plesk command line tool to regenerate the vhost files.
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain domain.comRead More
Vimeo, OAuth and CakePHP Session Security Settings
Posted by Timothy on Jan 12, 2011 in PHP, Programming, Software
So after ripping my hair out for a good 2-3hrs trying to figure out why my Vimeo OAuth requests wasn’t returning any sessions variables, I finally figured it out.
CakePHP’s Configure::write(‘Security.level’, ‘medium’); sets PHP’s session.referer_check and denies any other hosts from setting session variables. I was wondering why half my sessions vars were gone and it would appear I was logged-out. Setting Configure::write(‘Security.level’, ‘low’); seems to have fixed the issue. But anytime you read ‘Security Low’ in the same sentence, it leaves you with some sort of uncomfortable feeling.
I’m not exactly sure what the status of this is. But I found a link that pretty much explains it all. session.referer_check PHP ini var should be decoupled from ‘High’ and ‘Medium’ Session Security levels
Read MoreHosting CakePHP on GoDaddy
Posted by Timothy on Nov 24, 2010 in PHP, Programming
Found this simple .htaccess fix for getting CakePHP to work on GoDaddy.
mod_rewrite On GoDaddy Shared Hosting
Just adding the leading / fixes the “500 Internal Server Error” I was getting.
Read MoreCentOS 5.2 w/ CakePHP + PCRE
Posted by Timothy on Oct 2, 2010 in PHP, Programming
After wondering why CakePHP’s Inflector::slug() was returning gibberish, I found this post about how to fix it.
Unicode Support on CentOS 5.2 with PHP and PCRE
Read More