<?php
/*BEGIN_INFO V2.0 - See especific site downloads END_INFO*/
if(!defined("WCDDL_GUTS"))
exit;
class joma_site_downl {
private $modEnabled = false; //Change to false to turn it off
public $site = true;
public $siteInfo = true;
public function site(&$where, &$whereParams) {
if(isset($_GET['site']) && !empty($_GET['site']))
$this->site = Common::formatURL($_GET['site'],'.');
if(!empty($this->site))
$siteID = Site::existsByURL($this->site);
if($siteID) {
$where .= (empty($where) ? ' WHERE' : ' AND') . ' d.sid = :siteID';
$whereParams['siteID'] = $siteID;
}
else
unset($this->site);
}
function duplicateSiteData($rows) {
$ultimo_site = '';
foreach($rows as $row) {
if($row->site_name == $ultimo_site)
$row->arrowup = '^';
else
$row->arrowup = '<a href="index.php?site='.$row->site_url.'" target="_blank">'.$row->site_name.'</a>';
$ultimo_site = $row->site_name;
}
}
public function install() {
if(!$this->modEnabled)
echo '<h3>Install site Module</h3><p>
To install show site downloads set <strong>$modEnabled = true</strong> in '.WCDDL_PATH_MODULES.'wcddl_joma_site_downl.php</p>
<h2>Changes to be done in index.php</h2><p>
<b>FIND</b><br />
'.highlight_string('$downloads = Core::load()->mapRequest(\'Downloads\', array(\'page\', \'query\', \'type\'));',true).'<br />
<b>CHANGE TO</b><br />
'.highlight_string('$downloads = Core::load()->mapRequest(\'Downloads\', array(\'page\', \'query\', \'type\', \'site\'));',true).'<br />
<b>FIND</b><br />
'.highlight_string('$downloads->query = str_replace(\'-\', \' \', $downloads->query);',true).'<br />
<b>AFTER ADD</b><br />
'.highlight_string('$downloads->siteInfo = true;',true).'<br />
<b>FIND</b><br />
'.highlight_string('<td>Views</td>',true).'<br />
<b>CHANGE TO</b><br />
'.highlight_string('<td>Views</td><td>Provider</td>',true).'<br />
<b>FIND</b><br />
'.highlight_string('<td><?php echo $row->views; ?></td>',true).'<br />
<b>AFTER ADD</b><br />
'.highlight_string('<td><?php echo $row->arrowup ?></td>',true).'<br />
<b>FIND</b><br />
'.highlight_string('echo $downloads->pages(array(
array(\'default\', WCDDL_PAGES_DEFAULT),
array(\'query\', WCDDL_PAGES_QUERY),
array(\'type\', WCDDL_PAGES_TYPE),
array(array(\'query\', \'type\'), WCDDL_PAGES_QUERY_TYPE)
));',true).'<br />
<b>CHANGE TO</b><br />
'.highlight_string('echo $downloads->pages(array(
array(\'default\', WCDDL_PAGES_DEFAULT),
array(\'query\', WCDDL_PAGES_QUERY),
array(\'type\', WCDDL_PAGES_TYPE),
array(array(\'query\', \'type\'), WCDDL_PAGES_QUERY_TYPE),
array(\'site\', WCDDL_PAGES_SITE)
));',true).'<br />
<b>if uses the noxxx mod change one line</b><br />
'.highlight_string('if((empty($type) && !isset($_GET[\'q\']) && !isset($_GET[\'page\']) && !isset($_GET[\'site\'])) || (!isset($_GET[\'site\']) && isset($_GET[\'page\']) && $this->dontshow && $type != \'xxx\')) {',true).'
';
else
echo '<h3>Install site Module</h3><p>Already installed.</p>';
}
public function uninstall() {
if($this->modEnabled)
echo '<h3>Uninstall site Module</h3><p>
To disable this mod just set in '.WCDDL_PATH_MODULES.'wcddl_joma_site_downl.php:<br /><br /><strong>$modEnabled = false;</strong><br /><br /><br />Alternatively you can remove or disable the ' . WCDDL_DB_PREFIX . 'joma_site_downl.php file from the modules folder.<br /></a><\p>
';
else
echo '<h3>Uninstall site Module</h3><p>Not installed.</p>';
}
public function checkupdate() {
return '2.0;http://www.wjunction.com/1256499-post11.htm;http://www.wjunction.com/1256499-post11.htm';
}
} //end class
if($modEnabled) {
Core::load()->hook('DownloadsGetWhere', array('joma_site_downl','site'));
Core::load()->hook('DownloadsGetRows', array('joma_site_downl','duplicateSiteData'));
define('WCDDL_PAGES_SITE', '<a href="index.php?page=#page#&site=#site#">#page#</a>');
}
if(isset($_GET['go'])){
if($_GET['go']=='installjoma_site_downl')
Core::load()->hook('AdminHandleContent', array('joma_site_downl', 'install'));
if($_GET['go']=='uninstalljoma_site_downl')
Core::load()->hook('AdminHandleContent', array('joma_site_downl', 'uninstall'));
if(isset($_GET['go']) && $_GET['go']=='checkupdatejoma_site_downl')
Core::load()->hook('AdminHandleContent', array('joma_site_downl', 'checkupdate'));
}