<?php
/**
 * appRain CMF
 *
 * LICENSE
 *
 * This source file is subject to the MIT license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.opensource.org/licenses/mit-license.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@apprain.com so we can send you a copy immediately.
 *
 * @copyright  Copyright (c) 2010 appRain, Team. (http://www.apprain.com)
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 *
 * HELP
 *
 * Official Website
 * http://www.apprain.com/
 *
 * Download Link
 * http://www.apprain.com/download
 *
 * Documents Link
 * http ://www.apprain.com/docs
 */
?>
<?php
App::Helper('Toolbar')
    ->setTitle('Components Online')
    ->setBtnComponentSrcBox()
    ->setBtnCustomHTML(
    App::load("Helper/Html")->buttonTag("Button[Toggle]", "Refresh", array("onclick" => "window.location=siteInfo.baseUrl + '/developer/componentsonline/refresh';")) . ' ' .
        App::load("Helper/Html")->buttonTag("Button[Toggle]", "Component List", array("onclick" => "window.location=siteInfo.baseUrl + '/developer/components';"))
)
    ->setBtnBack()
    ->Render(array('code' => 'install_component_top'));
?>
<?php
if (!empty($onlineComponent['data'])) {
    $DataGrid = App::Module('DataGrid');
    $DataGrid->clear()->setHeader(array('Name', 'Component Information'));
    foreach ($onlineComponent['data'] as $component) {
        $info = '';
        if ($component['info'] != '') {
            $info = "<span class=\"info\">{$component['info']}</span>";
        }
        $warning = '';
        if ($component['info'] != '') {
            $warning = "<span class=\"warning\">{$component['warning']}</span>";
        }
        $DataGrid->addRow(
            "<strong>{$component['title']}</strong><br />
				<img src=\"{$component['thumuri']}\" style=\"margin-top:5px;width:60px;height:60px;\" />", "
				" . App::Helper('Utility')->codeFormated($component['description']) . "<br /><br />
				{$info}
				{$warning}
				<br />Version: {$component['version']} | Category: {$component['categoryname']}<br /><br />
					<strong>" . App::Helper('Html')->linkTag($component['parmauri'], $this->__('DOWNLOAD'), array('class' => "button", "target" => "_blank")) . "</strong>
					- <strong>" . App::Helper('Html')->linkTag($component['relatedcomponents'], $this->__('RELATED COMPONENTS'), array('class' => "button", "target" => "_blank")) . "</strong>
				</div>
			");
    }
    $DataGrid->setFooter($onlineComponent['paging_str']);
    $DataGrid->Render();
}
else {
    echo $this->callElement('default/tools/message', array('caption' => 'Message', 'type' => 'warning', 'message' => 'Online repository not found. Check your connection and click "Refresh" button.'));
}
?>
<?php App::Helper('Toolbar')->setBtnBack()->Render(array('code' => 'component_list_bottom')); ?>
