Errors when implementing WURFL with Zend - php

I've looked around and cant seem to find someone with the same issue as me, hoping i've not missed a clanger here.
I'm wanting to get device browser information for each user, i'm currently planning on doing this within the bootstrapper, following something i saw in PHP conference.
To that end i came across:
http://framework.zend.com/manual/en/zend.http.user-agent.html
Which explains how to install and use wurfl. I've followed the instructions and am coming up with the following exception:
Uncaught exception 'Zend_Http_UserAgent_Features_Exception' with message '"wurflapi" configuration is not defined'
My limited understanding of Zend leads me to think the issue is within configs/application.ini
I have the following:
resources.useragent.wurflapi.wurfl_api_version = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/wurfl-php-1.1/"
resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/configs/wurfl-config.php"
Where my wurfl-config.php looks like:
echo "Loaded";
die;
$resourcesDir = dirname(__FILE__) . '/../../data/wurlf/';
$wurfl['main-file'] = $resourcesDir . 'wurfl-latest.zip';
$wurfl['patches'] = array($resourcesDir . 'web_browsers_patch.xml');
$persistence['provider'] = 'file';
$persistence['dir'] = CACHE_ROOT . "/wurfl/";
$cache['provider'] = null;
$configuration['wurfl'] = $wurfl;
$configuration['persistence'] = $persistence;
$configuration['cache'] = $cache;
I'm expecting the script to die after priting loaded, but i'm not getting this, meaning the config isnt loading correctly.
Where might be the problem? What more information do you require? Has anyone else come across this dilemma before?
Thanks in advance

Seems that you're unable to do what i want.
In that this doesnt seem to want to work within a bootstrap. Instead you should do this as a plugin.
This video tutorial helps explain the documentation a little better:
http://mcloide.wordpress.com/2010/12/08/mobile-development-with-zend-framework-and-wurfl/
Now that i have setup the plugin i dont get the exception and my config loads perfectly. Humpf!!

Related

Notice: Trying to get property of non-object in ../libraries/src/UCM/UCMType.php on line 169

When I tried to install the Joomla! extension JCH, I came up with the title message above after finished installing.
I asked the developer and he replied that I don't have to worry about the extension as this is a Joomla! issue that it will not affect the way the extension works.
The line 169 of UCMType.php is the following:
$tableNameFromType = $tableFromType->special->prefix . $tableFromType->special->type;
And the specific part of the UCMType.php that includes line 169:
public function getTypeByTable($tableName)
{
$query = $this->db->getQuery(true);
$query->select('ct.*');
$query->from($this->db->quoteName('#__content_types', 'ct'));
// $query->where($this->db->quoteName('ct.type_alias') . ' = ' . (int) $typeAlias);
$this->db->setQuery($query);
$types = $this->db->loadObjectList();
foreach ($types as $type)
{
$tableFromType = json_decode($type->table);
$tableNameFromType = $tableFromType->special->prefix . $tableFromType->special->type;
if ($tableNameFromType === $tableName)
{
return $type;
}
}
return false;
}
You really do not have to give too much attention for this issue, so the third party extension developer was right in this. This is more like a small bug (thus the Notice is there), not a serious Error. Your site will operate without a problem.
As you see in this Notice, in the foreach(){} loop a variable is tried to be defined from another variable which is not an Object, so it is just getting back a NULL value or another TYPE most probably, which does not have an Object property what is expected there.
In this particular case this whole thing happens in a relatively new Joomla core class and interface (UCM and UCMType). In this class they want to define a content type by table and this part of the code has to be modified, improved by core Joomla developers.
What should you do?
1. If you want to help the development of Joomla and yourself a bit then please report this issue here: https://developer.joomla.org/tracker.html , and they will check and repair this most probably.
2. This PHP (error) Notice is usually for developers, so if your site is a live site you should not see this Notice basically. If you see this on live site, that could mean that either your Joomla error reporting is set incorrectly, or your server error reporting default is set incorrectly.
In your Joomla admin at System->Global Configuration->Server->Error reporting has to be set to System Default or to None. Thus these not relevant notices will not appear for users, visitors of your site. Other settings only recommended if your site is not a live site and you develop that further in a staging copy for example.
And please if you have Joomla questions, visit the Joomla Stack Exchange here: https://joomla.stackexchange.com/questions and please ask your questions regarding Joomla there.
I hope the above cleared the issue for you.

Validator "Restore" returned fail status on WAMP

trying to upgrade from 4.3.3sp1 to 4.3.4 on my localhost ( WAMP ).
However on the validation step it fails with:
Validation issue
Validator "Restore" returned fail status Unable to
prepare restore script.
Tried changing file permissions and some other things I found on Google.
Did not manage to find any additional data about this even on their bugtracker.
Any help would be appreciated.
Found the issue.
CS-Cart is trying to build the restore file name with this rule:
$target_restore_file_name = 'restore_' . date('Y-m-d_H:i:s', TIME) . '.php';
But Windows does not allow ":" in the filenames. So a workaround would be to do something like this:
$target_restore_file_name = 'restore_' . date('Y-m-d_His', TIME) . '.php';
Or other variations.
This code is in app/Tygh/UpgradeCenter/App.php in the prepareRestore() function
Hope this will help someone

php - DbQuery() class and T_OBJECT_OPERATOR

I need to connect a list of subscribers to a website that deals with newsletters, called newsman. The website is on prestashop, so I searched for a module to do the work, and found this: https://github.com/Newsman/PrestaShop-Newsman.
I downloaded it. uploaded it to the prestashop website, but I got an error:
Syntax error, unexpected T_OBJECT_OPERATOR`
So I started dabbling with the code and found that the issue is:
$q = (new DbQuery())
->select('`email`')
->from('newsletter')
->where('`active` = 1');
which I modified to this:
$q = new DbQuery();
$q->select('`email`')
->from('newsletter')
->where('`active` = 1');
After these changes, I was able to install the module, had access to it, but pressing the synchronize button( which calls a function that contains this bit of code from above) didn't do anything, so I guess I didn't really solve anything.
What can I do to solve this? And what is DbQuery? I cannot seem to find anything about this class online? I worked with SQL queries before, but never with this class and the structure of the query seems weird to me.

PHP code for a total newbie with just enough knowledge to debug

I'm just logical, not a coder.
I'm also not english, so i hope you will understand me.
I have some troubles with some PHP scripts and i don't find out where's the problem.
This code is working well as a standalone. When used with another module (joomla), it returns this error.
Code :
}
// Used for styling the active article
$item->active = $item->id == $active_article_id ? 'active' : '';
$item->title = self::truncate($item->title, $title_limit);
if ($show_introtext) {
$item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'mod_sj_carousel.content');
self::getAImages($item, $params);
$item->introtext = self::_cleanText($item->introtext);
} else {
$item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'mod_sj_carousel.content');
self::getAImages($item, $params);
}
$item->displayIntrotext = $show_introtext ? self::truncate($item->introtext, $introtext_limit) : '';
$item->displayReadmore = $item->alternative_readmore;
}
return $items;
}
}
Returned Error :
Fatal error: Call to undefined method SjCarouselHelper::getAImages() in /home/abecedai/public_html/advvpm/modules/mod_sj_carousel/core/helper.php on line 159
I've no idea how and where i should define this method. I guess the problem is in the code, not fair for my PHP configuration. What is strange, is that it's working well without another joomla plugin activated (Jcomments). When Jcomments is activated, it goes wrong and crash.
I've been parsing the code, and did not found any function or declaration with similar name. Ther is definatly a conflict.
Parsing the module code where i get this error, this is the only place where i can find getAImages().
PHP ver is 5.3.25
Please consider me as a total noob in coding. I can understand what it does, but i'm not able to code myslef as i never learned how to.
I don't see the sense of this line if it doesn't exists
self::getAImages($item, $params);
Delete and run it again.
Look for SjCarouselHelper. There must be 2 versions of that and one is probably overwriting the other. Keep the newer version, copy it to both locations if possible.
This is just a guess of course since I can't see the whole thing - but I'm almost certain this is what happens.

Tumblr API in PHP File structure

I'm trying to use the Tumblr API (PHP) and I cant seem to get all the required files to load correctly.
The Tumblr API can be found here: https://github.com/tumblr/tumblr.php
First thing I found out is that it doesnt include OAuth, so after some searching I found the files on github and uploaded them to my server.
Now it's saying it needs Guzzle. OK, got that uploaded now, but I cant seem to get all the Guzzle files to load up... Example error message:
Interface 'Guzzle\Common\HasDispatcherInterface' not found in /TumblrTest/Guzzle/Common/AbstractHasDispatcher.php
There's a HasDispatcherInterface.php file in that path...
Do the files need to be in a special order? I tried putting all .php files into a folder, and then using require_once I searched for all *.php files in that folder, but that didnt work...
Sorry for a super noob question, any help would be greatly appriciated! Let me know if there's any other info i need to give to help answer this question!
-D
UPDATE: I still have no idea how the above works, but I found a way around it... I actually think it might be easier then figuring the above out!! The following PHP code does what i need it to do, which is grab the posts of the provided user:
$apikey = **[insert api key here]**;
$limit = $_POST['limit'];
$user = $_POST['user'];
$tumblr=$user . ".tumblr.com";
$apidata = json_decode(file_get_contents("http://api.tumblr.com/v2/blog/$tumblr/posts/photo?api_key=$apikey&limit=$limit"));
$mypostsdata = $apidata->response->posts;
$myposts = array();
$j = 0;
foreach($mypostsdata as $postdata) {
$post["photo_url"] = $postdata->photos[0]->original_size->url;
$post["width"] = $postdata->photos[0]->original_size->width;
$post["height"] = $postdata->photos[0]->original_size->height;
$myposts[$j] = $post;
$j++;
}
echo json_encode($myposts);
For some reason I cant get it to pull a list of people i'm following and then get their posts, but oh well...
The tumblr.php Readme might be a bit confusing.
The package depends on other packages. All can be installed via composer.
Go to the http://getcomposer.org and read this carfully, if you are used to the concept, you will start rewriting all you classes to fit the composer dependency manager ;-)
to make it short:
install composer globally and
go into a blank directory and
type in your terminal
composer require tumblr/tumblr
you should get all the classes and the other projects in a dir called vendor.
before you do anything you need to require the autoload.php file.
And check out the concept of namespaces in php.

Categories