https://wiki.creativecommons.org/index.php?title=Cchost/developer/Reverse_Engineering&feed=atom&action=historyCchost/developer/Reverse Engineering - Revision history2024-03-28T17:22:54ZRevision history for this page on the wikiMediaWiki 1.30.0https://wiki.creativecommons.org/index.php?title=Cchost/developer/Reverse_Engineering&diff=19945&oldid=prevFourstones: /* A ccHost Quick Reverse Engineer */2008-11-17T23:10:53Z<p><span dir="auto"><span class="autocomment">A ccHost Quick Reverse Engineer</span></span></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr style="vertical-align: top;" lang="en">
<td colspan="2" style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: white; color:black; text-align: center;">Revision as of 23:10, 17 November 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l26" >Line 26:</td>
<td colspan="2" class="diff-lineno">Line 26:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>**the menu itself is embedded in the 'R' record</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>**the menu itself is embedded in the 'R' record</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>**a few lines above is line '''%map(#R,records/0)%''' which means 'R' is result of the query ('records' is the array of a query result in a template)</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>**a few lines above is line '''%map(#R,records/0)%''' which means 'R' is result of the query ('records' is the array of a query result in a template)</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>**every query must have a dataview somewhere, <del class="diffchange diffchange-inline">sure enough </del>at the top of the template  </div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>**every query must have a dataview somewhere, at the top of the template <ins class="diffchange diffchange-inline">is the meta declaration </ins>'''dataview = playlist_detail'''</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline"> to display this playlist, </del>'''dataview = playlist_detail'''</div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*I found '''ccdataviews/playlist_detail.php'''  </div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*I found '''ccdataviews/playlist_detail.php'''  </div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>*Since the 'menu' is a PHP array and not a normal SQL column, I deduced there must a dataview filter that is building the menu</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>*Since the 'menu' is a PHP array and not a normal SQL column, I deduced there must a dataview filter that is building the menu<ins class="diffchange diffchange-inline">.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*Filter events are returned in an array in a dataview and there was ''CC_EVENT_FILTER_CART_MENU'' (a playlist is actually a record in the ''cc_tbl_carts'' table)</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*Filter events are returned in an array in a dataview and there was ''CC_EVENT_FILTER_CART_MENU'' (a playlist is actually a record in the ''cc_tbl_carts'' table)</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*I searched '''cchost_lib/*''' for that event and found the declaration of a handler in '''cchost_lib/ccextras/cc-playlist.php'''</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*I searched '''cchost_lib/*''' for that event and found the declaration of a handler in '''cchost_lib/ccextras/cc-playlist.php'''</div></td></tr>
</table>Fourstoneshttps://wiki.creativecommons.org/index.php?title=Cchost/developer/Reverse_Engineering&diff=19944&oldid=prevFourstones: /* A ccHost Quick Reverse Engineer */2008-11-17T23:09:25Z<p><span dir="auto"><span class="autocomment">A ccHost Quick Reverse Engineer</span></span></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr style="vertical-align: top;" lang="en">
<td colspan="2" style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: white; color:black; text-align: center;">Revision as of 23:09, 17 November 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l3" >Line 3:</td>
<td colspan="2" class="diff-lineno">Line 3:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>When I sat down to write the [[Cchost/developer/tutorial/Featured_Playlist|auto 'feature this playlist']] feature I knew I wanted to add a menu item to the playlist's command window but I totally forgot how that menu was generated. It took less than a minute to figure it out but I thought it might be useful since I know this kind of 'view source/reverse engineer' is how most developers approach a codebase like ccHost.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>When I sat down to write the [[Cchost/developer/tutorial/Featured_Playlist|auto 'feature this playlist']] feature I knew I wanted to add a menu item to the playlist's command window but I totally forgot how that menu was generated. It took less than a minute to figure it out but I thought it might be useful since I know this kind of 'view source/reverse engineer' is how most developers approach a codebase like ccHost.</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">Firefox has a 'Web Developer Toolbar' that I find invaluable. </del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*I [http://ccmixter.org/playlist/browse/10 browsed to a playlist].  </div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*I [http://ccmixter.org/playlist/browse/10 browsed to a playlist].  </div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>*Selected 'View Style Information' from Firefox's Web Developer Toolbar which highlights the area under the cursor and gives you the CSS class selector name.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>*Selected 'View Style Information' from Firefox's Web Developer Toolbar which highlights the area under the cursor and gives you the CSS class selector name. <ins class="diffchange diffchange-inline">(Of course view source also works, this is just faster.)</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*For the menu that turned out to be 'cc_playlist_owner'</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*For the menu that turned out to be 'cc_playlist_owner'</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*I searched under '''ccskins''' for all occurances of that selector.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>*I searched under '''ccskins''' for all occurances of that selector.</div></td></tr>
</table>Fourstoneshttps://wiki.creativecommons.org/index.php?title=Cchost/developer/Reverse_Engineering&diff=19943&oldid=prevFourstones: New page: ==A ccHost Quick Reverse Engineer== by Victor When I sat down to write the auto 'feature this playlist' feature I knew I wanted to add a me...2008-11-17T23:08:33Z<p>New page: ==A ccHost Quick Reverse Engineer== by Victor When I sat down to write the <a href="/wiki/Cchost/developer/tutorial/Featured_Playlist" title="Cchost/developer/tutorial/Featured Playlist">auto 'feature this playlist'</a> feature I knew I wanted to add a me...</p>
<p><b>New page</b></p><div>==A ccHost Quick Reverse Engineer==<br />
by Victor<br />
<br />
When I sat down to write the [[Cchost/developer/tutorial/Featured_Playlist|auto 'feature this playlist']] feature I knew I wanted to add a menu item to the playlist's command window but I totally forgot how that menu was generated. It took less than a minute to figure it out but I thought it might be useful since I know this kind of 'view source/reverse engineer' is how most developers approach a codebase like ccHost.<br />
<br />
Firefox has a 'Web Developer Toolbar' that I find invaluable. <br />
<br />
*I [http://ccmixter.org/playlist/browse/10 browsed to a playlist]. <br />
*Selected 'View Style Information' from Firefox's Web Developer Toolbar which highlights the area under the cursor and gives you the CSS class selector name.<br />
*For the menu that turned out to be 'cc_playlist_owner'<br />
*I searched under '''ccskins''' for all occurances of that selector.<br />
*I found the template that built the menu at '''ccskins/shared/playlist_2_head.tpl'''<br />
<br />
<nowiki><ul class="cc_playlist_owner_menu </nowiki><br />
light_bg dark_border"><br />
%loop(#R/menu,mi)%<br />
<nowiki><li></nowiki><br />
<a target="_parent" href="%(#mi/url)%" <br />
id="%(#mi/id)%" <br />
class="%(#mi/class)%"><span>%text(#mi/text)%</span><br />
</a><br />
</li><br />
%end_loop%<br />
</ul><br />
<br />
*From the code in this template I could deduce the following:<br />
**the menu was just being displayed here. The menu was being built somewhere else.<br />
**the menu itself is embedded in the 'R' record<br />
**a few lines above is line '''%map(#R,records/0)%''' which means 'R' is result of the query ('records' is the array of a query result in a template)<br />
**every query must have a dataview somewhere, sure enough at the top of the template <br />
to display this playlist, '''dataview = playlist_detail'''<br />
*I found '''ccdataviews/playlist_detail.php''' <br />
*Since the 'menu' is a PHP array and not a normal SQL column, I deduced there must a dataview filter that is building the menu<br />
*Filter events are returned in an array in a dataview and there was ''CC_EVENT_FILTER_CART_MENU'' (a playlist is actually a record in the ''cc_tbl_carts'' table)<br />
*I searched '''cchost_lib/*''' for that event and found the declaration of a handler in '''cchost_lib/ccextras/cc-playlist.php'''<br />
*That pointed to a method in '''cchost_lib/ccextras/cc-playlist-browse.inc''' called ''CCPlaylistBrowse::OnFilterCartMenu''<br />
<br />
At this point I knew what event I had to handle ''CC_EVENT_FILTER_CART_MENU'' and I had an example of what the system was doing with that event in ''CCPlaylistBrowse::OnFilterCartMenu''.</div>Fourstones