The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Php project, joomla component
Discuss Php project, joomla component in the PHP Development forum on Dev Shed. Php project, joomla component PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 19th, 2012, 03:05 AM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
|
Php project, joomla component
Hello to all.
Excuse my bad Englishe, i will tray to short describe what this project is.
In Joomla is one component which conect Joomla website with MochiMedia game feed. In last few month MM change have share game, and therefore this component stop working. :S
I read php dokument within component, and change some thing, and games start showing.
Changes:
1.In folder \com_yoflash\admin\views\mochigames in view.html.php dokument i change this code.
PHP Code:
//$ffp=fopen("http://www.mochimedia.com/feeds/games/".$publisherID."/?limit=25&offset=10");
to
PHP Code:
//$ffp=fopen("http://feedmonger.mochimedia.com/feeds/query/partner_id=".$publisherID."/?limit=25&offset=10");
because old MM games feed use this structure of html :
Code:
http://www.mochimedia.com/feeds/games/XXXX
and new one use this
Code:
http://feedmonger.mochimedia.com/feeds/query/partner_id=XXXX
.
2.In folder \com_yoflash\admin\models in dokument yfl_mochifeed.php i change same thing, which for result have to show games.
But when i tray to add games, or to filter games trough category their is problems, because MM use new html structure for that. For that i need help to change so this component start working ok.
Last edited by Robotower : November 19th, 2012 at 03:36 AM.
|

November 19th, 2012, 04:04 AM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
Quote: | Originally Posted by Robotower But when i tray to add games, or to filter games trough category their is problems |
What problems?
|

November 19th, 2012, 04:40 AM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
Quote: | Originally Posted by requinix What problems? |
Old html structure for category look like this.
Code:
http://www.mochimedia.com/feeds/games/XXXX/action/
And new onr look like this.
Code:
http://feedmonger.mochimedia.com/feeds/query/?q=(recommendation%3A%3E%3D0)%20and%20category%3Aaction&partner_id=XXXX
So somewhere in some php document need to change this code. But problem is because it use so many code to make link. And i can get mowing with this. :S
|

November 19th, 2012, 04:46 AM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
This is php script for getting MM feeed for games.
PHP Code:
<?php
class YoflashModelFeed extends JModel {
function getFeed($cat, $offset, $limit, $keyword=NULL){
$db =& JFactory::getDBO();
//$session =&JFactory::getSession();
if(empty($cat))
$cat="all";
$params = &JComponentHelper::getParams( 'com_yoflash' );
$publisherid=$params->get('publisherid');
$game=array();
if($params->get('JSON_or_RSS')=="rss") {
if($params->get('curl_or_fopen')=="curl") {
//Curl support
$link="http://www.mochimedia.com/feeds/games/".$publisherid."/".$cat."/?limit=".$limit."&offset=".$offset."";
if($keyword) $link=$link."&tag=".$keyword;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
$ref = curl_exec ( $ch );
curl_close($ch);
$feed=simplexml_load_string($ref);
}
else {
//fopen support
$link="http://www.mochimedia.com/feeds/games/".$publisherid."/".$cat."/?limit=".$limit."&offset=".$offset."";
if($keyword) $link=$link."&tag=".$keyword;
$feed = simplexml_load_file($link);
}
for($i=0;$i<count($feed->entry);$i++) {
$entry=$feed->entry[$i];
$game[$i]->title=(string)$entry->title;;
$game[$i]->author=(string)$entry->author->name;
$game[$i]->file_swf=(string)$entry->link[1]->attributes()->href;
$game[$i]->file_type=(string)$entry->link[1]->attributes()->type;
$game[$i]->file_img=(string)$entry->summary->div->a->img->attributes()->src;
$summary=array();
for($j=0;$j<count($entry->summary->div->dl->dt);$j++) {
$summary[(string)$entry->summary->div->dl->dt[$j]] = (string)$entry->summary->div->dl->dd[$j];
//=array((string)$entry->summary->div->dl->dt[$j] => $entry->summary->div->dl->dd[$j]);
}
$game[$i]->uid = $summary['Tag'];
$game[$i]->slug = $summary['Slug'];
$game[$i]->description = $summary['Description'];
$game[$i]->res = $summary['Resolution'];
$resolution=explode("x", $summary['Resolution']);
$game[$i]->x=$resolution[0];
$game[$i]->y=$resolution[1];
$game[$i]->instruction = $summary['Instructions'];
$game[$i]->categories = $summary['Categories'];
$game[$i]->rating = $summary['Rating'];
$game[$i]->leaderboard= $summary['Leaderboards'];
@$game[$i]->file_size= $summary['SWF file size'];
$game[$i]->keywords= $summary['Keywords'];
}
}
else if ($params->get('JSON_or_RSS')=="json") {
if($params->get('curl_or_fopen')=="curl") {
//Curl support
$link="http://www.mochimedia.com/feeds/games/".$publisherid."/".$cat."/?limit=".$limit."&offset=".$offset."&format=json";
if($keyword) $link=$link."&tag=".$keyword;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
$json = curl_exec ( $ch );
curl_close($ch);
}
else {
//fopen support
$link="http://www.mochimedia.com/feeds/games/".$publisherid."/".$cat."/?limit=".$limit."&offset=".$offset."&format=json";
if($keyword) $link=$link."&tag=".$keyword;
$json = file_get_contents($link);
}
$feed=json_decode($json);
$feeds=$feed->games;
for($i=0;$i<count($feeds);$i++) {
$entry=$feeds[$i];
$game[$i]->title=$entry->name;
$game[$i]->slug=$entry->slug;
$game[$i]->author=$entry->author;
$game[$i]->file_swf=$entry->swf_url;
$game[$i]->file_type="application/x-shockwave-flash";
$game[$i]->file_img=$entry->thumbnail_url;
$game[$i]->uid = $entry->game_tag;
$game[$i]->description = $entry->description;
$game[$i]->res = $entry->resolution;
$resolution=explode("x", $entry->resolution);
$game[$i]->x=$resolution[0];
$game[$i]->y=$resolution[1];
$game[$i]->instruction = $entry->instructions;
$game[$i]->categories = implode(", ",$entry->categories);
$game[$i]->rating = $entry->rating;
if($entry->leaderboard_enabled=="1") $game[$i]->leaderboard="True";
else $game[$i]->leaderboard="False";
if($entry->coins_enabled=="1") $game[$i]->coins="True";
else $game[$i]->coins="False";
//Not yet implemented by mochi
// if($entry->premium_games=="1") $game[$i]->premium="True";
// else $game[$i]->premium="False";
@$game[$i]->file_size= $entry->swf_file_size;
$game[$i]->keywords= implode(", ",$entry->tags);
}
}
return $game;
}
function getCats() {
$filter['premium_games']=JText::_('Premium_Games');
$filter['coins_enabled']=JText::_('Coins_Games');
$filter['featured_games']=Jtext::_('Featured_Games');
$filter['leaderboard_enabled']=Jtext::_('Leaderboard_Games');
$filter['all']=Jtext::_('AlL_Games');
$filter['action']=Jtext::_('Action');
$filter['adventure']=Jtext::_('Adventure');
$filter['board_game']=Jtext::_('Board_Game');
$filter['casino']=Jtext::_('Casino');
$filter['dress-up']=Jtext::_('Dress_Up');
$filter['driving']=Jtext::_('Driving');
$filter['education']=Jtext::_('Education');
$filter['fighting']=Jtext::_('Fighting');
$filter['jigsaw']=Jtext::_('Jigsaw');
$filter['other']=Jtext::_('Other');
$filter['customize']=Jtext::_('Pimp_My___Customize');
$filter['puzzles']=Jtext::_('Puzzles');
$filter['rhythm']=Jtext::_('Rhythm');
$filter['shooting']=Jtext::_('Shooting');
$filter['sports']=Jtext::_('Sports');
$filter['strategy']=Jtext::_('Strategy');
return $filter;
}
function getGame($uid) {
$params = &JComponentHelper::getParams( 'com_yoflash' );
$publisherid=$params->get('publisherid');
if($params->get('JSON_or_RSS')=="rss") {
if($params->get('curl_or_fopen')=="curl") {
//Curl support
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, "http://www.mochimedia.com/feeds/games/".$publisherid."/".$uid."/");
curl_setopt($ch, CURLOPT_HEADER, FALSE);
$ref = curl_exec ( $ch );
curl_close($ch);
$feed=simplexml_load_string($ref);
}
else {
$feed = simplexml_load_file("http://www.mochimedia.com/feeds/games/".$publisherid."/".$uid."/");
}
$entry=$feed->entry[0];
$game->title=(string)$entry->title;;
$game->author=(string)$entry->author->name;
$game->file_swf=(string)$entry->link[1]->attributes()->href;
$game->file_type=(string)$entry->link[1]->attributes()->type;
$game->file_img=(string)$entry->summary->div->a->img->attributes()->src;
$summary=array();
for($j=0;$j<count($entry->summary->div->dl->dt);$j++) {
$summary[(string)$entry->summary->div->dl->dt[$j]] = (string)$entry->summary->div->dl->dd[$j];
//=array((string)$entry->summary->div->dl->dt[$j] => $entry->summary->div->dl->dd[$j]);
}
$game->uid = $summary['Tag'];
$game->slug = $summary['Slug'];
$game->description = $summary['Description'];
$game->res = $summary['Resolution'];
$resolution=explode("x", $summary['Resolution']);
$game->x=$resolution[0];
$game->y=$resolution[1];
$game->instruction = $summary['Instructions'];
$game->categories = $summary['Categories'];
$game->rating = $summary['Rating'];
$game->featured = $summary['Featured'];
$game->leaderboard= $summary['Leaderboards'];
$game->file_size= $summary['SWF file size'];
$game->keywords= $summary['Keywords'];
}
else if ($params->get('JSON_or_RSS')=="json") {
if($params->get('curl_or_fopen')=="curl") {
//Curl support
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, "http://www.mochimedia.com/feeds/games/".$publisherid."/".$uid."/?format=json");
curl_setopt($ch, CURLOPT_HEADER, FALSE);
$json = curl_exec ( $ch );
curl_close($ch);
}
else {
$json = file_get_contents("http://www.mochimedia.com/feeds/games/".$publisherid."/".$uid."/?format=json");
}
$feed=json_decode($json);
$entry=$feed->games[0];
$game->title=$entry->name;
$game->slug=$entry->slug;
$game->author=$entry->author;
$game->file_swf=$entry->swf_url;
$game->file_type="application/x-shockwave-flash";
$game->file_img=$entry->thumbnail_url;
$game->uid = $entry->game_tag;
$game->description = $entry->description;
$game->res = $entry->resolution;
$resolution=explode("x", $entry->resolution);
$game->x=$resolution[0];
$game->y=$resolution[1];
$game->instruction = $entry->instructions;
$game->categories = implode(", ",$entry->categories);
if(@$entry->featured=="True") $game->catgeories.=", Featured";
$game->rating = $entry->rating;
if($entry->leaderboard_enabled=="1") $game->leaderboard="True";
else $game->leaderboard="False";
if($entry->coins_enabled=="1") $game->coins="True";
else $game->coins="False";
$game->file_size= $entry->swf_file_size;
$game->keywords= implode(", ",$entry->tags);
}
return $game;
}
}
?>
Because new katalog, whic use new html struture, games filter dont work, and getting game too dont work. So little help or explantation haw this part work, would be good.
|

November 19th, 2012, 04:51 AM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
|
function getGame($uid)
and function getCats() need some update so it can make this two thing work. I think so, but dont know for sure, so that whay i ask you men.
|

November 19th, 2012, 12:08 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
Putting aside the fact that you've given two different URLs for the new search thing,
Describe what is not working. How do you know it's not working? What does it do and what does it not do? I understand that the URL is wrong, but you tried to fix that already, so what is left to fix?
|

November 19th, 2012, 12:40 PM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
Quote: | Originally Posted by requinix Putting aside the fact that you've given two different URLs for the new search thing,
Describe what is not working. How do you know it's not working? What does it do and what does it not do? I understand that the URL is wrong, but you tried to fix that already, so what is left to fix? |
I put onlie one url for new search thing, and second is old url structure.
When i go to this component, i see new games (whic i get when change old url to new), and then if i tray see game filtered bay category, this dont work, and if i go on some game (this game should be opened, and show details about game) but this dont work.
I can see games from catalog, youst can save them on server. :S
|

November 19th, 2012, 12:53 PM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
Quote: | Originally Posted by requinix Putting aside the fact that you've given two different URLs for the new search thing,
Describe what is not working. How do you know it's not working? What does it do and what does it not do? I understand that the URL is wrong, but you tried to fix that already, so what is left to fix? |
Yes, i tray fix links, and that is working, but MM put new code for filteryng games, so old structure dont work, and i can find where to fix that. :/
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|